Discussion:
Bug#522478: libio-socket-inet6-perl: AF_UNSPEC fails for IPv6 hosts
(too old to reply)
Martin v. Löwis
2009-04-16 07:10:15 UTC
Permalink
I tracked this down to the resolution of an unspecified local
address. On some systems, getaddrinfo('',0,0,2,17,1) returns
127.0.0.1, then ::1; on other systems, it's vice versa. The order
apparently depends on /etc/gai.conf; apparently, there was also
a recent change in the library defaults (to return IPv4 before
v6).

INET6 determines that the remote address is IPv6, and creates
an IPv6 socket. It then tries to bind it to '' (as no local
address was given); this determines that '' is an IPv4 address,
so binding fails.

I think the real error is that it tries to bind at all even
if no local address or port was given. It does so because
lres is defined, i.e. because it was able to resolve the
name '' (around line 211). As it is overwriting laddr for Win32,
it should remember the value of laddr before that, and then
bind only if either laddr or lport were given.

If no local address was given, but a local port, binding needs
to occur, but it needs to consider the server address family,
so it needs to redo getaddrinfo (passing AI_NUMERICHOST to avoid
name lookups).
--
To UNSUBSCRIBE, email to debian-bugs-dist-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
gregor herrmann
2009-04-17 15:50:08 UTC
Permalink
forwarded 522478 http://rt.cpan.org/Public/Bug/Display.html?id=39550
tags 522478 + fixed-upstream
thanks
Post by Martin v. Löwis
I tracked this down to the resolution of an unspecified local
address. On some systems, getaddrinfo('',0,0,2,17,1) returns
127.0.0.1, then ::1; on other systems, it's vice versa. The order
apparently depends on /etc/gai.conf; apparently, there was also
a recent change in the library defaults (to return IPv4 before
v6).
Thanks for the detailed analysis.

I've now looked further and I think this is upstream bug
http://rt.cpan.org/Public/Bug/Display.html?id=39550
which should be fixed as of 2.55 according to
http://cpansearch.perl.org/src/SHLOMIF/IO-Socket-INET6-2.56/ChangeLog

I've upgraded libio-socket-inet6-perl locally to 2.56, and it seems
to work: The output of the same test script is now:

$ perl sock.pl
Trying to connect to www.google.com ...
... via unspecified ...
Success!
... via IPv6 ...
Error: IO::Socket::INET6: getaddrinfo: Name or service not known
... via IPv4 ...
Success!
Trying to connect to ipv6.google.com ...
... via unspecified ...
Success!
... via IPv6 ...
Success!
... via IPv4 ...
Error: IO::Socket::INET6: getaddrinfo: Name or service not known
Trying to connect to ftp.at.debian.org ...
... via unspecified ...
Success!
... via IPv6 ...
Success!
... via IPv4 ...
Success!
Trying to connect to www.sixxs.net ...
... via unspecified ...
Success!
... via IPv6 ...
Success!
... via IPv4 ...
Success!


Masahito, could you upgrade the package please?

If you are busy I can offer to do a one-time NMU or to maintain the
package within the Debian Perl Group.

Cheers,
gregor
--
.''`. Home: http://info.comodo.priv.at/{,blog/} / GPG Key ID: 0x00F3CFE4
: :' : Debian GNU/Linux user, admin, & developer - http://www.debian.org/
`. `' Member of VIBE!AT, SPI Inc., fellow of FSFE | http://got.to/quote/
`- NP: Pat Metheny, B.B. King, Dave Brubeck: Dave Brubeck Quartet / Lover M
Loading...