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) 2010, Oracle and/or its affiliates. All rights reserved.
28 # Test sctp:::state-change and sctp:::{send,receive} by connecting to
29 # the remote http service.
30 # A number of state transition events along with sctp send and receive
31 # events for the message should result.
33 # This may fail due to:
35 # 1. A change to the ip stack breaking expected probe behavior,
36 # which is the reason we are testing.
37 # 2. The lo0 interface missing or not up.
38 # 3. The remote ssh service is not online.
39 # 4. An unlikely race causes the unlocked global send/receive
40 # variables to be corrupted.
42 # This test performs a SCTP association to the http service (port 80) and
43 # checks that at least the following packet counts were traced:
45 # 4 x ip:::send (2 during setup, 2 during teardown)
46 # 4 x sctp:::send (2 during setup, 2 during teardown)
47 # 3 x ip:::receive (2 during setup, 1 during teardown)
48 # 3 x sctp:::receive (2 during setup, 1 during teardown)
51 if (( $# != 1 )); then
52 print -u2 "expected one argument: <dtrace-path>"
57 getaddr=./get.ipv4remote.pl
61 if [[ ! -x $getaddr ]]; then
62 print -u2 "could not find or execute sub program: $getaddr"
65 $getaddr $sctpport sctp | read source dest
66 if (( $? != 0 )); then
73 cat > test.pl <<-EOPERL
75 my \$s = IO::Socket::INET->new(
78 LocalAddr => "$source",
80 PeerPort => $sctpport,
82 die "Could not connect to host $dest port $sctpport \$@" unless \$s;
87 $dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
90 ipsend = sctpsend = ipreceive = sctpreceive = 0;
94 /args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
95 args[4]->ipv4_protocol == IPPROTO_SCTP/
101 /args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
102 args[4]->sctp_dport == $sctpport/
108 /args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
109 args[4]->ipv4_protocol == IPPROTO_SCTP/
115 /args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
116 args[4]->sctp_sport == $sctpport/
123 state_event[args[3]->sctps_state]++;
128 printf("Minimum SCTP events seen\n\n");
129 printf("ip:::send - %s\n", ipsend >= 4 ? "yes" : "no");
130 printf("ip:::receive - %s\n", ipreceive >= 3 ? "yes" : "no");
131 printf("sctp:::send - %s\n", sctpsend >= 4 ? "yes" : "no");
132 printf("sctp:::receive - %s\n", sctpreceive >= 3 ? "yes" : "no");
133 printf("sctp:::state-change to cookie-wait - %s\n",
134 state_event[SCTP_STATE_COOKIE_WAIT] >=1 ? "yes" : "no");
135 printf("sctp:::state-change to cookie-echoed - %s\n",
136 state_event[SCTP_STATE_COOKIE_ECHOED] >= 1 ? "yes" : "no");
137 printf("sctp:::state-change to established - %s\n",
138 state_event[SCTP_STATE_ESTABLISHED] >= 1 ? "yes" : "no");
139 printf("sctp:::state-change to shutdown-sent - %s\n",
140 state_event[SCTP_STATE_SHUTDOWN-SENT] >= 1 ? "yes" : "no");