1210753Srpaulo#!/usr/bin/ksh 2210753Srpaulo# 3210753Srpaulo# CDDL HEADER START 4210753Srpaulo# 5210753Srpaulo# The contents of this file are subject to the terms of the 6210753Srpaulo# Common Development and Distribution License (the "License"). 7210753Srpaulo# You may not use this file except in compliance with the License. 8210753Srpaulo# 9210753Srpaulo# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10210753Srpaulo# or http://www.opensolaris.org/os/licensing. 11210753Srpaulo# See the License for the specific language governing permissions 12210753Srpaulo# and limitations under the License. 13210753Srpaulo# 14210753Srpaulo# When distributing Covered Code, include this CDDL HEADER in each 15210753Srpaulo# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16210753Srpaulo# If applicable, add the following below this CDDL HEADER, with the 17210753Srpaulo# fields enclosed by brackets "[]" replaced with your own identifying 18210753Srpaulo# information: Portions Copyright [yyyy] [name of copyright owner] 19210753Srpaulo# 20210753Srpaulo# CDDL HEADER END 21210753Srpaulo# 22210753Srpaulo 23210753Srpaulo# 24210753Srpaulo# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25210753Srpaulo# Use is subject to license terms. 26210753Srpaulo# 27210753Srpaulo#pragma ident "%Z%%M% %I% %E% SMI" 28210753Srpaulo 29210753Srpaulo# 30210753Srpaulo# Test ip:::{send,receive} of IPv6 ICMP to a local address. This creates a 31210753Srpaulo# temporary lo0/inet6 interface if one doesn't already exist. 32210753Srpaulo# 33210753Srpaulo# This may fail due to: 34210753Srpaulo# 35210753Srpaulo# 1. A change to the ip stack breaking expected probe behavior, 36210753Srpaulo# which is the reason we are testing. 37210753Srpaulo# 2. Unrelated ICMPv6 on lo0 traced by accident. 38210753Srpaulo# 39210753Srpaulo 40210753Srpauloif (( $# != 1 )); then 41210753Srpaulo print -u2 "expected one argument: <dtrace-path>" 42210753Srpaulo exit 2 43210753Srpaulofi 44210753Srpaulo 45210753Srpaulodtrace=$1 46210753Srpaulolocal=::1 47210753Srpaulo 48210753Srpauloif ! ifconfig lo0 inet6 > /dev/null 2>&1; then 49210753Srpaulo if ! ifconfig lo0 inet6 plumb up; then 50210753Srpaulo print -u2 "could not plumb lo0 inet6 for testing" 51210753Srpaulo exit 3 52210753Srpaulo fi 53210753Srpaulo removeinet6=1 54210753Srpauloelse 55210753Srpaulo removeinet6=0 56210753Srpaulofi 57210753Srpaulo 58280837Smarkj$dtrace -c "/sbin/ping6 -q -c 1 -X 3 $local" -qs /dev/stdin <<EOF | sort -n | \ 59280837Smarkj grep -v -e '^round-trip ' -e '^--- ' 60210753Srpauloip:::send 61210753Srpaulo/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && 62210753Srpaulo args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/ 63210753Srpaulo{ 64280837Smarkj printf("2 ip:::send ("); 65210753Srpaulo printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); 66210753Srpaulo printf("args[5]: %d %d %d)\n", 67210753Srpaulo args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen); 68210753Srpaulo} 69210753Srpaulo 70210753Srpauloip:::receive 71210753Srpaulo/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && 72210753Srpaulo args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/ 73210753Srpaulo{ 74280837Smarkj printf("3 ip:::receive ("); 75210753Srpaulo printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); 76210753Srpaulo printf("args[5]: %d %d %d)\n", 77210753Srpaulo args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen); 78210753Srpaulo} 79210753SrpauloEOF 80210753Srpaulo 81210753Srpauloif (( removeinet6 )); then 82210753Srpaulo ifconfig lo0 inet6 unplumb 83210753Srpaulofi 84