]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: do not bring down a bonding port interface when it is already joined
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Feb 2024 02:10:45 +0000 (11:10 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 Feb 2024 05:15:17 +0000 (14:15 +0900)
Follow-up for 9f913d37a01f71e559d099bff280827f8817d8c5.

Fixes #31165.

src/network/networkd-setlink.c

index d0cdca62982aaa6236baf7f2359c1c4c3e2adc6c..4c4e0d1cd97c23a1f45733709e2ae65c648dd9b4 100644 (file)
@@ -532,15 +532,6 @@ static int link_is_ready_to_set_link(Link *link, Request *req) {
                         if (!netdev_is_ready(link->network->bond))
                                 return false;
                         m = link->network->bond->ifindex;
-
-                        /* Do not check link->set_flags_messages here, as it is ok even if link->flags
-                         * is outdated, and checking the counter causes a deadlock. */
-                        if (FLAGS_SET(link->flags, IFF_UP)) {
-                                /* link must be down when joining to bond master. */
-                                r = link_down_now(link);
-                                if (r < 0)
-                                        return r;
-                        }
                 } else if (link->network->bridge) {
                         if (ordered_set_contains(link->manager->request_queue, &req_mac))
                                 return false;
@@ -559,6 +550,15 @@ static int link_is_ready_to_set_link(Link *link, Request *req) {
                         return -EALREADY; /* indicate to cancel the request. */
                 }
 
+                /* Do not check link->set_flags_messages here, as it is ok even if link->flags is outdated,
+                 * and checking the counter causes a deadlock. */
+                if (link->network->bond && FLAGS_SET(link->flags, IFF_UP)) {
+                        /* link must be down when joining to bond master. */
+                        r = link_down_now(link);
+                        if (r < 0)
+                                return r;
+                }
+
                 req->userdata = UINT32_TO_PTR(m);
                 break;
         }