* ipv6_addr_type() and mapped IPv4 loopback
@ 2008-11-03 23:01 Chuck Lever
2008-11-04 2:33 ` Brian Haley
0 siblings, 1 reply; 6+ messages in thread
From: Chuck Lever @ 2008-11-03 23:01 UTC (permalink / raw)
To: netdev
The __ipv6_addr_type() function does not recognize the mapped IPv4
loopback address:
::ffff:7f00:0001
as type IPV6_ADDR_LOOPBACK. Is this intentional?
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ipv6_addr_type() and mapped IPv4 loopback
2008-11-03 23:01 ipv6_addr_type() and mapped IPv4 loopback Chuck Lever
@ 2008-11-04 2:33 ` Brian Haley
2008-11-04 16:44 ` Chuck Lever
0 siblings, 1 reply; 6+ messages in thread
From: Brian Haley @ 2008-11-04 2:33 UTC (permalink / raw)
To: Chuck Lever; +Cc: netdev
Chuck Lever wrote:
> The __ipv6_addr_type() function does not recognize the mapped IPv4
> loopback address:
>
> ::ffff:7f00:0001
>
> as type IPV6_ADDR_LOOPBACK. Is this intentional?
I would think that since the IPv6 loopback address is ::1, and
ipv4-mapped is ::ffff:* that this would be IPV6_ADDR_MAPPED. That's
what RFC 4291 seems to say.
-Brian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ipv6_addr_type() and mapped IPv4 loopback
2008-11-04 2:33 ` Brian Haley
@ 2008-11-04 16:44 ` Chuck Lever
2008-11-04 20:19 ` David Stevens
2008-11-04 21:16 ` Brian Haley
0 siblings, 2 replies; 6+ messages in thread
From: Chuck Lever @ 2008-11-04 16:44 UTC (permalink / raw)
To: Brian Haley; +Cc: netdev
Hi Brian-
On Nov 3, 2008, at Nov 3, 2008, 9:33 PM, Brian Haley wrote:
> Chuck Lever wrote:
>> The __ipv6_addr_type() function does not recognize the mapped IPv4
>> loopback address:
>> ::ffff:7f00:0001
>> as type IPV6_ADDR_LOOPBACK. Is this intentional?
>
> I would think that since the IPv6 loopback address is ::1, and ipv4-
> mapped is ::ffff:* that this would be IPV6_ADDR_MAPPED. That's what
> RFC 4291 seems to say.
So the answer to my original question is then "yes, this is
intentional," correct?
On a system with an AF_INET6 listener, legacy applications use
127.0.0.1 to contact a local listener. The incoming source address
will be ::ffff:7f00:0001, not ::1. This means IPv6-enabled
applications have to perform a separate check for ::ffff:7f00:0001 if
they are looking for loopback addresses.
The kernel's lockd must verify that an NLM request comes from the
local user space. It's not a lot of extra logic, but it is a subtlety.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ipv6_addr_type() and mapped IPv4 loopback
2008-11-04 16:44 ` Chuck Lever
@ 2008-11-04 20:19 ` David Stevens
2008-11-04 21:16 ` Brian Haley
1 sibling, 0 replies; 6+ messages in thread
From: David Stevens @ 2008-11-04 20:19 UTC (permalink / raw)
To: Chuck Lever; +Cc: Brian Haley, netdev, netdev-owner
There is actually a difference.
The mapped-v4 loopback address uses IPv4 for packet
delivery while the IPv6 loopback uses IPv6. So, theoretically,
an application using a protocol-specific feature would need
to distinguish between the two.
I don't think it's a good idea to remap those to ::1.
+-DLS
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ipv6_addr_type() and mapped IPv4 loopback
2008-11-04 16:44 ` Chuck Lever
2008-11-04 20:19 ` David Stevens
@ 2008-11-04 21:16 ` Brian Haley
2008-11-04 21:33 ` Chuck Lever
1 sibling, 1 reply; 6+ messages in thread
From: Brian Haley @ 2008-11-04 21:16 UTC (permalink / raw)
To: Chuck Lever; +Cc: netdev
Chuck Lever wrote:
> Hi Brian-
>
> On Nov 3, 2008, at Nov 3, 2008, 9:33 PM, Brian Haley wrote:
>> Chuck Lever wrote:
>>> The __ipv6_addr_type() function does not recognize the mapped IPv4
>>> loopback address:
>>> ::ffff:7f00:0001
>>> as type IPV6_ADDR_LOOPBACK. Is this intentional?
>>
>> I would think that since the IPv6 loopback address is ::1, and
>> ipv4-mapped is ::ffff:* that this would be IPV6_ADDR_MAPPED. That's
>> what RFC 4291 seems to say.
>
> So the answer to my original question is then "yes, this is
> intentional," correct?
I didn't design the Linux IPv6 stack, but it looks right to me.
> On a system with an AF_INET6 listener, legacy applications use 127.0.0.1
> to contact a local listener. The incoming source address will be
> ::ffff:7f00:0001, not ::1. This means IPv6-enabled applications have to
> perform a separate check for ::ffff:7f00:0001 if they are looking for
> loopback addresses.
Right, applications have to see if it's really an IPv4 address if
necessary. If you're just looking for loopback and it's in the kernel,
it's only about this much code:
if (ipv6_addr_type(addr->sin6_addr) == IPV6_ADDR_MAPPED) {
__be32 v4addr = addr->sin6_addr.s6_addr32[3];
if (ipv4_is_loopback(v4addr)) {
/* it's 127.0.0.* */
}
}
There's the IN6_IS_ADDR_V4MAPPED() macro for user-space as well.
> The kernel's lockd must verify that an NLM request comes from the local
> user space. It's not a lot of extra logic, but it is a subtlety.
Agreed.
-Brian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ipv6_addr_type() and mapped IPv4 loopback
2008-11-04 21:16 ` Brian Haley
@ 2008-11-04 21:33 ` Chuck Lever
0 siblings, 0 replies; 6+ messages in thread
From: Chuck Lever @ 2008-11-04 21:33 UTC (permalink / raw)
To: Brian Haley; +Cc: netdev
Hi Brian-
On Nov 4, 2008, at Nov 4, 2008, 4:16 PM, Brian Haley wrote:
> Chuck Lever wrote:
>> Hi Brian-
>> On Nov 3, 2008, at Nov 3, 2008, 9:33 PM, Brian Haley wrote:
>>> Chuck Lever wrote:
>>>> The __ipv6_addr_type() function does not recognize the mapped
>>>> IPv4 loopback address:
>>>> ::ffff:7f00:0001
>>>> as type IPV6_ADDR_LOOPBACK. Is this intentional?
>>>
>>> I would think that since the IPv6 loopback address is ::1, and
>>> ipv4-mapped is ::ffff:* that this would be IPV6_ADDR_MAPPED.
>>> That's what RFC 4291 seems to say.
>> So the answer to my original question is then "yes, this is
>> intentional," correct?
>
> I didn't design the Linux IPv6 stack, but it looks right to me.
>
>> On a system with an AF_INET6 listener, legacy applications use
>> 127.0.0.1 to contact a local listener. The incoming source address
>> will be ::ffff:7f00:0001, not ::1. This means IPv6-enabled
>> applications have to perform a separate check for ::ffff:7f00:0001
>> if they are looking for loopback addresses.
>
> Right, applications have to see if it's really an IPv4 address if
> necessary. If you're just looking for loopback and it's in the
> kernel, it's only about this much code:
>
> if (ipv6_addr_type(addr->sin6_addr) == IPV6_ADDR_MAPPED) {
> __be32 v4addr = addr->sin6_addr.s6_addr32[3];
> if (ipv4_is_loopback(v4addr)) {
> /* it's 127.0.0.* */
> }
> }
>
> There's the IN6_IS_ADDR_V4MAPPED() macro for user-space as well.
Thanks for the steer. I'll submit this fix for 2.6.29. I'm hoping to
introduce AF_INET6-based kernel RPC services (namely NFSD and lockd)
in that release.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-11-04 21:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-03 23:01 ipv6_addr_type() and mapped IPv4 loopback Chuck Lever
2008-11-04 2:33 ` Brian Haley
2008-11-04 16:44 ` Chuck Lever
2008-11-04 20:19 ` David Stevens
2008-11-04 21:16 ` Brian Haley
2008-11-04 21:33 ` Chuck Lever
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).