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>"
61 while [ $sctpport -lt $bound ]; do
62 ncat --sctp -z $local $sctpport > /dev/null || break
63 sctpport=$(($sctpport + 1))
65 if [ $sctpport -eq $bound ]; then
66 echo "couldn't find an available SCTP port"
73 # ncat will exit when the association is closed.
74 ncat --sctp --listen $local $sctpport &
76 cat > test.pl <<-EOPERL
78 my \$s = IO::Socket::INET->new(
81 LocalAddr => "$local",
83 PeerPort => $sctpport,
85 die "Could not connect to host $local port $sctpport \$@" unless \$s;
90 $dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
93 ipsend = sctpsend = ipreceive = sctpreceive = 0;
97 /args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
98 args[4]->ipv4_protocol == IPPROTO_SCTP/
104 /args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
110 /args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
111 args[4]->ipv4_protocol == IPPROTO_SCTP/
117 /args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
124 printf("Minimum SCTP events seen\n\n");
125 printf("ip:::send (%d) - %s\n", ipsend, ipsend >= 7 ? "yes" : "no");
126 printf("ip:::receive (%d) - %s\n", ipreceive, ipreceive >= 7 ? "yes" : "no");
127 printf("sctp:::send (%d) - %s\n", sctpsend, sctpsend >= 7 ? "yes" : "no");
128 printf("sctp:::receive (%d) - %s\n", sctpreceive, sctpreceive >= 7 ? "yes" : "no");