[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH 1/8] libbb: set netlink socket revbuf size before binding
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2020-11-22 12:13:58
Message-ID: CAK1hOcNH+M8Fx7iqt05Av_hReGSpNdHFRPCzvyZhQuFcuMKdOw () mail ! gmail ! com
[Download RAW message or body]
Applied, thank you.
On Mon, Dec 16, 2019 at 10:57 PM Jan Klötzke <jan@kloetzke.net> wrote:
>
> 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>
> ---
> libbb/xconnect.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/libbb/xconnect.c b/libbb/xconnect.c
> index e9a2470e4..5b32599ca 100644
> --- a/libbb/xconnect.c
> +++ b/libbb/xconnect.c
> @@ -422,14 +422,10 @@ int FAST_FUNC create_and_bind_to_netlink(int proto, int grp, unsigned rcvbuf)
> struct sockaddr_nl sa;
> int fd;
>
> - memset(&sa, 0, sizeof(sa));
> - sa.nl_family = AF_NETLINK;
> - sa.nl_pid = getpid();
> - sa.nl_groups = grp;
> fd = xsocket(AF_NETLINK, SOCK_DGRAM, proto);
> - xbind(fd, (struct sockaddr *) &sa, sizeof(sa));
> - close_on_exec_on(fd);
>
> + // Set receive buffer size before binding the socket. We want to have
> + // enough space before we start receiving messages.
> if (rcvbuf != 0) {
> // SO_RCVBUFFORCE (root only) can go above net.core.rmem_max sysctl
> setsockopt_SOL_SOCKET_int(fd, SO_RCVBUF, rcvbuf);
> @@ -444,6 +440,13 @@ int FAST_FUNC create_and_bind_to_netlink(int proto, int grp, unsigned rcvbuf)
> # endif
> }
>
> + memset(&sa, 0, sizeof(sa));
> + sa.nl_family = AF_NETLINK;
> + sa.nl_pid = getpid();
> + sa.nl_groups = grp;
> + xbind(fd, (struct sockaddr *) &sa, sizeof(sa));
> + close_on_exec_on(fd);
> +
> return fd;
> }
> #endif
> --
> 2.20.1
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic