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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 25210753Srpaulo# 26210753Srpaulo 27210753Srpaulo# 28210753Srpaulo# Test {udp,ip}:::{send,receive} of IPv4 UDP to a remote host. 29210753Srpaulo# 30210753Srpaulo# This may fail due to: 31210753Srpaulo# 32210753Srpaulo# 1. A change to the ip stack breaking expected probe behavior, 33210753Srpaulo# which is the reason we are testing. 34210753Srpaulo# 2. No physical network interface is plumbed and up. 35210753Srpaulo# 3. No other hosts on this subnet are reachable and listening on rpcbind. 36210753Srpaulo# 4. An unlikely race causes the unlocked global send/receive 37210753Srpaulo# variables to be corrupted. 38210753Srpaulo# 39210753Srpaulo# This test sends a UDP message using ping and checks that at least the 40210753Srpaulo# following counts were traced: 41210753Srpaulo# 42210753Srpaulo# 1 x ip:::send (UDP sent to ping's base UDP port) 43210753Srpaulo# 1 x udp:::send (UDP sent to ping's base UDP port) 44210753Srpaulo# 45210753Srpaulo 46210753Srpauloif (( $# != 1 )); then 47210753Srpaulo print -u2 "expected one argument: <dtrace-path>" 48210753Srpaulo exit 2 49210753Srpaulofi 50210753Srpaulo 51210753Srpaulodtrace=$1 52210753Srpaulogetaddr=./get.ipv4remote.pl 53210753Srpaulo 54210753Srpauloif [[ ! -x $getaddr ]]; then 55210753Srpaulo print -u2 "could not find or execute sub program: $getaddr" 56210753Srpaulo exit 3 57210753Srpaulofi 58210753Srpaulo$getaddr | read source dest 59210753Srpauloif (( $? != 0 )); then 60210753Srpaulo exit 4 61210753Srpaulofi 62210753Srpaulo 63211545Srpaulo$dtrace -c "/sbin/ping -U $dest" -qs /dev/stdin <<EOF | grep -v 'is alive' 64210753SrpauloBEGIN 65210753Srpaulo{ 66210753Srpaulo ipsend = udpsend = 0; 67210753Srpaulo} 68210753Srpaulo 69210753Srpauloip:::send 70210753Srpaulo/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && 71210753Srpaulo args[4]->ipv4_protocol == IPPROTO_UDP/ 72210753Srpaulo{ 73210753Srpaulo ipsend++; 74210753Srpaulo} 75210753Srpaulo 76210753Srpauloudp:::send 77210753Srpaulo/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/ 78210753Srpaulo{ 79210753Srpaulo udpsend++; 80210753Srpaulo} 81210753Srpaulo 82210753SrpauloEND 83210753Srpaulo{ 84210753Srpaulo printf("Minimum UDP events seen\n\n"); 85210753Srpaulo printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no"); 86210753Srpaulo printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no"); 87210753Srpaulo} 88210753SrpauloEOF 89