From 4b4b1389d21d3803609423f30e4a4a5a0e1859dd Mon Sep 17 00:00:00 2001 From: bluhm Date: Sun, 12 Dec 2021 10:56:49 +0000 Subject: [PATCH] Replace deprecated IO::Socket::INET6 with IO::Socket::IP. --- regress/sys/kern/sosplice/Client.pm | 14 ++++++++------ regress/sys/kern/sosplice/Makefile.inc | 3 +-- regress/sys/kern/sosplice/Relay.pm | 19 ++++++++++++------- regress/sys/kern/sosplice/Server.pm | 12 +++++++----- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/regress/sys/kern/sosplice/Client.pm b/regress/sys/kern/sosplice/Client.pm index 674cdeb7922..fa815526892 100644 --- a/regress/sys/kern/sosplice/Client.pm +++ b/regress/sys/kern/sosplice/Client.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Client.pm,v 1.1.1.1 2013/01/03 17:36:37 bluhm Exp $ +# $OpenBSD: Client.pm,v 1.2 2021/12/12 10:56:49 bluhm Exp $ # Copyright (c) 2010-2012 Alexander Bluhm # @@ -23,7 +23,7 @@ use Carp; use Socket qw(IPPROTO_TCP TCP_NODELAY); use Socket6; use IO::Socket; -use IO::Socket::INET6; +use IO::Socket::IP -register; sub new { my $class = shift; @@ -42,10 +42,9 @@ sub new { or croak "$class connect port not given"; if ($self->{bindaddr}) { - my $cs = IO::Socket::INET6->new( + my $cs = IO::SocketIP->new( Proto => $self->{protocol}, Domain => $self->{connectdomain}, - Blocking => ($self->{nonblocking} ? 0 : 1), LocalAddr => $self->{bindaddr}, LocalPort => $self->{bindport}, ) or die ref($self), " socket connect failed: $!"; @@ -60,10 +59,9 @@ sub new { sub child { my $self = shift; - my $cs = $self->{cs} || IO::Socket::INET6->new( + my $cs = $self->{cs} || IO::Socket->new( Proto => $self->{protocol}, Domain => $self->{connectdomain}, - Blocking => ($self->{nonblocking} ? 0 : 1), ) or die ref($self), " socket connect failed: $!"; if ($self->{oobinline}) { setsockopt($cs, SOL_SOCKET, SO_OOBINLINE, pack('i', 1)) @@ -91,6 +89,10 @@ sub child { print STDERR "connect peer: ",$cs->peerhost()," ",$cs->peerport(),"\n"; $self->{bindaddr} = $cs->sockhost(); $self->{bindport} = $cs->sockport(); + if ($self->{nonblocking}) { + $cs->blocking(0) + or die ref($self), " set non-blocking connect failed: $!"; + } open(STDOUT, '>&', $cs) or die ref($self), " dup STDOUT failed: $!"; diff --git a/regress/sys/kern/sosplice/Makefile.inc b/regress/sys/kern/sosplice/Makefile.inc index a7b0c02b252..70e80024a24 100644 --- a/regress/sys/kern/sosplice/Makefile.inc +++ b/regress/sys/kern/sosplice/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.6 2021/05/17 13:13:27 bluhm Exp $ +# $OpenBSD: Makefile.inc,v 1.7 2021/12/12 10:56:49 bluhm Exp $ # The following ports must be installed for the regression tests: # p5-BSD-Socket-Splice perl interface to OpenBSD socket splicing @@ -12,7 +12,6 @@ PERL_REQUIRE != perl -Mstrict -Mwarnings -e ' \ eval { require BSD::Socket::Splice } or print $@; \ - eval { require IO::Socket::INET6 } or print $@; \ eval { require Socket6 } or print $@; \ ' .if ! empty (PERL_REQUIRE) && ! defined (TARGETS) diff --git a/regress/sys/kern/sosplice/Relay.pm b/regress/sys/kern/sosplice/Relay.pm index 41c8575ed45..83ff2dcffa3 100644 --- a/regress/sys/kern/sosplice/Relay.pm +++ b/regress/sys/kern/sosplice/Relay.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Relay.pm,v 1.2 2017/11/07 22:06:17 bluhm Exp $ +# $OpenBSD: Relay.pm,v 1.3 2021/12/12 10:56:49 bluhm Exp $ # Copyright (c) 2010-2017 Alexander Bluhm # @@ -23,7 +23,7 @@ use Carp; use Socket qw(IPPROTO_TCP TCP_NODELAY); use Socket6; use IO::Socket; -use IO::Socket::INET6; +use IO::Socket::IP -register; sub new { my $class = shift; @@ -42,7 +42,7 @@ sub new { or croak "$class connect addr not given"; $self->{connectport} or croak "$class connect port not given"; - my $ls = IO::Socket::INET6->new( + my $ls = IO::Socket->new( Proto => $self->{protocol}, ReuseAddr => 1, Domain => $self->{listendomain}, @@ -89,8 +89,10 @@ sub child { print STDERR "accept peer: ",$as->peerhost()," ", $as->peerport(),"\n"; } - $as->blocking($self->{nonblocking} ? 0 : 1) - or die ref($self), " non-blocking accept failed: $!"; + if ($self->{nonblocking}) { + $as->blocking(0) + or die ref($self), " set non-blocking accept failed: $!"; + } open(STDIN, '<&', $as) or die ref($self), " dup STDIN failed: $!"; @@ -106,10 +108,9 @@ sub child { and die ref($self), " select timeout"; } - my $cs = IO::Socket::INET6->new( + my $cs = IO::Socket->new( Proto => $self->{protocol}, Domain => $self->{connectdomain}, - Blocking => ($self->{nonblocking} ? 0 : 1), ) or die ref($self), " socket connect failed: $!"; if ($self->{oobinline}) { setsockopt($cs, SOL_SOCKET, SO_OOBINLINE, pack('i', 1)) @@ -137,6 +138,10 @@ sub child { print STDERR "connect peer: ",$cs->peerhost()," ",$cs->peerport(),"\n"; $self->{bindaddr} = $cs->sockhost(); $self->{bindport} = $cs->sockport(); + if ($self->{nonblocking}) { + $cs->blocking(0) + or die ref($self), " set non-blocking connect failed: $!"; + } open(STDOUT, '>&', $cs) or die ref($self), " dup STDOUT failed: $!"; diff --git a/regress/sys/kern/sosplice/Server.pm b/regress/sys/kern/sosplice/Server.pm index e9b831dd7e0..96a0a210ed4 100644 --- a/regress/sys/kern/sosplice/Server.pm +++ b/regress/sys/kern/sosplice/Server.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Server.pm,v 1.1.1.1 2013/01/03 17:36:38 bluhm Exp $ +# $OpenBSD: Server.pm,v 1.2 2021/12/12 10:56:49 bluhm Exp $ # Copyright (c) 2010 Alexander Bluhm # @@ -23,7 +23,7 @@ use Carp; use Socket qw(IPPROTO_TCP TCP_NODELAY); use Socket6; use IO::Socket; -use IO::Socket::INET6; +use IO::Socket::IP -register; sub new { my $class = shift; @@ -34,7 +34,7 @@ sub new { $self->{protocol} ||= "tcp"; $self->{listendomain} or croak "$class listen domain not given"; - my $ls = IO::Socket::INET6->new( + my $ls = IO::Socket->new( Proto => $self->{protocol}, ReuseAddr => 1, Domain => $self->{listendomain}, @@ -81,8 +81,10 @@ sub child { print STDERR "accept peer: ",$as->peerhost()," ", $as->peerport(),"\n"; } - $as->blocking($self->{nonblocking} ? 0 : 1) - or die ref($self), " non-blocking accept failed: $!"; + if ($self->{nonblocking}) { + $as->blocking(0) + or die ref($self), " set non-blocking accept failed: $!"; + } open(STDIN, '<&', $as) or die ref($self), " dup STDIN failed: $!"; -- 2.20.1