xref: /onnv-gate/usr/src/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh (revision 6878:360e73ea6b0c)
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 local address.
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. The lo0 interface missing or not up.
37*6878Sbrendan# 3. Unrelated ICMP on lo0 traced by accident.
38*6878Sbrendan#
39*6878Sbrendan
40*6878Sbrendanif (( $# != 1 )); then
41*6878Sbrendan	print -u2 "expected one argument: <dtrace-path>"
42*6878Sbrendan	exit 2
43*6878Sbrendanfi
44*6878Sbrendan
45*6878Sbrendandtrace=$1
46*6878Sbrendanlocal=127.0.0.1
47*6878Sbrendan
48*6878Sbrendan$dtrace -c "/usr/sbin/ping $local 3" -qs /dev/stdin <<EOF | sort -n
49*6878Sbrendanip:::send
50*6878Sbrendan/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
51*6878Sbrendan    args[4]->ipv4_protocol == IPPROTO_ICMP/
52*6878Sbrendan{
53*6878Sbrendan	printf("1 ip:::send    (");
54*6878Sbrendan	printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
55*6878Sbrendan	printf("args[4]: %d %d %d %d %d)\n",
56*6878Sbrendan	    args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
57*6878Sbrendan	    args[4]->ipv4_offset, args[4]->ipv4_ttl);
58*6878Sbrendan}
59*6878Sbrendan
60*6878Sbrendanip:::receive
61*6878Sbrendan/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
62*6878Sbrendan    args[4]->ipv4_protocol == IPPROTO_ICMP/
63*6878Sbrendan{
64*6878Sbrendan	printf("2 ip:::receive (");
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*6878SbrendanEOF
71