1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3# 4# Run a series of packet socket send regression tests 5 6set -e 7 8readonly mtu=1500 9readonly iphlen=20 10readonly udphlen=8 11 12readonly vnet_hlen=10 13readonly eth_hlen=14 14 15readonly mss="$((${mtu} - ${iphlen} - ${udphlen}))" 16readonly mss_exceeds="$((${mss} + 1))" 17 18readonly max_mtu=65535 19readonly max_mss="$((${max_mtu} - ${iphlen} - ${udphlen}))" 20readonly max_mss_exceeds="$((${max_mss} + 1))" 21 22# functional checks (not a full cross-product) 23 24echo "dgram" 25./in_netns.sh ./psock_snd -d 26 27echo "dgram bind" 28./in_netns.sh ./psock_snd -d -b 29 30echo "raw" 31./in_netns.sh ./psock_snd 32 33echo "raw bind" 34./in_netns.sh ./psock_snd -b 35 36echo "raw qdisc bypass" 37./in_netns.sh ./psock_snd -q 38 39echo "raw vlan" 40./in_netns.sh ./psock_snd -V 41 42echo "raw vnet hdr" 43./in_netns.sh ./psock_snd -v 44 45echo "raw csum_off" 46./in_netns.sh ./psock_snd -v -c 47 48echo "raw csum_off with bad offset (expected to fail)" 49(! ./in_netns.sh ./psock_snd -v -c -C) 50 51 52# bounds check: send {max, max + 1, min, min - 1} lengths 53 54echo "raw min size" 55./in_netns.sh ./psock_snd -l 0 56 57echo "raw mtu size" 58./in_netns.sh ./psock_snd -l "${mss}" 59 60echo "raw mtu size + 1 (expected to fail)" 61(! ./in_netns.sh ./psock_snd -l "${mss_exceeds}") 62 63# fails due to ARPHRD_ETHER check in packet_extra_vlan_len_allowed 64# 65# echo "raw vlan mtu size" 66# ./in_netns.sh ./psock_snd -V -l "${mss}" 67 68echo "raw vlan mtu size + 1 (expected to fail)" 69(! ./in_netns.sh ./psock_snd -V -l "${mss_exceeds}") 70 71echo "dgram mtu size" 72./in_netns.sh ./psock_snd -d -l "${mss}" 73 74echo "dgram mtu size + 1 (expected to fail)" 75(! ./in_netns.sh ./psock_snd -d -l "${mss_exceeds}") 76 77echo "raw truncate hlen (expected to fail: does not arrive)" 78(! ./in_netns.sh ./psock_snd -t "$((${vnet_hlen} + ${eth_hlen}))") 79 80echo "raw truncate hlen - 1 (expected to fail: EINVAL)" 81(! ./in_netns.sh ./psock_snd -t "$((${vnet_hlen} + ${eth_hlen} - 1))") 82 83 84# gso checks: implies -l, because with gso len must exceed gso_size 85 86echo "raw gso min size" 87./in_netns.sh ./psock_snd -v -c -g -l "${mss_exceeds}" 88 89echo "raw gso max size" 90./in_netns.sh ./psock_snd -v -c -g -l "${max_mss}" 91 92echo "raw gso max size + 1 (expected to fail)" 93(! ./in_netns.sh ./psock_snd -v -c -g -l "${max_mss_exceeds}") 94 95echo "OK. All tests passed" 96