[Bug 5042] busybox fails to connect to IPv6-and-V4 targets from v4-only hosts
bugzilla at busybox.net
bugzilla at busybox.net
Tue Jan 15 02:28:55 UTC 2013
https://bugs.busybox.net/show_bug.cgi?id=5042
--- Comment #2 from Kevin Baker <kbaker at gmail.com> 2013-01-15 02:29:17 UTC ---
The error is actually a bit more subtle than what Michael has posted, but he
pointed me in the right area to look at, so thanks!
tl;dr fix: pass AI_ADDRCONFIG as a hint flag to getaddrinfo. RFC 2553 states:
The AI_ADDRCONFIG flag specifies that a query for AAAA records
should occur only if the node has at least one IPv6 source
address configured and a query for A records should occur only
if the node has at least one IPv4 source address configured.
--
What seems to be happening, as far as I can tell: (Sorry for the intense
detail!)
getaddrinfo is returning not found, since it tries an IPV6 lookup, but with
only a link-local address, it fails.
If hints is NULL, then getaddrinfo should use the default (specified in
RFC2553), (AI_V4MAPPED|AI_ADDRCONFIG).
However, str2sockaddr is building hints manually since af is passed in to
choose IPv4/IPv6, and also for ai_flags which are used in the *2sockaddr
functions and the busybox-specific DIE_ON_ERROR support (and a faster path for
AI_NUMERICHOST.) This then doesn't include AI_ADDRCONFIG.
I have attached a patch to apply AI_ADDRCONFIG if it is available.
This has eliminated the 'Bad address' issues with wget for my test case.
I have only tested it on a v4-IP only host (with v6 support in the
kernel/glibc/busybox) that is experiencing the same random failures in wget.
Since it is the default value for when there hints is NULL however there
shouldn't be any side effects.
Environment is Yocto "danny" on armv7a: busybox-1.20.2, eglibc-2.16,
linux-2.6.37. Patch applies to latest git HEAD (30a8652f).
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the busybox-cvs
mailing list