From: Yu Watanabe Date: Thu, 11 Jun 2026 00:49:41 +0000 (+0900) Subject: Revert "network: check the received interface name is actually new" X-Git-Tag: v261-rc4~29^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70d83c3d35119006e4cab273236fe162379e8a40;p=thirdparty%2Fsystemd.git Revert "network: check the received interface name is actually new" 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. --- diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index c57657597f8..1b47b8cc3f4 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -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);