summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sock.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/sock.c b/src/sock.c
index f3da328..8d7e90a 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -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));