IPV6_RECVPKTINFO not working for IPv4-mapped addresses on Linux?

Benedikt Stockebrand bs at stepladder-it.com
Mon Jan 20 17:01:23 CET 2014

Hi Gert and list,

Gert Doering <gert at space.net> writes:

> On Mon, Jan 20, 2014 at 12:49:56PM +0000, Benedikt Stockebrand wrote:
>> I've run into this sort of problems a few years ago, but I used a
>> different solution: I didn't use mapped addresses but two separate
>> sockets, one for IPv4 and another for IPv6.  It isn't nice, but it
>> sorted out the problem in a way that worked on all platforms I tested
>> without any problems or #ifdefs or whatever.
> I expected that suggestion :-)

it's not as if mapped addresses didn't have their uses -- they keep code
significantly simpler in some cases.  It's just that the combination
with UDP had a habit of biting one in the backside especially when
things were meant to be portable... (been there, done that, got the bite

> (I'm surprised your code didn't need #ifdefs for the IPv4 part, as the
> ancilliary socket stuff is completely different on Linux and the BSDs
> here...  IP_PKTINFO vs. IP_RECVDSTADDR... for IPv6 it's the same, but
> even there you have 2292-only and 3542 implementations)

That wass I don't know how many years ago (2005?), so don't ask me about
the details---they are bound to have changed since then anyway.

All I do remember is that Linux was still lagging behind compared to the
BSD/KAME and Solaris code, and that Solaris IPv6 support was in a few
cases based on old RFCs which had since been updated.

>> Of course, the key question then is how much trouble is it to fix that
>> in the existing application code base.
> Much :-).  

Thought so:-( It's just that often enough the infrastructure is already
there to bind sockets to specific addresses, and as far as I've seen
that can sometimes be modified to handle IPv4 and IPv6 separately as

> This *is* a long-term goal, though, [...]
> So, for the time being, the decision was to go for a single server 
> socket at this point and fix other stuff first.  Then come back.

Fair enough.

Anyway, if you really want to make your life miserable, open sockets
bound to the individual IP addresses found on the machine---and then
also listen on a routing socket so you know you have to look for new
addresses coming in...  (Last time I checked that was pretty much the
only option you had with Java.)



Benedikt Stockebrand,               Stepladder IT Training+Consulting
Dipl.-Inform.                       http://www.stepladder-it.com/

	Business Grade IPv6 --- Consulting, Training, Projects

More information about the ipv6-ops mailing list