From 1e4a880125ed2d8991d10e8f8a41b37bad898c28 Mon Sep 17 00:00:00 2001 From: Will Woods Date: Thu, 5 Apr 2012 13:01:36 -0400 Subject: [PATCH] run setup_net at start of initqueue/online hook This makes sure the network is active and ready to use during the initqueue/online hook. It also makes it so you can run setup_net repeatedly without causing error messages. --- modules.d/40network/net-genrules.sh | 3 +++ modules.d/40network/net-lib.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/modules.d/40network/net-genrules.sh b/modules.d/40network/net-genrules.sh index 84fd3ac..b3d5584 100755 --- a/modules.d/40network/net-genrules.sh +++ b/modules.d/40network/net-genrules.sh @@ -53,5 +53,8 @@ fix_bootif() { # Run the "online" hook printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n' + # And make sure we run setup_net at the start of the hook + echo '. /lib/net-lib.sh; setup_net $netif' > \ + $hookdir/initqueue/online/05-setup_net.sh } > /etc/udev/rules.d/60-net.rules diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh index 467c79f..a7abe81 100644 --- a/modules.d/40network/net-lib.sh +++ b/modules.d/40network/net-lib.sh @@ -59,12 +59,14 @@ ifdown() { ip link set $netif down ip addr flush dev $netif echo "#empty" > /etc/resolv.conf + rm -f /tmp/net.$netif.did-setup # TODO: send "offline" uevent? } setup_net() { local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES="" [ -e /tmp/net.$netif.up ] || return 1 + [ -e /tmp/net.$netif.did-setup ] && return [ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces [ -z "$IFACES" ] && IFACES="$netif" for iface in $IFACES ; do @@ -100,6 +102,7 @@ setup_net() { if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then info "Resolving $dest via ARP on $netif failed" fi + > /tmp/net.$netif.did-setup } set_ifname() {