Support IPv6 on Linux,Solaris,Digital UNIX

RESOLVED FIXED

Status

NSPR
NSPR
P3
enhancement
RESOLVED FIXED
19 years ago
17 years ago

People

(Reporter: John G. Myers, Assigned: srinivas)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

19 years ago
Linux has native IPv6 support as a kernel compile-time option, with the
default of having the support off.  So, on Linux, NSPR will have to
probe for IPv6 support by calling socket() with AF_INET6; if that fails
with EINVAL then fall back to using the IPv6-to-IPv4 mapping layer.

Should this probing be done:

1) At NSPR initialization?
2) On the first (few) PR_Socket() calls; the fallback case setting a
global variable to suppress further probes?
3) Every time PR_Socket() is called to create a v6 socket?

I prefer (2).  I don't think the global variable needs to be protected
by a mutex, as cache coherency problems will only result in extra calls
to socket().

I propose to call the macro which indicates this probing behavior is
needed _PR_INET6_PROBE and the global variable _pr_ipv6_ipv6_not_present
(Reporter)

Updated

19 years ago
Status: NEW → ASSIGNED
(Reporter)

Updated

19 years ago
Severity: normal → enhancement
(Reporter)

Comment 1

19 years ago
_pr_ipv6_not_present should be tri-state (unknown, present, not-present) so that 
PR_GetIPNodeByName() can suppress returning IPv6 addresses when called with 
AI_ADDRCONFIG and kernel support is not present.

I would like some comments on the design before I start coding it up.

Comment 2

19 years ago
I think (3) is not worth considering.

(1) is simpler, but adds overhead to process
startup that some applications may not need
at all.

If I can be convinced that the global variable
does not need to be protected by a mutex, then
(2) is the best choice.  Otherwise I'd prefer (1).
(Reporter)

Comment 3

19 years ago
I think the global variable doesn't need a mutex because the probing is 
idempotent and thread safe.  When multiple CPUs all see the uninitialized value, 
they will each try to create a v6 socket, get the same result, and store the 
same result into the global variable.

It's similar to the reason that the initialized member of a PRCallOnceType may 
be examined without acquiring a mutex.

(Assignee)

Comment 4

19 years ago
I prefer to probe for native-ipv6-support at NSPR initialization, to 
keep things simple and because the additional cost should be negligible 
(compared to the cost of server startup).

The use of _PR_INET6_PROBE and _pr_ipv6_not_present should be fine. 
_PR_INET6_PROBE should be set for Linux and Solaris.
Also, shouldn't _pr_ipv6_not_present be a boolean? I don't understand what 
"unknown" state means?
(Reporter)

Comment 5

19 years ago
The "unknown" state is only relevant for (2).  It means we haven't probed yet.

I'll code _PR_INET6_PROBE generically and test it on Linux/noipv6.  I'll let 
someone else try it out on Solaris.
(Reporter)

Comment 6

19 years ago
Created attachment 4672 [details] [diff] [review]
proposed fix
(Reporter)

Comment 7

19 years ago
Reassign for review and checkin.
Assignee: jgmyers → srinivas
Status: ASSIGNED → NEW
(Assignee)

Comment 8

19 years ago
I have made modifications to

1. detect ipv6 support at runtime on Solaris. This includes looking up the 
addresses of getipnodebyname and freehostent.
2. moved the test for Ipv6 sockets to md-specific files
3. set the scope_id and flowinfo fields to 0 in PR_EnumerateHostEnt and 
PR_SetNetAddr.
4. remove check fo AI_ALL in PR_GetIPNodeByName, when _PR_INET6_PROBE is 
defined.

The symbols used during compilation are:

_PR_INET6 - ipv6-support available during compilation
_PR_INET6_PROBE - check for ipv6 support at runtime

If _PR_INET6_PROBE is defined, but not _PR_INET6, the relevant Ipv6 symbols 
(AF_INET6, AF_V4MAPPED, etc) need to be defined in NSPR.
Status: NEW → ASSIGNED
Summary: Support IPv6 on Linux → Support IPv6 on Linux,Solaris
(Assignee)

Comment 9

19 years ago
Created attachment 4712 [details]
The patch is attached.
(Assignee)

Comment 10

19 years ago
Patch checked in.

Files modified:

/cvsroot/mozilla/nsprpub/config/Linux.mk,v  <--  Linux.mk
new revision: 3.15.8.1; previous revision: 3.15
/cvsroot/mozilla/nsprpub/pr/include/md/_linux.h,v  <--  _linux.h
new revision: 3.23.10.1; previous revision: 3.23
/cvsroot/mozilla/nsprpub/pr/include/md/_solaris.h,v  <--  _solaris.h
new revision: 3.10.4.2; previous revision: 3.10.4.1
/cvsroot/mozilla/nsprpub/pr/src/io/pripv6.c,v  <--  pripv6.c
new revision: 3.2.58.4; previous revision: 3.2.58.3
/cvsroot/mozilla/nsprpub/pr/src/io/prsocket.c,v  <--  prsocket.c
new revision: 3.27.4.3; previous revision: 3.27.4.2
/cvsroot/mozilla/nsprpub/pr/src/misc/prinit.c,v  <--  prinit.c
new revision: 3.18.4.1; previous revision: 3.18
/cvsroot/mozilla/nsprpub/pr/src/misc/prnetdb.c,v  <--  prnetdb.c
new revision: 3.11.4.9; previous revision: 3.11.4.8
(Assignee)

Comment 11

19 years ago
Because _PR_INET6 is defined for Linux builds, ipv6-support is required at 
compile time. Is the ipv6 support available on older versions of RedHat Linux?
(Assignee)

Comment 12

19 years ago
Marking the bug fixed.
Status: ASSIGNED → RESOLVED
Last Resolved: 19 years ago
Resolution: --- → FIXED

Comment 13

19 years ago
I added runtime detection of IPv6 support on Digital UNIX
on NSPRPUB_RELEASE_4_0_BRANCH.
/cvsroot/mozilla/nsprpub/pr/include/md/_osf1.h, revision 3.8.14.1
Summary: Support IPv6 on Linux,Solaris → Support IPv6 on Linux,Solaris,Digital UNIX
You need to log in before you can comment on or make changes to this bug.