This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/1774] New: Incorrect handling of AI_ALL in getaddrinfo()


getaddrinfo() implementation in glibc does not conform with POSIX in regards
with AI_ALL flag.

If address family is AF_INET6 and flags are AI_ALL | AI_V4MAPPED, getaddrinfo()
should return all IPv6 address _and_ all IPv4 adresses (as IPv4-mapped ones).
However glibc implementation returns only IPV6 adresses (if they exists).

I use glibc-2.3.5 of Fedora Core 4, but looking at getaddrinfo.c source, the
behaviour applies on latest version as well.

In my opinion the condition at line 632 of getaddrinfo.c (revision 1.81.2.4.2.1)
is not correct.
/* If we do not have to look for IPv4 and IPv6 together, use
    the simple, old functions.  */
632:  if (req->ai_family == AF_INET || req->ai_family == AF_INET6)

because resolution on IPV4 adresses must be performed even if family is
AF_INET6, when AI_ALL flag is used in conjunction with AI_V4MAPPED.

-----------------------------------------------------------------------------
Citation from POSIX (contained in rfc3493 as well):
If the AI_V4MAPPED flag is specified along with an ai_family of AF_INET6, then
getaddrinfo() shall return IPv4-mapped IPv6 addresses on finding no matching
IPv6 addresses ( ai_addrlen shall be 16). The AI_V4MAPPED flag shall be ignored
unless ai_family equals AF_INET6. If the AI_ALL flag is used with the
AI_V4MAPPED flag, then getaddrinfo() shall return all matching IPv6 and IPv4
addresses. The AI_ALL flag without the AI_V4MAPPED flag is ignored.
-------------------------------------------------------------------------------

In the attachment there is a test program getaddrinfo_AI_ALL.c, which test the
AI_ALL | AI_V4MAPPED combination.
When called ./getaddinfo_AI_ALL www.kame.net
it returns IPv6 address, but with correct getaddrinfo() it should return
IPv4-mapped IPv6.

-- 
           Summary: Incorrect handling of AI_ALL in getaddrinfo()
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: klimes at centrum dot cz
                CC: glibc-bugs at sources dot redhat dot com,klimes at
                    centrum dot cz


http://sourceware.org/bugzilla/show_bug.cgi?id=1774

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]