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

net_setup_link doesn't rename interfaces after switchroot #9807

Closed
msekletar opened this issue Aug 6, 2018 · 1 comment
Closed

net_setup_link doesn't rename interfaces after switchroot #9807

msekletar opened this issue Aug 6, 2018 · 1 comment

Comments

@msekletar
Copy link
Contributor

systemd version the issue has been seen with

  • systemd-239

Used distribution

  • Fedora

Expected behavior you didn't see

  • Configuration from the link file is not applied.
#  /etc/systemd/network/50-net0.link
[Match]
MACAddress=FA:16:3E:5E:57:FA

[Link]
Name=net0

Unexpected behaviour you saw

  • After reboot interface still has the name taken from ID_NET_NAME_PATH.
[root@localhost ~]# ip link show enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether fa:16:3e:5e:57:fa brd ff:ff:ff:ff:ff:ff

Steps to reproduce the problem
No specific steps except using the above link file.

Additional info

I think that problem is this piece of code in src/udev/net/link-config.c,

        /* if we can't get the assgin type, assume we should rename */
        s = udev_device_get_sysattr_value(device, "name_assign_type");
        if (!s)
                return true;

        r = safe_atou(s, &type);
        if (r < 0)
                return true;

        switch (type) {
        case NET_NAME_USER:
        case NET_NAME_RENAMED:
                /* these were already named by userspace, do not touch again */
                return false;

Above code basically ensures that once udev renames the interface using stable name in initrd then it can't be renamed later via link file from real root (I could rename it manually or using initscripts ifcfg DEVICE+HWADDR combo). The obvious solution is to rebuild initrd every time you change Name= stanza in the link file. However, rebuilding initrd is too heavyweight and should be generally avoided if possible and likely even not possible on some systems.

Another reason why we should think about the current policy is that it brings inconsistency as only Name stanza is not applied and rest of the link file is applied.

Yet another reason is the inconsistency with basically any other tool out there that used to do NIC naming. All these tools allow you to rename the interface as many times as you want (though certain conditions must be met e.g. interface must be DOWN).

@yuwata
Copy link
Member

yuwata commented Aug 6, 2018

Duplicate of #9006.

@yuwata yuwata closed this as completed Aug 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants