aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/cmd/dtrace
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@FreeBSD.org>2019-04-28 19:07:31 +0000
committerMichael Tuexen <tuexen@FreeBSD.org>2019-04-28 19:07:31 +0000
commit6eb0062dd0bb8756d62ac569a22dd11a51271568 (patch)
tree203c56fe61aea81ec836553509edc3f8e6934b30 /cddl/contrib/opensolaris/cmd/dtrace
parent9891fa5592733757cc4aa1522cd59887bd234c87 (diff)
downloadsrc-6eb0062dd0bb8756d62ac569a22dd11a51271568.tar.gz
src-6eb0062dd0bb8756d62ac569a22dd11a51271568.zip
Some test scripts use ncat --sctp --listen port to run an SCTP discard
server in the background. However, when running in the background, stdin is closed and ncat initiates a graceful shutdown of the SCTP association. This is not expected by the client. Therefore, the ncat-based discard server is replaced by a perl-based one. In addition, to remove the dependency from ncat, which needs to be installed via the nmap port, also the code testing for a free SCTP port is changed to use the perl-based client. Finally, remove some debug output from the report generated. Reviewed by: lwhsu@ Differential Revision: https://reviews.freebsd.org/D20086
Notes
Notes: svn path=/head/; revision=346854
Diffstat (limited to 'cddl/contrib/opensolaris/cmd/dtrace')
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localsctp.ksh56
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh48
2 files changed, 68 insertions, 36 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localsctp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localsctp.ksh
index 594ef71dc597..1b151578afef 100755
--- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localsctp.ksh
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localsctp.ksh
@@ -58,36 +58,52 @@ DIR=/var/tmp/dtest.$$
sctpport=1024
bound=5000
-while [ $sctpport -lt $bound ]; do
- ncat --sctp -z $local $sctpport > /dev/null || break
- sctpport=$(($sctpport + 1))
-done
-if [ $sctpport -eq $bound ]; then
- echo "couldn't find an available SCTP port"
- exit 1
-fi
mkdir $DIR
cd $DIR
-# ncat will exit when the association is closed.
-ncat --sctp --listen $local $sctpport &
-
-cat > test.pl <<-EOPERL
+cat > client.pl <<-EOPERL
use IO::Socket;
my \$s = IO::Socket::INET->new(
Type => SOCK_STREAM,
Proto => "sctp",
LocalAddr => "$local",
PeerAddr => "$local",
- PeerPort => $sctpport,
+ PeerPort => \$ARGV[0],
Timeout => 3);
- die "Could not connect to host $local port $sctpport \$@" unless \$s;
+ die "Could not connect to host $local port \$ARGV[0] \$@" unless \$s;
close \$s;
- sleep(2);
+ sleep(\$ARGV[1]);
EOPERL
-$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+while [ $sctpport -lt $bound ]; do
+ perl client.pl $sctpport 0 2>&- || break
+ sctpport=$(($sctpport + 1))
+done
+if [ $sctpport -eq $bound ]; then
+ echo "couldn't find an available SCTP port"
+ exit 1
+fi
+
+cat > server.pl <<-EOPERL
+ use IO::Socket;
+ my \$l = IO::Socket::INET->new(
+ Type => SOCK_STREAM,
+ Proto => "sctp",
+ LocalAddr => "$local",
+ LocalPort => $sctpport,
+ Listen => 1,
+ Reuse => 1);
+ die "Could not listen on $local port $sctpport \$@" unless \$l;
+ my \$c = \$l->accept();
+ close \$l;
+ while (<\$c>) {};
+ close \$c;
+EOPERL
+
+perl server.pl &
+
+$dtrace -c "perl client.pl $sctpport 2" -qs /dev/stdin <<EODTRACE
BEGIN
{
ipsend = sctpsend = ipreceive = sctpreceive = 0;
@@ -122,10 +138,10 @@ sctp:::receive
END
{
printf("Minimum SCTP events seen\n\n");
- printf("ip:::send (%d) - %s\n", ipsend, ipsend >= 7 ? "yes" : "no");
- printf("ip:::receive (%d) - %s\n", ipreceive, ipreceive >= 7 ? "yes" : "no");
- printf("sctp:::send (%d) - %s\n", sctpsend, sctpsend >= 7 ? "yes" : "no");
- printf("sctp:::receive (%d) - %s\n", sctpreceive, sctpreceive >= 7 ? "yes" : "no");
+ printf("ip:::send - %s\n", ipsend >= 7 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 7 ? "yes" : "no");
+ printf("sctp:::send - %s\n", sctpsend >= 7 ? "yes" : "no");
+ printf("sctp:::receive - %s\n", sctpreceive >= 7 ? "yes" : "no");
}
EODTRACE
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh
index 7fb21644b459..959342fb4090 100755
--- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh
@@ -61,36 +61,52 @@ DIR=/var/tmp/dtest.$$
sctpport=1024
bound=5000
-while [ $sctpport -lt $bound ]; do
- ncat --sctp -z $local $sctpport > /dev/null || break
- sctpport=$(($sctpport + 1))
-done
-if [ $sctpport -eq $bound ]; then
- echo "couldn't find an available SCTP port"
- exit 1
-fi
mkdir $DIR
cd $DIR
-# ncat will exit when the association is closed.
-ncat --sctp --listen $local $sctpport &
-
-cat > test.pl <<-EOPERL
+cat > client.pl <<-EOPERL
use IO::Socket;
my \$s = IO::Socket::INET->new(
Type => SOCK_STREAM,
Proto => "sctp",
LocalAddr => "$local",
PeerAddr => "$local",
- PeerPort => $sctpport,
+ PeerPort => \$ARGV[0],
Timeout => 3);
- die "Could not connect to host $local port $sctpport \$@" unless \$s;
+ die "Could not connect to host $local port \$ARGV[0] \$@" unless \$s;
close \$s;
- sleep(2);
+ sleep(\$ARGV[1]);
EOPERL
-$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+while [ $sctpport -lt $bound ]; do
+ perl client.pl $sctpport 0 2>&- || break
+ sctpport=$(($sctpport + 1))
+done
+if [ $sctpport -eq $bound ]; then
+ echo "couldn't find an available SCTP port"
+ exit 1
+fi
+
+cat > server.pl <<-EOPERL
+ use IO::Socket;
+ my \$l = IO::Socket::INET->new(
+ Type => SOCK_STREAM,
+ Proto => "sctp",
+ LocalAddr => "$local",
+ LocalPort => $sctpport,
+ Listen => 1,
+ Reuse => 1);
+ die "Could not listen on $local port $sctpport \$@" unless \$l;
+ my \$c = \$l->accept();
+ close \$l;
+ while (<\$c>) {};
+ close \$c;
+EOPERL
+
+perl server.pl &
+
+$dtrace -c "perl client.pl $sctpport 2" -qs /dev/stdin <<EODTRACE
BEGIN
{
ipsend = sctpsend = ipreceive = sctpreceive = 0;