]> andersk Git - openssh.git/blobdiff - sshd.c
- (djm) Only listen for IPv6 connections on AF_INET6 sockets; patch from
[openssh.git] / sshd.c
diff --git a/sshd.c b/sshd.c
index 9019411acca83bd1dc15fa21737f2e1b87fc5326..27c38ba53168fa3dda6e2a3cbd3e72533f6c5c35 100644 (file)
--- a/sshd.c
+++ b/sshd.c
@@ -976,6 +976,16 @@ server_listen(void)
                    &on, sizeof(on)) == -1)
                        error("setsockopt SO_REUSEADDR: %s", strerror(errno));
 
+#ifdef IPV6_V6ONLY
+               /* Only communicate in IPv6 over AF_INET6 sockets. */
+               if (ai->ai_family == AF_INET6) {
+                       if (setsockopt(listen_sock, IPPROTO_IPV6, IPV6_V6ONLY,
+                           &on, sizeof(on)) == -1)
+                               error("setsockopt IPV6_V6ONLY: %s",
+                                   strerror(errno));
+               }
+#endif
+
                debug("Bind to port %s on %s.", strport, ntop);
 
                /* Bind the socket to the desired port. */
This page took 0.032152 seconds and 4 git commands to generate.