Subject: IPv4 mapped addresses issue

From: "João Graça Nobrega" <[email-masked]>
Date: Fri, 11 Jun 2004 19:28:58 +0100

Hello IPv6:
 
In RFC 3493 it is said AF_INET6 sockets receive connections from IPv4 nodes,
mapping their addresses to ::ffff:<IPv4 address>. I think this behaviour is
on by default. Although it is not explicitly stated, section 5.3 indicates a
way to turn off this behaviour using the IPv6_V6ONLY socket option.
I was wondering if you can or can't bind both AF_INET6 and AF_INET sockets
to the same port at the same time. Is it ok or is it a bind error? If it is
not an error which socket receives a IPv4 connection? Both? Only one? None?
In my test lab I can't seam to be able to get Microsoft's O.S. AF_INET6
sockets to receive connections from IPv4, forcing me to bind 2 sockets, one
in each protocol. In linux it works fine though, I only nead one socket. I
have not tested any other O.S. yet. This seams highly contraditory...
 
            Regards,
                        João Nóbrega.
--------------------------------------------------------------------
IETF IPv6 working group mailing list
[email-masked]
Administrative Requests: https://www1.ietf.org/mailman/listinfo/ipv6
--------------------------------------------------------------------

---

From: [email-masked] (Jun-ichiro itojun Hagino)
Date: Mon, 14 Jun 2004 16:05:04 +0900 (JST)

> have not tested any other O.S. yet. This seams highly contraditory...

	the behavior (relationship between AF_INET and AF_INET6 sockets/binds)
	is not documented, so there's no standard.  sigh.

itojun

---

From: Stig Venaas <[email-masked]>
Date: Mon, 14 Jun 2004 11:34:58 +0200

> 	is not documented, so there's no standard.  sigh.

I second that. I would hope that also Linux allows you to bind both
AF_INET6 and AF_INET when using IPV6_V6ONLY socket option; I think that
would be reasonable and logical behaviour. I don't know if that is the
case though.

This makes it hard to write portable code,

Stig

---

From: Colm MacCarthaigh <[email-masked]>
Date: Mon, 14 Jun 2004 11:08:32 +0100

> would be reasonable and logical behaviour. I don't know if that is the

It is the case these days (since 2.4.40), but many distributions do not
have IPV6_V6ONLY defined in their copy of linux/in6.h . It needs to be
defined to 26 for it to work. Their is also the NET_IPV6_BINDV6ONLY
(/proc/sys/net/ipv6/bindv6only) sysctl to define default system
behaviour.

-- 
Colm MacCárthaigh                        Public Key: [email-masked]

---

From: YOSHIFUJI Hideaki / 吉藤英明<[email-masked]>
Date: Mon, 14 Jun 2004 19:12:43 +0900 (JST)

> would be reasonable and logical behaviour. I don't know if that is the

Linux supports IPV6_V6ONLY socket option (default: off, as the RFC says).
If you set IPV6_V6ONLY socket option, you can 
bind(2) both IPv6 and IPv4 sockets on the port.

Thanks.

-- 
Hideaki YOSHIFUJI @ USAGI Project <[email-masked]>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

---

From: Francis Dupont <[email-masked]>
Date: Mon, 14 Jun 2004 12:52:34 +0200

In your previous mail you wrote:

   In RFC 3493 it is said AF_INET6 sockets receive connections from
  IPv4 nodes, mapping their addresses to ::ffff:<IPv4 address>. I think
  this behaviour is on by default.

=> you are right.

  Although it is not explicitly stated, section 5.3 indicates a way to
  turn off this behaviour using the IPv6_V6ONLY socket option.  I was
  wondering if you can or can't bind both AF_INET6 and AF_INET sockets
  to the same port at the same time. Is it ok or is it a bind error?

=> it depends on the REUSEADDR stuff, addresses, order of calls to bind().
Typically the default is to inject the IPv4 space into the IPv6 one
but there are subtle variations about this in current implementations.

  If it is not an error which socket receives a IPv4 connection? Both?
  Only one?  None?

=> only one and the one bound to the address.

  In my test lab I can't seam to be able to get Microsoft's
  O.S. AF_INET6 sockets to receive connections from IPv4, forcing me to
  bind 2 sockets, one in each protocol.

=> Microsoft's O.S. is known to be not conform (note that RFC 3493 is
informational): the IPv4 and the IPv6 stacks are separated.

   In linux it works fine though, I only nead one socket. I have not
  tested any other O.S. yet. This seams highly contraditory...

=> Linux is not conform too but the issue is more about REUSEADDR semantic.
One thing which works on every recent implementation is to set the IPv6_V6ONLY
to one and to bind two sockets to 0.0.0.0 and ::. Of course if you can use
only RFC 3493 there are better ways.

Regards

[email-masked]

---

From: YOSHIFUJI Hideaki / 吉藤英明<[email-masked]>
Date: Mon, 14 Jun 2004 20:38:42 +0900 (JST)

> only RFC 3493 there are better ways.

I beleive it IS. Tell me if you find anything it is not conforming to.
Thanks.

---

From: [email-masked]
Date: Wed, 16 Jun 2004 17:20:18 +0900 (JST)

> I beleive it IS. Tell me if you find anything it is not conforming to.

	i'm not sure about this, but isn't it distribution-dependent,
	or kernel-version dependent?

itojun

---

From: Francis Dupont <[email-masked]>
Date: Fri, 18 Jun 2004 13:52:05 +0200

=> there were many messages about REUSEADDR & IPv4 vs IPv6 in the mailing
list some years ago, including some test programs. Current (at this time)
Linux kernels were not compliant to the unwritten REUSEADDR spec...
By the way the whole issue was discovered by BIND people on Linux.

Regards

PS: Stevens' books include an usable definition of the REUSEADDR semantic
if you'd like to get one.