Subject: | Resolver fails TCP lookups on FreeBSD (IPv4) jail if kernel has IPv6 support. |
Server is running FreeBSD 5.4.
Kernel has support for IPv4 and IPv6.
A jail has only IPv4 transport due to the current nature of FreeBSD-jails.
Net::DNS assumes a TCP6 socket can be created but doesn't try to fall back to v4.
The attached patch solves this issue.
If the IO::Socket::INET6 call fails with EINVAL it will try IPv4.
I hope it doesn't introduce other problems ;-)
Let me know what you think.
-- robert
*** Resolver/Base.pm.459 Fri Jul 22 14:13:50 2005
--- Resolver/Base.pm Tue Sep 20 00:43:20 2005
***************
*** 586,591 ****
--- 586,592 ----
#my $old_wflag = $^W;
#$^W = 0;
+ $sock = undef;
if ($has_inet6 && ! $self->force_v4()){
# XXX IO::Socket::INET6 fails in a cryptic way upon send()
# on AIX5L if "0" is passed in as LocalAddr
***************
*** 603,609 ****
Timeout => $timeout,
);
! }else{
$sock = IO::Socket::INET->new(
PeerAddr => $ns,
PeerPort => $dstport,
--- 604,614 ----
Timeout => $timeout,
);
! }
! # OS might support IPv6 in kernel, but can't
! # really get an IPv6 socket. A reason might be
! # that we're a jailed process. -- robert
! if (not defined $sock and exists $!{EINVAL}) {
$sock = IO::Socket::INET->new(
PeerAddr => $ns,
PeerPort => $dstport,