xref: /linux/tools/testing/selftests/net/udpgso.sh (revision e3fc2fd77c63cd2e37ebd33a336602a68650f22b)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3#
4# Run a series of udpgso regression tests
5
6set -o errexit
7set -o nounset
8
9setup_loopback() {
10	ip addr add dev lo 10.0.0.1/32
11	ip addr add dev lo fd00::1/128 nodad noprefixroute
12}
13
14test_dev_mtu() {
15	setup_loopback
16	# Reduce loopback MTU
17	ip link set dev lo mtu 1500
18}
19
20test_route_mtu() {
21	setup_loopback
22	# Remove default local routes
23	ip route del local 10.0.0.1/32 table local dev lo
24	ip route del local fd00::1/128 table local dev lo
25	# Install local routes with reduced MTU
26	ip route add local 10.0.0.1/32 table local dev lo mtu 1500
27	ip route add local fd00::1/128 table local dev lo mtu 1500
28}
29
30setup_dummy_sink() {
31	ip link add name sink mtu 1500 type dummy
32	ip addr add dev sink 10.0.0.0/24
33	ip addr add dev sink fd00::2/64 nodad
34	ip link set dev sink up
35}
36
37test_hw_gso_hw_csum() {
38	setup_dummy_sink
39	ethtool -K sink tx-checksum-ip-generic on >/dev/null
40	ethtool -K sink tx-udp-segmentation on >/dev/null
41}
42
43test_sw_gso_hw_csum() {
44	setup_dummy_sink
45	ethtool -K sink tx-checksum-ip-generic on >/dev/null
46	ethtool -K sink tx-udp-segmentation off >/dev/null
47}
48
49test_sw_gso_sw_csum() {
50	setup_dummy_sink
51	ethtool -K sink tx-checksum-ip-generic off >/dev/null
52	ethtool -K sink tx-udp-segmentation off >/dev/null
53}
54
55if [ "$#" -gt 0 ]; then
56	"$1"
57	shift 2 # pop "test_*" arg and "--" delimiter
58	exec "$@"
59fi
60
61echo "ipv4 cmsg"
62./in_netns.sh "$0" test_dev_mtu -- ./udpgso -4 -C
63
64echo "ipv4 setsockopt"
65./in_netns.sh "$0" test_dev_mtu -- ./udpgso -4 -C -s
66
67echo "ipv6 cmsg"
68./in_netns.sh "$0" test_dev_mtu -- ./udpgso -6 -C
69
70echo "ipv6 setsockopt"
71./in_netns.sh "$0" test_dev_mtu -- ./udpgso -6 -C -s
72
73echo "ipv4 connected"
74./in_netns.sh "$0" test_route_mtu -- ./udpgso -4 -c
75
76echo "ipv6 connected"
77./in_netns.sh "$0" test_route_mtu -- ./udpgso -6 -c
78
79echo "ipv4 msg_more"
80./in_netns.sh "$0" test_dev_mtu -- ./udpgso -4 -C -m
81
82echo "ipv6 msg_more"
83./in_netns.sh "$0" test_dev_mtu -- ./udpgso -6 -C -m
84
85echo "ipv4 hw-gso hw-csum"
86./in_netns.sh "$0" test_hw_gso_hw_csum -- ./udpgso -4 -C -R
87
88echo "ipv6 hw-gso hw-csum"
89./in_netns.sh "$0" test_hw_gso_hw_csum -- ./udpgso -6 -C -R
90
91echo "ipv4 sw-gso hw-csum"
92./in_netns.sh "$0" test_sw_gso_hw_csum -- ./udpgso -4 -C -R
93
94echo "ipv6 sw-gso hw-csum"
95./in_netns.sh "$0" test_sw_gso_hw_csum -- ./udpgso -6 -C -R
96
97echo "ipv4 sw-gso sw-csum"
98./in_netns.sh "$0" test_sw_gso_sw_csum -- ./udpgso -4 -C -R
99
100echo "ipv6 sw-gso sw-csum"
101./in_netns.sh "$0" test_sw_gso_sw_csum -- ./udpgso -6 -C -R
102