INN commit: branches/2.4/innd (inndstart.c)

INN Commit Russ_Allbery at isc.org
Sun Apr 6 14:15:04 UTC 2008


    Date: Sunday, April 6, 2008 @ 07:15:04
  Author: iulius
Revision: 7749

This patch makes innd listen on separate sockets for IPv4 and IPv6
connections if the IPV6_V6ONLY socket option is available.

There might also be operating systems that still have separate
IPv4 and IPv6 TCP implementations, and advanced features like
TCP SACK might not be available on v6 sockets.

Thanks to Miquel van Smoorenburg for this patch.

Modified:
  branches/2.4/innd/inndstart.c

-------------+
 inndstart.c |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Modified: inndstart.c
===================================================================
--- inndstart.c	2008-04-06 13:49:56 UTC (rev 7748)
+++ inndstart.c	2008-04-06 14:15:04 UTC (rev 7749)
@@ -213,6 +213,23 @@
         syswarn("can't set file descriptor limit to %ld",
                 innconf->rlimitnofile);
 
+#if defined(HAVE_INET6) && defined(IPV6_V6ONLY)
+    /* If we have the IPV6_V6ONLY socket option, and it works,
+       always open separate IPv4 and IPv6 sockets. */
+    if (addr_specified == 0 && addr6_specified == 0) {
+	j = socket(PF_INET6, SOCK_STREAM, 0);
+	if (j >= 0) {
+	    i = 1;
+            if (setsockopt (j, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&i,
+			     sizeof i) == 0) {
+	        addr_specified = 1;
+	        addr6_specified = 1;
+	    }
+	    close (j);
+	}
+    }
+#endif
+
     /* Create a socket and name it. */
 #ifdef HAVE_INET6
     if( ! (addr_specified || addr6_specified) ) {
@@ -266,6 +283,12 @@
 			sizeof i) < 0)
 		syswarn("can't set SO_REUSEADDR");
 #endif
+#ifdef IPV6_V6ONLY
+	    i = 1;
+            if (setsockopt(s[snum], IPPROTO_IPV6, IPV6_V6ONLY, (char *)&i,
+			sizeof i) < 0)
+		syswarn("can't set IPV6_V6ONLY");
+#endif
 	    memset(&server6, 0, sizeof server6);
 	    server6.sin6_port = htons(port);
 	    server6.sin6_family = AF_INET6;



More information about the inn-committers mailing list