From 518fb3ba193cddc1369090bfdf827618b42791db Mon Sep 17 00:00:00 2001 From: James Clarke Date: Sat, 7 Oct 2017 18:53:23 +0100 Subject: udp_io, traceroute: Standardise IPv6 PKTINFO handling to be portable The current standard (RFC 3542) is for IPV6_RECVPKTINFO to be given to setsockopt, and IPV6_PKTINFO to be used as the packet type. Previously, RFC 2292 required IPV6_PKTINFO to be used for both, but RFC 3542 re-purposed IPV6_PKTINFO when given to setsockopt. The special Linux-specific IPV6_2292PKTINFO has the same semantics as IPV6_PKTINFO in RFC 2292, but was introduced at the same time as IPV6_RECVPKTINFO. Therefore, if we have IPV6_RECVPKTINFO available, we can use the RFC 3542 style, and if not, we assume that only the RFC 2292 API is available, using IPV6_PKTINFO for both. Signed-off-by: James Clarke Signed-off-by: Denys Vlasenko --- libbb/udp_io.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libbb/udp_io.c') diff --git a/libbb/udp_io.c b/libbb/udp_io.c index 6e3ef484e..68355e6c4 100644 --- a/libbb/udp_io.c +++ b/libbb/udp_io.c @@ -8,6 +8,10 @@ */ #include "libbb.h" +#if defined(IPV6_PKTINFO) && !defined(IPV6_RECVPKTINFO) +# define IPV6_RECVPKTINFO IPV6_PKTINFO +#endif + /* * This asks kernel to let us know dst addr/port of incoming packets * We don't check for errors here. Not supported == won't be used @@ -18,8 +22,8 @@ socket_want_pktinfo(int fd UNUSED_PARAM) #ifdef IP_PKTINFO setsockopt_1(fd, IPPROTO_IP, IP_PKTINFO); #endif -#if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) - setsockopt_1(fd, IPPROTO_IPV6, IPV6_PKTINFO); +#if ENABLE_FEATURE_IPV6 && defined(IPV6_RECVPKTINFO) + setsockopt_1(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO); #endif } -- cgit v1.2.3