diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-11-11 03:13:39 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-11-14 02:17:19 +0100 |
commit | f264cd20372d8a2c26398dd46cf2823d1a82cb8c (patch) | |
tree | 3e43aa216bc020239d0107a4e9080a10b062731c /src/network | |
parent | network/netdev: always queue request of creating netdev then process it later (diff) | |
download | systemd-f264cd20372d8a2c26398dd46cf2823d1a82cb8c.tar.xz systemd-f264cd20372d8a2c26398dd46cf2823d1a82cb8c.zip |
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.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/netdev/netdev.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c index 32050ecf60..6cce3838d1 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) { |