diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-03-05 10:44:48 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-03-05 10:44:48 -0500 |
commit | 298e08132f3368514b868eecc5f44e982280010d (patch) | |
tree | a2afecfb92995e73716c2cf6013b4eccbc165ff1 | |
parent | 77a7a980d0ab0bbfd4d99a062dbb0b5eadaa32ce (diff) | |
parent | dd68d596cdf68999c0cb4c0caf594d8580eaba40 (diff) | |
download | tor-298e08132f3368514b868eecc5f44e982280010d.tar.gz tor-298e08132f3368514b868eecc5f44e982280010d.zip |
Merge remote-tracking branch 'public/bug4760'
-rw-r--r-- | changes/bug4760 | 4 | ||||
-rw-r--r-- | src/or/connection.c | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/changes/bug4760 b/changes/bug4760 new file mode 100644 index 0000000000..ea8d16edb7 --- /dev/null +++ b/changes/bug4760 @@ -0,0 +1,4 @@ + o Minor bugfixes: + - When binding to an IPv6 address, set the IPV6_V6ONLY socket + option, so that the IP stack doesn't decide to use it for IPv4 + too. Fixes bug 4760; bugfix on 0.2.3.9-alpha. diff --git a/src/or/connection.c b/src/or/connection.c index bf65e8e81b..06a7562656 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -902,6 +902,25 @@ connection_listener_new(const struct sockaddr *listensockaddr, make_socket_reuseable(s); +#ifdef IPV6_V6ONLY + if (listensockaddr->sa_family == AF_INET6) { +#ifdef _WIN32 + /* In Redmond, this kind of thing passes for standards-conformance. */ + DWORD one = 1; +#else + int one = 1; +#endif + /* We need to set IPV6_V6ONLY so that this socket can't get used for + * IPv4 connections. */ + if (setsockopt(s,IPPROTO_IPV6, IPV6_V6ONLY, (void*)&one, sizeof(one))<0) { + int e = tor_socket_errno(s); + log_warn(LD_NET, "Error setting IPV6_V6ONLY flag: %s", + tor_socket_strerror(e)); + /* Keep going; probably not harmful. */ + } + } +#endif + if (bind(s,listensockaddr,socklen) < 0) { const char *helpfulhint = ""; int e = tor_socket_errno(s); |