network/link: ENODATA from reading IFLA_MASTER when an interface has no master

When an interface leaved from the master interface, then reading
IFLA_MASTER attribute causes ENODATA. When the interface was previously
enslaved to another interface, we need to remove reference to the
interface from the previous master interface.

This is especially important when
```
ip link set dev eth0 nomaster
```
is called.

Fixes a bug introduced by 0d411b7f8f (v249).
Fixes #37629.
This commit is contained in:
Yu Watanabe
2025-05-28 04:38:56 +09:00
parent ae6420c923
commit f44b20b7b6
+2 -2
View File
@@ -2205,8 +2205,8 @@ static int link_update_master(Link *link, sd_netlink_message *message) {
r = sd_netlink_message_read_u32(message, IFLA_MASTER, (uint32_t*) &master_ifindex);
if (r == -ENODATA)
return 0;
if (r < 0)
master_ifindex = 0; /* no master interface */
else if (r < 0)
return log_link_debug_errno(link, r, "rtnl: failed to read master ifindex: %m");
if (master_ifindex == link->ifindex)