Bug#911727: initramfs-tools-core: configure_networking avoid panic and wait for at least one network interface.
Package: initramfs-tools-core
Version: 0.130
Severity: normal
Tags: patch
In stable/stretch if there are no interfaces yet and ip-config doesn't
configure anything we get a panic.
I am using this patch in production with good results, it waits for
network interfaces to show and avoids sourcing an inexistent file,
avoiding the panic.
This happens with a USB network card but it could happen with other
cards too.
Maybe it is too much for stable/stretch, but unstable/sid version
0.132 seems to have the same problem so can be applied there.
Here it is, hope you find it useful:
--- functions.old 2017-03-06 19:42:55.000000000 -0300
+++ functions 2018-10-23 19:20:26.726994846 -0300
@@ -182,6 +182,15 @@
configure_networking()
{
+ for device_wait_try in 5 4 3 2 1; do
+ for device in /sys/class/net/*; do
+ [ $device = /sys/class/net/lo ] && continue
+ break 2
+ done
+ sleep 1
+ done
+ [ $device_wait_try = 1 ] && log_warning_msg "No network device found"
+
if [ -n "${BOOTIF}" ]; then
# pxelinux sets BOOTIF to a value based on the mac address of the
# network card used to PXE boot, so use this value for DEVICE rather
@@ -269,10 +278,12 @@
if [ -n "${DEVICE}" ]; then
# source specific bootdevice
. /run/net-${DEVICE}.conf
- else
+ elif [ -e /run/net-*.conf ]; then
# source any interface...
# ipconfig should have quit after first response
. /run/net-*.conf
+ else
+ log_warning_msg "Network configuration failed, maybe driver/module not loaded/initialized yet or cable/network problem"
fi
}
Thanks a lot!!!
-- System Information:
Debian Release: 9.5
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.9.0-8-amd64 (SMP w/2 CPU cores)
Locale: LANG=es_UY.UTF-8, LC_CTYPE=es_UY.UTF-8 (charmap=UTF-8), LANGUAGE=es_UY.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages initramfs-tools-core depends on:
ii cpio 2.11+dfsg-6
ii klibc-utils 2.0.4-9
ii kmod 23-2
ii udev 232-25+deb9u4
Versions of packages initramfs-tools-core recommends:
ii busybox 1:1.22.0-19+b3
Versions of packages initramfs-tools-core suggests:
ii bash-completion 1:2.1-4.3
-- Configuration Files:
/etc/initramfs-tools/initramfs.conf changed:
MODULES=netboot
BUSYBOX=auto
KEYMAP=n
COMPRESS=xz
DEVICE=
NFSROOT=auto
BOOT=nfs
-- no debconf information
-- debsums errors found:
debsums: changed file /usr/share/initramfs-tools/scripts/functions (from initramfs-tools-core package)
Reply to: