summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Mauchle <fabian.mauchle@switch.ch>2017-09-24 22:03:40 +0200
committerFabian Mauchle <fabian.mauchle@switch.ch>2017-09-24 22:14:59 +0200
commit3dc69a67bb3666a6c2fb31d34c4b864aaf10603f (patch)
tree31cc9d45cb3e4a8946bf8eb41e277fba21bf28b7
parent59b519f6607a24996f82a014c5cd9209746b5103 (diff)
Only set IPV6_IPV6ONLY if it actually is a IPv6 socket.v6only
Set message level back to warning.
-rw-r--r--dtls.c4
-rw-r--r--udp.c4
-rw-r--r--util.c10
-rw-r--r--util.h2
4 files changed, 10 insertions, 10 deletions
diff --git a/dtls.c b/dtls.c
index f866092..f4a7c3d 100644
--- a/dtls.c
+++ b/dtls.c
@@ -677,7 +677,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, 1);
+ 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);
}
@@ -685,7 +685,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 380db18..a52b3a8 100644
--- a/udp.c
+++ b/udp.c
@@ -324,7 +324,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, 1);
+ 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);
}
@@ -332,7 +332,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 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;
diff --git a/util.h b/util.h
index c421505..5008d49 100644
--- a/util.h
+++ b/util.h
@@ -24,7 +24,7 @@ void port_set(struct sockaddr *sa, uint16_t port);
void printfchars(char *prefixfmt, char *prefix, char *charfmt, char *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);