Subject: | IPv6 fast fallback patch for IO::Socket::IP |
I wrote a patch which enables "IPv6 fast fallback" to IO::Socket::IP.
I fixed some old code and added documents.
All tests pass after applied this patch.
% make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00use.t ........................... ok
t/01local-client-v4.t ............... ok
t/02local-server-v4.t ............... ok
t/03local-cross-v4.t ................ ok
t/04local-client-v6.t ............... ok
t/05local-server-v6.t ............... ok
t/06local-cross-v6.t ................ ok
t/10args.t .......................... ok
t/11sockopts.t ...................... ok
t/12port-fallback.t ................. ok
t/13addrinfo.t ...................... ok
t/14fileno.t ........................ ok
t/15io-socket.t ..................... ok
t/16v6only.t ........................ ok
t/17gai-flags.t ..................... ok
t/20nonblocking-connect.t ........... ok
t/21nonblocking-connect-internet.t .. ok
t/22ipv6fastfallback.t .............. 1/? # filter ipv6 packet
# restore ipv6 filter
t/22ipv6fastfallback.t .............. ok
t/99pod.t ........................... ok
All tests successful.
Files=19, Tests=188, 64 wallclock secs ( 0.06 usr 0.02 sys + 0.69 cusr
0.13 csys = 0.90 CPU)
Result: PASS
Subject: | 22ipv6fastfallback.t |
#!/usr/bin/perl -w
use strict;
use Test::More;
use IO::Socket::INET6;
use IO::Socket::IP;
SKIP: {
my $AF_INET6 = eval { Socket::AF_INET6() } ||
eval { require Socket6; Socket6::AF_INET6() };
$AF_INET6 or skip "No AF_INET6", 1;
my $ipv6server = IO::Socket::INET6->new(
Domain => PF_INET6,
Listen => 1,
LocalHost => "::1",
LocalPort => 0,
Type => SOCK_STREAM,
) or die "Cannot listen on PF_INET - $@";
my $sock = IO::Socket::IP->new(
PeerHost => "::1",
PeerService => $ipv6server->sockport,
Type => SOCK_STREAM,
IPv6FastFallback => 1,
);
isa_ok( $sock, "IO::Socket::IP", 'connect ipv6server' );
is $sock->sockdomain, PF_INET6, 'connected via IPv6';
}
if ( $ENV{TEST_IPV6HOST} ) {
my $sock = IO::Socket::IP->new(
PeerHost => $ENV{TEST_IPV6HOST},
PeerPort => 'http',
Type => SOCK_STREAM,
IPv6FastFallback => 1,
);
is $sock->sockdomain, PF_INET6, "connected to $ENV{TEST_IPV6HOST} via IPv6";
# do ipv6 filterling on linux
system( qw( sudo ip6tables -P OUTPUT DROP ) ) == 0
or skip( "failed ipv6tables" );
diag "filter ipv6 packet";
eval {
my $sock = IO::Socket::IP->new(
PeerAddr => $ENV{TEST_IPV6HOST},
Proto => 'tcp',
PeerPort => 80,
Type => SOCK_STREAM,
IPv6FastFallback => 1,
);
is $sock->sockdomain, PF_INET,
"connected to $ENV{TEST_IPV6HOST} via IPv4";
};
# release ipv6 filterling
system( qw( sudo ip6tables -P OUTPUT ACCEPT ) );
diag "restore ipv6 filter";
}
done_testing;