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 IPv4 ICMP to a remote host. 31*6878Sbrendan# 32*6878Sbrendan# This may fail due to: 33*6878Sbrendan# 34*6878Sbrendan# 1. A change to the ip stack breaking expected probe behavior, 35*6878Sbrendan# which is the reason we are testing. 36*6878Sbrendan# 2. No physical network interface is plumbed and up. 37*6878Sbrendan# 3. No other hosts on this subnet are reachable. 38*6878Sbrendan# 4. An unrelated ICMP between these hosts was traced by accident. 39*6878Sbrendan# 40*6878Sbrendan 41*6878Sbrendanif (( $# != 1 )); then 42*6878Sbrendan print -u2 "expected one argument: <dtrace-path>" 43*6878Sbrendan exit 2 44*6878Sbrendanfi 45*6878Sbrendan 46*6878Sbrendandtrace=$1 47*6878Sbrendangetaddr=./get.ipv4remote.pl 48*6878Sbrendan 49*6878Sbrendanif [[ ! -x $getaddr ]]; then 50*6878Sbrendan print -u2 "could not find or execute sub program: $getaddr" 51*6878Sbrendan exit 3 52*6878Sbrendanfi 53*6878Sbrendan$getaddr | read source dest 54*6878Sbrendanif (( $? != 0 )); then 55*6878Sbrendan exit 4 56*6878Sbrendanfi 57*6878Sbrendan 58*6878Sbrendan$dtrace -c "/usr/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \ 59*6878Sbrendan grep -v 'is alive' | sort -n 60*6878Sbrendanip:::send 61*6878Sbrendan/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && 62*6878Sbrendan args[4]->ipv4_protocol == IPPROTO_ICMP/ 63*6878Sbrendan{ 64*6878Sbrendan printf("1 ip:::send ("); 65*6878Sbrendan printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); 66*6878Sbrendan printf("args[4]: %d %d %d %d %d)\n", 67*6878Sbrendan args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags, 68*6878Sbrendan args[4]->ipv4_offset, args[4]->ipv4_ttl); 69*6878Sbrendan} 70*6878Sbrendan 71*6878Sbrendanip:::receive 72*6878Sbrendan/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" && 73*6878Sbrendan args[4]->ipv4_protocol == IPPROTO_ICMP/ 74*6878Sbrendan{ 75*6878Sbrendan printf("2 ip:::receive ("); 76*6878Sbrendan printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); 77*6878Sbrendan printf("args[4]: %d %d %d %d %d)\n", 78*6878Sbrendan args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags, 79*6878Sbrendan args[4]->ipv4_offset, args[4]->ipv4_ttl); 80*6878Sbrendan} 81*6878SbrendanEOF 82