aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Klötzke <jan@kloetzke.net>2019-12-16 22:56:49 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-11-22 13:12:51 +0100
commit12aa68d10fdcc5bd2d9385506d11aed3a0c2eaf1 (patch)
treef1b778c61fc1be4005759e300a3bf3f347d6fde4
parent9bf4499dd7c72db7636555ec386804540a3266fe (diff)
downloadbusybox-w32-12aa68d10fdcc5bd2d9385506d11aed3a0c2eaf1.tar.gz
busybox-w32-12aa68d10fdcc5bd2d9385506d11aed3a0c2eaf1.tar.bz2
busybox-w32-12aa68d10fdcc5bd2d9385506d11aed3a0c2eaf1.zip
libbb: set netlink socket revbuf size before binding
As soon as the socket is bound it will receive messages. Make sure the recieve buffer size is increased before the first message is received. Signed-off-by: Jan Klötzke <jan@kloetzke.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/xconnect.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index e9a2470e4..5dd9cfd28 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -422,17 +422,14 @@ int FAST_FUNC create_and_bind_to_netlink(int proto, int grp, unsigned rcvbuf)
422 struct sockaddr_nl sa; 422 struct sockaddr_nl sa;
423 int fd; 423 int fd;
424 424
425 memset(&sa, 0, sizeof(sa));
426 sa.nl_family = AF_NETLINK;
427 sa.nl_pid = getpid();
428 sa.nl_groups = grp;
429 fd = xsocket(AF_NETLINK, SOCK_DGRAM, proto); 425 fd = xsocket(AF_NETLINK, SOCK_DGRAM, proto);
430 xbind(fd, (struct sockaddr *) &sa, sizeof(sa));
431 close_on_exec_on(fd);
432 426
427 /* Set receive buffer size before binding the socket
428 * We want to have enough space before we start receiving messages.
429 */
433 if (rcvbuf != 0) { 430 if (rcvbuf != 0) {
434 // SO_RCVBUFFORCE (root only) can go above net.core.rmem_max sysctl 431 setsockopt_SOL_SOCKET_int(fd, SO_RCVBUF, rcvbuf);
435 setsockopt_SOL_SOCKET_int(fd, SO_RCVBUF, rcvbuf); 432 /* SO_RCVBUFFORCE (root only) can go above net.core.rmem_max */
436 setsockopt_SOL_SOCKET_int(fd, SO_RCVBUFFORCE, rcvbuf); 433 setsockopt_SOL_SOCKET_int(fd, SO_RCVBUFFORCE, rcvbuf);
437# if 0 434# if 0
438 { 435 {
@@ -444,6 +441,13 @@ int FAST_FUNC create_and_bind_to_netlink(int proto, int grp, unsigned rcvbuf)
444# endif 441# endif
445 } 442 }
446 443
444 memset(&sa, 0, sizeof(sa));
445 sa.nl_family = AF_NETLINK;
446 sa.nl_pid = getpid();
447 sa.nl_groups = grp;
448 xbind(fd, (struct sockaddr *) &sa, sizeof(sa));
449 close_on_exec_on(fd);
450
447 return fd; 451 return fd;
448} 452}
449#endif 453#endif