Bug#780705: udev: floating net device number on devices with ro rootfs

You-Sheng Yang vicamo at gmail.com
Wed Mar 18 06:57:33 GMT 2015


Typo in the proposed patch. Re-attach the correct one.

-- 
You-Sheng Yang (Vicamo)
-------------- next part --------------
>From 6247d5017dcab60c1e1ae2b061fb6748765d1d1f Mon Sep 17 00:00:00 2001
From: You-Sheng Yang <vicamo at gmail.com>
Date: Wed, 18 Mar 2015 11:33:32 +0800
Subject: [PATCH] Load tmp rules for persistent netdev names

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 ....

This patch add symlink from "/lib/udev/rules.d/70-persistent-net.rules"
to "/run/udev/tmp-ruiles--70-persistent-net.rules".

Signed-off-by: You-Sheng Yang <vicamo at gmail.com>
---
 debian/udev.links | 1 +
 1 file changed, 1 insertion(+)

diff --git a/debian/udev.links b/debian/udev.links
index 1a4356e..4e5ed91 100644
--- a/debian/udev.links
+++ b/debian/udev.links
@@ -2,3 +2,4 @@
 /lib/systemd/system/systemd-udevd.service /lib/systemd/system/udev.service
 /usr/share/man/man8/systemd-udevd.8 /usr/share/man/man8/udevd.8
 /bin/udevadm /sbin/udevadm
+/lib/udev/rules.d/70-persistent-net.rules /run/udev/tmp-ruiles--70-persistent-net.rules
-- 
2.1.4



More information about the Pkg-systemd-maintainers mailing list