[PATCH 1/2] run setup_net at start of initqueue/online hook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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(+), 0 deletions(-)

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 e51ce94..b9a4953 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() {
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux