]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh
MFV r351500: Fix CLEAR_HASH macro to be usable as a single statement.
[FreeBSD/FreeBSD.git] / cddl / contrib / opensolaris / cmd / dtrace / test / tst / common / ip / tst.ipv6localicmp.ksh
1 #!/usr/bin/env ksh
2 #
3 # CDDL HEADER START
4 #
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.
8 #
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.
13 #
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]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
25 # Use is subject to license terms.
26 #
27 #pragma ident   "%Z%%M% %I%     %E% SMI"
28
29 #
30 # Test ip:::{send,receive} of IPv6 ICMP to a local address.  This creates a
31 # temporary lo0/inet6 interface if one doesn't already exist.
32 #
33 # This may fail due to:
34 #
35 # 1. A change to the ip stack breaking expected probe behavior,
36 #    which is the reason we are testing.
37 # 2. Unrelated ICMPv6 on lo0 traced by accident.
38 #
39
40 if (( $# != 1 )); then
41         print -u2 "expected one argument: <dtrace-path>"
42         exit 2
43 fi
44
45 dtrace=$1
46 local=::1
47
48 if ! ifconfig lo0 inet6 > /dev/null 2>&1; then
49         if ! ifconfig lo0 inet6 plumb up; then
50                 print -u2 "could not plumb lo0 inet6 for testing"
51                 exit 3
52         fi
53         removeinet6=1
54 else
55         removeinet6=0
56 fi
57
58 $dtrace -c "/sbin/ping6 -q -c 1 -X 3 $local" -qs /dev/stdin <<EOF | sort -n | \
59     grep -v -e '^round-trip ' -e '^--- '
60 ip:::send
61 /args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
62     args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
63 {
64         printf("2 ip:::send    (");
65         printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
66         printf("args[5]: %d %d %d)\n",
67             args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
68 }
69
70 ip:::receive
71 /args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
72     args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
73 {
74         printf("3 ip:::receive (");
75         printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
76         printf("args[5]: %d %d %d)\n",
77             args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
78 }
79 EOF
80
81 if (( removeinet6 )); then
82         ifconfig lo0 inet6 unplumb
83 fi