Bug 59964

Summary: udev 197 network device renaming race condition
Product: systemd Reporter: Alexei Robyn <shados>
Component: generalAssignee: systemd-bugs
Status: RESOLVED WONTFIX QA Contact: systemd-bugs
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Alexei Robyn 2013-01-28 10:42:33 UTC
Currently, udev is not guaranteed to have completed renaming the initial set of network devices to persistent names before network.target and it's Wants are run. This can cause a race condition where a network configuration unit file will fail because it is attempting to configure devices that to do not (yet) exist. 

This can be be worked around by using an instantiated unit file and specifying 'After=sys-subsystem-net-devices-%i.device', but this would have to be done for every initial network configuration unit file. Additionally, this is not a valid solution for unit files that may need to configure multiple interfaces based upon configuration information elsewhere. Such services would each need to handle this case themselves, which seems like an unnecessary duplication of functionality across the system.

Having read http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget, I understand the difficulty in choosing a good general default for the meaning of "the network is up", but "initial attached network devices have their persistent names" does seem like a minimal prerequisite; I'm having trouble coming up with a sane meaning of "the network is up" that doesn't depend on it.



For some extra context, I'm coming from: https://bbs.archlinux.org/viewtopic.php?id=156956
Comment 1 Lennart Poettering 2013-02-11 23:45:44 UTC
Hmm? The network interface naming takes place in udev rules, so that clients listening to that will never see the original name at all.

I figure you are using some tool that watches netlink only, but not udev for devices appearing and then configures them? It really shouldn't do that. Watching netlink is fine, but apps must also take udev into account and not up the device (in fact, not touch it at all) before the udev rules finished with it. udev rules might not just set the name of a device, but alter all kinds of parameters on the device, and hence apps should never take possesion of the iface before waiting for udev.

NetworkManager gets this all right. What network management are you using? Most likely that software should be fixed to watch libudev.
Comment 2 Lennart Poettering 2013-02-11 23:47:35 UTC
This looks like the same issue:

https://bugs.freedesktop.org/show_bug.cgi?id=59610

if this is also about dhcpcd, then we should close this one as duplicate....
Comment 3 Alexei Robyn 2013-02-12 09:59:31 UTC
(In reply to comment #2)
> This looks like the same issue:
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=59610
> 
> if this is also about dhcpcd, then we should close this one as duplicate....

It's not about dhcpcd per se, it's about simple networking unit files (straight `ip` commands configuring a static address, for instance). Your point about network configuration tools is true, but you don't always necessarily want to use them if your network configuration is pretty trivial. For that kind of situation, it'd be a lot nicer if you could just trigger off of network.target and not have to worry about writing code to wait on udev's renaming of boot-time interfaces to finish. 

True, this kind of simplistic configuration approach isn't exactly durable, but it does work well in a lot of situations and is useful during initial setup and any other circumstance where you might not have access to more flexible tools.

If you haven't read it already, the Arch forums link at the bottom of my report may help illuminate things.
Comment 4 Zbigniew Jedrzejewski-Szmek 2013-06-03 19:55:53 UTC
Looks like sys-subsystem-net-devices-<device>.device should be symlinked into /etc/systemd/system/network.target.wants for this specific use case.

There isn't much that udev can do, because "initially attached network devices" is an undefined concept, especially with hot-pluggable hardware. udev has no way of knowing that enp0s29u1u2u2 will be configured by some custom script, so it must be told explictly to wait, by adding Wants= dependencies or similar.

I think that this qualifies as not a bug.
Comment 5 Lennart Poettering 2013-09-12 18:27:20 UTC
I am convinced that this is really something to fix in the networking scripts (i.e. they need to watch network devices only via udev, and not otherwise), and not systemd.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.