1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0 3 # 4 # Run a series of packet socket send regression tests 5 6 set -e 7 8 readonly mtu=1500 9 readonly iphlen=20 10 readonly udphlen=8 11 12 readonly vnet_hlen=10 13 readonly eth_hlen=14 14 15 readonly mss="$((${mtu} - ${iphlen} - ${udphlen}))" 16 readonly mss_exceeds="$((${mss} + 1))" 17 18 readonly max_mtu=65535 19 readonly max_mss="$((${max_mtu} - ${iphlen} - ${udphlen}))" 20 readonly max_mss_exceeds="$((${max_mss} + 1))" 21 22 # functional checks (not a full cross-product) 23 24 echo "dgram" 25 ./in_netns.sh ./psock_snd -d 26 27 echo "dgram bind" 28 ./in_netns.sh ./psock_snd -d -b 29 30 echo "raw" 31 ./in_netns.sh ./psock_snd 32 33 echo "raw bind" 34 ./in_netns.sh ./psock_snd -b 35 36 echo "raw qdisc bypass" 37 ./in_netns.sh ./psock_snd -q 38 39 echo "raw vlan" 40 ./in_netns.sh ./psock_snd -V 41 42 echo "raw vnet hdr" 43 ./in_netns.sh ./psock_snd -v 44 45 echo "raw csum_off" 46 ./in_netns.sh ./psock_snd -v -c 47 48 echo "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 54 echo "raw min size" 55 ./in_netns.sh ./psock_snd -l 0 56 57 echo "raw mtu size" 58 ./in_netns.sh ./psock_snd -l "${mss}" 59 60 echo "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 68 echo "raw vlan mtu size + 1 (expected to fail)" 69 (! ./in_netns.sh ./psock_snd -V -l "${mss_exceeds}") 70 71 echo "dgram mtu size" 72 ./in_netns.sh ./psock_snd -d -l "${mss}" 73 74 echo "dgram mtu size + 1 (expected to fail)" 75 (! ./in_netns.sh ./psock_snd -d -l "${mss_exceeds}") 76 77 echo "raw truncate hlen (expected to fail: does not arrive)" 78 (! ./in_netns.sh ./psock_snd -t "$((${vnet_hlen} + ${eth_hlen}))") 79 80 echo "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 86 echo "raw gso min size" 87 ./in_netns.sh ./psock_snd -v -c -g -l "${mss_exceeds}" 88 89 echo "raw gso max size" 90 ./in_netns.sh ./psock_snd -v -c -g -l "${max_mss}" 91 92 echo "raw gso max size + 1 (expected to fail)" 93 (! ./in_netns.sh ./psock_snd -v -c -g -l "${max_mss_exceeds}") 94 95 echo "OK. All tests passed"
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.