From 75657dc71465268086218d4328cc00208976c675 Mon Sep 17 00:00:00 2001 From: bluhm Date: Tue, 14 Dec 2021 12:37:49 +0000 Subject: [PATCH] IO::Socket::IP non-blocking connect works a bit differently than IO::Socket::INET6. Tweak the non-blocking for connect in the sosplice scapy test. --- regress/sys/kern/sosplice/Relay.pm | 9 +++++++-- regress/sys/kern/sosplice/scapy/scapy.pl | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/regress/sys/kern/sosplice/Relay.pm b/regress/sys/kern/sosplice/Relay.pm index 83ff2dcffa3..aca919724ff 100644 --- a/regress/sys/kern/sosplice/Relay.pm +++ b/regress/sys/kern/sosplice/Relay.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Relay.pm,v 1.3 2021/12/12 10:56:49 bluhm Exp $ +# $OpenBSD: Relay.pm,v 1.4 2021/12/14 12:37:49 bluhm Exp $ # Copyright (c) 2010-2017 Alexander Bluhm # @@ -20,6 +20,7 @@ use warnings; package Relay; use parent 'Proc'; use Carp; +use Errno 'EINPROGRESS'; use Socket qw(IPPROTO_TCP TCP_NODELAY); use Socket6; use IO::Socket; @@ -130,9 +131,13 @@ sub child { setsockopt($cs, IPPROTO_TCP, TCP_NODELAY, pack('i', 1)) or die ref($self), " set nodelay connect failed: $!"; } + if ($self->{connectnonblocking}) { + $cs->blocking(0) + or die ref($self), " set non-blocking connect failed: $!"; + } my @rres = getaddrinfo($self->{connectaddr}, $self->{connectport}, $self->{connectdomain}, SOCK_STREAM); - $cs->connect($rres[3]) + $cs->connect($rres[3]) || $!{EINPROGRESS} or die ref($self), " connect failed: $!"; print STDERR "connect sock: ",$cs->sockhost()," ",$cs->sockport(),"\n"; print STDERR "connect peer: ",$cs->peerhost()," ",$cs->peerport(),"\n"; diff --git a/regress/sys/kern/sosplice/scapy/scapy.pl b/regress/sys/kern/sosplice/scapy/scapy.pl index f6844bef202..e19a0c9e9ea 100644 --- a/regress/sys/kern/sosplice/scapy/scapy.pl +++ b/regress/sys/kern/sosplice/scapy/scapy.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: scapy.pl,v 1.4 2020/12/27 14:37:54 bluhm Exp $ +# $OpenBSD: scapy.pl,v 1.5 2021/12/14 12:37:49 bluhm Exp $ # Copyright (c) 2010-2017 Alexander Bluhm # @@ -72,7 +72,7 @@ if ($mode eq "relay") { sndbuf => 2**12, down => "Broken pipe|Connection reset by peer", clientreadable => $testfile =~ /delay-connect/ ? 1 : 0, - nonblocking => 1, + connectnonblocking => 1, ); open(my $log, '<', $r->{logfile}) or die "Remote log file open failed: $!"; -- 2.20.1