1#!/usr/bin/ksh 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright 2025 Oxide Computer Company 15# 16 17unalias -a 18 19mac_test_dir="$(dirname $0)" 20mac_data_dir="$mac_test_dir/data" 21mac_cksum="$mac_test_dir/mac_cksum" 22mac_lso="$mac_test_dir/mac_lso" 23mac_exit=0 24 25run_one() 26{ 27 typeset prog="$1" 28 typeset input="$mac_data_dir/$2" 29 shift 2 30 31 typeset output="" 32 if [[ $prog == $mac_lso ]]; then 33 output="$mac_data_dir/$1" 34 shift 35 fi 36 37 echo "$prog $* $input $output" 38 if ! $prog $* $input $output; then 39 mac_exit=1 40 fi 41} 42 43run_test() 44{ 45 # Run with and without 2-byte padding for offset reasons 46 run_one $* 47 run_one $* -b 2 48 49 # Try some various mblk split combinations 50 run_one $* -e 51 run_one $* -s 20 52 run_one $* -e -s 8 53} 54 55run_cso() 56{ 57 run_test $mac_cksum $* 58} 59 60run_lso() 61{ 62 run_test $mac_lso $* 63} 64 65# The bad-L4-proto case should only try getting a IPv4 checksum. 66# It would fail to get an L4 checksum 67run_cso ipv4_bad_proto.snoop -4 68 69ipv4_cases="ipv4_icmp.snoop ipv4_tcp.snoop ipv4_udp.snoop" 70for c in $ipv4_cases; do 71 run_cso $c -4 -p 72 run_cso $c -4 -f 73done 74 75ipv6_cases="ipv6_icmp.snoop ipv6_tcp.snoop ipv6_udp.snoop ipv6_eh_udp.snoop" 76for c in $ipv6_cases; do 77 run_cso $c -p 78 run_cso $c -f 79done 80 81# Only full checksums are supported for SCTP 82run_cso "ipv4_sctp.snoop" -4 -f 83run_cso "ipv6_sctp.snoop" -f 84 85# Only TCP is supported for LSO. 86run_lso "ipv4_tcp_lso_in.snoop" "ipv4_tcp_lso_out.snoop" -4 -f -m 8948 87run_lso "ipv4_tcp_lso_in.snoop" "ipv4_tcp_lso_out.snoop" -4 -p -m 8948 88run_lso "ipv6_tcp_lso_in.snoop" "ipv6_tcp_lso_out.snoop" -f -m 8928 89run_lso "ipv6_tcp_lso_in.snoop" "ipv6_tcp_lso_out.snoop" -p -m 8928 90 91exit $mac_exit 92