summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2009-10-06 15:07:52 +0200
committerHarald Hoyer <harald@redhat.com>2009-10-06 15:07:52 +0200
commitbf87d252f3780de0fd77de39c57e66a48f663b91 (patch)
treef3fd8ab4ceab94c39e3ab62fdfa2656e25367fcc
parent8f397a9be7978901ddbe90973920d706208d2226 (diff)
network: wait for interfaces to come up, before proceeding
-rwxr-xr-xmodules.d/40network/dhclient-script2
-rwxr-xr-xmodules.d/40network/ifup4
-rw-r--r--modules.d/99base/dracut-lib.sh11
3 files changed, 15 insertions, 2 deletions
diff --git a/modules.d/40network/dhclient-script b/modules.d/40network/dhclient-script
index 27bd765..afe2799 100755
--- a/modules.d/40network/dhclient-script
+++ b/modules.d/40network/dhclient-script
@@ -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
diff --git a/modules.d/40network/ifup b/modules.d/40network/ifup
index d73049e..dd45800 100755
--- a/modules.d/40network/ifup
+++ b/modules.d/40network/ifup
@@ -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
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 01d8bd9..f9aa2d5 100644
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -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
+}