View Issue Details

IDProjectCategoryView StatusLast Update
0001597libmicrohttpdIPv6 supportpublic2010-08-13 20:44
Reportercandrews Assigned ToChristian Grothoff  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionwon't fix 
Product Version0.9.0 
Summary0001597: With IPv6 enabled, binds to only IPv6 and not IPv4
DescriptionWhen libmicrohttpd detects IPv6 and is compiled with that support, and is used at runtime with the MHD_USE_IPv6 option, it sets the IPV6_V6ONLY option on the socket. Because of this socket option, the socket only responds on IPv6, and not IPv4 - and there is no way for the socket to respond on both.

I think setting the IPV6_V6ONLY socket option is a bug. If it were not set, the socket would respond on both IPv4 and v6 like (almost) all other servers.

Bug originally reported in XBMC: http://trac.xbmc.org/ticket/9052
TagsNo tags attached.
Attached Files
no-ipv6only.patch (490 bytes)   
Index: src/daemon/daemon.c
===================================================================
--- src/daemon/daemon.c	(revision 12520)
+++ src/daemon/daemon.c	(working copy)
@@ -1639,13 +1639,6 @@
 	}
       retVal->socket_fd = socket_fd;
 
-      if ((options & MHD_USE_IPv6) != 0)
-	{
-	  const int on = 1;
-	  setsockopt (socket_fd, 
-		      IPPROTO_IPV6, IPV6_V6ONLY, 
-		      &on, sizeof (on));      
-	}
       if (BIND (socket_fd, servaddr, addrlen) == -1)
 	{
 #if HAVE_MESSAGES
no-ipv6only.patch (490 bytes)   

Activities

candrews

2010-08-12 19:22

reporter   ~0004110

attached no-ipv6only.patch which removes the setting of the IPV6_V6ONLY socket option.

Christian Grothoff

2010-08-13 20:44

manager   ~0004111

Actually, this is not a bug but a feature. Before 0.9.0, the behaviour was undefined (on some OSes, the bind would be against v4 and v6, on others only against v6 -- sometimes depending on kernel configuration).

The recommended (!) behaviour is to bind only against v6 (in general) based on most current IPv6 literature that I can find.

If you want to also bind against v4, simply run the start-daemon function once more without the USE_IPV6 option. Alternatively, 0.9.0 also offers the ability for the client code to do the socket, bind and listen call itself and pass the listen socket using the LISTEN_SOCKET option. That way, you *can* still use the not-recommended, non-portable one-socket two-protocols bind if your OS supports it (good luck).

Issue History

Date Modified Username Field Change
2010-08-12 18:41 candrews New Issue
2010-08-12 19:21 candrews File Added: no-ipv6only.patch
2010-08-12 19:22 candrews Note Added: 0004110
2010-08-13 20:44 Christian Grothoff Assigned To => Christian Grothoff
2010-08-13 20:44 Christian Grothoff Status new => closed
2010-08-13 20:44 Christian Grothoff Resolution open => won't fix
2010-08-13 20:44 Christian Grothoff Additional Information Updated
2010-08-13 20:44 Christian Grothoff Note Added: 0004111
2010-08-13 20:44 Christian Grothoff Additional Information Updated
2013-05-06 12:53 Christian Grothoff Category IPv6 => IPv6 support