1#!/usr/bin/env ksh93 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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 25# 26 27# 28# Test {udplite,ip}:::{send,receive} of IPv4 UDP-Lite to a remote host. 29# 30# This may fail due to: 31# 32# 1. A change to the ip stack breaking expected probe behavior, 33# which is the reason we are testing. 34# 2. No physical network interface is plumbed and up. 35# 3. No other hosts on this subnet are reachable and listening on rpcbind. 36# 4. An unlikely race causes the unlocked global send/receive 37# variables to be corrupted. 38# 39# This test sends a UDP-Lite message using perl and checks that at least the 40# following counts were traced: 41# 42# 1 x ip:::send (UDP-Lite sent to UDP-Lite port 33434) 43# 1 x udplite:::send (UDP-Lite sent to UDP-Lite port 33434) 44# 45 46if (( $# != 1 )); then 47 print -u2 "expected one argument: <dtrace-path>" 48 exit 2 49fi 50 51dtrace=$1 52getaddr=./get.ipv4remote.pl 53port=33434 54DIR=/var/tmp/dtest.$$ 55 56if [[ ! -x $getaddr ]]; then 57 print -u2 "could not find or execute sub program: $getaddr" 58 exit 3 59fi 60$getaddr | read source dest 61if (( $? != 0 )); then 62 exit 4 63fi 64 65mkdir $DIR 66cd $DIR 67 68cat > test.pl <<-EOPERL 69 use IO::Socket; 70 my \$s = IO::Socket::INET->new( 71 Type => SOCK_DGRAM, 72 Proto => "udplite", 73 PeerAddr => "$dest", 74 PeerPort => $port); 75 die "Could not create UDP-Lite socket $dest port $port" unless \$s; 76 send \$s, "Hello", 0; 77 close \$s; 78 sleep(2); 79EOPERL 80 81$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE 82BEGIN 83{ 84 ipsend = udplitesend = 0; 85} 86 87ip:::send 88/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && 89 args[4]->ipv4_protocol == IPPROTO_UDPLITE/ 90{ 91 ipsend++; 92} 93 94udplite:::send 95/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/ 96{ 97 udplitesend++; 98} 99 100END 101{ 102 printf("Minimum UDPLite events seen\n\n"); 103 printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no"); 104 printf("udplite:::send - %s\n", udplitesend >= 1 ? "yes" : "no"); 105} 106EODTRACE 107 108status=$? 109 110cd / 111/bin/rm -rf $DIR 112 113exit $status 114