Skip to content

Commit e87f53b

Browse files
Paolo Abenidavem330
authored andcommitted
selftests: add some benchmark for UDP GRO
Run on top of veth pair, using a dummy XDP program to enable the GRO. rfc v3 -> v1: - use ip route to attach the xdp helper to the veth Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent bd8e1af commit e87f53b

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

tools/testing/selftests/net/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CFLAGS += -I../../../../usr/include/
77
TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh rtnetlink.sh
88
TEST_PROGS += fib_tests.sh fib-onlink-tests.sh pmtu.sh udpgso.sh ip_defrag.sh
99
TEST_PROGS += udpgso_bench.sh fib_rule_tests.sh msg_zerocopy.sh psock_snd.sh
10+
TEST_PROGS += udpgro_bench.sh
1011
TEST_PROGS_EXTENDED := in_netns.sh
1112
TEST_GEN_FILES = socket
1213
TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# Run a series of udpgro benchmarks
5+
6+
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
7+
8+
cleanup() {
9+
local -r jobs="$(jobs -p)"
10+
local -r ns="$(ip netns list|grep $PEER_NS)"
11+
12+
[ -n "${jobs}" ] && kill -INT ${jobs} 2>/dev/null
13+
[ -n "$ns" ] && ip netns del $ns 2>/dev/null
14+
}
15+
trap cleanup EXIT
16+
17+
run_one() {
18+
# use 'rx' as separator between sender args and receiver args
19+
local -r all="$@"
20+
local -r tx_args=${all%rx*}
21+
local -r rx_args=${all#*rx}
22+
23+
ip netns add "${PEER_NS}"
24+
ip -netns "${PEER_NS}" link set lo up
25+
ip link add type veth
26+
ip link set dev veth0 up
27+
ip addr add dev veth0 192.168.1.2/24
28+
ip addr add dev veth0 2001:db8::2/64 nodad
29+
30+
ip link set dev veth1 netns "${PEER_NS}"
31+
ip -netns "${PEER_NS}" addr add dev veth1 192.168.1.1/24
32+
ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad
33+
ip -netns "${PEER_NS}" link set dev veth1 up
34+
35+
ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section xdp_dummy
36+
ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
37+
ip netns exec "${PEER_NS}" ./udpgso_bench_rx -t ${rx_args} -r &
38+
39+
# Hack: let bg programs complete the startup
40+
sleep 0.1
41+
./udpgso_bench_tx ${tx_args}
42+
}
43+
44+
run_in_netns() {
45+
local -r args=$@
46+
47+
./in_netns.sh $0 __subprocess ${args}
48+
}
49+
50+
run_udp() {
51+
local -r args=$@
52+
53+
echo "udp gso - over veth touching data"
54+
run_in_netns ${args} -S rx
55+
56+
echo "udp gso and gro - over veth touching data"
57+
run_in_netns ${args} -S rx -G
58+
}
59+
60+
run_tcp() {
61+
local -r args=$@
62+
63+
echo "tcp - over veth touching data"
64+
run_in_netns ${args} -t rx
65+
}
66+
67+
run_all() {
68+
local -r core_args="-l 4"
69+
local -r ipv4_args="${core_args} -4 -D 192.168.1.1"
70+
local -r ipv6_args="${core_args} -6 -D 2001:db8::1"
71+
72+
echo "ipv4"
73+
run_tcp "${ipv4_args}"
74+
run_udp "${ipv4_args}"
75+
76+
echo "ipv6"
77+
run_tcp "${ipv4_args}"
78+
run_udp "${ipv6_args}"
79+
}
80+
81+
if [ ! -f ../bpf/xdp_dummy.o ]; then
82+
echo "Missing xdp_dummy helper. Build bpf selftest first"
83+
exit -1
84+
fi
85+
86+
if [[ $# -eq 0 ]]; then
87+
run_all
88+
elif [[ $1 == "__subprocess" ]]; then
89+
shift
90+
run_one $@
91+
else
92+
run_in_netns $@
93+
fi

0 commit comments

Comments
 (0)