]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/link: ENODATA from reading IFLA_MASTER when an interface has no master
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 27 May 2025 14:17:40 +0000 (23:17 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 27 May 2025 19:38:56 +0000 (04:38 +0900)
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 0d411b7f8f5407e9ce84dcb4ede0b029ade7fede (v249).
Fixes #37629.

src/network/networkd-link.c

index 96739b0d0a6d6df25a6a3f8948f7a3a0f72d77e4..ccaaba25d339d3d90ef2b4b76a3fdae418d0982a 100644 (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)