apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 49678] New: getRemoteAddr() returns IPv6 address on RedHat 9 when IPv6 is disabled
Date Fri, 30 Jul 2010 11:09:12 GMT

           Summary: getRemoteAddr() returns IPv6 address on RedHat 9 when
                    IPv6 is disabled
           Product: APR
           Version: 1.3.9
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
        AssignedTo: bugs@apr.apache.org
        ReportedBy: lalit.mishra@airtightnetworks.com

This issue is reported in bug#39621. 
Opening this bug in product APR.

The address returned is not actually an IPv6 address, but looks like one. 

We faced this problem with RedHat 9 only when IPv6 is disabled.
Linux #1 SMP Tue Jun 10 17:56:55 IST 2008 i686 i686 i386 GNU/Linux
(this is not the stock kernel in RH 9).

APR version 1.3.9.

Absence of AI_ADDRCONFIG flag for getaddrinfo in glibc (2.3.2-27.9.7) is the
root cause. 
>From man getaddrinfo -

    If hints.ai_flags includes the AI_ADDRCONFIG flag, then IPv4 addresses are
returned in the list pointed to by result only if the  local system has at lea
st one IPv4 address configured, and IPv6 addresses are only returned if the
local system has at least one IPv6 address configured.

When tomcat searches for local address to bind, it finally calls call_resolver
function of sockaddr.c in APR with hostname=null. As AI_ADDRCONFIG flag is not
present, getaddrinfo returns "::" and in the list of available
addresses.  The tcnative method (Address.info, see address.c) prefers the IPv6
(::) address among these and returns this to Tomcat, and Tomcat specifies this
address to bind to the socket (surprisingly, the kernel does not complain when
binding an IPv6 address to an AF_INET socket). Therefore, APR code falsely ends
up setting AF_INET6 to local_addr->family and (later when accept returns) to
remote_addr->family as well. Thus when an IPv4 host connects, though accept
returns proper IPv4 address to APR, APR still believes it to be IPv6 address
and messes up while translating to presentation format.

If AI_ADDRCONFIF flag is not present, we need to determine if IPv6 is
*actually* available or not. This can be achieved by trying to open an IPv6
socket. If this fails then set hints.ai_family to AF_INET so that getaddrinfo
returns IPv4 addresses only. Of course do this only when family has been
specified as AF_UNSPEC. We do not want to return IPv4 addresses when asked
specifically for IPv6 addresses.
Please see attached patch (for APR 1.3.9).

Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org

View raw message