aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip')
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl107
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl97
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh71
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh.out8
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localsctp.ksh153
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localsctp.ksh.out7
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh135
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh.out7
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh124
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh.out7
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudplite.ksh125
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudplite.ksh.out7
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh81
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh.out3
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotesctp.ksh130
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotesctp.ksh.out7
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh131
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh.out7
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh112
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh.out5
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudplite.ksh113
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudplite.ksh.out5
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh83
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out8
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh88
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh.out3
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh175
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh.out13
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh190
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh.out18
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotesctpstate.ksh149
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotesctpstate.ksh.out12
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh172
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh.out15
34 files changed, 2368 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl
new file mode 100755
index 000000000000..c07e46bbd976
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl
@@ -0,0 +1,107 @@
+#!/usr/bin/env perl
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# get.ipv4remote.pl [port] [proto]
+#
+# Find an IPv4 reachable remote host using both ifconfig(1M) and ping(1M).
+# If a port is specified, return a host that is also listening on this
+# port. If the port is specified, the protocol can also be specified and
+# defaults to tcp. Print the local address and the remote address, or an
+# error message if no suitable remote host was found. Exit status is 0 if
+# a host was found.
+#
+
+use strict;
+use IO::Socket;
+
+my $MAXHOSTS = 32; # max hosts to port scan
+my $TIMEOUT = 3; # connection timeout
+my $port = @ARGV >= 1 ? $ARGV[0] : 0;
+my $proto = @ARGV == 2 ? $ARGV[1] : "tcp";
+
+#
+# Determine local IP address
+#
+my $local = "";
+my $remote = "";
+my %Broadcast;
+my $up;
+open IFCONFIG, '/sbin/ifconfig -a |' or die "Couldn't run ifconfig: $!\n";
+while (<IFCONFIG>) {
+ next if /^lo/;
+
+ # "UP" is always printed first (see print_flags() in ifconfig.c):
+ $up = 1 if /^[a-z].*<UP,/;
+ $up = 0 if /^[a-z].*<,/;
+
+ # assume output is "inet X ... broadcast Z":
+ if (/inet (\S+) .* broadcast (\S+)/) {
+ my ($addr, $bcast) = ($1, $2);
+ $Broadcast{$addr} = $bcast;
+ $local = $addr if $up and $local eq "";
+ $up = 0;
+ }
+}
+close IFCONFIG;
+die "Could not determine local IP address" if $local eq "";
+
+#
+# Find the first remote host that responds to an icmp echo,
+# which isn't a local address.
+#
+open PING, "/sbin/ping -n -s 56 -c $MAXHOSTS $Broadcast{$local} |" or
+ die "Couldn't run ping: $!\n";
+while (<PING>) {
+ if (/bytes from (.*): / and not defined $Broadcast{$1}) {
+ my $addr = $1;
+
+ if ($port != 0) {
+ #
+ # Test TCP
+ #
+ my $socket = IO::Socket::INET->new(
+ Type => SOCK_STREAM,
+ Proto => $proto,
+ PeerAddr => $addr,
+ PeerPort => $port,
+ Timeout => $TIMEOUT,
+ );
+ next unless $socket;
+ close $socket;
+ }
+
+ $remote = $addr;
+ last;
+ }
+}
+close PING;
+die "Can't find a remote host for testing: No suitable response from " .
+ "$Broadcast{$local}\n" if $remote eq "";
+
+print "$local $remote\n";
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl
new file mode 100755
index 000000000000..fbfcdfdab35f
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl
@@ -0,0 +1,97 @@
+#!/usr/bin/env perl
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# get.ipv6remote.pl
+#
+# Find an IPv6 reachable remote host using both ifconfig(1M) and ping(1M).
+# Print the local address and the remote address, or print nothing if either
+# no IPv6 interfaces or remote hosts were found. (Remote IPv6 testing is
+# considered optional, and so not finding another IPv6 host is not an error
+# state we need to log.) Exit status is 0 if a host was found.
+#
+
+use strict;
+use IO::Socket;
+
+my $MAXHOSTS = 32; # max hosts to scan
+my $TIMEOUT = 3; # connection timeout
+my $MULTICAST = "FF02::1"; # IPv6 multicast address
+
+#
+# Determine local IP address
+#
+my $local = "";
+my $remote = "";
+my $interf = "";
+my %Local;
+my %Addr;
+my $up;
+open IFCONFIG, '/sbin/ifconfig -a inet6 |'
+ or die "Couldn't run ifconfig: $!\n";
+while (<IFCONFIG>) {
+ next if /^lo/;
+
+ # "UP" is always printed first (see print_flags() in ifconfig.c):
+ $up = 1 if /^[a-z].*<UP,/;
+ $up = 0 if /^[a-z].*<,/;
+
+ if (m:(\S+\d+)\: :) {
+ $interf = $1;
+ }
+
+ # assume output is "inet6 ...":
+ if (m:inet6 (\S+) :) {
+ my $addr = $1;
+ $Local{$addr} = 1;
+ $Addr{$interf} = $addr;
+ $up = 0;
+ $interf = "";
+ }
+}
+close IFCONFIG;
+
+#
+# Find the first remote host that responds to an icmp echo,
+# which isn't a local address. Try each IPv6-enabled interface.
+#
+foreach $interf (split(' ', `ifconfig -l -u inet6`)) {
+ next if $interf =~ /lo[0-9]+/;
+ open PING, "/sbin/ping6 -n -s 56 -c $MAXHOSTS $MULTICAST\%$interf |" or next;
+ while (<PING>) {
+ if (/bytes from (.*), / and not defined $Local{$1}) {
+ $remote = $1;
+ $local = $Addr{$interf};
+ last;
+ }
+ }
+}
+close PING;
+exit 2 if $remote eq "";
+
+print "$local $remote\n";
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh
new file mode 100755
index 000000000000..88a619edf589
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh
@@ -0,0 +1,71 @@
+#!/usr/bin/env ksh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# Test ip:::{send,receive} of IPv4 ICMP to a local address.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. The lo0 interface missing or not up.
+# 3. Unrelated ICMP on lo0 traced by accident.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=127.0.0.1
+
+$dtrace -c "/sbin/ping -q -c 1 -t 3 $local" -qs /dev/stdin <<EOF | sort -n | \
+ grep -v -e '^round-trip ' -e '^--- '
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_ICMP/
+{
+ printf("2 ip:::send (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[4]: %d %d %d %d %d)\n",
+ args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
+ args[4]->ipv4_offset, args[4]->ipv4_ttl);
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_ICMP/
+{
+ printf("3 ip:::receive (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[4]: %d %d %d %d %d)\n",
+ args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
+ args[4]->ipv4_offset, args[4]->ipv4_ttl);
+}
+EOF
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh.out
new file mode 100644
index 000000000000..c62b0c8e2557
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh.out
@@ -0,0 +1,8 @@
+
+
+PING 127.0.0.1 (127.0.0.1): 56 data bytes
+1 packets transmitted, 1 packets received, 0.0% packet loss
+2 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 64)
+2 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 64)
+3 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 64)
+3 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 64)
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
new file mode 100755
index 000000000000..1b151578afef
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localsctp.ksh
@@ -0,0 +1,153 @@
+#!/usr/bin/env ksh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test {ip,sctp}:::{send,receive} of IPv4 SCTP to local host.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. The lo0 interface missing or not up.
+# 3. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs a SCTP association and checks that at least the
+# following packet counts were traced:
+#
+# 7 x ip:::send (4 during the setup, 3 during the teardown)
+# 7 x sctp:::send (4 during the setup, 3 during the teardown)
+# 7 x ip:::receive (4 during the setup, 3 during the teardown)
+# 7 x sctp:::receive (4 during the setup, 3 during the teardown)
+
+# The actual count tested is 7 each way, since we are tracing both
+# source and destination events.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=127.0.0.1
+DIR=/var/tmp/dtest.$$
+
+sctpport=1024
+bound=5000
+
+mkdir $DIR
+cd $DIR
+
+cat > client.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Type => SOCK_STREAM,
+ Proto => "sctp",
+ LocalAddr => "$local",
+ PeerAddr => "$local",
+ PeerPort => \$ARGV[0],
+ Timeout => 3);
+ die "Could not connect to host $local port \$ARGV[0] \$@" unless \$s;
+ close \$s;
+ sleep(\$ARGV[1]);
+EOPERL
+
+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;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_SCTP/
+{
+ ipsend++;
+}
+
+sctp:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
+{
+ sctpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_SCTP/
+{
+ ipreceive++;
+}
+
+sctp:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
+{
+ sctpreceive++;
+}
+
+END
+{
+ printf("Minimum SCTP events seen\n\n");
+ 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
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localsctp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localsctp.ksh.out
new file mode 100644
index 000000000000..8c708770971b
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localsctp.ksh.out
@@ -0,0 +1,7 @@
+Minimum SCTP events seen
+
+ip:::send - yes
+ip:::receive - yes
+sctp:::send - yes
+sctp:::receive - yes
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh
new file mode 100755
index 000000000000..42e1372c9c81
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh
@@ -0,0 +1,135 @@
+#!/usr/bin/env ksh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test {ip,tcp}:::{send,receive} of IPv4 TCP to local host.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. The lo0 interface missing or not up.
+# 3. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs a TCP connection and checks that at least the
+# following packet counts were traced:
+#
+# 7 x ip:::send (3 during the setup, 4 during the teardown)
+# 7 x tcp:::send (3 during the setup, 4 during the teardown)
+# 7 x ip:::receive (3 during the setup, 4 during the teardown)
+# 7 x tcp:::receive (3 during the setup, 4 during the teardown)
+
+# The actual count tested is 7 each way, since we are tracing both
+# source and destination events.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=127.0.0.1
+DIR=/var/tmp/dtest.$$
+
+tcpport=1024
+bound=5000
+while [ $tcpport -lt $bound ]; do
+ nc -z $local $tcpport >/dev/null || break
+ tcpport=$(($tcpport + 1))
+done
+if [ $tcpport -eq $bound ]; then
+ echo "couldn't find an available TCP port"
+ exit 1
+fi
+
+mkdir $DIR
+cd $DIR
+
+# nc will exit when the connection is closed.
+nc -l $local $tcpport &
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => "$local",
+ PeerPort => $tcpport,
+ Timeout => 3);
+ die "Could not connect to host $local port $tcpport" unless \$s;
+ close \$s;
+ sleep(2);
+EOPERL
+
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = tcpsend = ipreceive = tcpreceive = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipsend++;
+}
+
+tcp:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
+{
+ tcpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipreceive++;
+}
+
+tcp:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
+{
+ tcpreceive++;
+}
+
+END
+{
+ printf("Minimum TCP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 7 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 7 ? "yes" : "no");
+ printf("tcp:::send - %s\n", tcpsend >= 7 ? "yes" : "no");
+ printf("tcp:::receive - %s\n", tcpreceive >= 7 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh.out
new file mode 100644
index 000000000000..2a85b98b6b7d
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh.out
@@ -0,0 +1,7 @@
+Minimum TCP events seen
+
+ip:::send - yes
+ip:::receive - yes
+tcp:::send - yes
+tcp:::receive - yes
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh
new file mode 100755
index 000000000000..196448b66027
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh
@@ -0,0 +1,124 @@
+#!/usr/bin/env ksh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test {ip,udp}:::{send,receive} of IPv4 UDP to a local address.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. No physical network interface is plumbed and up.
+# 3. No other hosts on this subnet are reachable and listening on rpcbind.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test sends a UDP message using perl and checks that at least the
+# following counts were traced:
+#
+# 1 x ip:::send (UDP sent to UDP port 33434)
+# 1 x udp:::send (UDP sent to UDP port 33434)
+# 1 x ip:::receive (UDP received)
+# 1 x udp:::receive (UDP received)
+#
+# A udp:::receive event is expected even if the received UDP packet
+# elicits an ICMP PORT_UNREACHABLE message since there is no UDP
+# socket for receiving the packet.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=127.0.0.1
+port=33434
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Proto => "udp",
+ PeerAddr => "$local",
+ PeerPort => $port);
+ die "Could not create UDP socket $local port $port" unless \$s;
+ send \$s, "Hello", 0;
+ close \$s;
+ sleep(2);
+EOPERL
+
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = udpsend = ipreceive = udpreceive = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_UDP/
+{
+ ipsend++;
+}
+
+udp:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
+{
+ udpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_UDP/
+{
+ ipreceive++;
+}
+
+udp:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
+{
+ udpreceive++;
+}
+
+END
+{
+ printf("Minimum UDP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 1 ? "yes" : "no");
+ printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no");
+ printf("udp:::receive - %s\n", udpreceive >= 1 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh.out
new file mode 100644
index 000000000000..d94aa3104dad
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh.out
@@ -0,0 +1,7 @@
+Minimum UDP events seen
+
+ip:::send - yes
+ip:::receive - yes
+udp:::send - yes
+udp:::receive - yes
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudplite.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudplite.ksh
new file mode 100755
index 000000000000..902d278a8388
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudplite.ksh
@@ -0,0 +1,125 @@
+#!/usr/bin/env ksh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test {ip,udplite}:::{send,receive} of IPv4 UDP-Lite to a local address.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. No physical network interface is plumbed and up.
+# 3. No other hosts on this subnet are reachable and listening on rpcbind.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test sends a UDP-Lite message using perl and checks that at least the
+# following counts were traced:
+#
+# 1 x ip:::send (UDPLite sent to UDP-Lite port 33434)
+# 1 x udplite:::send (UDPLite sent to UDP-Lite port 33434)
+# 1 x ip:::receive (UDP-Lite received)
+# 1 x udplite:::receive (UDP-Lite received)
+#
+# A udplite:::receive event is expected even if the received UDP-Lite packet
+# elicits an ICMP PORT_UNREACHABLE message since there is no UDP-Lite
+# socket for receiving the packet.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=127.0.0.1
+port=33434
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Type => SOCK_DGRAM,
+ Proto => "udplite",
+ PeerAddr => "$local",
+ PeerPort => $port);
+ die "Could not create UDP-Lite socket $local port $port" unless \$s;
+ send \$s, "Hello", 0;
+ close \$s;
+ sleep(2);
+EOPERL
+
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = udplitesend = ipreceive = udplitereceive = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_UDPLITE/
+{
+ ipsend++;
+}
+
+udplite:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
+{
+ udplitesend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_UDPLITE/
+{
+ ipreceive++;
+}
+
+udplite:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
+{
+ udplitereceive++;
+}
+
+END
+{
+ printf("Minimum UDP-Lite events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 1 ? "yes" : "no");
+ printf("udplite:::send - %s\n", udplitesend >= 1 ? "yes" : "no");
+ printf("udplite:::receive - %s\n", udplitereceive >= 1 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudplite.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudplite.ksh.out
new file mode 100644
index 000000000000..b5970ffa57fb
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudplite.ksh.out
@@ -0,0 +1,7 @@
+Minimum UDP-Lite events seen
+
+ip:::send - yes
+ip:::receive - yes
+udplite:::send - yes
+udplite:::receive - yes
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh
new file mode 100755
index 000000000000..7b456aa61f46
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh
@@ -0,0 +1,81 @@
+#!/usr/bin/env ksh93
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# Test ip:::{send,receive} of IPv4 ICMP to a remote host.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. No physical network interface is plumbed and up.
+# 3. No other hosts on this subnet are reachable.
+# 4. An unrelated ICMP between these hosts was traced by accident.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv4remote.pl
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr | read source dest
+if (( $? != 0 )); then
+ exit 4
+fi
+
+$dtrace -c "/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \
+ grep -v 'is alive' | sort -n
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->ipv4_protocol == IPPROTO_ICMP/
+{
+ printf("1 ip:::send (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[4]: %d %d %d %d %d)\n",
+ args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
+ args[4]->ipv4_offset, args[4]->ipv4_ttl);
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->ipv4_protocol == IPPROTO_ICMP/
+{
+ printf("2 ip:::receive (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[4]: %d %d %d %d %d)\n",
+ args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
+ args[4]->ipv4_offset, args[4]->ipv4_ttl);
+}
+EOF
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh.out
new file mode 100644
index 000000000000..b5915f8db477
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh.out
@@ -0,0 +1,3 @@
+
+1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255)
+2 ip:::receive (args[2]: 4 64, args[4]: 4 84 4 0 255)
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotesctp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotesctp.ksh
new file mode 100755
index 000000000000..60dabf7a8b94
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotesctp.ksh
@@ -0,0 +1,130 @@
+#!/usr/bin/env ksh93
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test {sctp,ip}:::{send,receive} of IPv4 SCTP to a remote host.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. No physical network interface is plumbed and up.
+# 3. No other hosts on this subnet are reachable and listening on ssh.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs an SCTP association and checks that at least the
+# following packet counts were traced:
+#
+# 4 x ip:::send (2 during setup, 2 during teardown)
+# 4 x sctp:::send (2 during connection setup, 2 during connection teardown)
+# 3 x ip:::receive (2 during setup, 1 during teardown)
+# 3 x sctp:::receive (2 during setup, 1 during teardown)
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv4remote.pl
+sctpport=80
+DIR=/var/tmp/dtest.$$
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr $sctpport sctp | read source dest
+if (( $? != 0 )); then
+ exit 4
+fi
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Type => SOCK_STREAM,
+ Proto => "sctp",
+ LocalAddr => "$source",
+ PeerAddr => "$dest",
+ PeerPort => $sctpport,
+ Timeout => 3);
+ die "Could not connect to host $dest port $sctpport \$@" unless \$s;
+ close \$s;
+ sleep(2);
+EOPERL
+
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = sctpsend = ipreceive = sctpreceive = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->ipv4_protocol == IPPROTO_SCTP/
+{
+ ipsend++;
+}
+
+sctp:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/
+{
+ sctpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->ipv4_protocol == IPPROTO_SCTP/
+{
+ ipreceive++;
+}
+
+sctp:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source"/
+{
+ sctpreceive++;
+}
+
+END
+{
+ printf("Minimum SCTP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 4 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 3 ? "yes" : "no");
+ printf("sctp:::send - %s\n", sctpsend >= 4 ? "yes" : "no");
+ printf("sctp:::receive - %s\n", sctpreceive >= 3 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotesctp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotesctp.ksh.out
new file mode 100644
index 000000000000..8c708770971b
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotesctp.ksh.out
@@ -0,0 +1,7 @@
+Minimum SCTP events seen
+
+ip:::send - yes
+ip:::receive - yes
+sctp:::send - yes
+sctp:::receive - yes
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh
new file mode 100755
index 000000000000..6eda63f90c1d
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh
@@ -0,0 +1,131 @@
+#!/usr/bin/env ksh93
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test {tcp,ip}:::{send,receive} of IPv4 TCP to a remote host.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. No physical network interface is plumbed and up.
+# 3. No other hosts on this subnet are reachable and listening on ssh.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs a TCP connection and checks that at least the
+# following packet counts were traced:
+#
+# 4 x ip:::send (2 during connection setup, 2 during connection teardown)
+# 4 x tcp:::send (2 during connection setup, 2 during connection teardown)
+# 5 x ip:::receive (1 during connection setup, the response, 1 window update,
+# 1 banner line, 2 during connection teardown)
+# 5 x tcp:::receive (1 during connection setup, the response, 1 window update,
+# 1 banner line, 2 during connection teardown)
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv4remote.pl
+tcpport=22
+DIR=/var/tmp/dtest.$$
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr $tcpport | read source dest
+if (( $? != 0 )); then
+ exit 4
+fi
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => "$dest",
+ PeerPort => $tcpport,
+ Timeout => 3);
+ die "Could not connect to host $dest port $tcpport" unless \$s;
+ readline \$s;
+ close \$s;
+ sleep(2);
+EOPERL
+
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = tcpsend = ipreceive = tcpreceive = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipsend++;
+}
+
+tcp:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/
+{
+ tcpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipreceive++;
+}
+
+tcp:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source"/
+{
+ tcpreceive++;
+}
+
+END
+{
+ printf("Minimum TCP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 4 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 5 ? "yes" : "no");
+ printf("tcp:::send - %s\n", tcpsend >= 4 ? "yes" : "no");
+ printf("tcp:::receive - %s\n", tcpreceive >= 5 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh.out
new file mode 100644
index 000000000000..2a85b98b6b7d
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh.out
@@ -0,0 +1,7 @@
+Minimum TCP events seen
+
+ip:::send - yes
+ip:::receive - yes
+tcp:::send - yes
+tcp:::receive - yes
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh
new file mode 100755
index 000000000000..e16034c95c4d
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh
@@ -0,0 +1,112 @@
+#!/usr/bin/env ksh93
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test {udp,ip}:::{send,receive} of IPv4 UDP to a remote host.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. No physical network interface is plumbed and up.
+# 3. No other hosts on this subnet are reachable and listening on rpcbind.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test sends a UDP message using perl and checks that at least the
+# following counts were traced:
+#
+# 1 x ip:::send (UDP sent to ping's base UDP port)
+# 1 x udp:::send (UDP sent to ping's base UDP port)
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv4remote.pl
+port=33434
+DIR=/var/tmp/dtest.$$
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr | read source dest
+if (( $? != 0 )); then
+ exit 4
+fi
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Proto => "udp",
+ PeerAddr => "$dest",
+ PeerPort => $port);
+ die "Could not create UDP socket $dest port $port" unless \$s;
+ send \$s, "Hello", 0;
+ close \$s;
+ sleep(2);
+EOPERL
+
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = udpsend = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->ipv4_protocol == IPPROTO_UDP/
+{
+ ipsend++;
+}
+
+udp:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/
+{
+ udpsend++;
+}
+
+END
+{
+ printf("Minimum UDP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no");
+ printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh.out
new file mode 100644
index 000000000000..bdbbe1fd6562
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh.out
@@ -0,0 +1,5 @@
+Minimum UDP events seen
+
+ip:::send - yes
+udp:::send - yes
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudplite.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudplite.ksh
new file mode 100755
index 000000000000..8837112d5d78
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudplite.ksh
@@ -0,0 +1,113 @@
+#!/usr/bin/env ksh93
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test {udplite,ip}:::{send,receive} of IPv4 UDP-Lite to a remote host.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. No physical network interface is plumbed and up.
+# 3. No other hosts on this subnet are reachable and listening on rpcbind.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test sends a UDP-Lite message using perl and checks that at least the
+# following counts were traced:
+#
+# 1 x ip:::send (UDP-Lite sent to UDP-Lite port 33434)
+# 1 x udplite:::send (UDP-Lite sent to UDP-Lite port 33434)
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv4remote.pl
+port=33434
+DIR=/var/tmp/dtest.$$
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr | read source dest
+if (( $? != 0 )); then
+ exit 4
+fi
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Type => SOCK_DGRAM,
+ Proto => "udplite",
+ PeerAddr => "$dest",
+ PeerPort => $port);
+ die "Could not create UDP-Lite socket $dest port $port" unless \$s;
+ send \$s, "Hello", 0;
+ close \$s;
+ sleep(2);
+EOPERL
+
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = udplitesend = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->ipv4_protocol == IPPROTO_UDPLITE/
+{
+ ipsend++;
+}
+
+udplite:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/
+{
+ udplitesend++;
+}
+
+END
+{
+ printf("Minimum UDPLite events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no");
+ printf("udplite:::send - %s\n", udplitesend >= 1 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudplite.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudplite.ksh.out
new file mode 100644
index 000000000000..66e39e736e23
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudplite.ksh.out
@@ -0,0 +1,5 @@
+Minimum UDP-Lite events seen
+
+ip:::send - yes
+udplite:::send - yes
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh
new file mode 100755
index 000000000000..96ec03be1ba3
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh
@@ -0,0 +1,83 @@
+#!/usr/bin/env ksh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# Test ip:::{send,receive} of IPv6 ICMP to a local address. This creates a
+# temporary lo0/inet6 interface if one doesn't already exist.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. Unrelated ICMPv6 on lo0 traced by accident.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=::1
+
+if ! ifconfig lo0 inet6 > /dev/null 2>&1; then
+ if ! ifconfig lo0 inet6 plumb up; then
+ print -u2 "could not plumb lo0 inet6 for testing"
+ exit 3
+ fi
+ removeinet6=1
+else
+ removeinet6=0
+fi
+
+$dtrace -c "/sbin/ping6 -q -c 1 -t 3 $local" -qs /dev/stdin <<EOF | sort -n | \
+ grep -v -e '^round-trip ' -e '^--- '
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
+{
+ printf("2 ip:::send (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[5]: %d %d %d)\n",
+ args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
+{
+ printf("3 ip:::receive (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[5]: %d %d %d)\n",
+ args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
+}
+EOF
+
+if (( removeinet6 )); then
+ ifconfig lo0 inet6 unplumb
+fi
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out
new file mode 100644
index 000000000000..2e94ff35de88
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out
@@ -0,0 +1,8 @@
+
+
+PING6(56=40+8+8 bytes) ::1 --> ::1
+1 packets transmitted, 1 packets received, 0.0% packet loss
+2 ip:::send (args[2]: 6 16, args[5]: 6 0 16)
+2 ip:::send (args[2]: 6 16, args[5]: 6 0 16)
+3 ip:::receive (args[2]: 6 16, args[5]: 6 0 16)
+3 ip:::receive (args[2]: 6 16, args[5]: 6 0 16)
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh
new file mode 100755
index 000000000000..303a1e455680
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh
@@ -0,0 +1,88 @@
+#!/usr/bin/env ksh93
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# Test ip:::{send,receive} of IPv6 ICMP to a remote host. This test is
+# skipped if there are no physical interfaces configured with IPv6, or no
+# other IPv6 hosts are reachable.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. An unrelated ICMPv6 between these hosts was traced by accident.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv6remote.pl
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr | read source dest
+if (( $? != 0 )); then
+ print -nu2 "Could not find a local IPv6 interface and a remote IPv6 "
+ print -u2 "host. Aborting test.\n"
+ print -nu2 "For this test to continue, a \"ping -ns -A inet6 FF02::1\" "
+ print -u2 "must respond with a\nremote IPv6 host."
+ exit 3
+fi
+
+#
+# Shake loose any ICMPv6 Neighbor advertisement messages before tracing.
+#
+/sbin/ping $dest 3 > /dev/null 2>&1
+
+$dtrace -c "/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \
+ grep -v 'is alive' | sort -n
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
+{
+ printf("1 ip:::send (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[5]: %d %d %d)\n",
+ args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
+{
+ printf("2 ip:::receive (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[5]: %d %d %d)\n",
+ args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
+}
+EOF
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh.out
new file mode 100644
index 000000000000..1ddcd07b367e
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh.out
@@ -0,0 +1,3 @@
+
+1 ip:::send (args[2]: 6 64, args[5]: 6 0 64)
+2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64)
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
new file mode 100755
index 000000000000..959342fb4090
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh
@@ -0,0 +1,175 @@
+#!/usr/bin/env ksh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test sctp:::state-change and sctp:::{send,receive} by connecting to
+# the local discard service.
+# A number of state transition events along with SCTP send and
+# receive events for the message should result.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. The lo0 interface missing or not up.
+# 3. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs a SCTP connection and checks that at least the
+# following packet counts were traced:
+#
+# 7 x ip:::send (4 during the setup, 3 during the teardown)
+# 7 x sctp:::send (4 during the setup, 3 during the teardown)
+# 7 x ip:::receive (4 during the setup, 3 during the teardown)
+# 7 x sctp:::receive (4 during the setup, 3 during the teardown)
+#
+# The actual count tested is 7 each way, since we are tracing both
+# source and destination events.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=127.0.0.1
+DIR=/var/tmp/dtest.$$
+
+sctpport=1024
+bound=5000
+
+mkdir $DIR
+cd $DIR
+
+cat > client.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Type => SOCK_STREAM,
+ Proto => "sctp",
+ LocalAddr => "$local",
+ PeerAddr => "$local",
+ PeerPort => \$ARGV[0],
+ Timeout => 3);
+ die "Could not connect to host $local port \$ARGV[0] \$@" unless \$s;
+ close \$s;
+ sleep(\$ARGV[1]);
+EOPERL
+
+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;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_SCTP/
+{
+ ipsend++;
+}
+
+sctp:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ (args[4]->sctp_sport == $sctpport || args[4]->sctp_dport == $sctpport)/
+{
+ sctpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_SCTP/
+{
+ ipreceive++;
+}
+
+sctp:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ (args[4]->sctp_sport == $sctpport || args[4]->sctp_dport == $sctpport)/
+{
+ sctpreceive++;
+}
+
+sctp:::state-change
+{
+ state_event[args[3]->sctps_state]++;
+}
+
+END
+{
+ printf("Minimum SCTP events seen\n\n");
+ 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");
+ printf("sctp:::state-change to cookie-wait - %s\n",
+ state_event[SCTP_STATE_COOKIE_WAIT] >=1 ? "yes" : "no");
+ printf("sctp:::state-change to cookie-echoed - %s\n",
+ state_event[SCTP_STATE_COOKIE_ECHOED] >=1 ? "yes" : "no");
+ printf("sctp:::state-change to established - %s\n",
+ state_event[SCTP_STATE_ESTABLISHED] >= 2 ? "yes" : "no");
+ printf("sctp:::state-change to shutdown-sent - %s\n",
+ state_event[SCTP_STATE_SHUTDOWN_SENT] >= 1 ? "yes" : "no");
+ printf("sctp:::state-change to shutdown-received - %s\n",
+ state_event[SCTP_STATE_SHUTDOWN_RECEIVED] >= 1 ? "yes" : "no");
+ printf("sctp:::state-change to shutdown-ack-sent - %s\n",
+ state_event[SCTP_STATE_SHUTDOWN_ACK_SENT] >= 1 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh.out
new file mode 100644
index 000000000000..340e0ee2780c
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh.out
@@ -0,0 +1,13 @@
+Minimum SCTP events seen
+
+ip:::send - yes
+ip:::receive - yes
+sctp:::send - yes
+sctp:::receive - yes
+sctp:::state-change to cookie-wait - yes
+sctp:::state-change to cookie-echoed - yes
+sctp:::state-change to established - yes
+sctp:::state-change to shutdown-sent - yes
+sctp:::state-change to shutdown-received - yes
+sctp:::state-change to shutdown-ack-sent - yes
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
new file mode 100755
index 000000000000..528157072117
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
@@ -0,0 +1,190 @@
+#!/usr/bin/env ksh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test tcp:::state-change and tcp:::{send,receive} by connecting to
+# the local ssh service and sending a test message. This should result
+# in a "Protocol mismatch" response and a close of the connection.
+# A number of state transition events along with tcp fusion send and
+# receive events for the message should result.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. The lo0 interface missing or not up.
+# 3. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs a TCP connection and checks that at least the
+# following packet counts were traced:
+#
+# 7 x ip:::send (3 during the setup, 4 during the teardown)
+# 7 x tcp:::send (3 during the setup, 4 during the teardown)
+# 7 x ip:::receive (3 during the setup, 4 during the teardown)
+# 7 x tcp:::receive (3 during the setup, 4 during the teardown)
+#
+# The actual count tested is 7 each way, since we are tracing both
+# source and destination events.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=127.0.0.1
+DIR=/var/tmp/dtest.$$
+
+tcpport=1024
+bound=5000
+while [ $tcpport -lt $bound ]; do
+ nc -z $local $tcpport >/dev/null || break
+ tcpport=$(($tcpport + 1))
+done
+if [ $tcpport -eq $bound ]; then
+ echo "couldn't find an available TCP port"
+ exit 1
+fi
+
+mkdir $DIR
+cd $DIR
+
+# nc will exit when the connection is closed.
+nc -l $local $tcpport &
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => "$local",
+ PeerPort => $tcpport,
+ Timeout => 3);
+ die "Could not connect to host $local port $tcpport" unless \$s;
+ close \$s;
+ sleep(2);
+EOPERL
+
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = tcpsend = ipreceive = tcpreceive = 0;
+ connreq = connest = connaccept = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipsend++;
+}
+
+tcp:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ (args[4]->tcp_sport == $tcpport || args[4]->tcp_dport == $tcpport)/
+{
+ tcpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipreceive++;
+}
+
+tcp:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ (args[4]->tcp_sport == $tcpport || args[4]->tcp_dport == $tcpport)/
+{
+ tcpreceive++;
+}
+
+tcp:::state-change
+{
+ state_event[args[3]->tcps_state]++;
+}
+
+tcp:::connect-request
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->tcp_dport == $tcpport/
+{
+ connreq++;
+}
+
+tcp:::connect-established
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->tcp_sport == $tcpport/
+{
+ connest++;
+}
+
+tcp:::accept-established
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->tcp_dport == $tcpport/
+{
+ connaccept++;
+}
+
+END
+{
+ printf("Minimum TCP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 7 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 7 ? "yes" : "no");
+ printf("tcp:::send - %s\n", tcpsend >= 7 ? "yes" : "no");
+ printf("tcp:::receive - %s\n", tcpreceive >= 7 ? "yes" : "no");
+ printf("tcp:::state-change to syn-sent - %s\n",
+ state_event[TCP_STATE_SYN_SENT] >=1 ? "yes" : "no");
+ printf("tcp:::state-change to syn-received - %s\n",
+ state_event[TCP_STATE_SYN_RECEIVED] >=1 ? "yes" : "no");
+ printf("tcp:::state-change to established - %s\n",
+ state_event[TCP_STATE_ESTABLISHED] >= 2 ? "yes" : "no");
+ printf("tcp:::state-change to fin-wait-1 - %s\n",
+ state_event[TCP_STATE_FIN_WAIT_1] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to close-wait - %s\n",
+ state_event[TCP_STATE_CLOSE_WAIT] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to fin-wait-2 - %s\n",
+ state_event[TCP_STATE_FIN_WAIT_2] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to last-ack - %s\n",
+ state_event[TCP_STATE_LAST_ACK] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to time-wait - %s\n",
+ state_event[TCP_STATE_TIME_WAIT] >= 1 ? "yes" : "no");
+ printf("tcp:::connect-request - %s\n",
+ connreq >=1 ? "yes" : "no");
+ printf("tcp:::connect-established - %s\n",
+ connest >=1 ? "yes" : "no");
+ printf("tcp:::accept-established - %s\n",
+ connaccept >=1 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh.out
new file mode 100644
index 000000000000..ea1c27e5020c
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh.out
@@ -0,0 +1,18 @@
+Minimum TCP events seen
+
+ip:::send - yes
+ip:::receive - yes
+tcp:::send - yes
+tcp:::receive - yes
+tcp:::state-change to syn-sent - yes
+tcp:::state-change to syn-received - yes
+tcp:::state-change to established - yes
+tcp:::state-change to fin-wait-1 - yes
+tcp:::state-change to close-wait - yes
+tcp:::state-change to fin-wait-2 - yes
+tcp:::state-change to last-ack - yes
+tcp:::state-change to time-wait - yes
+tcp:::connect-request - yes
+tcp:::connect-established - yes
+tcp:::accept-established - yes
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotesctpstate.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotesctpstate.ksh
new file mode 100755
index 000000000000..3209c04e042c
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotesctpstate.ksh
@@ -0,0 +1,149 @@
+#!/usr/bin/env ksh93
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test sctp:::state-change and sctp:::{send,receive} by connecting to
+# the remote http service.
+# A number of state transition events along with sctp send and receive
+# events for the message should result.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. The lo0 interface missing or not up.
+# 3. The remote ssh service is not online.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs a SCTP association to the http service (port 80) and
+# checks that at least the following packet counts were traced:
+#
+# 4 x ip:::send (2 during setup, 2 during teardown)
+# 4 x sctp:::send (2 during setup, 2 during teardown)
+# 3 x ip:::receive (2 during setup, 1 during teardown)
+# 3 x sctp:::receive (2 during setup, 1 during teardown)
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv4remote.pl
+sctpport=80
+DIR=/var/tmp/dtest.$$
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr $sctpport sctp | read source dest
+if (( $? != 0 )); then
+ exit 4
+fi
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Type => SOCK_STREAM,
+ Proto => "sctp",
+ LocalAddr => "$source",
+ PeerAddr => "$dest",
+ PeerPort => $sctpport,
+ Timeout => 3);
+ die "Could not connect to host $dest port $sctpport \$@" unless \$s;
+ close \$s;
+ sleep(2);
+EOPERL
+
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = sctpsend = ipreceive = sctpreceive = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->ipv4_protocol == IPPROTO_SCTP/
+{
+ ipsend++;
+}
+
+sctp:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->sctp_dport == $sctpport/
+{
+ sctpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->ipv4_protocol == IPPROTO_SCTP/
+{
+ ipreceive++;
+}
+
+sctp:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->sctp_sport == $sctpport/
+{
+ sctpreceive++;
+}
+
+sctp:::state-change
+{
+ state_event[args[3]->sctps_state]++;
+}
+
+END
+{
+ printf("Minimum SCTP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 4 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 3 ? "yes" : "no");
+ printf("sctp:::send - %s\n", sctpsend >= 4 ? "yes" : "no");
+ printf("sctp:::receive - %s\n", sctpreceive >= 3 ? "yes" : "no");
+ printf("sctp:::state-change to cookie-wait - %s\n",
+ state_event[SCTP_STATE_COOKIE_WAIT] >=1 ? "yes" : "no");
+ printf("sctp:::state-change to cookie-echoed - %s\n",
+ state_event[SCTP_STATE_COOKIE_ECHOED] >= 1 ? "yes" : "no");
+ printf("sctp:::state-change to established - %s\n",
+ state_event[SCTP_STATE_ESTABLISHED] >= 1 ? "yes" : "no");
+ printf("sctp:::state-change to shutdown-sent - %s\n",
+ state_event[SCTP_STATE_SHUTDOWN-SENT] >= 1 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotesctpstate.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotesctpstate.ksh.out
new file mode 100644
index 000000000000..a39b14fcfcb3
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotesctpstate.ksh.out
@@ -0,0 +1,12 @@
+Minimum SCTP events seen
+
+ip:::send - yes
+ip:::receive - yes
+SCTP:::send - yes
+sctp:::receive - yes
+sctp:::state-change to cookie-wait - yes
+sctp:::state-change to cookie-echoed - yes
+sctp:::state-change to established - yes
+sctp:::state-change to shutdown-sent - yes
+sctp:::state-change to closed - yes
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh
new file mode 100755
index 000000000000..b8066131d2f1
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh
@@ -0,0 +1,172 @@
+#!/usr/bin/env ksh93
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test tcp:::state-change and tcp:::{send,receive} by connecting to
+# the remote ssh service and sending a test message. This should result
+# in a "Protocol mismatch" response and a close of the connection.
+# A number of state transition events along with tcp send and receive
+# events for the message should result.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. The lo0 interface missing or not up.
+# 3. The remote ssh service is not online.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs a TCP connection to the ssh service (port 22) and
+# checks that at least the following packet counts were traced:
+#
+# 4 x ip:::send (2 during connection setup, 2 during connection teardown)
+# 4 x tcp:::send (2 during connection setup, 2 during connection teardown)
+# 5 x ip:::receive (1 during connection setup, the response, 1 window update,
+# 1 banner line, 2 during connection teardown)
+# 5 x tcp:::receive (1 during connection setup, the response, 1 window update,
+# 1 banner line, 2 during connection teardown)
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv4remote.pl
+tcpport=22
+DIR=/var/tmp/dtest.$$
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr $tcpport | read source dest
+if (( $? != 0 )); then
+ exit 4
+fi
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => "$dest",
+ PeerPort => $tcpport,
+ Timeout => 3);
+ die "Could not connect to host $dest port $tcpport" unless \$s;
+ readline \$s;
+ close \$s;
+ sleep(2);
+EOPERL
+
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = tcpsend = ipreceive = tcpreceive = 0;
+ connreq = connest = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipsend++;
+}
+
+tcp:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->tcp_dport == $tcpport/
+{
+ tcpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipreceive++;
+}
+
+tcp:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->tcp_sport == $tcpport/
+{
+ tcpreceive++;
+}
+
+tcp:::state-change
+{
+ state_event[args[3]->tcps_state]++;
+}
+
+tcp:::connect-request
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->tcp_dport == $tcpport/
+{
+ connreq++;
+}
+
+tcp:::connect-established
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->tcp_sport == $tcpport/
+{
+ connest++;
+}
+
+END
+{
+ printf("Minimum TCP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 4 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 5 ? "yes" : "no");
+ printf("tcp:::send - %s\n", tcpsend >= 4 ? "yes" : "no");
+ printf("tcp:::receive - %s\n", tcpreceive >= 5 ? "yes" : "no");
+ printf("tcp:::state-change to syn-sent - %s\n",
+ state_event[TCP_STATE_SYN_SENT] >=1 ? "yes" : "no");
+ printf("tcp:::state-change to established - %s\n",
+ state_event[TCP_STATE_ESTABLISHED] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to fin-wait-1 - %s\n",
+ state_event[TCP_STATE_FIN_WAIT_1] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to fin-wait-2 - %s\n",
+ state_event[TCP_STATE_FIN_WAIT_2] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to time-wait - %s\n",
+ state_event[TCP_STATE_TIME_WAIT] >= 1 ? "yes" : "no");
+ printf("tcp:::connect-request - %s\n",
+ connreq >=1 ? "yes" : "no");
+ printf("tcp:::connect-established - %s\n",
+ connest >=1 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/bin/rm -rf $DIR
+
+exit $status
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh.out
new file mode 100644
index 000000000000..27388fba65dc
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh.out
@@ -0,0 +1,15 @@
+Minimum TCP events seen
+
+ip:::send - yes
+ip:::receive - yes
+tcp:::send - yes
+tcp:::receive - yes
+tcp:::state-change to syn-sent - yes
+tcp:::state-change to established - yes
+tcp:::state-change to fin-wait-1 - yes
+tcp:::state-change to close-wait - yes
+tcp:::state-change to fin-wait-2 - yes
+tcp:::state-change to time-wait - yes
+tcp:::connect-request - yes
+tcp:::connect-established - yes
+