]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/link: always join to the main interface when we receive IFLA_MASTER attribute
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Jan 2024 16:58:01 +0000 (01:58 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 6 Jan 2024 20:25:55 +0000 (05:25 +0900)
Otherwise, e.g. when we enumerate a bridge port first, then the bridge
main interface, then the port cannot be managed by the main interface.

Fixes #30682.

src/network/networkd-link.c

index 01817737d06e3243486ef4ff872292e163cca04f..ca3e4fbc9f7eaeaf1c5176235222d24579db331c 100644 (file)
@@ -2000,20 +2000,18 @@ static int link_update_master(Link *link, sd_netlink_message *message) {
         if (master_ifindex == link->ifindex)
                 master_ifindex = 0;
 
-        if (master_ifindex == link->master_ifindex)
-                return 0;
-
-        if (link->master_ifindex == 0)
-                log_link_debug(link, "Attached to master interface: %i", master_ifindex);
-        else if (master_ifindex == 0)
-                log_link_debug(link, "Detached from master interface: %i", link->master_ifindex);
-        else
-                log_link_debug(link, "Master interface changed: %i %s %i", link->master_ifindex,
-                               special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), master_ifindex);
-
-        link_drop_from_master(link);
+        if (master_ifindex != link->master_ifindex) {
+                if (link->master_ifindex == 0)
+                        log_link_debug(link, "Attached to master interface: %i", master_ifindex);
+                else if (master_ifindex == 0)
+                        log_link_debug(link, "Detached from master interface: %i", link->master_ifindex);
+                else
+                        log_link_debug(link, "Master interface changed: %i %s %i", link->master_ifindex,
+                                       special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), master_ifindex);
 
-        link->master_ifindex = master_ifindex;
+                link_drop_from_master(link);
+                link->master_ifindex = master_ifindex;
+        }
 
         r = link_append_to_master(link);
         if (r < 0)