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_exit=0 23 24run_one() 25{ 26 typeset input="$mac_data_dir/$1" 27 shift 28 29 echo "$mac_cksum $* $input" 30 $mac_cksum $* $input 31 if (( $? != 0 )); then 32 mac_exit=1 33 fi 34} 35 36run_test() 37{ 38 # Run with and without 2-byte padding for offset reasons 39 run_one $* 40 run_one $* -b 2 41 42 # Try some various mblk split combinations 43 run_one $* -e 44 run_one $* -s 20 45 run_one $* -e -s 8 46} 47 48# The bad-L4-proto case should only try getting a IPv4 checksum. 49# It would fail to get an L4 checksum 50run_test ipv4_bad_proto.snoop -4 51 52ipv4_cases="ipv4_icmp.snoop ipv4_tcp.snoop ipv4_udp.snoop" 53for c in $ipv4_cases; do 54 run_test $c -4 -p 55 run_test $c -4 -f 56done 57 58ipv6_cases="ipv6_icmp.snoop ipv6_tcp.snoop ipv6_udp.snoop ipv6_eh_udp.snoop" 59for c in $ipv6_cases; do 60 run_test $c -p 61 run_test $c -f 62done 63 64# Only full checksums are supported for SCTP 65run_test "ipv4_sctp.snoop" -4 -f 66run_test "ipv6_sctp.snoop" -f 67 68exit $mac_exit 69