selftests/net: synchronize udpgro tests' tx and rx connection
The sockets used by udpgso_bench_tx aren't always ready when udpgso_bench_tx transmits packets. This issue is more prevalent in -rt kernels, but can occur in both. Replace the hacky sleep calls with a function that checks whether the ports in the namespace are ready for use. Suggested-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Lucas Karpinski <lkarpins@redhat.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e47ef9eb5b
commit
3bdd9fd29c
4 changed files with 34 additions and 11 deletions
22
tools/testing/selftests/net/net_helper.sh
Executable file
22
tools/testing/selftests/net/net_helper.sh
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
# Helper functions
|
||||||
|
|
||||||
|
wait_local_port_listen()
|
||||||
|
{
|
||||||
|
local listener_ns="${1}"
|
||||||
|
local port="${2}"
|
||||||
|
local protocol="${3}"
|
||||||
|
local port_hex
|
||||||
|
local i
|
||||||
|
|
||||||
|
port_hex="$(printf "%04X" "${port}")"
|
||||||
|
for i in $(seq 10); do
|
||||||
|
if ip netns exec "${listener_ns}" cat /proc/net/"${protocol}"* | \
|
||||||
|
grep -q "${port_hex}"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
}
|
|
@ -3,6 +3,8 @@
|
||||||
#
|
#
|
||||||
# Run a series of udpgro functional tests.
|
# Run a series of udpgro functional tests.
|
||||||
|
|
||||||
|
source net_helper.sh
|
||||||
|
|
||||||
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
|
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
|
||||||
|
|
||||||
BPF_FILE="../bpf/xdp_dummy.bpf.o"
|
BPF_FILE="../bpf/xdp_dummy.bpf.o"
|
||||||
|
@ -51,8 +53,7 @@ run_one() {
|
||||||
echo "ok" || \
|
echo "ok" || \
|
||||||
echo "failed" &
|
echo "failed" &
|
||||||
|
|
||||||
# Hack: let bg programs complete the startup
|
wait_local_port_listen ${PEER_NS} 8000 udp
|
||||||
sleep 0.2
|
|
||||||
./udpgso_bench_tx ${tx_args}
|
./udpgso_bench_tx ${tx_args}
|
||||||
ret=$?
|
ret=$?
|
||||||
wait $(jobs -p)
|
wait $(jobs -p)
|
||||||
|
@ -97,7 +98,7 @@ run_one_nat() {
|
||||||
echo "ok" || \
|
echo "ok" || \
|
||||||
echo "failed"&
|
echo "failed"&
|
||||||
|
|
||||||
sleep 0.1
|
wait_local_port_listen "${PEER_NS}" 8000 udp
|
||||||
./udpgso_bench_tx ${tx_args}
|
./udpgso_bench_tx ${tx_args}
|
||||||
ret=$?
|
ret=$?
|
||||||
kill -INT $pid
|
kill -INT $pid
|
||||||
|
@ -118,11 +119,9 @@ run_one_2sock() {
|
||||||
echo "ok" || \
|
echo "ok" || \
|
||||||
echo "failed" &
|
echo "failed" &
|
||||||
|
|
||||||
# Hack: let bg programs complete the startup
|
wait_local_port_listen "${PEER_NS}" 12345 udp
|
||||||
sleep 0.2
|
|
||||||
./udpgso_bench_tx ${tx_args} -p 12345
|
./udpgso_bench_tx ${tx_args} -p 12345
|
||||||
sleep 0.1
|
wait_local_port_listen "${PEER_NS}" 8000 udp
|
||||||
# first UDP GSO socket should be closed at this point
|
|
||||||
./udpgso_bench_tx ${tx_args}
|
./udpgso_bench_tx ${tx_args}
|
||||||
ret=$?
|
ret=$?
|
||||||
wait $(jobs -p)
|
wait $(jobs -p)
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#
|
#
|
||||||
# Run a series of udpgro benchmarks
|
# Run a series of udpgro benchmarks
|
||||||
|
|
||||||
|
source net_helper.sh
|
||||||
|
|
||||||
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
|
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
|
||||||
|
|
||||||
BPF_FILE="../bpf/xdp_dummy.bpf.o"
|
BPF_FILE="../bpf/xdp_dummy.bpf.o"
|
||||||
|
@ -40,8 +42,7 @@ run_one() {
|
||||||
ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
|
ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
|
||||||
ip netns exec "${PEER_NS}" ./udpgso_bench_rx -t ${rx_args} -r &
|
ip netns exec "${PEER_NS}" ./udpgso_bench_rx -t ${rx_args} -r &
|
||||||
|
|
||||||
# Hack: let bg programs complete the startup
|
wait_local_port_listen "${PEER_NS}" 8000 udp
|
||||||
sleep 0.2
|
|
||||||
./udpgso_bench_tx ${tx_args}
|
./udpgso_bench_tx ${tx_args}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#
|
#
|
||||||
# Run a series of udpgro benchmarks
|
# Run a series of udpgro benchmarks
|
||||||
|
|
||||||
|
source net_helper.sh
|
||||||
|
|
||||||
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
|
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
|
||||||
|
|
||||||
BPF_FILE="../bpf/xdp_dummy.bpf.o"
|
BPF_FILE="../bpf/xdp_dummy.bpf.o"
|
||||||
|
@ -45,8 +47,7 @@ run_one() {
|
||||||
echo ${rx_args}
|
echo ${rx_args}
|
||||||
ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
|
ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
|
||||||
|
|
||||||
# Hack: let bg programs complete the startup
|
wait_local_port_listen "${PEER_NS}" 8000 udp
|
||||||
sleep 0.2
|
|
||||||
./udpgso_bench_tx ${tx_args}
|
./udpgso_bench_tx ${tx_args}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue