From 1776de0140fb663777d4590fbb849c1d0a0c7885 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 25 Jan 2022 19:55:54 +0100 Subject: tcp, netlink, HAS{BYTES_ACKED,MIN_RTT,GETRANDOM} and NETLINK_GET_STRICT_CHK tcpi_bytes_acked and tcpi_min_rtt are only available on recent kernel versions: provide fall-back paths (incurring some grade of performance penalty). Support for getrandom() was introduced in Linux 3.17 and glibc 2.25: provide an alternate mechanism for that as well, reading from /dev/random. Also check if NETLINK_GET_STRICT_CHK is defined before using it: it's not strictly needed, we'll filter out irrelevant results from netlink anyway. Signed-off-by: Stefano Brivio --- netlink.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'netlink.c') diff --git a/netlink.c b/netlink.c index 0948f45..3ba5f05 100644 --- a/netlink.c +++ b/netlink.c @@ -46,7 +46,10 @@ static int nl_seq; static int nl_sock_init_do(void *arg) { struct sockaddr_nl addr = { .nl_family = AF_NETLINK, }; - int *s = &nl_sock, v = 1; + int *s = &nl_sock; +#ifdef NETLINK_GET_STRICT_CHK + int y = 1; +#endif ns: if (((*s) = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) < 0 || @@ -56,7 +59,9 @@ ns: if (*s == -1 || !arg || s == &nl_sock_ns) return 0; - setsockopt(*s, SOL_NETLINK, NETLINK_GET_STRICT_CHK, &v, sizeof(v)); +#ifdef NETLINK_GET_STRICT_CHK + setsockopt(*s, SOL_NETLINK, NETLINK_GET_STRICT_CHK, &y, sizeof(y)); +#endif ns_enter((struct ctx *)arg); s = &nl_sock_ns; -- cgit v1.2.3