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