xref: /onnv-gate/usr/src/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh (revision 6878:360e73ea6b0c)
1*6878Sbrendan#!/usr/bin/ksh
2*6878Sbrendan#
3*6878Sbrendan# CDDL HEADER START
4*6878Sbrendan#
5*6878Sbrendan# The contents of this file are subject to the terms of the
6*6878Sbrendan# Common Development and Distribution License (the "License").
7*6878Sbrendan# You may not use this file except in compliance with the License.
8*6878Sbrendan#
9*6878Sbrendan# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*6878Sbrendan# or http://www.opensolaris.org/os/licensing.
11*6878Sbrendan# See the License for the specific language governing permissions
12*6878Sbrendan# and limitations under the License.
13*6878Sbrendan#
14*6878Sbrendan# When distributing Covered Code, include this CDDL HEADER in each
15*6878Sbrendan# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*6878Sbrendan# If applicable, add the following below this CDDL HEADER, with the
17*6878Sbrendan# fields enclosed by brackets "[]" replaced with your own identifying
18*6878Sbrendan# information: Portions Copyright [yyyy] [name of copyright owner]
19*6878Sbrendan#
20*6878Sbrendan# CDDL HEADER END
21*6878Sbrendan#
22*6878Sbrendan
23*6878Sbrendan#
24*6878Sbrendan# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
25*6878Sbrendan# Use is subject to license terms.
26*6878Sbrendan#
27*6878Sbrendan#pragma ident	"%Z%%M%	%I%	%E% SMI"
28*6878Sbrendan
29*6878Sbrendan#
30*6878Sbrendan# Test ip:::{send,receive} of IPv6 ICMP to a local address.  This creates a
31*6878Sbrendan# temporary lo0/inet6 interface if one doesn't already exist.
32*6878Sbrendan#
33*6878Sbrendan# This may fail due to:
34*6878Sbrendan#
35*6878Sbrendan# 1. A change to the ip stack breaking expected probe behavior,
36*6878Sbrendan#    which is the reason we are testing.
37*6878Sbrendan# 2. Unrelated ICMPv6 on lo0 traced by accident.
38*6878Sbrendan#
39*6878Sbrendan
40*6878Sbrendanif (( $# != 1 )); then
41*6878Sbrendan	print -u2 "expected one argument: <dtrace-path>"
42*6878Sbrendan	exit 2
43*6878Sbrendanfi
44*6878Sbrendan
45*6878Sbrendandtrace=$1
46*6878Sbrendanlocal=::1
47*6878Sbrendan
48*6878Sbrendanif ! ifconfig lo0 inet6 > /dev/null 2>&1; then
49*6878Sbrendan	if ! ifconfig lo0 inet6 plumb up; then
50*6878Sbrendan		print -u2 "could not plumb lo0 inet6 for testing"
51*6878Sbrendan		exit 3
52*6878Sbrendan	fi
53*6878Sbrendan	removeinet6=1
54*6878Sbrendanelse
55*6878Sbrendan	removeinet6=0
56*6878Sbrendanfi
57*6878Sbrendan
58*6878Sbrendan$dtrace -c "/usr/sbin/ping -A inet6 $local 3" -qs /dev/stdin <<EOF | sort -n
59*6878Sbrendanip:::send
60*6878Sbrendan/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
61*6878Sbrendan    args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
62*6878Sbrendan{
63*6878Sbrendan	printf("1 ip:::send    (");
64*6878Sbrendan	printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
65*6878Sbrendan	printf("args[5]: %d %d %d)\n",
66*6878Sbrendan	    args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
67*6878Sbrendan}
68*6878Sbrendan
69*6878Sbrendanip:::receive
70*6878Sbrendan/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
71*6878Sbrendan    args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
72*6878Sbrendan{
73*6878Sbrendan	printf("2 ip:::receive (");
74*6878Sbrendan	printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
75*6878Sbrendan	printf("args[5]: %d %d %d)\n",
76*6878Sbrendan	    args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
77*6878Sbrendan}
78*6878SbrendanEOF
79*6878Sbrendan
80*6878Sbrendanif (( removeinet6 )); then
81*6878Sbrendan	ifconfig lo0 inet6 unplumb
82*6878Sbrendanfi
83