1*10e6dadfSbrendan#!/usr/bin/ksh
2*10e6dadfSbrendan#
3*10e6dadfSbrendan# CDDL HEADER START
4*10e6dadfSbrendan#
5*10e6dadfSbrendan# The contents of this file are subject to the terms of the
6*10e6dadfSbrendan# Common Development and Distribution License (the "License").
7*10e6dadfSbrendan# You may not use this file except in compliance with the License.
8*10e6dadfSbrendan#
9*10e6dadfSbrendan# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*10e6dadfSbrendan# or http://www.opensolaris.org/os/licensing.
11*10e6dadfSbrendan# See the License for the specific language governing permissions
12*10e6dadfSbrendan# and limitations under the License.
13*10e6dadfSbrendan#
14*10e6dadfSbrendan# When distributing Covered Code, include this CDDL HEADER in each
15*10e6dadfSbrendan# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*10e6dadfSbrendan# If applicable, add the following below this CDDL HEADER, with the
17*10e6dadfSbrendan# fields enclosed by brackets "[]" replaced with your own identifying
18*10e6dadfSbrendan# information: Portions Copyright [yyyy] [name of copyright owner]
19*10e6dadfSbrendan#
20*10e6dadfSbrendan# CDDL HEADER END
21*10e6dadfSbrendan#
22*10e6dadfSbrendan
23*10e6dadfSbrendan#
24*10e6dadfSbrendan# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
25*10e6dadfSbrendan# Use is subject to license terms.
26*10e6dadfSbrendan#
27*10e6dadfSbrendan#pragma ident	"%Z%%M%	%I%	%E% SMI"
28*10e6dadfSbrendan
29*10e6dadfSbrendan#
30*10e6dadfSbrendan# Test ip:::{send,receive} of IPv6 ICMP to a remote host.  This test is
31*10e6dadfSbrendan# skipped if there are no physical interfaces configured with IPv6, or no
32*10e6dadfSbrendan# other IPv6 hosts are reachable.
33*10e6dadfSbrendan#
34*10e6dadfSbrendan# This may fail due to:
35*10e6dadfSbrendan#
36*10e6dadfSbrendan# 1. A change to the ip stack breaking expected probe behavior,
37*10e6dadfSbrendan#    which is the reason we are testing.
38*10e6dadfSbrendan# 2. An unrelated ICMPv6 between these hosts was traced by accident.
39*10e6dadfSbrendan#
40*10e6dadfSbrendan
41*10e6dadfSbrendanif (( $# != 1 )); then
42*10e6dadfSbrendan	print -u2 "expected one argument: <dtrace-path>"
43*10e6dadfSbrendan	exit 2
44*10e6dadfSbrendanfi
45*10e6dadfSbrendan
46*10e6dadfSbrendandtrace=$1
47*10e6dadfSbrendangetaddr=./get.ipv6remote.pl
48*10e6dadfSbrendan
49*10e6dadfSbrendanif [[ ! -x $getaddr ]]; then
50*10e6dadfSbrendan	print -u2 "could not find or execute sub program: $getaddr"
51*10e6dadfSbrendan	exit 3
52*10e6dadfSbrendanfi
53*10e6dadfSbrendan$getaddr | read source dest
54*10e6dadfSbrendanif (( $? != 0 )); then
55*10e6dadfSbrendan	print -nu2 "Could not find a local IPv6 interface and a remote IPv6 "
56*10e6dadfSbrendan	print -u2 "host.  Aborting test.\n"
57*10e6dadfSbrendan	print -nu2 "For this test to continue, a \"ping -ns -A inet6 FF02::1\" "
58*10e6dadfSbrendan	print -u2 "must respond with a\nremote IPv6 host."
59*10e6dadfSbrendan	exit 3
60*10e6dadfSbrendanfi
61*10e6dadfSbrendan
62*10e6dadfSbrendan#
63*10e6dadfSbrendan# Shake loose any ICMPv6 Neighbor advertisement messages before tracing.
64*10e6dadfSbrendan#
65*10e6dadfSbrendan/usr/sbin/ping $dest 3 > /dev/null 2>&1
66*10e6dadfSbrendan
67*10e6dadfSbrendan$dtrace -c "/usr/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \
68*10e6dadfSbrendan    grep -v 'is alive' | sort -n
69*10e6dadfSbrendanip:::send
70*10e6dadfSbrendan/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
71*10e6dadfSbrendan    args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
72*10e6dadfSbrendan{
73*10e6dadfSbrendan	printf("1 ip:::send    (");
74*10e6dadfSbrendan	printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
75*10e6dadfSbrendan	printf("args[5]: %d %d %d)\n",
76*10e6dadfSbrendan	    args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
77*10e6dadfSbrendan}
78*10e6dadfSbrendan
79*10e6dadfSbrendanip:::receive
80*10e6dadfSbrendan/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
81*10e6dadfSbrendan    args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
82*10e6dadfSbrendan{
83*10e6dadfSbrendan	printf("2 ip:::receive (");
84*10e6dadfSbrendan	printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
85*10e6dadfSbrendan	printf("args[5]: %d %d %d)\n",
86*10e6dadfSbrendan	    args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
87*10e6dadfSbrendan}
88*10e6dadfSbrendanEOF
89