[Linuxptp-devel] [PATCH] Force IPv6 to IPV6 only, no ipv4 to ipv6 mapping.
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Gary E. M. <ge...@re...> - 2015-08-10 19:15:13
|
By default, at least on Linux, opening a PF_INET6 socket also grabs the matching IPv4 port. This patch stops that. Only tested on Linux. Unknown how this will work on *BSD or WinXX. --- udp6.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/udp6.c b/udp6.c index f098b8c..54df133 100644 --- a/udp6.c +++ b/udp6.c @@ -121,6 +121,10 @@ static int open_socket_ipv6(const char *name, struct in6_addr mc_addr[2], short *interface_index = index; + if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on))) { + pr_err("setsockopt IPV6_V6ONLY failed: %m"); + goto no_option; + } if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) { pr_err("setsockopt SO_REUSEADDR failed: %m"); goto no_option; -- 2.4.6 |