From 3dc69a67bb3666a6c2fb31d34c4b864aaf10603f Mon Sep 17 00:00:00 2001 From: Fabian Mauchle Date: Sun, 24 Sep 2017 22:03:40 +0200 Subject: Only set IPV6_IPV6ONLY if it actually is a IPv6 socket. Set message level back to warning. --- util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index 876cb6c..69aa385 100644 --- a/util.c +++ b/util.c @@ -134,7 +134,7 @@ void disable_DF_bit(int socket, struct addrinfo *res) { } } -int bindtoaddr(struct addrinfo *addrinfo, int family, int reuse, int v6only) { +int bindtoaddr(struct addrinfo *addrinfo, int family, int reuse) { int s, on = 1; struct addrinfo *res; @@ -153,9 +153,9 @@ int bindtoaddr(struct addrinfo *addrinfo, int family, int reuse, int v6only) { if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) debugerrno(errno, DBG_WARN, "Failed to set SO_REUSEADDR"); #ifdef IPV6_V6ONLY - if (v6only) - if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) == -1) - debugerrno(errno, DBG_INFO, "Failed to set IPV6_V6ONLY"); + if (family == AF_INET6) + if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY , &on, sizeof(on)) == -1) + debugerrno(errno, DBG_WARN, "Failed to set IPV6_V6ONLY"); #endif if (!bind(s, res->ai_addr, res->ai_addrlen)) return s; @@ -215,7 +215,7 @@ int connecttcp(struct addrinfo *addrinfo, struct addrinfo *src, uint16_t timeout } for (res = addrinfo; res; res = res->ai_next) { - s = bindtoaddr(src, res->ai_family, 1, 1); + s = bindtoaddr(src, res->ai_family, 1); if (s < 0) { debug(DBG_WARN, "connecttoserver: socket failed"); continue; -- cgit v1.1