From 25596ffb1df269be0dd123f274e3ff00f477ea80 Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Tue, 8 Jun 2021 12:31:17 -0500 Subject: [PATCH] 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. --- bootscripts/ChangeLog | 6 +++++- bootscripts/lfs/init.d/network | 17 +++++++++-------- chapter01/changelog.xml | 9 +++++++++ packages.ent | 2 +- 4 files changed, 24 insertions(+), 10 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 + * When shutting down the network, ignore invalid interfaces + or interfaces that are not UP. + 2021-06-02 Thomas Trepl * 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 * 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 diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml index 6f534292b..5cbc2f5fa 100644 --- a/chapter01/changelog.xml +++ b/chapter01/changelog.xml @@ -42,6 +42,15 @@ or as appropriate for the entry or if needed the entire day's listitem. --> + + 2021-06-08 + + + [bdubbs] - Make shutting down the netwrok more robust. + + + + 2021-06-02 diff --git a/packages.ent b/packages.ent index b08620c86..05b3d4875 100644 --- a/packages.ent +++ b/packages.ent @@ -376,7 +376,7 @@ - +