PATCH: innd: seperate sockets for IPv4 and IPV6
"Miquel van Smoorenburg"
list-inn-workers at news.cistron.nl
Sun Mar 23 13:17:08 UTC 2008
This patch makes innd listen on seperate sockets for IPv4 and IPv6
connections if the IPV6_V6ONLY socketoption is available.
Advantages are mostly cosmetic, but for me it's very useful to be
able to better see what connections are IPv4 and what connections
are IPv6 when running for example 'netstat -tn'.
There might also be operating systems that still have seperate
ipv4 and ipv6 TCP implementations, and advanced features like
TCP SACK might not be available on V6 sockets.
diff -ruN t/inn-2.4.3/innd/inndstart.c inn-2.4.3/innd/inndstart.c
--- t/inn-2.4.3/innd/inndstart.c 2006-03-20 05:14:57.000000000 +0100
+++ inn-2.4.3/innd/inndstart.c 2008-03-18 21:17:33.000000000 +0100
@@ -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;
--
The From: and Reply-To: addresses are internal news2mail gateway addresses.
Reply to the list or to "Miquel van Smoorenburg" <miquels at cistron.nl>
More information about the inn-workers
mailing list