1#!/usr/bin/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 IPv4 UDP to a remote host. 31# 32# This may fail due to: 33# 34# 1. A change to the ip stack breaking expected probe behavior, 35# which is the reason we are testing. 36# 2. No physical network interface is plumbed and up. 37# 3. No other hosts on this subnet are reachable and listening on rpcbind. 38# 4. An unlikely race causes the unlocked global send/receive 39# variables to be corrupted. 40# 41# This test sends a UDP message using ping and checks that at least the 42# following counts were traced: 43# 44# 1 x ip:::send (UDP sent to ping's base UDP port) 45# 46 47if (( $# != 1 )); then 48 print -u2 "expected one argument: <dtrace-path>" 49 exit 2 50fi 51 52dtrace=$1 53getaddr=./get.ipv4remote.pl 54 55if [[ ! -x $getaddr ]]; then 56 print -u2 "could not find or execute sub program: $getaddr" 57 exit 3 58fi 59$getaddr | read source dest 60if (( $? != 0 )); then 61 exit 4 62fi 63 64$dtrace -c "/usr/sbin/ping -U $dest" -qs /dev/stdin <<EOF | grep -v 'is alive' 65BEGIN 66{ 67 send = 0; 68} 69 70ip:::send 71/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && 72 args[4]->ipv4_protocol == IPPROTO_UDP/ 73{ 74 send++; 75} 76 77END 78{ 79 printf("Minimum UDP events seen\n\n"); 80 printf("ip:::send - %s\n", send >= 1 ? "yes" : "no"); 81} 82EOF 83