[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#438179: getaddrinfo() sorts results.

Kurt Roeckx a écrit :
> reopen 438179
> thanks
> On Thu, Aug 16, 2007 at 08:24:51PM +0200, Aurelien Jarno wrote:
>> This is a feature, not a bug. getaddrinfo() sorts results according to
>> RFC3484. You can configure the way they are sorted using /etc/gai.conf.
> None of the rules in rfc3484 say anything about this.  In fact, the last
> rule says:
>    Rule 10:  Otherwise, leave the order unchanged.
>    If DA preceded DB in the original list, prefer DA.  Otherwise prefer
>    DB.

Rule 9 comes before:

   Rule 9:  Use longest matching prefix.
   When DA and DB belong to the same address family (both are IPv6 or
   both are IPv4): If CommonPrefixLen(DA, Source(DA)) >
   CommonPrefixLen(DB, Source(DB)), then prefer DA.  Similarly, if
   CommonPrefixLen(DA, Source(DA)) < CommonPrefixLen(DB, Source(DB)),
   then prefer DB.

That's why you see small variation among the returned address.

> Also, I don't see an option to prevent it from sorting the list.

Because this thing is not configurable. This is not required by the RFC
and this is a bad idea as you start using IPv6.

>> If you don't want results to be sorted, don't use getaddrinfo().
> Do you have a suggestion for an other interface that works with
> different address types other than getipnodebyname()?

No I don't. Anyway if you don't want to sort to the returned addresses,
you only want to do that for IPv4, and thus need two different interfaces.

  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

Reply to: