network: wait for interfaces to come up, before proceeding
parent
8f397a9be7
commit
bf87d252f3
|
@ -17,6 +17,7 @@ setup_interface() {
|
||||||
echo ip link set $netif down
|
echo ip link set $netif down
|
||||||
echo ip link set $netif mtu $mtu
|
echo ip link set $netif mtu $mtu
|
||||||
echo ip link set $netif up
|
echo ip link set $netif up
|
||||||
|
echo wait_for_if_up $netif
|
||||||
fi > /tmp/net.$netif.up
|
fi > /tmp/net.$netif.up
|
||||||
|
|
||||||
echo ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif >> /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
|
case $reason in
|
||||||
PREINIT)
|
PREINIT)
|
||||||
ip link set $netif up
|
ip link set $netif up
|
||||||
|
wait_for_if_up $netif
|
||||||
;;
|
;;
|
||||||
BOUND)
|
BOUND)
|
||||||
setup_interface
|
setup_interface
|
||||||
|
|
|
@ -32,8 +32,9 @@ do_dhcp() {
|
||||||
|
|
||||||
# Handle static ip configuration
|
# Handle static ip configuration
|
||||||
do_static() {
|
do_static() {
|
||||||
{
|
{
|
||||||
echo ip link set $netif up
|
echo ip link set $netif up
|
||||||
|
echo wait_for_if_up $netif
|
||||||
echo ip addr flush dev $netif
|
echo ip addr flush dev $netif
|
||||||
echo ip addr add $ip/$mask dev $netif
|
echo ip addr add $ip/$mask dev $netif
|
||||||
} > /tmp/net.$netif.up
|
} > /tmp/net.$netif.up
|
||||||
|
@ -89,6 +90,7 @@ fi
|
||||||
# start bridge if necessary
|
# start bridge if necessary
|
||||||
if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
|
if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
|
||||||
ip link set $ethname up
|
ip link set $ethname up
|
||||||
|
wait_for_if_up $ethname
|
||||||
# Create bridge and add eth to bridge
|
# Create bridge and add eth to bridge
|
||||||
brctl addbr $bridgename
|
brctl addbr $bridgename
|
||||||
brctl setfd $bridgename 0
|
brctl setfd $bridgename 0
|
||||||
|
|
|
@ -152,4 +152,13 @@ udevproperty() {
|
||||||
fi
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue