Subject: | Problem with connect to IPv4 w/o given domain on FreeBSD6.1 (patch included) |
If I just give
IO::Socket::INET6->new( PeerAddr => '127.0.0.1', PeerPort => 10 )
e.g not specifying Domain (leaving it AF_UNSPEC) and not specifying
a local address then it will fail to connect on FreeBSD6.1.
Reason:
the code in configure uses getaddrinfo to find out the addrinfo for
the peer (127.0.0.1, gives only family AF_INET) and the local addr
('', gives AF_INET6 and AF_INET). Then it builds the socket with
the family it got from the peer (AF_INET) and binds the listenaddr
on this socket. If this fails the whole configure fails.
What happens on FreeBSD6.1 in this scenario (only schematic, of
course we don't give the address as a string to bind)
socket(my $sock, AF_INET..)
bind( $sock,'::' ) -> fails because AF_INET6 but socket is AF_INET
-> configure fails
When using linux this seems to be no problem, because the bind succeeds
(maybe it doesn't distinguish between unspecified AF_INET6 and AF_INET)
Fix: make sure, that the socket uses the same family as the peer
(patch against 2.54)
@@ -178,7 +178,8 @@
$family = (exists $arg->{PeerAddr})? ($rres[0]):($lres[0]) ; #
One concrete family.
#printf "DEBUG $family \n";
- (undef,undef,undef,$lres,undef,@lres) = @lres;
+ (my $fam_listen,undef,undef,$lres,undef,@lres) = @lres;
+ next if $fam_listen != $family;
if ($lres && $family == AF_INET6) {
if ($arg->{LocalFlow} || $arg->{LocalScope}) {