Linux 4.19.133
[linux/fpc-iii.git] / tools / testing / selftests / net / psock_snd.sh
blob6331d91b86a662dad85c02a4e71b06378bf8b6e3
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Run a series of packet socket send regression tests
6 set -e
8 readonly mtu=1500
9 readonly iphlen=20
10 readonly udphlen=8
12 readonly vnet_hlen=10
13 readonly eth_hlen=14
15 readonly mss="$((${mtu} - ${iphlen} - ${udphlen}))"
16 readonly mss_exceeds="$((${mss} + 1))"
18 readonly max_mtu=65535
19 readonly max_mss="$((${max_mtu} - ${iphlen} - ${udphlen}))"
20 readonly max_mss_exceeds="$((${max_mss} + 1))"
22 # functional checks (not a full cross-product)
24 echo "dgram"
25 ./in_netns.sh ./psock_snd -d
27 echo "dgram bind"
28 ./in_netns.sh ./psock_snd -d -b
30 echo "raw"
31 ./in_netns.sh ./psock_snd
33 echo "raw bind"
34 ./in_netns.sh ./psock_snd -b
36 echo "raw qdisc bypass"
37 ./in_netns.sh ./psock_snd -q
39 echo "raw vlan"
40 ./in_netns.sh ./psock_snd -V
42 echo "raw vnet hdr"
43 ./in_netns.sh ./psock_snd -v
45 echo "raw csum_off"
46 ./in_netns.sh ./psock_snd -v -c
48 echo "raw csum_off with bad offset (fails)"
49 (! ./in_netns.sh ./psock_snd -v -c -C)
52 # bounds check: send {max, max + 1, min, min - 1} lengths
54 echo "raw min size"
55 ./in_netns.sh ./psock_snd -l 0
57 echo "raw mtu size"
58 ./in_netns.sh ./psock_snd -l "${mss}"
60 echo "raw mtu size + 1 (fails)"
61 (! ./in_netns.sh ./psock_snd -l "${mss_exceeds}")
63 # fails due to ARPHRD_ETHER check in packet_extra_vlan_len_allowed
65 # echo "raw vlan mtu size"
66 # ./in_netns.sh ./psock_snd -V -l "${mss}"
68 echo "raw vlan mtu size + 1 (fails)"
69 (! ./in_netns.sh ./psock_snd -V -l "${mss_exceeds}")
71 echo "dgram mtu size"
72 ./in_netns.sh ./psock_snd -d -l "${mss}"
74 echo "dgram mtu size + 1 (fails)"
75 (! ./in_netns.sh ./psock_snd -d -l "${mss_exceeds}")
77 echo "raw truncate hlen (fails: does not arrive)"
78 (! ./in_netns.sh ./psock_snd -t "$((${vnet_hlen} + ${eth_hlen}))")
80 echo "raw truncate hlen - 1 (fails: EINVAL)"
81 (! ./in_netns.sh ./psock_snd -t "$((${vnet_hlen} + ${eth_hlen} - 1))")
84 # gso checks: implies -l, because with gso len must exceed gso_size
86 echo "raw gso min size"
87 ./in_netns.sh ./psock_snd -v -c -g -l "${mss_exceeds}"
89 echo "raw gso min size - 1 (fails)"
90 (! ./in_netns.sh ./psock_snd -v -c -g -l "${mss}")
92 echo "raw gso max size"
93 ./in_netns.sh ./psock_snd -v -c -g -l "${max_mss}"
95 echo "raw gso max size + 1 (fails)"
96 (! ./in_netns.sh ./psock_snd -v -c -g -l "${max_mss_exceeds}")
98 echo "OK. All tests passed"