Bug 89623 - udev: floating net device number on devices with ro rootfs
Summary: udev: floating net device number on devices with ro rootfs
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-18 02:40 UTC by You-Sheng Yang [:vicamo]
Modified: 2015-03-18 03:45 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description You-Sheng Yang [:vicamo] 2015-03-18 02:40:34 UTC
On devices with read-only rootfs, e.g. mobile phones, nic device number (wlan<N>) may increase every time disabled and re-enabled. To be more precisely, this happens only on devices when disabling a nic removes the corresponding driver.

"/lib/udev/rules.d/75-persistent-net-generator.rules" checks whether NAME attribute has been assigned to wlan<N> device: if yes, skip all the followed steps, or, call to "/lib/udev/write_net_rules" to generate a persistent device name rule file. That persistent file should be created under "/etc/udev/rules.d" and named "70-persistent-net.rules", so it guarantees NAME attribute should be assigned if available before being read. However, when rootfs was previously mounted as read-only, a file "/run/udev/tmp-ruiles--70-persistent-net.rules" is created instead. This temporary file is supposed to be moved back into "/etc/udev/rules.d" by a systemd service udev-finish right after the system finishes start-up chaos. Again, if rootfs is still mounted as read-only, this move will certainly fail. One last important thing, /run/udev is _NOT_ included in udev rules inclusion paths, so any rules written here will not be taken into account when processing uevents.

So, when wlan0 is probed for the first time on a device with read-only rootfs, udev creates "/run/udev/tmp-ruiles--70-persistent-net.rules" and inserts one rule for it. When wlan0 is disabled and re-enabled, since "/run/udev/tmp-ruiles--70-persistent-net.rules" is not taken into account, its NAME attribute will not be set, and udev recognize it as a new nic and tries to write another rule for it again. However, in this time, "wlan0" has been taken in the previously written temporary rules file, so "wlan1" is chosen instead, and an exactly the same matching rule (except for NAME= part) is appended to "/run/udev/tmp-ruiles--70-persistent-net.rules". When the device is again disabled and re-enabled, "wlan2" will be assigned. And so on ....
Comment 1 You-Sheng Yang [:vicamo] 2015-03-18 02:45:55 UTC
This was observed on a Ubuntu Phone, but I think it should probably affect all devices utilizing systemd as init daemon judging from there is no related, significant changes introduced by Ubuntu.
Comment 2 Zbigniew Jedrzejewski-Szmek 2015-03-18 02:49:42 UTC
I'm pretty sure udevd is supposed to read file from /run/udev. If it doesn't, that's probably just a bug to fix.
Comment 3 You-Sheng Yang [:vicamo] 2015-03-18 02:58:43 UTC
Sorry, this should be Debian and its derived only. "75-persistent-net-generator.rules" and other related parts are added by Debian.
Comment 4 Zbigniew Jedrzejewski-Szmek 2015-03-18 03:01:32 UTC
OK, then please file a bug in Debian or Ubuntu. They should be able to help.
Comment 5 You-Sheng Yang [:vicamo] 2015-03-18 03:45:02 UTC
Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=780705


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.