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
_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.
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).
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.
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?
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.
Reassign for review and checkin.
Assignee: jgmyers → srinivas
Status: ASSIGNED → NEW
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
Patch checked in. Files modified: /cvsroot/mozilla/nsprpub/config/Linux.mk,v <-- Linux.mk new revision: 188.8.131.52; previous revision: 3.15 /cvsroot/mozilla/nsprpub/pr/include/md/_linux.h,v <-- _linux.h new revision: 184.108.40.206; previous revision: 3.23 /cvsroot/mozilla/nsprpub/pr/include/md/_solaris.h,v <-- _solaris.h new revision: 220.127.116.11; previous revision: 18.104.22.168 /cvsroot/mozilla/nsprpub/pr/src/io/pripv6.c,v <-- pripv6.c new revision: 22.214.171.124; previous revision: 126.96.36.199 /cvsroot/mozilla/nsprpub/pr/src/io/prsocket.c,v <-- prsocket.c new revision: 188.8.131.52; previous revision: 184.108.40.206 /cvsroot/mozilla/nsprpub/pr/src/misc/prinit.c,v <-- prinit.c new revision: 220.127.116.11; previous revision: 3.18 /cvsroot/mozilla/nsprpub/pr/src/misc/prnetdb.c,v <-- prnetdb.c new revision: 18.104.22.168; previous revision: 22.214.171.124
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?
Marking the bug fixed.
Status: ASSIGNED → RESOLVED
Last Resolved: 19 years ago
Resolution: --- → FIXED
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 126.96.36.199
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.