Revert "network: check the received interface name is actually new"

This reverts commit 176b8be10f.

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.
This commit is contained in:
Yu Watanabe
2026-06-13 18:55:31 +09:00
parent 92e4afc4d3
commit 70d83c3d35
-13
View 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);