2 # SPDX-License-Identifier: GPL-2.0
4 # Run a series of udpgro functional tests.
6 readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
9 local -r jobs="$(jobs -p)"
10 local -r ns="$(ip netns list|grep $PEER_NS)"
12 [ -n "${jobs}" ] && kill -1 ${jobs} 2>/dev/null
13 [ -n "$ns" ] && ip netns del $ns 2>/dev/null
18 ip netns add "${PEER_NS}"
19 ip -netns "${PEER_NS}" link set lo up
21 ip link set dev veth0 up
22 ip addr add dev veth0 192.168.1.2/24
23 ip addr add dev veth0 2001:db8::2/64 nodad
25 ip link set dev veth1 netns "${PEER_NS}"
26 ip -netns "${PEER_NS}" addr add dev veth1 192.168.1.1/24
27 ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad
28 ip -netns "${PEER_NS}" link set dev veth1 up
29 ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section xdp_dummy
33 # use 'rx' as separator between sender args and receiver args
35 local -r tx_args=${all%rx*}
36 local -r rx_args=${all#*rx}
40 ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} && \
44 # Hack: let bg programs complete the startup
46 ./udpgso_bench_tx ${tx_args}
54 ./in_netns.sh $0 __subprocess $2 rx -G -r $3
58 # use 'rx' as separator between sender args and receiver args
59 local addr1 addr2 pid family="" ipt_cmd=ip6tables
61 local -r tx_args=${all%rx*}
62 local -r rx_args=${all#*rx}
64 if [[ ${tx_args} = *-4* ]]; then
71 addr2="2001:db8::3/64 nodad"
75 ip -netns "${PEER_NS}" addr add dev veth1 ${addr2}
77 # fool the GRO engine changing the destination address ...
78 ip netns exec "${PEER_NS}" $ipt_cmd -t nat -I PREROUTING -d ${addr1} -j DNAT --to-destination ${addr2%/*}
80 # ... so that GRO will match the UDP_GRO enabled socket, but packets
81 # will land on the 'plain' one
82 ip netns exec "${PEER_NS}" ./udpgso_bench_rx -G ${family} -b ${addr1} -n 0 &
84 ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${family} -b ${addr2%/*} ${rx_args} && \
89 ./udpgso_bench_tx ${tx_args}
98 ./in_netns.sh $0 __subprocess_nat $2 rx -r $3
102 local -r core_args="-l 4"
103 local -r ipv4_args="${core_args} -4 -D 192.168.1.1"
104 local -r ipv6_args="${core_args} -6 -D 2001:db8::1"
107 run_test "no GRO" "${ipv4_args} -M 10 -s 1400" "-4 -n 10 -l 1400"
109 # explicitly check we are not receiving UDP_SEGMENT cmsg (-S -1)
110 # when GRO does not take place
111 run_test "no GRO chk cmsg" "${ipv4_args} -M 10 -s 1400" "-4 -n 10 -l 1400 -S -1"
113 # the GSO packets are aggregated because:
114 # * veth schedule napi after each xmit
115 # * segmentation happens in BH context, veth napi poll is delayed after
116 # the transmission of the last segment
117 run_test "GRO" "${ipv4_args} -M 1 -s 14720 -S 0 " "-4 -n 1 -l 14720"
118 run_test "GRO chk cmsg" "${ipv4_args} -M 1 -s 14720 -S 0 " "-4 -n 1 -l 14720 -S 1472"
119 run_test "GRO with custom segment size" "${ipv4_args} -M 1 -s 14720 -S 500 " "-4 -n 1 -l 14720"
120 run_test "GRO with custom segment size cmsg" "${ipv4_args} -M 1 -s 14720 -S 500 " "-4 -n 1 -l 14720 -S 500"
122 run_nat_test "bad GRO lookup" "${ipv4_args} -M 1 -s 14720 -S 0" "-n 10 -l 1472"
125 run_test "no GRO" "${ipv6_args} -M 10 -s 1400" "-n 10 -l 1400"
126 run_test "no GRO chk cmsg" "${ipv6_args} -M 10 -s 1400" "-n 10 -l 1400 -S -1"
127 run_test "GRO" "${ipv6_args} -M 1 -s 14520 -S 0" "-n 1 -l 14520"
128 run_test "GRO chk cmsg" "${ipv6_args} -M 1 -s 14520 -S 0" "-n 1 -l 14520 -S 1452"
129 run_test "GRO with custom segment size" "${ipv6_args} -M 1 -s 14520 -S 500" "-n 1 -l 14520"
130 run_test "GRO with custom segment size cmsg" "${ipv6_args} -M 1 -s 14520 -S 500" "-n 1 -l 14520 -S 500"
132 run_nat_test "bad GRO lookup" "${ipv6_args} -M 1 -s 14520 -S 0" "-n 10 -l 1452"
135 if [ ! -f ../bpf/xdp_dummy.o ]; then
136 echo "Missing xdp_dummy helper. Build bpf selftest first"
140 if [[ $# -eq 0 ]]; then
142 elif [[ $1 == "__subprocess" ]]; then
145 elif [[ $1 == "__subprocess_nat" ]]; then