Bug#941636: udev: 73-usb-net-by-mac.rules breaks systemd.link(5) network interface renaming for usb network adapters

Michael Biebl biebl at debian.org
Thu Oct 3 12:34:03 BST 2019


Hi

Am 03.10.19 um 10:17 schrieb Benjamin Poirier:
> Package: udev
> Version: 243-2
> Severity: normal
> 
> /lib/udev/rules.d/73-usb-net-by-mac.rules prevents the renaming of network
> interfaces from usb adapters using the systemd.link(5) mechanism.
> 
> The latter is implemented using /lib/udev/rules.d/80-net-setup-link.rules
> which is ineffective because 73-usb-net-by-mac.rules has previously
> unconditionally set a name (based on the mac address).

Not quite unconditionally. The conditions are
- user has not disabled persistent interface naming via the kernel
command line (net.ifnames=0)
- the interface name has not been provided by user space
ATTR{name_assign_type}=="3"
- NAME= is unset
- it has a universally administered (stable) MAC address (second bit
  is 0).
- the user has no custom /etc/udev/rules.d/80-net-setup-link.rules or
/etc/systemd/network/99-default.link

You are correct though, we do not handle the case where a user has a
arbitrarily named .link file which is used to rename a USB device.

Fwiw, I've run into this issue myself some time ago, where I created a
.link file which supposedly was not applied. After some head scratching
it was then clear that the udev rule file had already renamed the interface.

My solution back then was a
touch /etc/udev/rules.d/73-usb-net-by-mac.rules (basically what you
figured out as well)


> For example
> 	ben at f3:~$ cat /etc/systemd/network/10-dock.link
> 	[Match]
> 	MACAddress=3c:e1:a1:01:02:03
> 
> 	[Link]
> 	Name=dock
> does not work (with the related interface being a usb adapter).
> 
> I believe that /lib/udev/rules.d/73-usb-net-by-mac.rules should be removed. In
> fact, the same functionality can be provided by the systemd.link mechanism
> while also allowing users to override the default rule. I tested this by
> setting up
> 	/etc/udev/rules.d/73-usb-net-by-mac.rules -> /dev/null
> and adding
> 	ben at f3:~$ cat /etc/systemd/network/73-usb-net-by-mac.link
> 	[Match]
> 	Path=*-usb-*
> 
> 	[Link]
> 	NamePolicy=mac
> 
> (Ideally the match would be done using something like Type= but DEVTYPE is not
> an attribute of the network device. Matching on the ID_BUS udev attribute
> would work but is not supported by net_setup_link I think.)
> 
> This still used a name based on the mac address by default (instead of based
> on the slot) and also allowed me to change the name by adding a file like the
> 10-dock.link example above.


Using a .link file is an interesting idea but afaics we can't express
all the conditions I mentioned above.
So we would trade one set of corner cases where it doesn't behave as
expected with another set of corner cases.
Not sure if we can make everyone happy.

Martin, as main author of 73-usb-net-by-mac.rules, what's your take on this?

Michael

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20191003/9ac597ed/attachment.sig>


More information about the Pkg-systemd-maintainers mailing list