Open Bug 439244 Opened 16 years ago Updated 2 years ago

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

Categories

(NSPR :: NSPR, defect)

x86
Solaris
defect

Tracking

(Not tracked)

People

(Reporter: glenbeasley, Unassigned)

Details

Attachments

(2 files)

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: wtc → glen.beasley
Status: NEW → ASSIGNED
Attachment #325108 - Flags: review?(wtc)
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 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-
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

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: glenbeasley → nobody
Status: ASSIGNED → NEW
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: