From 4e1c52b2e8419ec78ee489c32b004823e34edaee Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 30 Jan 2014 20:32:46 +0100 Subject: cleanup setup_network script; dalay (final) br0 setup until IFACE linkstate is up --- .../rootfs/rootfs-stage31/data/inc/setup_network | 35 ++++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'remote/rootfs') diff --git a/remote/rootfs/rootfs-stage31/data/inc/setup_network b/remote/rootfs/rootfs-stage31/data/inc/setup_network index 9e52cfaa..b0e6f756 100755 --- a/remote/rootfs/rootfs-stage31/data/inc/setup_network +++ b/remote/rootfs/rootfs-stage31/data/inc/setup_network @@ -4,6 +4,26 @@ echo "Setting up network..." echo "Main MAC address is '$MAC'" +wait_for_iface() { + DEVICE=$1 + echo -n "Waiting for interface $DEVICE: " + # Some systems don't have operstate. Seems to be hardware dependent + [ ! -e "/sys/class/net/${DEVICE}/operstate" ] && usleep 1000 + if [ -e "/sys/class/net/${DEVICE}/operstate" ]; then + while true; do + # check linkstate + [ "x$(cat "/sys/class/net/${DEVICE}/operstate")" == "xup" ] && break + # else + echo -n "." + usleep 500000 + done + else + # we really don't have a operstate .. then just wait a sec and hope for the best. + sleep 1 + fi + echo "." +} + # setup network # set up loopback networking @@ -35,6 +55,7 @@ for LINE in $IP_OUT; do brctl setfd "$BRIDGE" 0.000000000001 ip link set addr "$IFMAC" "$BRIDGE" || drop_shell "Could not set mac of $BRIDGE" ip link set dev "$IFACE" up + wait_for_iface "$IFACE" brctl addif "$BRIDGE" "$IFACE" || drop_shell "Could not add $IFACE to $BRIDGE" # analyze ip information from the kernel command line and put parts @@ -67,19 +88,7 @@ for LINE in $IP_OUT; do IFACE="" done -echo -n "Waiting for interface $BRIDGE: " -# Some systems don't have operstate. Seems to be hardware dependent -[ ! -e "/sys/class/net/${BRIDGE}/operstate" ] && sleep 2 -while true; do - # still no operstate? assume up and hope for the best... - [ ! -e "/sys/class/net/${BRIDGE}/operstate" ] && break - # check linkstate - [ "x$(cat "/sys/class/net/${BRIDGE}/operstate")" == "xup" ] && break - # else - echo -n "." - usleep 500000 -done -echo "." +wait_for_iface "$BRIDGE" # udhcpc PARAM= -- cgit v1.2.3-55-g7522