Comment 18 for bug 1770082

Revision history for this message
Daniel Axtens (daxtens) wrote :

Hi Ryan,

[Journal Output]
Attached.

[Reproducer]
uvt-kvm create xenial-test release=xenial arch=amd64
virsh edit xenial-test # change network interface pci slot: s/0x03/0x10/
virsh destroy xenial-test
virsh start xenial-test
uvt-kvm ssh xenial-test
dmesg|grep rename
[ 2.790623] virtio_net virtio3 ens16: renamed from eth0
[ 6.048520] virtio_net virtio3 ens3: renamed from ens16

[Analysis]
I've been working on this a lot, and I think I have the cause of the difference.

In udev-events.c, udev_execute_rules will _forcibly_ rename a device with via a netlink message if there is a matching rule that sets a name. Under Xenial, there *is* a matching rule, in 70-persistent-net.rules, so this forces a rename. This rename will occur even if the device already has a name, and therefore even if the rules file isn't in the initramfs.

Under Bionic, this rules file doesn't exist, there is a .link file instead. Unfortunately, a name in a .link file will only take effect if the device hasn't been renamed - because of the renaming in initrd, this means that a link file that is not present in the initrd will never be able to cause a rename.

[Solutions]
There are a couple of ways we could fix this that come to mind:

 - make netplan generate a file in /run/udev/rules.d for each device
 - make systemd rename devices from a link file even if they've been renamed

My preference is the first, but I'm open to anything we can get upstream.

Thanks again.

Regards,
Daniel