Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 615056 - sys-apps/openrc-0.24.2 & sys-fs/eudev-3.2.1-r1: race condition with renamed network interfaces
Summary: sys-apps/openrc-0.24.2 & sys-fs/eudev-3.2.1-r1: race condition with renamed n...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-09 08:53 UTC by Mihai Moldovan
Modified: 2017-04-25 23:15 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mihai Moldovan 2017-04-09 08:53:30 UTC
This is an odd request, but my system is booting up too quickly.

This triggers a race condition: after my wifi module is loaded, it takes udev about 2.5 seconds to rename the interface to the name I defined in /etc/udev/rules.d/76-net-name-use-custom.rules:

[    5.361370] ath10k_pci 0000:70:00.0: enabling device (0000 -> 0002)
[    7.823223] ath10k_pci 0000:70:00.0 wifi: renamed from wlan0

Sadly, openrc takes less than 2 seconds to go through the "boot" runlevel and then a few more milliseconds to process the "default" runlevel, which includes libvirtd.

Since net.lo is not enough to satisfy the net dependency for some reason (even though I explicitly set rc_depend_strict="NO"), the next available net interface is being started instead: net.wifi. At that point in time, it's not available though, failing badly:

 * Executing: /lib64/rc/sh/openrc-run.sh /lib64/rc/sh/openrc-run.sh /etc/init.d/net.wifi start
 * Bringing up interface wifi
 *   Skipping module apipa due to missing program: /sbin/arping /bin/arping
 *   Skipping module arping due to missing program: /sbin/arping /bin/arping /usr/sbin/arping /usr/sbin/arping2
 *   Skipping module br2684ctl due to missing program: br2684ctl
 *   Skipping module clip due to missing program: /usr/sbin/atmsigd
 *   Skipping module netplugd due to missing program: /sbin/netplugd
 *   Skipping module ifplugd due to missing program: /usr/sbin/ifplugd
 *   Skipping module ipppd due to missing program: /usr/sbin/ipppd
 *   Skipping module firewalld due to missing program: firewall-cmd
 *   Skipping module pump due to missing program: /sbin/pump
 *   Skipping module dhcpcd due to missing program: dhcpcd
 *   Loaded modules: adsl bonding l2tp tuntap bridge ccwgroup ethtool dummy hsr macvlan macchanger macnet wpa_supplicant ssidnet iproute2 pppd system vlan dhclient ip6rd ip6to4
 *   ip link set dev wifi up
 *   ERROR: interface wifi does not exist
 *   Ensure that you have loaded the correct kernel module for your hardware
 * ERROR: net.wifi failed to start
 * ERROR: cannot start libvirtd as net.wifi would not start
 * Executing: /lib64/rc/sh/openrc-run.sh /lib64/rc/sh/openrc-run.sh /etc/init.d/xdm-setup start
 * ERROR: cannot start netmount as net.wifi would not start

Note that normally openrc would try to also start my other interface through net.ether, but I explicitly prohibited hotplugging it, to not block the boot process for two minutes due to an DHCP timeout:

rc_hotplug="pcscd net.wifi !net.ether"


To counter this race condition, I've also tried having net.* to depend upon udev-settle, hoping that this would block long enough until all events (especially rename events...) have been processed via:

rc_net_wifi_need="udev-settle"
rc_net_ether_need="udev-settle"


but still no dice:

 * Executing: /lib64/rc/sh/openrc-run.sh /lib64/rc/sh/openrc-run.sh /etc/init.d/virtlogd start
 * Starting virtlogd ...
 * start-stop-daemon: fopen `/var/run/virtlogd.pid': No such file or directory
 * Detaching to start `/usr/sbin/virtlogd' ...
 [ ok ]
 * Executing: /lib64/rc/sh/openrc-run.sh /lib64/rc/sh/openrc-run.sh /etc/init.d/udev-settle start
 * Waiting for uevents to be processed ...
 [ ok ]
 * Executing: /lib64/rc/sh/openrc-run.sh /lib64/rc/sh/openrc-run.sh /etc/init.d/net.wifi start
 * Bringing up interface wifi
 *   Skipping module apipa due to missing program: /sbin/arping /bin/arping
 *   Skipping module arping due to missing program: /sbin/arping /bin/arping /usr/sbin/arping /usr/sbin/arping2
 *   Skipping module br2684ctl due to missing program: br2684ctl
 *   Skipping module clip due to missing program: /usr/sbin/atmsigd
 *   Skipping module netplugd due to missing program: /sbin/netplugd
 *   Skipping module ifplugd due to missing program: /usr/sbin/ifplugd
 *   Skipping module ipppd due to missing program: /usr/sbin/ipppd
 *   Skipping module firewalld due to missing program: firewall-cmd
 *   Skipping module pump due to missing program: /sbin/pump
 *   Skipping module dhcpcd due to missing program: dhcpcd
 *   Loaded modules: adsl bonding l2tp tuntap bridge ccwgroup ethtool dummy hsr macvlan macchanger macnet wpa_supplicant ssidnet iproute2 pppd system vlan dhclient ip6rd ip6to4
 *   ip link set dev wifi up
 *   ERROR: interface wifi does not exist
 *   Ensure that you have loaded the correct kernel module for your hardware
 * ERROR: net.wifi failed to start
 * ERROR: cannot start libvirtd as net.wifi would not start
 * Executing: /lib64/rc/sh/openrc-run.sh /lib64/rc/sh/openrc-run.sh /etc/init.d/xdm-setup start
 * ERROR: cannot start netmount as net.wifi would not start


Ironically, a few moments later when the rename is through, net.wifi gets hotplugged and started automatically.
Comment 1 Mihai Moldovan 2017-04-09 09:37:02 UTC
Using a patch like that to trigger a short timeouted loop is allowing enough time to pass so that the device becomes available. Note that I explicitly do not upload it as an attachment to not encourage applying it, since it feels more like an ugly hack than a real solution to the problem:


--- /etc/init.d/net.lo.bak	2017-03-20 03:20:31.376968301 +0100
+++ /etc/init.d/net.lo	2017-04-09 11:26:10.205556961 +0200
@@ -604,20 +604,34 @@ start()
 		eoutdent
 	fi
 
-	_up 2>/dev/null
-
-	for module in ${MODULES}; do
-		if [ "$(command -v "${module}_pre_start")" = "${module}_pre_start" ]; then
-			${module}_pre_start || exit $?
+	local exists_timeout="3" found_dev="0"
+	while [ "${exists_timeout}" -ne "0" ]; do
+		if ! _exists; then
+			ewarn "WARNING: interface ${IFACE} did not turn up yet, waiting for it ..."
+			sleep 1
+		else
+			found_dev="1"
+			break
 		fi
+
+		exists_timeout="$((exists_timeout - 1))"
 	done
 
-	if ! _exists; then
+	if [ "${found_dev}" -ne "1" ]; then
+		eerror "ERROR: timeout while waiting for interface ${IFACE}"
 		eerror "ERROR: interface ${IFACE} does not exist"
 		eerror "Ensure that you have loaded the correct kernel module for your hardware"
 		return 1
 	fi
 
+	_up 2>/dev/null
+
+	for module in ${MODULES}; do
+		if [ "$(command -v "${module}_pre_start")" = "${module}_pre_start" ]; then
+			${module}_pre_start || exit $?
+		fi
+	done
+
 	if ! _wait_for_carrier; then
 		if service_started devd; then
 			ewarn "no carrier, but devd will start us when we have one"


Result:

 * Executing: /lib64/rc/sh/openrc-run.sh /lib64/rc/sh/openrc-run.sh /etc/init.d/virtlogd start
 * Starting virtlogd ...
 * start-stop-daemon: fopen `/var/run/virtlogd.pid': No such file or directory
 * Detaching to start `/usr/sbin/virtlogd' ...
 [ ok ]
 * Executing: /lib64/rc/sh/openrc-run.sh /lib64/rc/sh/openrc-run.sh /etc/init.d/udev-settle start
 * Waiting for uevents to be processed ...
 [ ok ]
 * Executing: /lib64/rc/sh/openrc-run.sh /lib64/rc/sh/openrc-run.sh /etc/init.d/net.wifi start
 * Bringing up interface wifi
 *   Skipping module apipa due to missing program: /sbin/arping /bin/arping
 *   Skipping module arping due to missing program: /sbin/arping /bin/arping /usr/sbin/arping /usr/sbin/arping2
 *   Skipping module br2684ctl due to missing program: br2684ctl
 *   Skipping module clip due to missing program: /usr/sbin/atmsigd
 *   Skipping module netplugd due to missing program: /sbin/netplugd
 *   Skipping module ifplugd due to missing program: /usr/sbin/ifplugd
 *   Skipping module ipppd due to missing program: /usr/sbin/ipppd
 *   Skipping module firewalld due to missing program: firewall-cmd
 *   Skipping module pump due to missing program: /sbin/pump
 *   Skipping module dhcpcd due to missing program: dhcpcd
 *   Loaded modules: adsl bonding l2tp tuntap bridge ccwgroup ethtool dummy hsr macvlan macchanger macnet wpa_supplicant ssidnet iproute2 pppd system vlan dhclient ip6rd ip6to4
 *   WARNING: interface wifi did not turn up yet, waiting for it ...
 *   ip link set dev wifi up
 *   Configuring wifi for MAC address XX:XX:XX:XX:XX:XX ...
 [ ok ]
 *   Starting wpa_supplicant on wifi ...
 *   start-stop-daemon: fopen `/run/wpa_supplicant-wifi.pid': No such file or directory
 *   Detaching to start `/usr/sbin/wpa_supplicant' ...
Successfully initialized wpa_supplicant
 [ ok ]
 *   Starting wpa_cli on wifi ...
 *   start-stop-daemon: fopen `/run/wpa_cli-wifi.pid': No such file or directory
 *   Detaching to start `/usr/bin/wpa_cli' ...
 [ ok ]
 *   Backgrounding ... ...
 * WARNING: net.wifi has started, but is inactive
 * WARNING: libvirtd will start when net.wifi has started
 * Executing: /lib64/rc/sh/openrc-run.sh /lib64/rc/sh/openrc-run.sh /etc/init.d/xdm-setup start
 * WARNING: netmount will start when net.wifi has started


While that hack works, I don't particularly like it. Hopefully the maintainer has got a better idea.
Comment 2 William Hubbs gentoo-dev 2017-04-25 23:15:18 UTC
@netifrc maintainers:
Is this an OpenRC or netifrc issue?

What are your thoughts about it?

Thanks,

William