--- sshd.c 2007-06-05 01:22:32.000000000 -0700
+++ sshd.c.new 2007-11-17 00:07:08.000000000 -0800
@@ -971,12 +971,27 @@
}
/*
* Set socket options.
+ */
+
+ /*
* Allow local port reuse in TIME_WAIT.
*/
if (setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR,
&on, sizeof(on)) == -1)
error("setsockopt SO_REUSEADDR: %s", strerror(errno));
+#ifdef IPV6_V6ONLY
+ if (ai->ai_family == AF_INET6) {
+ /*
+ * Only communicate in IPv6 over AF_INET6 sockets.
+ */
+ 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. */