Bug#520628: libc6: getaddrinfo now prefers listening on ipv4-only over ipv4+ipv6.
On Tue, Apr 14, 2009 at 07:15:12PM +0200, Nicolas George wrote:
> Le primidi 1er germinal, an CCXVII, Andreas Henriksson a écrit :
> > em@amd64:/tmp$ gcc -o gt gaitest.c && ./gt
> > When given unspecified protocol, host:(null) and port:12345, as hints...
> > This machine prefers listening on (in order of preference):
> > * ipv4 (only)
> > * ipv6+ipv4
> I stumbled on the same problem and found the cause:
> > gem@amd64:/tmp$ grep '^#*label' /etc/gai.conf
> > label ::1/128 0
> > label ::/0 1
> > #label 2002::/16 2
> > label ::/96 3
> > label ::ffff:0:0/96 4
> > label fec0::/10 5
> > label fc00::/7 6
> > label 2001:0::/32 7
> The labels are related to the rule 6 of RFC 3484 (although the comment in
> the source code of the glibc says rule 5). The algorithm needs to choose
> between two addresses:
They are two paragraphs in the RFC3484, one for the source addresses,
one for the destinations addresses. The source code correctly matches
the rules for destination addresses in the RFC.
> - ::0 (IPv6 mildcard)
> - ::FFFF:0.0.0.0 (mapped IPv4 wildcard)
> It uses a corresponding source address, respectively:
> According to the labels above (or the hardcoded ones), the addresses get the
> following labels:
> - ::1 (IPv6 looopback) -> 0
> - ::0 (IPv6 mildcard) -> 3
> - ::FFFF:0.0.0.0 (mapped IPv4 wildcard) -> 4
> - ::FFFF:127.0.0.1 (mapped IPv4 loopback) -> 4
> The rule 6 says that addresses with the same label for the source and the
> destination should be selected.
> I "fixed" the problem by adding the following line to gai.conf:
> label ::/128 0
> I am not completely sure whether this is correct, but it seems to work.
In my opinion, it is more a workaround then a fix, as the default labels
are defined by the RFC. Moreover this may have some side effects.
Aurelien Jarno GPG: 1024D/F1BCDB73