Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Rev 73 | Blame | Compare with Previous | Last modification | View Log | RSS feed

Author: Magnus Holmgren <holmgren@debian.org>
Description: Set the IPV6_V6ONLY socket option on AF_INET6 sockets
 Since lshd by default enumerates available address families and calls
 bind() once for each, conflicts will occur otherwise.

diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' trunk~/src/io.c trunk/src/io.c
--- trunk~/src/io.c     2006-01-23 18:49:58.000000000 +0100
+++ trunk/src/io.c      2010-07-27 02:17:04.000000000 +0200
@@ -1690,6 +1690,13 @@
   {
     int yes = 1;
     setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof yes);
+#if WITH_IPV6 && defined (IPV6_V6ONLY)
+    if (local->sa_family == AF_INET6)
+      {
+        if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &yes, sizeof(yes)) < 0)
+          werror("setsockopt IPV6_V6ONLY failed: %e.\n", errno);
+      }
+#endif
   }
 
   if (bind(s, local, length) < 0)