netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] lib/libnetlink: ensure a minimum of 32KB for the buffer used in rtnl_recvmsg()
@ 2019-02-13  1:58 Eric Dumazet
  2019-02-13  2:04 ` David Ahern
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Eric Dumazet @ 2019-02-13  1:58 UTC (permalink / raw)
  To: David Ahern, Stephen Hemminger
  Cc: netdev, Eric Dumazet, Eric Dumazet, Hangbin Liu, Phil Sutter

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 <edumazet@google.com>
Cc: Hangbin Liu <liuhangbin@gmail.com>
Cc: Phil Sutter <phil@nwl.cc>
---
 lib/libnetlink.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 1892a02ab5d0d73776c9882ffc77edcd2c663d01..0d48a3d43cf03065dacbd419578ab10af56431a4 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");
-- 
2.21.0.rc0.258.g878e2cd30e-goog


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-06-05  7:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-13  1:58 [PATCH iproute2] lib/libnetlink: ensure a minimum of 32KB for the buffer used in rtnl_recvmsg() Eric Dumazet
2019-02-13  2:04 ` David Ahern
2019-02-13  2:08   ` Eric Dumazet
2019-02-13  6:20     ` Hangbin Liu
2019-02-14 13:51       ` Michal Kubecek
2019-02-14 13:49   ` Michal Kubecek
2019-02-14 17:34     ` David Ahern
2019-02-14 17:47       ` Phil Sutter
2023-05-29 12:29   ` Gal Pressman
2023-05-31 21:51     ` Stephen Hemminger
2023-06-04 13:33       ` Gal Pressman
2023-06-04 16:03         ` David Ahern
2023-06-05  7:24           ` Gal Pressman
2019-02-13 17:46 ` Phil Sutter
2019-02-13 17:58   ` Eric Dumazet
2019-02-13 21:57 ` Stephen Hemminger
2019-02-13 21:59   ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).