summaryrefslogtreecommitdiffstats
path: root/remote
diff options
context:
space:
mode:
Diffstat (limited to 'remote')
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/inc/setup_network35
1 files changed, 22 insertions, 13 deletions
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=