From: Felix Fietkau Date: Wed, 25 Aug 2021 11:29:45 +0000 (+0200) Subject: libnetlink: fix netlink buffer space handling X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=9622264cf92691f18ae9222b0a4c9db95af5d80d;p=project%2Fustp.git libnetlink: fix netlink buffer space handling Significantly increaese buffer size in order to avoid missing events Do not stop polling socket after running out of buffer space Signed-off-by: Felix Fietkau --- diff --git a/libnetlink.c b/libnetlink.c index 477e1a2..5c5523d 100644 --- a/libnetlink.c +++ b/libnetlink.c @@ -27,7 +27,7 @@ #include "libnetlink.h" #ifndef DEFAULT_RTNL_BUFSIZE -#define DEFAULT_RTNL_BUFSIZE 256 * 1024 +#define DEFAULT_RTNL_BUFSIZE 4 * 1024 * 1024 #endif #ifndef RTNL_SND_BUFSIZE @@ -48,6 +48,7 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, socklen_t addr_len; int sndbuf = RTNL_SND_BUFSIZE; int rcvbuf = RTNL_RCV_BUFSIZE; + int yes = 1; memset(rth, 0, sizeof(*rth)); @@ -69,6 +70,9 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, return -1; } + if (setsockopt(rth->fd, SOL_NETLINK, NETLINK_NO_ENOBUFS, &yes, sizeof(yes)) < 0) + ERROR("NETLINK_NO_EBUFS"); + memset(&rth->local, 0, sizeof(rth->local)); rth->local.nl_family = AF_NETLINK; rth->local.nl_groups = subscriptions;