diff options
author | James Clarke <jrtc27@jrtc27.com> | 2017-10-07 18:53:23 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-10-30 16:06:50 +0100 |
commit | 518fb3ba193cddc1369090bfdf827618b42791db (patch) | |
tree | 437b68db12aaa6910a1f2d717f2374c5ad78acb7 /libbb | |
parent | d1535216ca27047e3962d61b975bd2a638aa45a2 (diff) | |
download | busybox-w32-518fb3ba193cddc1369090bfdf827618b42791db.tar.gz busybox-w32-518fb3ba193cddc1369090bfdf827618b42791db.tar.bz2 busybox-w32-518fb3ba193cddc1369090bfdf827618b42791db.zip |
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 <jrtc27@jrtc27.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/udp_io.c | 8 |
1 files changed, 6 insertions, 2 deletions
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 @@ | |||
8 | */ | 8 | */ |
9 | #include "libbb.h" | 9 | #include "libbb.h" |
10 | 10 | ||
11 | #if defined(IPV6_PKTINFO) && !defined(IPV6_RECVPKTINFO) | ||
12 | # define IPV6_RECVPKTINFO IPV6_PKTINFO | ||
13 | #endif | ||
14 | |||
11 | /* | 15 | /* |
12 | * This asks kernel to let us know dst addr/port of incoming packets | 16 | * This asks kernel to let us know dst addr/port of incoming packets |
13 | * We don't check for errors here. Not supported == won't be used | 17 | * We don't check for errors here. Not supported == won't be used |
@@ -18,8 +22,8 @@ socket_want_pktinfo(int fd UNUSED_PARAM) | |||
18 | #ifdef IP_PKTINFO | 22 | #ifdef IP_PKTINFO |
19 | setsockopt_1(fd, IPPROTO_IP, IP_PKTINFO); | 23 | setsockopt_1(fd, IPPROTO_IP, IP_PKTINFO); |
20 | #endif | 24 | #endif |
21 | #if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) | 25 | #if ENABLE_FEATURE_IPV6 && defined(IPV6_RECVPKTINFO) |
22 | setsockopt_1(fd, IPPROTO_IPV6, IPV6_PKTINFO); | 26 | setsockopt_1(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO); |
23 | #endif | 27 | #endif |
24 | } | 28 | } |
25 | 29 | ||