getaddrinfo performance problems

Ed W lists at wildgooses.com
Mon Apr 16 16:57:47 UTC 2012


On 16/04/2012 16:48, Rich Felker wrote:
> On Mon, Apr 16, 2012 at 03:05:54PM +0100, Ed W wrote:
>> Hi, I'm suffering extreme performance problems with getaddrinfo
>> being used by ipset to do conversions from IP textual strings to
>> number.  Although the IP address is textual there is a reverse DNS
>> lookup performed and in the event that my resolver is slow, this is
>> sometimes taking 60seconds or so to return
> I have not looked at the source, but I suspect this is a uClibc bug
> based on a misreading of the standard. Many incorrect historical
> getaddrinfo implementations performed unnecessary reverse dns lookups
> to fill in the ai_canonname field of the addrinfo structure. POSIX is
> very clear that this is wrong:
>
>    A numeric host address string is not a ``name'', and thus does not
>    have a ``canonical name'' form; no address to host name translation
>    is performed. See below for handling of the case where a canonical
>    name cannot be obtained.
>
> Source:
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html
>
> Rich
>

Rich, disregarding posix for a moment, what does glibc do?  Options are: 
canonname=NULL  or IP as string?

At present uclibc is returning the reverse dns lookup or textual IP 
format.  It should be trivial for me to supply a patch to make this 
whatever we want - can someone define what we want? (Posix or emulate 
some other wierdness?)

Just to be clear - my understanding is (for posix)

if ( inet_pton(addr) )
     canonname = NULL;
else
     canonname = reverse_dns;

Therefore we don't need to examine AI_NUMERICHOST and will return 
canonname=NULL for any case of an IP addr?

(We should of course return an error if the user hints AI_NUMERICHOST 
and it's not numeric)

Grateful for confirm this is the implementation we want?

Ed W


More information about the uClibc mailing list