Comment 8 for bug 1770082

Revision history for this message
Ryan Harper (raharper) wrote : Re: [Bug 1770082] Re: systemd-networkd not renaming devices on boot

On Fri, May 11, 2018 at 3:25 AM, Daniel Axtens
<email address hidden> wrote:
> Ryan, I can't get that to work on my systems. What is it that update-
> initramfs is supposed to change? I don't see any files in my initramfs
> that are generated or read by netplan. Neither do I see netplan itself
> in the initramfs!

The .link files end up getting pulled into the initramfs, where
systemd-udev will run and apply the
names there. When systemd-udev does a rename, the kernel marks an
interface 'name_assign_type' to a value of 4
and systemd-udev will refuse to further rename a device, despite
having a rule (.link file) to do so.

Netplan works around this in 'apply' by unplugging the driver, which
resets the state of the 'name_assign_type' value
in the kernel.

>
> Mathieu, I thought netplan was supposed to be initramfs friendly by
> virtue of being in C. Is it supposed to be in the initramfs?

The generator is, the cli is not.

>
> For both of you, how are you getting through initrd without your device
> being given a generic udev name (like ens3 or enp1s0)? On both my
> physical and virtual machines, my various network cards all get renamed
> in initrd, well before netplan is run.

We're not; udev runs in the initramfs and triggers renames there.

>
> [PS. I know the scenario as described sounds far-fetched - the original
> way this came up was a cloud setup where you can change the type of a
> network interface but keep the same MAC. The different type leads to a
> different udev name, which is what revealed that set-name: wasn't taking
> effect.]

Cloud scenarios are slightly different when cloud-init is involved;
Cloud-init itself will handle device renames if
they are needed. Typically cloud-init just re-uses the name the
interface got from udev when it renders it's netplan config during
boot.

For non-cloud scenarios (or if you attempt to use set-name in a cloud
instances without launching a new instance) we're seeing this
situation where we are creating new .link files but they need to be
present in the initramfs otherwise when udevd runs, it will set the
name
to the predictable name and then ignore any of the .link files on the rootfs.

This really needs fixing in udev; I don't think there's a good reason
to have udev refuse to rename an interface.

>
> --
> You received this bug notification because you are subscribed to
> netplan.
> Matching subscriptions: netplan
> https://bugs.launchpad.net/bugs/1770082
>
> Title:
> systemd-networkd not renaming devices on boot
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/netplan/+bug/1770082/+subscriptions