diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/xconnect.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 39e56b223..ea5fe173f 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
@@ -11,6 +11,9 @@ | |||
11 | #include <netinet/in.h> | 11 | #include <netinet/in.h> |
12 | #include <net/if.h> | 12 | #include <net/if.h> |
13 | #include <sys/un.h> | 13 | #include <sys/un.h> |
14 | #if ENABLE_IFPLUGD || ENABLE_FEATURE_MDEV_DAEMON || ENABLE_UEVENT | ||
15 | # include <linux/netlink.h> | ||
16 | #endif | ||
14 | #include "libbb.h" | 17 | #include "libbb.h" |
15 | 18 | ||
16 | int FAST_FUNC setsockopt_int(int fd, int level, int optname, int optval) | 19 | int FAST_FUNC setsockopt_int(int fd, int level, int optname, int optval) |
@@ -412,6 +415,38 @@ int FAST_FUNC create_and_bind_dgram_or_die(const char *bindaddr, int port) | |||
412 | } | 415 | } |
413 | 416 | ||
414 | 417 | ||
418 | #if ENABLE_IFPLUGD || ENABLE_FEATURE_MDEV_DAEMON || ENABLE_UEVENT | ||
419 | int FAST_FUNC create_and_bind_to_netlink(int proto, int grp, unsigned rcvbuf) | ||
420 | { | ||
421 | struct sockaddr_nl sa; | ||
422 | int fd; | ||
423 | |||
424 | memset(&sa, 0, sizeof(sa)); | ||
425 | sa.nl_family = AF_NETLINK; | ||
426 | sa.nl_pid = getpid(); | ||
427 | sa.nl_groups = grp; | ||
428 | fd = xsocket(AF_NETLINK, SOCK_DGRAM, proto); | ||
429 | xbind(fd, (struct sockaddr *) &sa, sizeof(sa)); | ||
430 | close_on_exec_on(fd); | ||
431 | |||
432 | if (rcvbuf != 0) { | ||
433 | // SO_RCVBUFFORCE (root only) can go above net.core.rmem_max sysctl | ||
434 | setsockopt_SOL_SOCKET_int(fd, SO_RCVBUF, rcvbuf); | ||
435 | setsockopt_SOL_SOCKET_int(fd, SO_RCVBUFFORCE, rcvbuf); | ||
436 | # if 0 | ||
437 | { | ||
438 | int z; | ||
439 | socklen_t zl = sizeof(z); | ||
440 | getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &z, &zl); | ||
441 | bb_error_msg("SO_RCVBUF:%d", z); | ||
442 | } | ||
443 | # endif | ||
444 | } | ||
445 | |||
446 | return fd; | ||
447 | } | ||
448 | #endif | ||
449 | |||
415 | int FAST_FUNC create_and_connect_stream_or_die(const char *peer, int port) | 450 | int FAST_FUNC create_and_connect_stream_or_die(const char *peer, int port) |
416 | { | 451 | { |
417 | int fd; | 452 | int fd; |