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