[PATCH] make getaddrinfo hint AI_ADDRCONFIG work

Ricard Wanderlof ricard.wanderlof at axis.com
Thu Feb 21 16:09:23 UTC 2008

On Thu, 21 Feb 2008, sjhill at real.realitydiluted.com wrote:

>> The problem turned out to be in getaddrinfo(). When hints.ai_flags has
>> the AI_ADDRCONFIG bit set in a call to getaddrinfo, IPv4 and IPv6
>> addresses should only be returned if the system as at least one address
>> of the appropriate type configured. However, this turned out not to be
>> the case, and both types of addresses were returned in any case, causing
>> IPv6 DNS traffic even if no interface had an IPv6 address configured.
>> The following patch fixes the problem, while still touching the existing
>> code as little as possible. It has been tested and works and I would like
>> to commit it, but comments would be valued.
> How does glibc handle this?

The latest (2.7) glibc (which is much newer than what uClibc is based on) 
has a similar way of introducing additional checks in various parts of the 
code. However, it relies on getifaddrs() to determine the existance of an 
interface instead of checking the /proc filesystem.

Which as you are implying might be a better way to do it.

Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

More information about the uClibc mailing list