]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Revert "network: check the received interface name is actually new"
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 11 Jun 2026 00:49:41 +0000 (09:49 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 13 Jun 2026 09:55:31 +0000 (18:55 +0900)
This reverts commit 176b8be10ffce2f8c1fc931a37904a528057016f.

The check introduced by the commit is racy, as when format_ifname() is
called, the interface may be already renamed (again) to another name.

This is typically problematic when we swap interface names:
```
ip link set aaa name tmpname
ip link set bbb name aaa
ip link set tmpname bbb
```
When networkd received the notification about name change aaa -> tmpname,
the interface is already renamed from tmpname to bbb. So, the reverted
logic skips updating Link.ifname:
```
aaa: New interface name 'tmpname' received from the kernel does not correspond with the name currently configured on the actual interface 'bbb'. Ignoring.
```
On the second notification about name change bbb -> aaa, networkd fails to
update the mapping Manager.links_by_name, as we skipped previous renaming
and the mapping still has an outdated entry for 'aaa'.
```
bbb: Interface name change detected, renamed to aaa.
aaa: Failed to manage link by its new name: File exists
aaa: Could not process link message: File exists
aaa: Failed
aaa: State changed: configured -> failed
```

By reverting the commit, the issue is fixed. But the commit intended to
fix another issue #20203. So this reintroduces #20203. Let's fix it
in a later commit.

Fixes #42527.
Reintroduces #20203.

src/network/networkd-link.c

index c57657597f81df3211a5f27e234e42ebf3145c70..1b47b8cc3f4fec4d17780d9952a05ec700af4b05 100644 (file)
@@ -30,7 +30,6 @@
 #include "errno-util.h"
 #include "ethtool-util.h"
 #include "event-util.h"
-#include "format-ifname.h"
 #include "fs-util.h"
 #include "glyph-util.h"
 #include "logarithm.h"
@@ -2609,7 +2608,6 @@ static int link_update_alternative_names(Link *link, sd_netlink_message *message
 }
 
 static int link_update_name(Link *link, sd_netlink_message *message) {
-        char ifname_from_index[IF_NAMESIZE];
         const char *ifname;
         int r;
 
@@ -2626,17 +2624,6 @@ static int link_update_name(Link *link, sd_netlink_message *message) {
         if (streq(ifname, link->ifname))
                 return 0;
 
-        r = format_ifname(link->ifindex, ifname_from_index);
-        if (r < 0)
-                return log_link_debug_errno(link, r, "Could not get interface name for index %i.", link->ifindex);
-
-        if (!streq(ifname, ifname_from_index)) {
-                log_link_debug(link, "New interface name '%s' received from the kernel does not correspond "
-                               "with the name currently configured on the actual interface '%s'. Ignoring.",
-                               ifname, ifname_from_index);
-                return 0;
-        }
-
         log_link_info(link, "Interface name change detected, renamed to %s.", ifname);
 
         hashmap_remove(link->manager->links_by_name, link->ifname);