Stopping udev from renaming your VLAN interfaces to bad names
Back in early December I wrote about Why udev may be trying to rename your VLAN interfaces to bad names, where modern versions of udev tried to rename VLAN devices from the arbitrary names you give them to the base name of the network device they're on. Since the base name is already taken, this fails.
There turns out to be a simple cause and workaround for this, at
least in my configuration, from Zbigniew Jędrzejewski-Szmek. In Fedora,
all I need to do is add 'NamePolicy=keep'
to the [Link] section of my .link
file. This makes my
.link file be:
[Match] MACAddress=60:45:cb:a0:e8:dd [Link] Description=Onboard port MACAddressPolicy=persistent Name=em0 # Stop VLAN renaming NamePolicy=keep
Setting 'NamePolicy=keep' doesn't keep the actual network device from being renamed from the kernel's original name for it to 'em0', but it makes udev leave the VLAN devices alone. In turn this means udev and systemd consider them to have been successfully created, so you get the usual systemd sys-subsystem-net-devices .devices units for them showing up as fully up.
In a way, 'NamePolicy=keep' in a .link file is an indirect way for me to tell apart real network hardware from created virtual devices that share the same MAC, or at least ones created through networkd. As covered in the systemd.netdev manpage, giving a name to your virtual device is mandatory (Name= is a required field), so I think such devices will always be considered to already have a name by udev.
(This was a change in systemd-241, apparently. It changes the semantics of existing .link files in a way that's subtly not backward compatible, but such is the systemd way.)
However, I suspect that things might be different if I didn't use
'biosdevname=0
' in my kernel command line parameters. These days
this is implemented in udev, so allowing udev to rename your network
devices from the kernel assigned names to the consistent network
device naming
scheme may be considered a rename for the purposes of 'NamePolicy=keep'.
That would leave me with the same problem of telling real hardware
apart from virtual hardware that I had in the original entry.
However, for actual matching against physical hardware, I suspect that you can also generally use a Property= on selected attributes (as suggested by Alex Xu in the comments on the original entry). For instance, most people's network devices are on PCI busses, so:
Property=ID_BUS=pci
There are a whole variety of properties that real network hardware
has that VLANs don't (based on 'udev info
' output), although I
don't know about other types of virtual network devices. It does
seem pretty safe that no virtual network device will claim to be
on a PCI bus, though.
(I haven't tested the Property= approach, since 'NamePolicy=keep' is sufficient in my case.)
|
|