Skip to content

Commit 4e6a35e

Browse files
committed
network: do not send too many netlink messages in a single event
Fixes #26743.
1 parent b3a4f4f commit 4e6a35e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/network/networkd-queue.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "networkd-queue.h"
88
#include "string-table.h"
99

10+
#define REPLY_CALLBACK_COUNT_THRESHOLD 128
11+
1012
static Request *request_free(Request *req) {
1113
if (!req)
1214
return NULL;
@@ -220,6 +222,13 @@ int manager_process_requests(sd_event_source *s, void *userdata) {
220222
if (req->waiting_reply)
221223
continue; /* Waiting for netlink reply. */
222224

225+
/* Typically, requests send netlink message asynchronously. If there are many requests
226+
* queued, then this event may make reply callback queue in sd-netlink full. */
227+
if (netlink_get_reply_callback_count(manager->rtnl) >= REPLY_CALLBACK_COUNT_THRESHOLD ||
228+
netlink_get_reply_callback_count(manager->genl) >= REPLY_CALLBACK_COUNT_THRESHOLD ||
229+
fw_ctx_get_reply_callback_count(manager->fw_ctx) >= REPLY_CALLBACK_COUNT_THRESHOLD)
230+
return 0;
231+
223232
r = req->process(req, link, req->userdata);
224233
if (r == 0)
225234
continue;

0 commit comments

Comments
 (0)