::FFFF:127.0.0.1 not identified as PR_IpAddrV4Mapped causes gethost.c to fail

ASSIGNED
Assigned to

Status

NSPR
NSPR
ASSIGNED
10 years ago
10 years ago

People

(Reporter: glen beasley, Assigned: glen beasley)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Assignee)

Description

10 years ago
the nspr test gethost.c fails on: 
PR_StringToNetAddr("::FFFF:127.0.0.1", &addr);
if (PR_IsNetAddrType(&addr, PR_IpAddrV4Mapped) == PR_FALSE) {
           fprintf(stderr, "addr should be ipv4 mapped address\n");
           exit(1);
}

On Solaris ::FFFF:127.0.0.1 is translated straight to IPV4 127.0.0.1
On Solaris ifconfig -a returns:
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000 
 
ping ::FFFF:127.0.0.1
127.0.0.1 is alive
ping ::1
::1 is alive
(Assignee)

Comment 1

10 years ago
Created attachment 325108 [details] [diff] [review]
check the ip family is PR_AF_INET6 before testing for R_IpAddrV4Mapped
Assignee: wtc → glen.beasley
Status: NEW → ASSIGNED
Attachment #325108 - Flags: review?(wtc)
(Assignee)

Comment 2

10 years ago
Created attachment 325110 [details]
test program that I used

I doubt this attachment is necessary but this is a small test program that I used to see the differences on 
Solaris: 
./family ::FFFF:127.0.0.1
testing ::FFFF:127.0.0.1
IPV4 family

and Mac OS X:
./family ::FFFF:127.0.0.1
testing ::FFFF:127.0.0.1
IPV6 family

Comment 3

10 years ago
Comment on attachment 325108 [details] [diff] [review]
check the ip family is PR_AF_INET6 before testing for R_IpAddrV4Mapped

Thanks for the patch and the nice test program.

::FFFF:127.0.0.1 should ideally be converted into an
IPv4-mapped IPv6 address.  In NSPR 4.7, we changed the
implementation of PR_StringToNetAddr to use getaddrinfo
with the AI_NUMERICHOST flag (bug 34843).  So this
platform-dependent behavior looks like a regression.

It is acceptable for PR_StringToNetAddr to convert
::FFFF:127.0.0.1 to a real IPv4 address, but we should
strive for cross-platform behavior of NSPR functions.

We can probably just add "|| defined(SOLARIS)" to:
http://lxr.mozilla.org/nspr/source/nsprpub/pr/src/misc/prnetdb.c#2236

and update the comment (On Solaris, getaddrinfo
converts ::FFFF::a.b.c.d into a real IPv4 address
rather than an IPv4-mapped IPv6 address).

Could you use your test program to convert a normal
IPv4-mapped address string such as ::FFFF:74.125.19.104?
What is its output on Solaris?
Attachment #325108 - Flags: review?(wtc) → review-
(Assignee)

Comment 4

10 years ago
Thanks Wan-teh for the review. I understand your reasons and will see 
what I can do.

To answer your question about the test program to convert a normal
IPv4-mapped address string and test program shows the conversion 
straight to IPV4. (tested on Solaris 8 and Solaris 10) 

Test: 
eri0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.18.77.258 netmask ffffff00 broadcast 192.18.72.255
/family ::FFFF:192.18.77.258
testing ::FFFF:192.18.77.258
IPV4 family
and 
ping ::FFFF:192.18.77.258
192.18.77.258 is alive
You need to log in before you can comment on or make changes to this bug.