From: Yu Watanabe Date: Thu, 30 Nov 2023 10:07:36 +0000 (+0900) Subject: network: do not send too many netlink messages in a single event X-Git-Tag: v255-rc4~5^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F30268%2Fhead;p=thirdparty%2Fsystemd.git network: do not send too many netlink messages in a single event Fixes #26743. --- diff --git a/src/network/networkd-queue.c b/src/network/networkd-queue.c index 90caefbc72c..1695aacf765 100644 --- a/src/network/networkd-queue.c +++ b/src/network/networkd-queue.c @@ -7,6 +7,8 @@ #include "networkd-queue.h" #include "string-table.h" +#define REPLY_CALLBACK_COUNT_THRESHOLD 128 + static Request *request_free(Request *req) { if (!req) return NULL; @@ -220,6 +222,13 @@ int manager_process_requests(sd_event_source *s, void *userdata) { if (req->waiting_reply) continue; /* Waiting for netlink reply. */ + /* Typically, requests send netlink message asynchronously. If there are many requests + * queued, then this event may make reply callback queue in sd-netlink full. */ + if (netlink_get_reply_callback_count(manager->rtnl) >= REPLY_CALLBACK_COUNT_THRESHOLD || + netlink_get_reply_callback_count(manager->genl) >= REPLY_CALLBACK_COUNT_THRESHOLD || + fw_ctx_get_reply_callback_count(manager->fw_ctx) >= REPLY_CALLBACK_COUNT_THRESHOLD) + return 0; + r = req->process(req, link, req->userdata); if (r == 0) continue;