18971c
From 853897808af835b23edacbd815087df3543d835f Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Fri, 28 Feb 2014 10:36:12 +0100
18971c
Subject: [PATCH] network: merge setup_net_$netif.ok and net.$netif.did-setup
18971c
18971c
one marker per interface is enough
18971c
---
18971c
 modules.d/40network/dhclient-script.sh | 8 ++------
18971c
 modules.d/40network/ifup.sh            | 9 ++++++---
18971c
 modules.d/40network/net-genrules.sh    | 2 +-
18971c
 modules.d/40network/net-lib.sh         | 6 ++++++
18971c
 modules.d/45ifcfg/write-ifcfg.sh       | 4 +++-
18971c
 5 files changed, 18 insertions(+), 11 deletions(-)
18971c
18971c
diff --git a/modules.d/40network/dhclient-script.sh b/modules.d/40network/dhclient-script.sh
18971c
index a9c25238..822cce95 100755
18971c
--- a/modules.d/40network/dhclient-script.sh
18971c
+++ b/modules.d/40network/dhclient-script.sh
18971c
@@ -116,12 +116,10 @@ case $reason in
18971c
             echo "setup_net $netif"
18971c
             echo "source_hook initqueue/online $netif"
18971c
             [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
18971c
-            echo "> /tmp/setup_net_$netif.ok"
18971c
-            echo "> /tmp/setup_net_\$(cat /sys/class/net/$netif/address).ok"
18971c
             echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
18971c
         } > $hookdir/initqueue/setup_net_$netif.sh
18971c
 
18971c
-        echo "[ -f /tmp/setup_net_$netif.ok ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
18971c
+        echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
18971c
         >/tmp/net.$netif.up
18971c
         ;;
18971c
 
18971c
@@ -139,12 +137,10 @@ case $reason in
18971c
             echo "setup_net $netif"
18971c
             echo "source_hook initqueue/online $netif"
18971c
             [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
18971c
-            echo "> /tmp/setup_net_$netif.ok"
18971c
-            echo "> /tmp/setup_net_\$(cat /sys/class/net/$netif/address).ok"
18971c
             echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
18971c
         } > $hookdir/initqueue/setup_net_$netif.sh
18971c
 
18971c
-        echo "[ -f /tmp/setup_net_$netif.ok ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
18971c
+        echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
18971c
         >/tmp/net.$netif.up
18971c
         ;;
18971c
     *) echo "dhcp: $reason";;
18971c
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
18971c
index e4391068..02dfc947 100755
18971c
--- a/modules.d/40network/ifup.sh
18971c
+++ b/modules.d/40network/ifup.sh
18971c
@@ -83,7 +83,9 @@ fi
18971c
 if [ -n "$manualup" ]; then
18971c
     >/tmp/net.$netif.manualup
18971c
 else
18971c
-    [ -f /tmp/net.${iface}.did-setup ] && exit 0
18971c
+    [ -e /tmp/net.${netif}.did-setup ] && exit 0
18971c
+    [ -e /sys/class/net/$netif/address ] && \
18971c
+        [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0
18971c
 fi
18971c
 
18971c
 # Run dhclient
18971c
@@ -145,7 +147,6 @@ do_static() {
18971c
     [ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
18971c
     [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
18971c
 
18971c
-    > /tmp/setup_net_${netif}.ok
18971c
     return 0
18971c
 }
18971c
 
18971c
@@ -334,6 +335,8 @@ for p in $(getargs ip=); do
18971c
             do_static ;;
18971c
     esac
18971c
 
18971c
+    > /tmp/net.${netif}.up
18971c
+
18971c
     case $autoconf in
18971c
         dhcp|on|any|dhcp6)
18971c
             ;;
18971c
@@ -359,7 +362,7 @@ if [ -n "$DO_BOND_SETUP" -o -n "$DO_TEAM_SETUP" -o -n "$DO_VLAN_SETUP" ]; then
18971c
 fi
18971c
 
18971c
 # no ip option directed at our interface?
18971c
-if [ ! -e /tmp/setup_net_${netif}.ok ]; then
18971c
+if [ ! -e /tmp/net.${netif}.up ]; then
18971c
     do_dhcp -4
18971c
 fi
18971c
 
18971c
diff --git a/modules.d/40network/net-genrules.sh b/modules.d/40network/net-genrules.sh
18971c
index c4def61b..af2f09c1 100755
18971c
--- a/modules.d/40network/net-genrules.sh
18971c
+++ b/modules.d/40network/net-genrules.sh
18971c
@@ -89,7 +89,7 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
18971c
 
18971c
         for iface in $wait_ifaces; do
18971c
             if [ "$bootdev" = "$iface" ] || [ "$NEEDNET" = "1" ]; then
18971c
-                echo "[ -f /tmp/setup_net_${iface}.ok ]" >$hookdir/initqueue/finished/wait-$iface.sh
18971c
+                echo "[ -f /tmp/net.${iface}.did-setup ]" >$hookdir/initqueue/finished/wait-$iface.sh
18971c
             fi
18971c
         done
18971c
     # Default: We don't know the interface to use, handle all
18971c
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
18971c
index a5867118..7430e4ce 100755
18971c
--- a/modules.d/40network/net-lib.sh
18971c
+++ b/modules.d/40network/net-lib.sh
18971c
@@ -82,12 +82,16 @@ ifdown() {
18971c
     ip addr flush dev $netif
18971c
     echo "#empty" > /etc/resolv.conf
18971c
     rm -f -- /tmp/net.$netif.did-setup
18971c
+    [ -e /sys/class/net/$netif/address ] && \
18971c
+        rm -f -- /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
18971c
     # TODO: send "offline" uevent?
18971c
 }
18971c
 
18971c
 setup_net() {
18971c
     local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES=""
18971c
     [ -e /tmp/net.$netif.did-setup ] && return
18971c
+    [ -e /sys/class/net/$netif/address ] && \
18971c
+        [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && return
18971c
     [ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
18971c
     [ -z "$IFACES" ] && IFACES="$netif"
18971c
     # run the scripts written by ifup
18971c
@@ -129,6 +133,8 @@ setup_net() {
18971c
     unset layer2
18971c
 
18971c
     > /tmp/net.$netif.did-setup
18971c
+    [ -e /sys/class/net/$netif/address ] && \
18971c
+        > /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
18971c
 }
18971c
 
18971c
 save_netinfo() {
18971c
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
18971c
index d9e9f3af..e2fa4850 100755
18971c
--- a/modules.d/45ifcfg/write-ifcfg.sh
18971c
+++ b/modules.d/45ifcfg/write-ifcfg.sh
18971c
@@ -85,6 +85,7 @@ for netup in /tmp/net.*.did-setup ; do
18971c
 
18971c
     netif=${netup%%.did-setup}
18971c
     netif=${netif##*/net.}
18971c
+    strstr "$netif" ":*:*:*:*:" && continue
18971c
     [ -e /tmp/ifcfg/ifcfg-$netif ] && continue
18971c
     unset bridge
18971c
     unset bond
18971c
@@ -111,7 +112,8 @@ for netup in /tmp/net.*.did-setup ; do
18971c
     if [ "$netif" = "$vlanname" ]; then
18971c
         vlan=yes
18971c
     fi
18971c
-    cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
18971c
+    [ -e /sys/class/net/$netif/address ] && \
18971c
+        cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
18971c
     {
18971c
         echo "# Generated by dracut initrd"
18971c
         echo "DEVICE=\"$netif\""