[ntp:questions] Pool returns IPv6 address to IPv4 query

Danny Mayer mayer at ntp.org
Tue Nov 19 18:45:16 UTC 2013


On 11/19/2013 1:01 PM, Brian Utterback wrote:
> On 11/19/2013 12:33 PM, Rick Jones wrote:
>> Danny Mayer <mayer at ntp.org> wrote:
>>> That must have been a short discussion. getaddrinfo() has nothing to
>>> do with the IP stack. getaddrinfo()'s job is to get information from
>>> the nameservers you specify in resolv.conf or wherever else the OS
>>> has that information. Its job is NOT to make decisions about what it
>>> should ask for. That's the programmer's job when setting up the API
>>> call as to what addresses to ask for.
>> I suspect it all boils down to the behaviour when one sets
>> AI_ADDRCONFIG in the getaddrinfo() call.  When that is set, ostensibly
>> getaddrinfo() is supposed to filter-out any reponses that are of a
>> type that cannot be used by the application.  The decision made was if
>> there were no non-loopback-interface IPv6 addresses configured, AAAA
>> records would not be returned from the getaddrinfo() call.  Similarly
>> for A recorecords if there were no IPv4 addresses configured on the
>> system.
>>
>> Later, when interfaces started getting auto-configured, local scope
>> IPv6 addresses, there was a call to change that to be "don't return
>> IPv6 addresses unless there is a better-than-local-scope IPv6 address
>> assigned."  Started causing me all manner of pain in netperf :( Not
>> sure where that stands now in the Linux world.
>>
>> rick jones
> Yes, that was the issue. Further complicating it was what do you return
> if you have no IPv6 interfaces and you set AI_ADDRCONFIG and you pass in
> a literal IPv6 address. The problem is that getaddrinfo replaces both
> gethostbyname and inet_aton, each of which you might expect to have
> different results in that case. We had people citing two RFC's and the
> ipng working group mailing list. Great fun.
> 

I think you mean inet_ntoa. As I already said you should be setting the
ai_family in the hints structure and you want to have it only a
particular type of address. If you want to pass an IP address you should
be setting AI_NUMERICHOST in ai_flags of the hint structure. Note that
inet_ntoa does not perform a lookup. It's just a formatter.

Danny


More information about the questions mailing list