diff options
author | Michael Adam <obnox@samba.org> | 2013-11-08 15:31:11 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-11-09 13:34:33 +0100 |
commit | 0698e4d18006df53e5ca76a722e7d38bf9a227bf (patch) | |
tree | 7cb267bce1c31b6c4f8ade0bcaccddeef268b789 /src | |
parent | d7f67768ebb6a9b3fe19effc8c89de5fa832d946 (diff) | |
download | tinyproxy-0698e4d18006df53e5ca76a722e7d38bf9a227bf.tar.gz tinyproxy-0698e4d18006df53e5ca76a722e7d38bf9a227bf.zip |
sock: set IPV6_V6ONLY on the socket before binding an IPv6 address
so that we can bind wildcard for both IPv4 and IPv6.
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/sock.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -204,6 +204,18 @@ static int listen_on_one_socket(struct addrinfo *ad) return -1; } + if (ad->ai_family == AF_INET6) { + ret = setsockopt(listenfd, IPPROTO_IPV6, IPV6_V6ONLY, &on, + sizeof(on)); + if (ret != 0) { + log_message(LOG_ERR, + "setsockopt failed to set IPV6_V6ONLY: %s", + strerror(errno)); + close(listenfd); + return -1; + } + } + ret = bind(listenfd, ad->ai_addr, ad->ai_addrlen); if (ret != 0) { log_message(LOG_ERR, "bind failed: %s", strerror (errno)); |