This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
getaddrinfo with AF_CANONNAME making PTR lookups
- From: Lorenzo Colitti <lorenzo at colitti dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Fri, 13 Aug 2004 12:13:03 +0200
- Subject: getaddrinfo with AF_CANONNAME making PTR lookups
This is spun off from discussion in mozilla bug 239358 [1].
The bug is that with recent glibc code (e.g. that in Fedora Core 2), many
DNS lookups take a long time and sites like google.com and nytimes.com take
a long time to load.
This is because recently the behaviour of the AI_CANONNAME flag in
getaddrinfo was changed. Previously, glibc used to return as the canonical
name the name at the end of the DNS CNAME chain. But the current code uses
reverse DNS (PTR) lookups to get the canonical name. This has several
disadvantages: see my comment in the mozilla bug [2].
From discussion with Ulrich Drepper in the bug it appears that glibc does
this to comply with POSIX. However, nothing in RFC 3493 [3] nor POSIX [4]
suggests that the canonical name should be obtained using reverse lookups.
In fact, POSIX strongly seems to suggest that the canonical name should be
obtained by using CNAMEs.
Both the RFC and POSIX state:
If the AI_CANONNAME flag is specified and the nodename argument is
not null, the function shall attempt to determine the canonical name
corresponding to nodename (for example, if nodename is an alias or
shorthand notation for a complete name).
which does not say anything about how the canonical name should be
obtained. However, POSIX adds the following:
The term ``canonical name'' is misleading; it is taken from the Domain
Name System (RFC 2181). It should be noted that the canonical name is a
result of alias processing, and not necessarily a unique attribute of a
host, address, or set of addresses. See RFC 2181 for more discussion of
this in the Domain Name System context.
It seems clear to me that if the canonical name is to be obtained by "alias
processing", then it must be obtained by following the CNAME chain, which
is a chain of aliases. Furthermore, no other platform that I know of uses
PTR lookups. I and others in the IPv6 community have tested Solaris 9,
FreeBSD 4.9 (with the stock, KAME and BIND resolvers), 4.10 and 5.2, and
Windows (and of course previous versions of glibc) and none of them do this.
We can work around this in mozilla (a patch has been written and is
awaiting review), but we do not want to add workarounds unless it is
necessary. And it seems to me that this is incorrect behaviour on glibc's
part and should be fixed in glibc.
Can we expect this to be the case or do we need to work around it?
Thanks,
Lorenzo
[1] http://bugzilla.mozilla.org/show_bug.cgi?id=239358
[2] http://bugzilla.mozilla.org/show_bug.cgi?id=239358#c60
[3] http://www.ietf.org/rfc/rfc3493.txt
[4] http://www.opengroup.org/onlinepubs/009695399/functions/getaddrinfo.html