5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 # Test {ip,sctp}:::{send,receive} of IPv4 SCTP to local host.
30 # This may fail due to:
32 # 1. A change to the ip stack breaking expected probe behavior,
33 # which is the reason we are testing.
34 # 2. The lo0 interface missing or not up.
35 # 3. An unlikely race causes the unlocked global send/receive
36 # variables to be corrupted.
38 # This test performs a SCTP association and checks that at least the
39 # following packet counts were traced:
41 # 7 x ip:::send (4 during the setup, 3 during the teardown)
42 # 7 x sctp:::send (4 during the setup, 3 during the teardown)
43 # 7 x ip:::receive (4 during the setup, 3 during the teardown)
44 # 7 x sctp:::receive (4 during the setup, 3 during the teardown)
46 # The actual count tested is 7 each way, since we are tracing both
47 # source and destination events.
50 if (( $# != 1 )); then
51 print -u2 "expected one argument: <dtrace-path>"
65 cat > client.pl <<-EOPERL
67 my \$s = IO::Socket::INET->new(
70 LocalAddr => "$local",
72 PeerPort => \$ARGV[0],
74 die "Could not connect to host $local port \$ARGV[0] \$@" unless \$s;
79 while [ $sctpport -lt $bound ]; do
80 perl client.pl $sctpport 0 2>&- || break
81 sctpport=$(($sctpport + 1))
83 if [ $sctpport -eq $bound ]; then
84 echo "couldn't find an available SCTP port"
88 cat > server.pl <<-EOPERL
90 my \$l = IO::Socket::INET->new(
93 LocalAddr => "$local",
94 LocalPort => $sctpport,
97 die "Could not listen on $local port $sctpport \$@" unless \$l;
98 my \$c = \$l->accept();
106 $dtrace -c "perl client.pl $sctpport 2" -qs /dev/stdin <<EODTRACE
109 ipsend = sctpsend = ipreceive = sctpreceive = 0;
113 /args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
114 args[4]->ipv4_protocol == IPPROTO_SCTP/
120 /args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
126 /args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
127 args[4]->ipv4_protocol == IPPROTO_SCTP/
133 /args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
140 printf("Minimum SCTP events seen\n\n");
141 printf("ip:::send - %s\n", ipsend >= 7 ? "yes" : "no");
142 printf("ip:::receive - %s\n", ipreceive >= 7 ? "yes" : "no");
143 printf("sctp:::send - %s\n", sctpsend >= 7 ? "yes" : "no");
144 printf("sctp:::receive - %s\n", sctpreceive >= 7 ? "yes" : "no");