]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
network: wait for interfaces to come up, before proceeding
authorHarald Hoyer <harald@redhat.com>
Tue, 6 Oct 2009 13:07:52 +0000 (15:07 +0200)
committerHarald Hoyer <harald@redhat.com>
Tue, 6 Oct 2009 13:07:52 +0000 (15:07 +0200)
modules.d/40network/dhclient-script
modules.d/40network/ifup
modules.d/99base/dracut-lib.sh

index 27bd7652126c501a27ebca56addc78e78641ad0a..afe2799caddd840144aeb4ae69116523134a1388 100755 (executable)
@@ -17,6 +17,7 @@ setup_interface() {
        echo ip link set $netif down
        echo ip link set $netif mtu $mtu
        echo ip link set $netif up
+       echo wait_for_if_up $netif
     fi > /tmp/net.$netif.up
 
     echo ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif >> /tmp/net.$netif.up
@@ -52,6 +53,7 @@ netif=$interface
 case $reason in
     PREINIT)
        ip link set $netif up
+       wait_for_if_up $netif
        ;;
     BOUND)
        setup_interface 
index d73049e8aa589918e62646fa8b58e2a4ed20e3e4..dd45800d760bc15584544e51503a35eaffd4760d 100755 (executable)
@@ -32,8 +32,9 @@ do_dhcp() {
 
 # Handle static ip configuration
 do_static() {
-{
+    {
        echo ip link set $netif up 
+       echo wait_for_if_up $netif
        echo ip addr flush dev $netif
        echo ip addr add $ip/$mask dev $netif
     } > /tmp/net.$netif.up
@@ -89,6 +90,7 @@ fi
 # start bridge if necessary
 if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
     ip link set $ethname up
+    wait_for_if_up $ethname
     # Create bridge and add eth to bridge
     brctl addbr $bridgename
     brctl setfd $bridgename 0
index 01d8bd9cf5140662dd208db185312e2f1ed0e2b2..f9aa2d5eaba493d0548196f8d1514770e4acdd87 100644 (file)
@@ -152,4 +152,13 @@ udevproperty() {
     fi
 }
 
-
+wait_for_if_up() {
+    local cnt=0
+    while [ $cnt -lt 20 ]; do 
+       li=$(ip link show $1)
+       [ -z "${li##*state UP*}" ] && return 0
+       sleep 0.1
+       cnt=$[cnt+1]
+    done 
+    return 1
+}