Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface Naming broken in 2345 Stable #36

Closed
goochjj opened this issue Mar 4, 2020 · 6 comments
Closed

Interface Naming broken in 2345 Stable #36

goochjj opened this issue Mar 4, 2020 · 6 comments
Labels
channel/stable Issue concerns the Stable channel. kind/bug Something isn't working

Comments

@goochjj
Copy link

goochjj commented Mar 4, 2020

When 2345 was installed this morning, all my network renaming rules stopped working.

This is in the release notes, and broke it coreos/bugs#1767

My link file is pretty simple:
[Match]
MacAddress=....

[Link]
Name=srv0

This worked in previous stables releases of coreos and flatcar.

My server was in-place upgraded to flatcar per your documentation.

Upon running
SYSTEMD_LOG_LEVEL=debug udevadm test-builtin net_setup_link /sys/class/net/ens192

It indicates the default naming scheme is v238 - this naming scheme IMPLICITLY has the NamePolicy "keep" behavior applied. The keep option isn't available until v240 - BEFORE v240 it is ALWAYS applied even if you try to clear it. So what happens is in the initrd, eth0 gets renamed to ens192, and then when non-initrd systemd picks it up, it won't rename something that the "userspace" has already renamed. Ever.

I had to add this
set linux_append="net.naming-scheme=latest"
to my /usr/share/oem/grub.cfg to fix it. After boot, the interfaces are renamed properly, and udevadm shows it's using v240.

If there's a more permanent fix to this, or this needs to be documented, or re-changed, or the coreos to flatcar upgrade process needs another step... I don't know. Please investigate.

@pothos
Copy link
Member

pothos commented Mar 5, 2020

Hello,
thanks for reporting!
In /usr/lib/systemd/network/99-default.link we set NamePolicy=keep kernel database onboard slot path as default for all links. According to the docs for Name, NamePolicy always takes precedence so I tried to unset it but without success (I tried both unsetting it for all links as directly below Name). I guess it is a bug in the old naming scheme behavior. Switching to the new one seems the correct way to fix this problem in the next release.

@pothos pothos added kind/bug Something isn't working channel/stable Issue concerns the Stable channel. labels Mar 5, 2020
pothos added a commit to flatcar-archive/coreos-overlay that referenced this issue Mar 5, 2020
When the initramfs gave a persistent name to
a network interface, renaming it via Name is
not working with the v238 naming scheme even
if NamePolicy is unset.
Switch to the newest network interface naming
scheme to resolve this issue.

flatcar/Flatcar#36
pothos added a commit to flatcar-archive/coreos-overlay that referenced this issue Mar 5, 2020
When the initramfs gave a persistent name to
a network interface, renaming it via Name is
not working with the v238 naming scheme even
if NamePolicy is unset.
Switch to the newest network interface naming
scheme to resolve this issue.

flatcar/Flatcar#36
@goochjj
Copy link
Author

goochjj commented Mar 5, 2020

Yeah I saw that, but masking 99-default.link didn't help. The docs also seem to indicate that if an earlier lexical file matches (i.e. 20-ens192.link), and that file DOESN'T have a NamePolicy defined, then the NamePolicy is blank. I also tried explicitly setting NamePolicy= in my 20-ens192.link file but it didn't help.

I had to dig into the code of systemd.

For detail:

SYSTEMD_LOG_LEVEL=debug udevadm test-builtin net_setup_link /sys/class/net/ens192

Config file /etc/systemd/network/20-ens192.link applies to device ens192
link_config: autonegotiation is unset or enabled, the speed and duplex are not writable.
ens192: Device has name_assign_type=4
Using default interface naming scheme 'v238'.
ens192: Device already has a name given by userspace, not renaming.
ID_NET_LINK_FILE=/etc/systemd/network/20-ens192.link

Led me to this code in v244:
https://fossies.org/linux/systemd/src/udev/net/link-config.c

  396         if (IN_SET(name_type, NET_NAME_USER, NET_NAME_RENAMED)
  397             && !naming_scheme_has(NAMING_ALLOW_RERENAMES)) {
  398                 log_device_debug(device, "Device already has a name given by userspace, not renaming.");
  399                 goto no_rename;
  400         }

I didn't trace it back further - it seemed pretty clear to me at that point that if the naming scheme came up as v238, upon further digging I'd probably find that RERENAMES aren't allowed.

@goochjj
Copy link
Author

goochjj commented Mar 5, 2020

Just for confirmation:
https://github.com/hramrach/systemd-1/blob/master/src/udev/net/naming-scheme.h

typedef enum NamingSchemeFlags {
        /* First, the individual features */
        NAMING_SR_IOV_V            = 1 << 0, /* Use "v" suffix for SR-IOV, see 609948c7043a */
        NAMING_NPAR_ARI            = 1 << 1, /* Use NPAR "ARI", see 6bc04997b6ea */
        NAMING_INFINIBAND          = 1 << 2, /* Use "ib" prefix for infiniband, see 938d30aa98df */
        NAMING_ZERO_ACPI_INDEX     = 1 << 3, /* Use zero acpi_index field, see d81186ef4f6a */
        NAMING_ALLOW_RERENAMES     = 1 << 4, /* Allow re-renaming of devices, see #9006 */
        NAMING_STABLE_VIRTUAL_MACS = 1 << 5, /* Use device name to generate MAC, see 6d3646406560 */
        NAMING_NETDEVSIM           = 1 << 6, /* Generate names for netdevsim devices, see eaa9d507d855 */
        NAMING_LABEL_NOPREFIX      = 1 << 7, /* Don't prepend ID_NET_LABEL_ONBOARD with interface type prefix */

        /* And now the masks that combine the features above */
        NAMING_V238 = 0,
        NAMING_V239 = NAMING_V238 | NAMING_SR_IOV_V | NAMING_NPAR_ARI,
        NAMING_V240 = NAMING_V239 | NAMING_INFINIBAND | NAMING_ZERO_ACPI_INDEX | NAMING_ALLOW_RERENAMES,
        NAMING_V241 = NAMING_V240 | NAMING_STABLE_VIRTUAL_MACS,
        NAMING_V243 = NAMING_V241 | NAMING_NETDEVSIM | NAMING_LABEL_NOPREFIX,

        _NAMING_SCHEME_FLAGS_INVALID = -1,
} NamingSchemeFlags;

The NamePolicy setup will work with scheme v240 or newer.

@pothos
Copy link
Member

pothos commented Mar 5, 2020

Good, thanks for the details!

pothos added a commit to flatcar-archive/coreos-overlay that referenced this issue Mar 6, 2020
When the initramfs gave a persistent name to
a network interface, renaming it via Name is
not working with the v238 naming scheme even
if NamePolicy is unset.
Switch to the newest network interface naming
scheme to resolve this issue.

flatcar/Flatcar#36
pothos added a commit to flatcar-archive/coreos-overlay that referenced this issue Mar 6, 2020
When the initramfs gave a persistent name to
a network interface, renaming it via Name is
not working with the v238 naming scheme even
if NamePolicy is unset.
Switch to the newest network interface naming
scheme to resolve this issue.

flatcar/Flatcar#36
@pothos
Copy link
Member

pothos commented Mar 10, 2020

The change will land in the next release but has some other possible side effects where in few cases the persistent name will change slightly. Also a persistent name will be used where there was no one available before.

@dongsupark
Copy link
Member

Stable 2345.3.1 was just released, so this issue should be fixed.
If you still see the issue, feel free to reopen it.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
channel/stable Issue concerns the Stable channel. kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants