Skip to content

Commit bb5ae62

Browse files
Eric Dumazetshemminger
authored andcommitted
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 2d34851 ("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: 2d34851 ("lib/libnetlink: re malloc buff if size is not enough") Signed-off-by: Eric Dumazet <[email protected]> Cc: Hangbin Liu <[email protected]> Cc: Phil Sutter <[email protected]> Signed-off-by: Stephen Hemminger <[email protected]>
1 parent 9e46c5c commit bb5ae62

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/libnetlink.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ static int rtnl_recvmsg(int fd, struct msghdr *msg, char **answer)
718718
if (len < 0)
719719
return len;
720720

721+
if (len < 32768)
722+
len = 32768;
721723
buf = malloc(len);
722724
if (!buf) {
723725
fprintf(stderr, "malloc error: not enough buffer\n");

0 commit comments

Comments
 (0)