xref: /onnv-gate/usr/src/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh (revision 12507:501806a754d2)
16878Sbrendan#!/usr/bin/ksh
26878Sbrendan#
36878Sbrendan# CDDL HEADER START
46878Sbrendan#
56878Sbrendan# The contents of this file are subject to the terms of the
66878Sbrendan# Common Development and Distribution License (the "License").
76878Sbrendan# You may not use this file except in compliance with the License.
86878Sbrendan#
96878Sbrendan# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
106878Sbrendan# or http://www.opensolaris.org/os/licensing.
116878Sbrendan# See the License for the specific language governing permissions
126878Sbrendan# and limitations under the License.
136878Sbrendan#
146878Sbrendan# When distributing Covered Code, include this CDDL HEADER in each
156878Sbrendan# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
166878Sbrendan# If applicable, add the following below this CDDL HEADER, with the
176878Sbrendan# fields enclosed by brackets "[]" replaced with your own identifying
186878Sbrendan# information: Portions Copyright [yyyy] [name of copyright owner]
196878Sbrendan#
206878Sbrendan# CDDL HEADER END
216878Sbrendan#
226878Sbrendan
236878Sbrendan#
24*12507SAlan.Maguire@Sun.COM# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
256878Sbrendan#
266878Sbrendan
276878Sbrendan#
28*12507SAlan.Maguire@Sun.COM# Test {udp,ip}:::{send,receive} of IPv4 UDP to a remote host.
296878Sbrendan#
306878Sbrendan# This may fail due to:
316878Sbrendan#
326878Sbrendan# 1. A change to the ip stack breaking expected probe behavior,
336878Sbrendan#    which is the reason we are testing.
346878Sbrendan# 2. No physical network interface is plumbed and up.
356878Sbrendan# 3. No other hosts on this subnet are reachable and listening on rpcbind.
366878Sbrendan# 4. An unlikely race causes the unlocked global send/receive
376878Sbrendan#    variables to be corrupted.
386878Sbrendan#
396878Sbrendan# This test sends a UDP message using ping and checks that at least the
406878Sbrendan# following counts were traced:
416878Sbrendan#
426878Sbrendan# 1 x ip:::send (UDP sent to ping's base UDP port)
43*12507SAlan.Maguire@Sun.COM# 1 x udp:::send (UDP sent to ping's base UDP port)
446878Sbrendan#
456878Sbrendan
466878Sbrendanif (( $# != 1 )); then
476878Sbrendan	print -u2 "expected one argument: <dtrace-path>"
486878Sbrendan	exit 2
496878Sbrendanfi
506878Sbrendan
516878Sbrendandtrace=$1
526878Sbrendangetaddr=./get.ipv4remote.pl
536878Sbrendan
546878Sbrendanif [[ ! -x $getaddr ]]; then
556878Sbrendan	print -u2 "could not find or execute sub program: $getaddr"
566878Sbrendan	exit 3
576878Sbrendanfi
586878Sbrendan$getaddr | read source dest
596878Sbrendanif (( $? != 0 )); then
606878Sbrendan	exit 4
616878Sbrendanfi
626878Sbrendan
636878Sbrendan$dtrace -c "/usr/sbin/ping -U $dest" -qs /dev/stdin <<EOF | grep -v 'is alive'
646878SbrendanBEGIN
656878Sbrendan{
66*12507SAlan.Maguire@Sun.COM	ipsend = udpsend = 0;
676878Sbrendan}
686878Sbrendan
696878Sbrendanip:::send
706878Sbrendan/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
716878Sbrendan    args[4]->ipv4_protocol == IPPROTO_UDP/
726878Sbrendan{
73*12507SAlan.Maguire@Sun.COM	ipsend++;
74*12507SAlan.Maguire@Sun.COM}
75*12507SAlan.Maguire@Sun.COM
76*12507SAlan.Maguire@Sun.COMudp:::send
77*12507SAlan.Maguire@Sun.COM/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/
78*12507SAlan.Maguire@Sun.COM{
79*12507SAlan.Maguire@Sun.COM	udpsend++;
806878Sbrendan}
816878Sbrendan
826878SbrendanEND
836878Sbrendan{
846878Sbrendan	printf("Minimum UDP events seen\n\n");
85*12507SAlan.Maguire@Sun.COM	printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no");
86*12507SAlan.Maguire@Sun.COM	printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no");
876878Sbrendan}
886878SbrendanEOF
89