From c3e12de0a634f15154b8b0826b00c9f0816ef1fb Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 2 Feb 2024 11:10:45 +0900 Subject: [PATCH] network: do not bring down a bonding port interface when it is already joined Follow-up for 9f913d37a01f71e559d099bff280827f8817d8c5. Fixes #31165. --- src/network/networkd-setlink.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/network/networkd-setlink.c b/src/network/networkd-setlink.c index d0cdca62982..4c4e0d1cd97 100644 --- a/src/network/networkd-setlink.c +++ b/src/network/networkd-setlink.c @@ -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; }