aboutsummaryrefslogtreecommitdiffstats
path: root/bootscripts
diff options
context:
space:
mode:
authorBruce Dubbs <bdubbs@linuxfromscratch.org>2021-06-08 12:31:17 -0500
committerBruce Dubbs <bdubbs@linuxfromscratch.org>2021-06-08 12:31:17 -0500
commit25596ffb1df269be0dd123f274e3ff00f477ea80 (patch)
tree86c5cc4ede7e8404a97530e9b3c019107314b3ee /bootscripts
parent06cdaed873b0a951bdf97b70d65428df87bf4670 (diff)
Make stopping the network interfaces more robust.
SysV only. When stopping or rebooting the system, the network boot script is run and looks at all the /etc/sysconfig/ifconfig.* files. Some of the devices these files refer to may not be active or even refer to interfaces that are not defined on the current system. This change ignores non-existant interfaces and any interfaces that are not UP. This change also avoids bogus warning or error error messages when the system is shutting down.
Diffstat (limited to 'bootscripts')
-rw-r--r--bootscripts/ChangeLog6
-rw-r--r--bootscripts/lfs/init.d/network17
2 files changed, 14 insertions, 9 deletions
diff --git a/bootscripts/ChangeLog b/bootscripts/ChangeLog
index 9c8cca44f..8d37e862f 100644
--- a/bootscripts/ChangeLog
+++ b/bootscripts/ChangeLog
@@ -1,3 +1,7 @@
+2021-06-08 Bruce Dubbs <bdubbs@linuxfromscratch.org>
+ * When shutting down the network, ignore invalid interfaces
+ or interfaces that are not UP.
+
2021-06-02 Thomas Trepl <thomas@linuxfromscratch.org>
* Prevent sendsignals from killing an active mdmon
@@ -5,7 +9,7 @@
* Make check_signal more robust.
* Use a better methog for killproc to remove a dead pid file.
* Clarify what signals killproc accepts.
- * Thanks to input an ddiscussion from Scott Andrews.
+ * Thanks to input and discussion from Scott Andrews.
2021-02-01 Bruce Dubbs <bdubbs@linuxfromscratch.org>
* Tweak mountfs to properly exit when an error is found.
diff --git a/bootscripts/lfs/init.d/network b/bootscripts/lfs/init.d/network
index 17afa0983..710cfcfd4 100644
--- a/bootscripts/lfs/init.d/network
+++ b/bootscripts/lfs/init.d/network
@@ -35,10 +35,7 @@ case "${1}" in
interface=${file##*/ifconfig.}
# Skip if $file is * (because nothing was found)
- if [ "${interface}" = "*" ]
- then
- continue
- fi
+ if [ "${interface}" = "*" ]; then continue; fi
/sbin/ifup ${interface}
done
@@ -61,10 +58,14 @@ case "${1}" in
interface=${file##*/ifconfig.}
# Skip if $file is * (because nothing was found)
- if [ "${interface}" = "*" ]
- then
- continue
- fi
+ if [ "${interface}" = "*" ]; then continue; fi
+
+ # See if interface exists
+ if [ ! -e /sys/class/net/$interface ]; then continue; fi
+
+ # Is interface UP?
+ ip link show $interface 2>/dev/null | grep -q "state UP"
+ if [ $? -ne 0 ]; then continue; fi
/sbin/ifdown ${interface}
done