From 1e8f4c7ee2282dc96e25476053e149f5d74a2c24 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Mon, 20 Nov 2017 15:25:24 +0100 Subject: Stop trying to set IPV6_V6ONLY on non-ipv6 sockets. See RADSECPROXY-79 for rationale. --- dtls.c | 6 +++--- udp.c | 6 +++--- util.c | 6 +++--- util.h | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dtls.c b/dtls.c index daeacca..e96e704 100644 --- a/dtls.c +++ b/dtls.c @@ -1,5 +1,5 @@ /* Copyright (c) 2007-2009, UNINETT AS - * Copyright (c) 2012,2016 NORDUnet A/S */ + * Copyright (c) 2012,2016-2017, NORDUnet A/S */ /* See LICENSE for licensing information. */ #include @@ -670,7 +670,7 @@ void addserverextradtls(struct clsrvconf *conf) { switch (((struct hostportres *)list_first(conf->hostports)->data)->addrinfo->ai_family) { case AF_INET: if (client4_sock < 0) { - client4_sock = bindtoaddr(srcres, AF_INET, 0, 0); + client4_sock = bindtoaddr(srcres, AF_INET, 0); if (client4_sock < 0) debugx(1, DBG_ERR, "addserver: failed to create client socket for server %s", conf->name); } @@ -678,7 +678,7 @@ void addserverextradtls(struct clsrvconf *conf) { break; case AF_INET6: if (client6_sock < 0) { - client6_sock = bindtoaddr(srcres, AF_INET6, 0, 1); + client6_sock = bindtoaddr(srcres, AF_INET6, 0); if (client6_sock < 0) debugx(1, DBG_ERR, "addserver: failed to create client socket for server %s", conf->name); } diff --git a/udp.c b/udp.c index 273460e..57225e3 100644 --- a/udp.c +++ b/udp.c @@ -1,5 +1,5 @@ /* Copyright (c) 2007-2009, UNINETT AS - * Copyright (c) 2012, NORDUnet A/S */ + * Copyright (c) 2012-2013, 2017, NORDUnet A/S */ /* See LICENSE for licensing information. */ #include @@ -320,7 +320,7 @@ void addserverextraudp(struct clsrvconf *conf) { switch (((struct hostportres *)list_first(conf->hostports)->data)->addrinfo->ai_family) { case AF_INET: if (client4_sock < 0) { - client4_sock = bindtoaddr(srcres, AF_INET, 0, 0); + client4_sock = bindtoaddr(srcres, AF_INET, 0); if (client4_sock < 0) debugx(1, DBG_ERR, "addserver: failed to create client socket for server %s", conf->name); } @@ -328,7 +328,7 @@ void addserverextraudp(struct clsrvconf *conf) { break; case AF_INET6: if (client6_sock < 0) { - client6_sock = bindtoaddr(srcres, AF_INET6, 0, 1); + client6_sock = bindtoaddr(srcres, AF_INET6, 0); if (client6_sock < 0) debugx(1, DBG_ERR, "addserver: failed to create client socket for server %s", conf->name); } diff --git a/util.c b/util.c index eb251ab..6db7112 100644 --- a/util.c +++ b/util.c @@ -123,7 +123,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; @@ -142,7 +142,7 @@ 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 (family == AF_INET6) if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) == -1) debugerrno(errno, DBG_WARN, "Failed to set IPV6_V6ONLY"); #endif @@ -204,7 +204,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; diff --git a/util.h b/util.h index 36a5cdd..5784eb9 100644 --- a/util.h +++ b/util.h @@ -1,5 +1,5 @@ /* Copyright (c) 2007-2009, UNINETT AS - * Copyright (c) 2016, NORDUnet A/S */ + * Copyright (c) 2016-2017, NORDUnet A/S */ /* See LICENSE for licensing information. */ #include @@ -20,7 +20,7 @@ void port_set(struct sockaddr *sa, uint16_t port); void printfchars(char *prefixfmt, char *prefix, char *charfmt, uint8_t *chars, int len); 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 connecttcp(struct addrinfo *addrinfo, struct addrinfo *src, uint16_t timeout); -- cgit v1.1