@@ -7,8 +7,6 @@ source net_helper.sh
77
88readonly PEER_NS=" ns-peer-$( mktemp -u XXXXXX) "
99
10- BPF_FILE=" xdp_dummy.bpf.o"
11-
1210# set global exit status, but never reset nonzero one.
1311check_err ()
1412{
@@ -38,25 +36,27 @@ cfg_veth() {
3836 ip -netns " ${PEER_NS} " addr add dev veth1 192.168.1.1/24
3937 ip -netns " ${PEER_NS} " addr add dev veth1 2001:db8::1/64 nodad
4038 ip -netns " ${PEER_NS} " link set dev veth1 up
41- ip -n " ${PEER_NS} " link set veth1 xdp object ${BPF_FILE} section xdp
39+ ip netns exec " ${PEER_NS} " ethtool -K veth1 gro on
4240}
4341
4442run_one () {
4543 # use 'rx' as separator between sender args and receiver args
4644 local -r all=" $@ "
4745 local -r tx_args=${all% rx* }
4846 local -r rx_args=${all#* rx}
47+ local ret=0
4948
5049 cfg_veth
5150
52- ip netns exec " ${PEER_NS} " ./udpgso_bench_rx -C 1000 -R 10 ${rx_args} && \
53- echo " ok" || \
54- echo " failed" &
51+ ip netns exec " ${PEER_NS} " ./udpgso_bench_rx -C 1000 -R 10 ${rx_args} &
52+ local PID1=$!
5553
5654 wait_local_port_listen ${PEER_NS} 8000 udp
5755 ./udpgso_bench_tx ${tx_args}
58- ret=$?
59- wait $( jobs -p)
56+ check_err $?
57+ wait ${PID1}
58+ check_err $?
59+ [ " $ret " -eq 0 ] && echo " ok" || echo " failed"
6060 return $ret
6161}
6262
@@ -73,6 +73,7 @@ run_one_nat() {
7373 local -r all=" $@ "
7474 local -r tx_args=${all% rx* }
7575 local -r rx_args=${all#* rx}
76+ local ret=0
7677
7778 if [[ ${tx_args} = * -4* ]]; then
7879 ipt_cmd=iptables
@@ -93,16 +94,17 @@ run_one_nat() {
9394 # ... so that GRO will match the UDP_GRO enabled socket, but packets
9495 # will land on the 'plain' one
9596 ip netns exec " ${PEER_NS} " ./udpgso_bench_rx -G ${family} -b ${addr1} -n 0 &
96- pid=$!
97- ip netns exec " ${PEER_NS} " ./udpgso_bench_rx -C 1000 -R 10 ${family} -b ${addr2%/* } ${rx_args} && \
98- echo " ok" || \
99- echo " failed" &
97+ local PID1=$!
98+ ip netns exec " ${PEER_NS} " ./udpgso_bench_rx -C 1000 -R 10 ${family} -b ${addr2%/* } ${rx_args} &
99+ local PID2=$!
100100
101101 wait_local_port_listen " ${PEER_NS} " 8000 udp
102102 ./udpgso_bench_tx ${tx_args}
103- ret=$?
104- kill -INT $pid
105- wait $( jobs -p)
103+ check_err $?
104+ kill -INT ${PID1}
105+ wait ${PID2}
106+ check_err $?
107+ [ " $ret " -eq 0 ] && echo " ok" || echo " failed"
106108 return $ret
107109}
108110
@@ -111,20 +113,26 @@ run_one_2sock() {
111113 local -r all=" $@ "
112114 local -r tx_args=${all% rx* }
113115 local -r rx_args=${all#* rx}
116+ local ret=0
114117
115118 cfg_veth
116119
117120 ip netns exec " ${PEER_NS} " ./udpgso_bench_rx -C 1000 -R 10 ${rx_args} -p 12345 &
118- ip netns exec " ${PEER_NS} " ./udpgso_bench_rx -C 2000 -R 10 ${rx_args} && \
119- echo " ok " || \
120- echo " failed " &
121+ local PID1= $!
122+ ip netns exec " ${PEER_NS} " ./udpgso_bench_rx -C 2000 -R 10 ${rx_args} &
123+ local PID2= $!
121124
122125 wait_local_port_listen " ${PEER_NS} " 12345 udp
123126 ./udpgso_bench_tx ${tx_args} -p 12345
127+ check_err $?
124128 wait_local_port_listen " ${PEER_NS} " 8000 udp
125129 ./udpgso_bench_tx ${tx_args}
126- ret=$?
127- wait $( jobs -p)
130+ check_err $?
131+ wait ${PID1}
132+ check_err $?
133+ wait ${PID2}
134+ check_err $?
135+ [ " $ret " -eq 0 ] && echo " ok" || echo " failed"
128136 return $ret
129137}
130138
@@ -196,11 +204,6 @@ run_all() {
196204 return $ret
197205}
198206
199- if [ ! -f ${BPF_FILE} ]; then
200- echo " Missing ${BPF_FILE} . Run 'make' first"
201- exit -1
202- fi
203-
204207if [[ $# -eq 0 ]]; then
205208 run_all
206209elif [[ $1 == " __subprocess" ]]; then
0 commit comments