diff options
| author | Paolo Abeni <pabeni@redhat.com> | 2021-08-26 09:30:42 +0200 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2021-08-26 12:03:49 +0100 |
| commit | 9af771d2ec044ffc19192711ac29f1d5c31dc181 (patch) | |
| tree | 220fa17406f455331137c8c963a4e43fb2148feb /tools/testing/selftests/net/setup_loopback.sh | |
| parent | 8b325d2a099e6fa0f3e1113fc1e7b590360594fa (diff) | |
| download | cachepc-linux-9af771d2ec044ffc19192711ac29f1d5c31dc181.tar.gz cachepc-linux-9af771d2ec044ffc19192711ac29f1d5c31dc181.zip | |
selftests/net: allow GRO coalesce test on veth
This change extends the existing GRO coalesce test to
allow running on top of a veth pair, so that no H/W dep
is required to run them.
By default gro.sh will use the veth backend, and will try
to use exiting H/W in loopback mode if a specific device
name is provided with the '-i' command line option.
No functional change is intended for the loopback-based
tests, just move all the relevant initialization/cleanup
code into the related script.
Introduces a new initialization helper script for the
veth backend, and plugs the correct helper script according
to the provided command line.
Additionally, enable veth-based tests by default.
v1 -> v2:
- drop unused code in setup_veth_ns() - Willem
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/net/setup_loopback.sh')
| -rwxr-xr-x | tools/testing/selftests/net/setup_loopback.sh | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/tools/testing/selftests/net/setup_loopback.sh b/tools/testing/selftests/net/setup_loopback.sh index 0a8ad97b07ea..e57bbfbc5208 100755 --- a/tools/testing/selftests/net/setup_loopback.sh +++ b/tools/testing/selftests/net/setup_loopback.sh @@ -1,5 +1,11 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 + +readonly FLUSH_PATH="/sys/class/net/${dev}/gro_flush_timeout" +readonly IRQ_PATH="/sys/class/net/${dev}/napi_defer_hard_irqs" +readonly FLUSH_TIMEOUT="$(< ${FLUSH_PATH})" +readonly HARD_IRQS="$(< ${IRQ_PATH})" + netdev_check_for_carrier() { local -r dev="$1" @@ -18,7 +24,7 @@ netdev_check_for_carrier() { # Assumes that there is no existing ipvlan device on the physical device setup_loopback_environment() { - local dev="$1" + local dev="$1" # Fail hard if cannot turn on loopback mode for current NIC ethtool -K "${dev}" loopback on || exit 1 @@ -80,3 +86,33 @@ cleanup_loopback(){ exit 1 fi } + +setup_interrupt() { + # Use timer on host to trigger the network stack + # Also disable device interrupt to not depend on NIC interrupt + # Reduce test flakiness caused by unexpected interrupts + echo 100000 >"${FLUSH_PATH}" + echo 50 >"${IRQ_PATH}" +} + +setup_ns() { + # Set up server_ns namespace and client_ns namespace + setup_macvlan_ns "${dev}" server_ns server "${SERVER_MAC}" + setup_macvlan_ns "${dev}" client_ns client "${CLIENT_MAC}" +} + +cleanup_ns() { + cleanup_macvlan_ns server_ns server client_ns client +} + +setup() { + setup_loopback_environment "${dev}" + setup_interrupt +} + +cleanup() { + cleanup_loopback "${dev}" + + echo "${FLUSH_TIMEOUT}" >"${FLUSH_PATH}" + echo "${HARD_IRQS}" >"${IRQ_PATH}" +} |
