Bug 37788 - Use IPv6 with APR Connectors
Summary: Use IPv6 with APR Connectors
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Connector:HTTP (show other bugs)
Version: 5.5.13
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-05 14:15 UTC by Markus Schönhaber
Modified: 2006-01-30 06:26 UTC (History)
0 users



Attachments
Change AprEndpoint to use APR_INET6 as address family when creating socket (849 bytes, patch)
2005-12-05 14:17 UTC, Markus Schönhaber
Details | Diff
HotSpot error log of JVM crash when using APR_UNSPEC (18.48 KB, text/plain)
2006-01-28 14:59 UTC, Markus Schönhaber
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Schönhaber 2005-12-05 14:15:29 UTC
On an IPv6-enabled host the normal Java Connectors will bind to the IPv6
unspecified address ::0 (if no address is configured for the Connector element).
OTOH APR Connectors will bind only to the IPv4 unspecified address 0.0.0.0 -
even on an IPv6-enabled host. IMO it shouldn't depend on the type of connector
used to which address(-family) Tomcat binds. Therefore I propose to use
APR_INET6 instead of APR_INET as address family when creating the APR endpoint.
Since I'm in no way familiar with the Tomcat source, I'm not sure if the trivial
change I made to org.apache.tomcat.util.net.AprEndpoint is the right thing at
the right place. What I can say after trying out the so-patched Tomcat is the
following:
- On an IPv6-enabled Linux host, Tomcat's APR Connector bound to ::0.
- On an IPv4-only Linux host and an IPv4-only Windows XP host, Tomcat still
worked (binding to 0.0.0.0 obviously).
Comment 1 Markus Schönhaber 2005-12-05 14:17:03 UTC
Created attachment 17149 [details]
Change AprEndpoint to use APR_INET6 as address family when creating socket
Comment 2 Jim Jagielski 2006-01-19 22:34:52 UTC
The patch looks reasonable to me, but I would like to do further testing before committing
Comment 3 Jim Jagielski 2006-01-28 00:50:24 UTC
Upon further testing here, the better solution is to use APR_UNSPEC, which allows for APR to correctly 
make the required selection. Can you also test with the change of APR_INET -> APR_UNSPEC in your 
environment as well. I'd like to commit this.

Thanks!
Comment 4 Markus Schönhaber 2006-01-28 13:44:25 UTC
(In reply to comment #3)
> Upon further testing here, the better solution is to use APR_UNSPEC, which
allows for APR to correctly 
> make the required selection. Can you also test with the change of APR_INET ->
APR_UNSPEC in your 
> environment as well. I'd like to commit this.

I seemed to remember that changing APR_INET -> APR_UNSPEC was my first attempt
to get the AprEndpoint to listen on IPv6 addresses, and that I dropped it in
favour of APR_INET6 for some reason.
I just did try APR_UNSPEC again and the JVM crashed on starting up tomcat - so
this is obviously the reason I had forgotten about. If the HotSpot error log the
JVM writes is of any interest to you, just say so and I'll attach it.

System spec:
Gentoo Linux with kernel 2.6.15-gentoo-r1
Sun JDK 1.5.0.06
APR 1.2.2
tomcat-native-1.1.1
gcc 3.4.4
Tomcat built today (Jan 28th 2006) from svn
Comment 5 Jim Jagielski 2006-01-28 14:40:48 UTC
Yes, please attach. I cannot recreate the crash here; using UNSPEC it works as expected. 
Comment 6 Markus Schönhaber 2006-01-28 14:59:00 UTC
Created attachment 17525 [details]
HotSpot error log of JVM crash when using APR_UNSPEC
Comment 7 Jim Jagielski 2006-01-30 15:03:17 UTC
Hotspot shows, and others confirm, that the exception is due to several places where the family value is 
being unduly restrictive. Will be addressed in HEAD.