2 # SPDX-License-Identifier: GPL-2.0
6 BPF_FILE
="xdp_dummy.bpf.o"
7 readonly BASE
="ns-$(mktemp -u XXXXXX)"
11 readonly NS_SRC
=$BASE$SRC
12 readonly NS_DST
=$BASE$DST
14 # "baremetal" network used for raw UDP traffic
15 readonly BM_NET_V4
=192.168.1.
16 readonly BM_NET_V6
=2001:db8
::
18 # "overlay" network used for UDP over UDP tunnel traffic
19 readonly OL_NET_V4
=172.16.1.
20 readonly OL_NET_V6
=2001:db8
:1::
21 readonly NPROCS
=`nproc`
25 local -r jobs="$(jobs -p)"
26 [ -n "${jobs}" ] && kill -1 ${jobs} 2>/dev
/null
28 for ns
in $NS_SRC $NS_DST; do
29 ip netns del
$ns 2>/dev
/null
39 for ns
in $NS_SRC $NS_DST; do
41 ip
-n $ns link
set dev lo up
43 # disable route solicitations to decrease 'noise' traffic
44 ip netns
exec $ns sysctl
-qw net.ipv6.conf.default.router_solicitations
=0
45 ip netns
exec $ns sysctl
-qw net.ipv6.conf.all.router_solicitations
=0
48 ip link add name veth
$SRC type veth peer name veth
$DST
50 for ns
in $SRC $DST; do
51 ip link
set dev veth
$ns netns
$BASE$ns
52 ip
-n $BASE$ns link
set dev veth
$ns up
53 ip
-n $BASE$ns addr add dev veth
$ns $BM_NET_V4$ns/24
54 ip
-n $BASE$ns addr add dev veth
$ns $BM_NET_V6$ns/64 nodad
56 ip
-n $NS_DST link
set veth
$DST xdp object
${BPF_FILE} section xdp
2>/dev
/null
59 create_vxlan_endpoint
() {
62 local -r bm_rem_addr
=$3
65 local -r vxlan_port
=4789
67 ip
-n $netns link
set dev
$bm_dev up
68 ip
-n $netns link add dev
$vxlan_dev type vxlan id
$vxlan_id \
69 dstport
$vxlan_port remote
$bm_rem_addr
70 ip
-n $netns link
set dev
$vxlan_dev up
78 for ns
in $SRC $DST; do
79 # note that 3 - $SRC == $DST and 3 - $DST == $SRC
80 create_vxlan_endpoint
$BASE$ns veth
$ns $BM_NET_V4$
((3 - $ns)) vxlan
$ns 4
81 ip
-n $BASE$ns addr add dev vxlan
$ns $OL_NET_V4$ns/24
83 for ns
in $SRC $DST; do
84 create_vxlan_endpoint
$BASE$ns veth
$ns $BM_NET_V6$
((3 - $ns)) vxlan6
$ns 6
85 ip
-n $BASE$ns addr add dev vxlan6
$ns $OL_NET_V6$ns/24 nodad
88 # preload neighbur cache, do avoid some noisy traffic
89 local addr_dst
=$
(ip
-j -n $BASE$DST link show dev vxlan6
$DST |jq
-r '.[]["address"]')
90 local addr_src
=$
(ip
-j -n $BASE$SRC link show dev vxlan6
$SRC |jq
-r '.[]["address"]')
91 ip
-n $BASE$DST neigh add dev vxlan6
$DST lladdr
$addr_src $OL_NET_V6$SRC
92 ip
-n $BASE$SRC neigh add dev vxlan6
$SRC lladdr
$addr_dst $OL_NET_V6$DST
96 if [[ $1 =~ .
*:.
* ]]; then
111 local filter
=IpInReceives
114 printf "%-40s" "$msg"
116 if is_ipv6
$dst; then
117 # rx program does not support '-6' and implies ipv6 usage by default
125 [ -n "$bind" ] && rx_args
="$rx_args -b $bind"
127 # send a single GSO packet, segmented in 10 UDP frames.
128 # Always expect 10 UDP frames on RX side as rx socket does
130 ip netns
exec $NS_DST $ipt -A INPUT
-p udp
--dport 4789
131 ip netns
exec $NS_DST $ipt -A INPUT
-p udp
--dport 8000
132 ip netns
exec $NS_DST .
/udpgso_bench_rx
-C 2000 -R 100 -n 10 -l 1300 $rx_args &
134 wait_local_port_listen
"$NS_DST" 8000 udp
135 ip netns
exec $NS_SRC .
/udpgso_bench_tx
$family -M 1 -s 13000 -S 1300 -D $dst
139 if [ ${rets} -ne 0 ] ||
[ ${retc} -ne 0 ]; then
140 echo " fail client exit code $retc, server $rets"
145 local rcv
=`ip netns exec $NS_DST $ipt"-save" -c | grep 'dport 8000' | \
146 sed -e 's/\[//' -e 's/:.*//'`
147 if [ $rcv != $pkts ]; then
148 echo " fail - received $rcv packets, expected $pkts"
153 local vxrcv
=`ip netns exec $NS_DST $ipt"-save" -c | grep 'dport 4789' | \
154 sed -e 's/\[//' -e 's/:.*//'`
156 # upper net can generate a little noise, allow some tolerance
157 if [ $vxrcv -lt $vxpkts -o $vxrcv -gt $
((vxpkts
+ 3)) ]; then
158 echo " fail - received $vxrcv vxlan packets, expected $vxpkts"
170 printf "%-40s" "$msg"
171 if [ $NPROCS -lt 2 ]; then
172 echo " skip - needed 2 CPUs found $NPROCS"
176 is_ipv6
$dst && family
=-6
178 # bind the sender and the receiver to different CPUs to try
179 # get reproducible results
180 ip netns
exec $NS_DST bash
-c "echo 2 > /sys/class/net/veth$DST/queues/rx-0/rps_cpus"
181 ip netns
exec $NS_DST taskset
0x2 .
/udpgso_bench_rx
-C 2000 -R 100 &
183 wait_local_port_listen
"$NS_DST" 8000 udp
184 ip netns
exec $NS_SRC taskset
0x1 .
/udpgso_bench_tx
$family -l 3 -S 1300 -D $dst
188 if [ ${rets} -ne 0 ] ||
[ ${retc} -ne 0 ]; then
189 echo " fail client exit code $retc, server $rets"
195 for family
in 4 6; do
203 if [ $family = 6 ]; then
209 # Use ping6 on systems where ping doesn't handle IPv6
210 ping -w 1 -c 1 ::1 > /dev
/null
2>&1 || PING
="ping6"
216 run_test
"No GRO" $BM_NET$DST 10 0
220 ip netns
exec $NS_DST ethtool
-K veth
$DST generic-receive-offload on
221 ip netns
exec $NS_DST ethtool
-K veth
$DST rx-gro-list on
222 run_test
"GRO frag list" $BM_NET$DST 1 0
225 # UDP GRO fwd skips aggregation when find an udp socket with the GRO option
226 # if there is an UDP tunnel in the running system, such lookup happen
228 # use NAT to circumvent GRO FWD check
230 ip
-n $NS_DST addr add dev veth
$DST $BM_NET$DST_NAT/$SUFFIX
231 ip netns
exec $NS_DST ethtool
-K veth
$DST generic-receive-offload on
232 ip netns
exec $NS_DST ethtool
-K veth
$DST rx-udp-gro-forwarding on
233 ip netns
exec $NS_DST $IPT -t nat
-I PREROUTING
-d $BM_NET$DST_NAT \
234 -j DNAT
--to-destination $BM_NET$DST
235 run_test
"GRO fwd" $BM_NET$DST_NAT 1 0 $BM_NET$DST
239 run_bench
"UDP fwd perf" $BM_NET$DST
240 ip netns
exec $NS_DST ethtool
-K veth
$DST rx-udp-gro-forwarding on
241 run_bench
"UDP GRO fwd perf" $BM_NET$DST
245 ip netns
exec $NS_DST ethtool
-K veth
$DST generic-receive-offload on
246 ip netns
exec $NS_DST ethtool
-K veth
$DST rx-gro-list on
247 run_test
"GRO frag list over UDP tunnel" $OL_NET$DST 10 10
250 # use NAT to circumvent GRO FWD check
252 ip
-n $NS_DST addr add dev
$VXDEV$DST $OL_NET$DST_NAT/$SUFFIX
253 ip netns
exec $NS_DST ethtool
-K veth
$DST generic-receive-offload on
254 ip netns
exec $NS_DST ethtool
-K veth
$DST rx-udp-gro-forwarding on
255 ip netns
exec $NS_DST $IPT -t nat
-I PREROUTING
-d $OL_NET$DST_NAT \
256 -j DNAT
--to-destination $OL_NET$DST
258 # load arp cache before running the test to reduce the amount of
259 # stray traffic on top of the UDP tunnel
260 ip netns
exec $NS_SRC $PING -q -c 1 $OL_NET$DST_NAT >/dev
/null
261 run_test
"GRO fwd over UDP tunnel" $OL_NET$DST_NAT 10 10 $OL_NET$DST