From: Yu Watanabe Date: Mon, 11 Nov 2024 02:13:39 +0000 (+0900) Subject: network/netdev: fix counter handling if request is cancelled X-Git-Tag: v257-rc2~18^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f264cd20372d8a2c26398dd46cf2823d1a82cb8c;p=thirdparty%2Fsystemd.git network/netdev: fix counter handling if request is cancelled Follow-up for 1003093604661bd984574889167f2ff4dfd6209c. If a netdev is detached for some reasons, then previously the request was simply cancelled, and the underlying interface never enter the configured state, as the 'stacked_netdevs_created' flag never set. This makes the counter decremented manually by the function, and set the flag. So, the underlying interface can eter the configured state. --- diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c index 32050ecf60d..6cce3838d1f 100644 --- a/src/network/netdev/netdev.c +++ b/src/network/netdev/netdev.c @@ -854,7 +854,7 @@ static int stacked_netdev_process_request(Request *req, Link *link, void *userda assert(link); if (!netdev_is_managed(netdev)) - return 1; /* Already detached, due to e.g. reloading .netdev files, cancelling the request. */ + goto cancelled; /* Already detached, due to e.g. reloading .netdev files, cancelling the request. */ r = netdev_is_ready_to_create(netdev, link); if (r <= 0) @@ -865,6 +865,18 @@ static int stacked_netdev_process_request(Request *req, Link *link, void *userda return log_netdev_warning_errno(netdev, r, "Failed to create netdev: %m"); return 1; + +cancelled: + assert_se(TAKE_PTR(req->counter) == &link->create_stacked_netdev_messages); + link->create_stacked_netdev_messages--; + + if (link->create_stacked_netdev_messages == 0) { + link->stacked_netdevs_created = true; + log_link_debug(link, "Stacked netdevs created."); + link_check_ready(link); + } + + return 1; } static int create_stacked_netdev_handler(sd_netlink *rtnl, sd_netlink_message *m, Request *req, Link *link, void *userdata) {