Fix traceroute applet on the FreeBSD
This patch addressing 2 issues: 1. Replacing source/dest with uh_sport/uh_dport. It seems that uh_* members are defined on both Linux and BSD, so no #ifdef here 2. Use SOL_IPV6 instead of SOL_RAW on the FreeBSD to fix IPV6_CHECKSUM setsockopt Signed-off-by: Alex Samorukov <samm@os2.kiev.ua> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
ca2dc96be8
commit
2b94c053d1
@ -716,8 +716,8 @@ packet4_ok(int read_len, int seq)
|
|||||||
// Off: since we do not form the entire IP packet,
|
// Off: since we do not form the entire IP packet,
|
||||||
// but defer it to kernel, we can't set source port,
|
// but defer it to kernel, we can't set source port,
|
||||||
// and thus can't check it here in the reply
|
// and thus can't check it here in the reply
|
||||||
/* && up->source == ident */
|
/* && up->uh_sport == ident */
|
||||||
&& up->dest == htons(port + seq)
|
&& up->uh_dport == htons(port + seq)
|
||||||
) {
|
) {
|
||||||
return (type == ICMP_TIMXCEED ? -1 : code + 1);
|
return (type == ICMP_TIMXCEED ? -1 : code + 1);
|
||||||
}
|
}
|
||||||
@ -985,8 +985,13 @@ traceroute_init(int op, char **argv)
|
|||||||
snd = xsocket(AF_INET, SOCK_DGRAM, 0);
|
snd = xsocket(AF_INET, SOCK_DGRAM, 0);
|
||||||
}
|
}
|
||||||
#if ENABLE_TRACEROUTE6
|
#if ENABLE_TRACEROUTE6
|
||||||
|
# if defined(__FreeBSD__)
|
||||||
|
# define SOL_V6_OPTION SOL_IPV6
|
||||||
|
# else
|
||||||
|
# define SOL_V6_OPTION SOL_RAW
|
||||||
|
# endif
|
||||||
else {
|
else {
|
||||||
if (setsockopt_int(rcvsock, SOL_RAW, IPV6_CHECKSUM, 2) != 0)
|
if (setsockopt_int(rcvsock, SOL_V6_OPTION, IPV6_CHECKSUM, 2) != 0)
|
||||||
bb_perror_msg_and_die("setsockopt(%s)", "IPV6_CHECKSUM");
|
bb_perror_msg_and_die("setsockopt(%s)", "IPV6_CHECKSUM");
|
||||||
if (op & OPT_USE_ICMP)
|
if (op & OPT_USE_ICMP)
|
||||||
snd = xsocket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
|
snd = xsocket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
|
||||||
|
Loading…
Reference in New Issue
Block a user