libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] Patch to improve IPv6 support in libmicrohttpd


From: Christian Grothoff
Subject: Re: [libmicrohttpd] Patch to improve IPv6 support in libmicrohttpd
Date: Sun, 15 Jan 2012 17:11:14 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20111004 Lightning/1.0b1 Icedove/3.0.11

On 01/15/2012 04:41 PM, Steinar H. Gunderson wrote:
Hi,

Apologies for not using the bug tracker, but I really couldn't get it to
work; on one of my email addresses, it never sent a notification, and in
another one, I got a notification but as soon as I had created an account and
set a password, I was logged right out and denied access back in :-)

Very strange. I saw some account creation e-mails (I get notifications), and it works for others.

Anyway, included is a patch to improve the IPv6 support in libmicrohttpd;
it supports a “dual-stack” mode that allows for both IPv4 and IPv6
connections on the same socket. The MHD_USE_IPv6 mode already does this
more-or-less by accident on some operating systems, but on Linux it depends
on a sysctl, and on *BSD you won't get it at all. Also, MHD_USE_IPv6 does not
fall back to IPv4 if IPv6 is unavailable, making it a less attractive option
for application developers -- MHD_USE_DUALSTACK should be safe for general
use unless you specifically do not want IPv6.

The patch also includes a fix so that if you _do_ receive an IPv4 connection
on the dual-stack socket, you get back the proper IPv4 address (e.g.
127.0.0.1) and not the mapped-v4 address (::ffff:127.0.0.1).

I've tested this on Debian, with XBMC as the user (that's what I wanted it
for in the first place :-) ). Thus, the patch is against 0.4.6. Let me know
if there are any questions.

0.4.6? You got to be kidding me. We're at 0.9.17, 0.4.6 is about 2 years old. More importantly, the patch is overall not taking the code in the right direction. The modern, recommended way to do dual-stack IPv6 is what MHD already supports: use two listen sockets. Your approach may work on some systems (see: need for sysctl) but is again not how it should be done. There've been discussions about this on the MHD mailinglist in the past. Maybe I'll need to put something more explicit into the documentation...

Anyway, you *can* do your style of dual-stack with MHD 0.9.x using the MHD_OPTION_LISTEN_SOCKET (you'll need to move some of the code from your patch, specifically the code doing SOCKET + SETSOCKOPT) before MHD_start_daemon and pass the resulting listen socket to MHD_start_daemon. However, I won't accept a patch to put explicit support for this style into the code as it is not the recommended way to dual-stack modern applications and thus we should not encourage the use of a socket bound to both IPv4 and IPv6.

Happy hacking!

Christian

Attachment: libmicrohttpd-dualstack.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]