[Patch] [BZ 14505] Avoid unwanted A lookups on IPV6 only host
Jeff Law
law@redhat.com
Tue Aug 21 22:01:00 GMT 2012
As mentioned in the BZ, when looking up a name via getaddrinfo with
AI_ADDRCONFIG on an IPv6 only host, IN A queries are being sent.
According to RFC 3493, they should not.
The issue is gaih_inet calls gethostbyname4 which issues both A and AAAA
queries.
If we look up in getaddrinfo we see that when the AI_ADDRCONFIG hint is
set, we look at the configured interfaces and set the ai_family flag to
either PF_INET or PF_INET6 if only one type of interface is configured.
If both kinds of interfaces are enabled the hint should continue to be
AF_UNSPEC.
We then pass that information down to gaih_inet where we can trivially
query it before calling gethostbyname4. That's precisely what this
patch implements.
-------------- next part --------------
2012-08-21 Jeff Law <law@redhat.com>
[BZ #14505]
* sysdeps/posix/getaddrinfo.c (gaih_inet): If the caller has
requested either A or AAAA requests explicitly, then do not use
gethostbyname4 as it sends out both A and AAAA requests.
diff -Nrup a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
--- a/sysdeps/posix/getaddrinfo.c 2012-08-21 13:43:07.291667596 -0600
+++ b/sysdeps/posix/getaddrinfo.c 2012-08-21 13:48:19.840427211 -0600
@@ -832,7 +832,13 @@ gaih_inet (const char *name, const struc
no_data = 0;
nss_gethostbyname4_r fct4
= __nss_lookup_function (nip, "gethostbyname4_r");
- if (fct4 != NULL)
+
+ /* gethostbyname4 sends out parallel queries. If we are
+ suppressing either IPV4 or IPV6 by asking for a specific
+ protocol, then gethostbyname4 is not appropriate. */
+ if (fct4 != NULL
+ && !(req->ai_family == PF_INET6
+ || req->ai_family == PF_INET))
{
int herrno;
More information about the Libc-alpha
mailing list