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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 25# Copyright 2025 Oxide computer Company 26# 27 28# 29# Test {tcp,ip}:::{send,receive} of IPv4 TCP to a remote host. 30# 31# This may fail due to: 32# 33# 1. A change to the ip stack breaking expected probe behavior, 34# which is the reason we are testing. 35# 2. No physical network interface is plumbed and up. 36# 3. No other hosts on this subnet are reachable and listening on ssh. 37# 4. An unlikely race causes the unlocked global send/receive 38# variables to be corrupted. 39# 40# This test performs a TCP connection and checks that at least the 41# following packet counts were traced: 42# 43# 3 x ip:::send (2 during the TCP handshake, then a FIN) 44# 3 x tcp:::send (2 during the TCP handshake, then a FIN) 45# 2 x ip:::receive (1 during the TCP handshake, then the FIN ACK) 46# 2 x tcp:::receive (1 during the TCP handshake, then the FIN ACK) 47# 48 49if (( $# != 1 )); then 50 print -u2 "expected one argument: <dtrace-path>" 51 exit 2 52fi 53 54dtrace=$1 55getaddr=./get.ipv4remote.pl 56tcpport=22 57 58if [[ ! -x $getaddr ]]; then 59 print -u2 "could not find or execute sub program: $getaddr" 60 exit 3 61fi 62$getaddr $tcpport | read source dest 63if (( $? != 0 )); then 64 exit 4 65fi 66 67$dtrace -c "./msnc.exe $dest $tcpport" -qs /dev/stdin <<EODTRACE 68BEGIN 69{ 70 ipsend = tcpsend = ipreceive = tcpreceive = 0; 71} 72 73ip:::send 74/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && 75 args[4]->ipv4_protocol == IPPROTO_TCP/ 76{ 77 ipsend++; 78} 79 80tcp:::send 81/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/ 82{ 83 tcpsend++; 84} 85 86ip:::receive 87/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" && 88 args[4]->ipv4_protocol == IPPROTO_TCP/ 89{ 90 ipreceive++; 91} 92 93tcp:::receive 94/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source"/ 95{ 96 tcpreceive++; 97} 98 99END 100{ 101 printf("Minimum TCP events seen\n\n"); 102 printf("ip:::send - %s\n", ipsend >= 3 ? "yes" : "no"); 103 printf("ip:::receive - %s\n", ipreceive >= 2 ? "yes" : "no"); 104 printf("tcp:::send - %s\n", tcpsend >= 3 ? "yes" : "no"); 105 printf("tcp:::receive - %s\n", tcpreceive >= 2 ? "yes" : "no"); 106} 107EODTRACE 108 109status=$? 110 111exit $? 112