From: Eric Dumazet Date: Wed, 13 Feb 2019 01:58:41 +0000 (-0800) Subject: lib/libnetlink: ensure a minimum of 32KB for the buffer used in rtnl_recvmsg() X-Git-Tag: v5.0.0~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb5ae621d0c7b9caf3a101903783bd5a1c997fa4;p=thirdparty%2Fiproute2.git lib/libnetlink: ensure a minimum of 32KB for the buffer used in rtnl_recvmsg() In the past, we tried to increase the buffer size up to 32 KB in order to reduce number of syscalls per dump. Commit 2d34851cd341 ("lib/libnetlink: re malloc buff if size is not enough") brought the size back to 4KB because the kernel can not know the application is ready to receive bigger requests. See kernel commits 9063e21fb026 ("netlink: autosize skb lengthes") and d35c99ff77ec ("netlink: do not enter direct reclaim from netlink_dump()") for more details. Fixes: 2d34851cd341 ("lib/libnetlink: re malloc buff if size is not enough") Signed-off-by: Eric Dumazet Cc: Hangbin Liu Cc: Phil Sutter Signed-off-by: Stephen Hemminger --- diff --git a/lib/libnetlink.c b/lib/libnetlink.c index 1892a02ab..0d48a3d43 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -718,6 +718,8 @@ static int rtnl_recvmsg(int fd, struct msghdr *msg, char **answer) if (len < 0) return len; + if (len < 32768) + len = 32768; buf = malloc(len); if (!buf) { fprintf(stderr, "malloc error: not enough buffer\n");