Blame 0002-run-setup_net-at-start-of-initqueue-online-hook.patch

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