race condition

Joined
Dec 29, 2019
Messages
4
I'm using a post init script to bridge some 10gb network cards, which works fine. The problem arises
now that I want to add an interface for my virtualized router so I can boot some disk less machines
via PXE. Specifically, if I create the tap at the top of the script the router VM grabs the interface and it
doesn't get added to the bridge, if I create the tap at the end of the script then the router VM fails to
start along with any other VM's that have not started at the time of the error. I have tried to run the
script as pre-init with something like this
(while ! ifconfig -l | grep "bridge0" >> /dev/null; do sleep 1; echo waiting; done; /root/bridge.sh)&
but ether is stops the boot at "creating or tailing logs" if I run it in the foreground for obvious reasons, or doesn't
seem to run at all if run in the background.

anybody know of a way to get this to work? delay starting of the VM or someway to make the script wait for
networking to come up and so it can set up its interfaces.

Code:
#!/bin/sh

TAPS="tap100"
BRIDGE="bridge100"
MTU="9000"
INTERFACES="bxe0 bxe1 bxe2 bxe3 mlxen0"

for TAP in ${TAPS}
    do
        /sbin/ifconfig ${TAP} create
    done

/sbin/ifconfig ${BRIDGE} create

for INTERFACE in ${INTERFACES}
    do
        /sbin/ifconfig ${INTERFACE} mtu ${MTU} up
        /sbin/ifconfig ${BRIDGE} addm ${INTERFACE}
    done

/sbin/ifconfig ${BRIDGE} inet 172.16.1.4/24 mtu ${MTU} up

for TAP in ${TAPS}
    do
        /sbin/ifconfig ${TAP} mtu ${MTU} up
        /sbin/ifconfig ${BRIDGE} addm ${TAP}
    done

exit 0
 
Joined
Dec 29, 2019
Messages
4
came up with a workaround, disable auto start, set up the network taps and start the router VM from the script.
 
Top