GRO and Toeplitz hash selftests
Subsystems (3)
cover GRO and Toeplitz hash selftests
This patch contains two selftests in net, as well as respective scripts to run the tests on a single machine in loopback mode.
GRO: tests the Linux kernel GRO behavior
Toeplitz: tests the toeplitz has implementation
Coco Li (2):
selftests/net: GRO coalesce test
selftests/net: toeplitz test
tools/testing/selftests/net/Makefile | 2 + tools/testing/selftests/net/gro.c | 1095 +++++++++++++++++ tools/testing/selftests/net/gro.sh | 128 ++ tools/testing/selftests/net/setup_loopback.sh | 82 ++ tools/testing/selftests/net/toeplitz.c | 585 +++++++++ tools/testing/selftests/net/toeplitz.sh | 199 +++ .../testing/selftests/net/toeplitz_client.sh | 28 + 7 files changed, 2119 insertions(+) create mode 100644 tools/testing/selftests/net/gro.c create mode 100755 tools/testing/selftests/net/gro.sh create mode 100755 tools/testing/selftests/net/setup_loopback.sh create mode 100644 tools/testing/selftests/net/toeplitz.c create mode 100755 tools/testing/selftests/net/toeplitz.sh create mode 100755 tools/testing/selftests/net/toeplitz_client.sh
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
PATCH 1/2 selftests/net: GRO coalesce test
Implement a GRO testsuite that expects Linux kernel GRO behavior. All tests pass with the kernel software GRO stack. Run against a device with hardware GRO to verify that it matches the software stack.
gro.c generates packets and sends them out through a packet socket. The receiver in gro.c (run separately) receives the packets on a packet socket, filters them by destination ports using BPF and checks the packet geometry to see whether GRO was applied.
gro.sh provides a wrapper to run the gro.c in NIC loopback mode. It is not included in continuous testing because it modifies network configuration around a physical NIC: gro.sh sets the NIC in loopback mode, creates macvlan devices on the physical device in separate namespaces, and sends traffic generated by gro.c between the two namespaces to observe coalescing behavior.
GRO coalescing is time sensitive.
Some tests may prove flaky on some hardware.
Note that this test suite tests for software GRO unless hardware GRO is enabled (ethtool -K $DEV rx-gro-hw on).
To test, run ./gro.sh.
The wrapper will output success or failed test names, and generate log.txt and stderr.
Sample log.txt result:
...
pure data packet of same size: Test succeeded
large data packets followed by a smaller one: Test succeeded
small data packets followed by a larger one: Test succeeded
...
Sample stderr result:
...
carrier ready
running test ipv4 data
Expected {200 }, Total 1 packets
Received {200 }, Total 1 packets.
...
--- tools/testing/selftests/net/Makefile | 1 + tools/testing/selftests/net/gro.c | 1095 +++++++++++++++++ tools/testing/selftests/net/gro.sh | 128 ++ tools/testing/selftests/net/setup_loopback.sh | 82 ++ 4 files changed, 1306 insertions(+) create mode 100644 tools/testing/selftests/net/gro.c create mode 100755 tools/testing/selftests/net/gro.sh create mode 100755 tools/testing/selftests/net/setup_loopback.sh
tools/testing/selftests/net/Makefile +1 -0
@@ -38,6 +38,7 @@ TEST_GEN_FILES += reuseaddr_ports_exhausted TEST_GEN_FILES += hwtstamp_config rxtimestamp timestamping txtimestamp TEST_GEN_FILES += ipsec TEST_GEN_FILES += ioam6_parser +TEST_GEN_FILES += gro TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls
tools/testing/selftests/net/gro.c new file +1095 -0
1,095 lines not on this page · raw message
tools/testing/selftests/net/gro.sh new file +128 -0
128 lines not on this page · raw message
tools/testing/selftests/net/setup_loopback.sh new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
Paolo Abeni
maintainerRe: [PATCH net-next 1/2] selftests/net: GRO coalesce test
Hello,
Quoted 9 lines · Coco Li
Implement a GRO testsuite that expects Linux kernel GRO behavior. All tests pass with the kernel software GRO stack. Run against a device with hardware GRO to verify that it matches the software stack.
gro.cgenerates packets and sends them out through a packet socket. The receiver ingro.c(run separately) receives the packets on a packet socket, filters them by destination ports using BPF and checks the packet geometry to see whether GRO was applied.
Quoted 6 lines
gro.shprovides a wrapper to run thegro.cin NIC loopback mode. It is not included in continuous testing because it modifies network configuration around a physical NIC:gro.shsets the NIC in loopback mode, creates macvlan devices on the physical device in separate namespaces, and sends traffic generated bygro.cbetween the two namespaces to observe coalescing behavior.
I like this idea a lot!
Have you considered additionally run the same test of top of a veth pair, and have such tests always enabled, so we could have some coverage regardless of specific H/W available?
To do the above you should disable TSO on the veth sender peer and enable GRO on the other end.
[...]
tools/testing/selftests/net/gro.sh line 54
Quoted 4 lines
tools/testing/selftests/net/gro.sh new file +4
-0+ setup_ns + # Each test is run 3 times to deflake, because given the receive timing, + # not all packets that should coalesce will be considered in the same flow + # on every try.
I thought that tuning 'gro_flush_timeout' appropriatelly, you should be able to control exactly which packets will be aggregated ???
Thanks!
Paolo
Re: [PATCH net-next 1/2] selftests/net: GRO coalesce test
Quoted 20 lines · Paolo Abeni
Hello,
Quoted 9 lines · Coco Li
Implement a GRO testsuite that expects Linux kernel GRO behavior. All tests pass with the kernel software GRO stack. Run against a device with hardware GRO to verify that it matches the software stack.
gro.cgenerates packets and sends them out through a packet socket. The receiver ingro.c(run separately) receives the packets on a packet socket, filters them by destination ports using BPF and checks the packet geometry to see whether GRO was applied.Quoted 6 lines
gro.shprovides a wrapper to run thegro.cin NIC loopback mode. It is not included in continuous testing because it modifies network configuration around a physical NIC:gro.shsets the NIC in loopback mode, creates macvlan devices on the physical device in separate namespaces, and sends traffic generated bygro.cbetween the two namespaces to observe coalescing behavior.
Quoted 8 lines
I like this idea a lot!
Have you considered additionally run the same test of top of a veth pair, and have such tests always enabled, so we could have some coverage regardless of specific H/W available?
To do the above you should disable TSO on the veth sender peer and enable GRO on the other end.
Thanks for the suggestion! To make sure I understand you correctly, would this be another script that creates the veth pair separate from the gro.sh wrapper?
A message that is not in the archive (sent off-list or not yet received): CADjXwjhvb9BVNPjY2f-4yfE51RGL88U3VbiN_gwaMSGbagzQEg@mail.gmail.com
Paolo Abeni
maintainerRe: [PATCH net-next 1/2] selftests/net: GRO coalesce test
Hello,
Quoted 10 lines · Coco Li
Quoted 6 lines
Have you considered additionally run the same test of top of a veth pair, and have such tests always enabled, so we could have some coverage regardless of specific H/W available?
To do the above you should disable TSO on the veth sender peer and enable GRO on the other end.
Thanks for the suggestion! To make sure I understand you correctly, would this be another script that creates the veth pair separate from the
gro.shwrapper?
I personally don't have any strict preference. I *think* the veth thing could still fit the gro.sh script, but whatever is easier coding wise would fit.
The gro.sh script with no/default argument could run all the tests on a veth pair; if a device name is specified via the command line, it could additionally run (the specified set of tests) on such device.
Cheers,
Paolo
Re: [PATCH net-next 1/2] selftests/net: GRO coalesce test
Sounds good! I'll work on a follow up patch.
Best,
Coco
PATCH 2/2 selftests/net: toeplitz test
In reply to Coco LiTo verify that this hash implements the Toeplitz hash function.
Additionally, provide a script toeplitz.sh to run the test in loopback mode on a networking device of choice (see setup_loopback.sh). Since the script modifies the NIC setup, it will not be run by selftests automatically.
Tested:
./toeplitz.sh -i eth0 -irq_prefix <eth0_pattern> -t -6
carrier ready
rxq 0: cpu 14
rxq 1: cpu 20
rxq 2: cpu 17
rxq 3: cpu 23
cpu 14: rx_hash 0x69103ebc [saddr fda8::2 daddr fda8::1 sport 58938 dport 8000] OK rxq 0 (cpu 14)
...
cpu 20: rx_hash 0x257118b9 [saddr fda8::2 daddr fda8::1 sport 59258 dport 8000] OK rxq 1 (cpu 20)
count: pass=111 nohash=0 fail=0
Test Succeeded!
--- tools/testing/selftests/net/Makefile | 1 + tools/testing/selftests/net/toeplitz.c | 585 ++++++++++++++++++ tools/testing/selftests/net/toeplitz.sh | 199 ++++++ .../testing/selftests/net/toeplitz_client.sh | 28 + 4 files changed, 813 insertions(+) create mode 100644 tools/testing/selftests/net/toeplitz.c create mode 100755 tools/testing/selftests/net/toeplitz.sh create mode 100755 tools/testing/selftests/net/toeplitz_client.sh
tools/testing/selftests/net/Makefile +1 -0
@@ -41,6 +41,7 @@ TEST_GEN_FILES += ioam6_parser TEST_GEN_FILES += gro TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls +TEST_GEN_FILES += toeplitz TEST_FILES := settings
tools/testing/selftests/net/toeplitz.c new file +585 -0
585 lines not on this page · raw message
tools/testing/selftests/net/toeplitz.sh new file +199 -0
199 lines not on this page · raw message
tools/testing/selftests/net/toeplitz_client.sh new file +28 -0
@@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# A simple program for generating traffic for the toeplitz test. +# +# This program sends packets periodically for, conservatively, 20 seconds. The +# intent is for the calling program to kill this program once it is no longer +# needed, rather than waiting for the 20 second expiration. + +send_traffic() { + expiration=$((SECONDS+20)) + while [[ "${SECONDS}" -lt "${expiration}" ]] + do + if [[ "${PROTO}" == "-u" ]]; then + echo "msg $i" | nc "${IPVER}" -u -w 0 "${ADDR}" "${PORT}" + else + echo "msg $i" | nc "${IPVER}" -w 0 "${ADDR}" "${PORT}" + fi + sleep 0.001 + done +} + +PROTO=$1 +IPVER=$2 +ADDR=$3 +PORT=$4 + +send_traffic
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 10 lines · On Thu, 5 Aug 2021 07:36:39 +0000 you wrote:
This patch contains two selftests in net, as well as respective scripts to run the tests on a single machine in loopback mode.
GRO: tests the Linux kernel GRO behavior
Toeplitz: tests the toeplitz has implementationCoco Li (2):
selftests/net: GRO coalesce test
selftests/net: toeplitz test[...]
Here is the summary with links:
- [net-next,1/2] selftests/net: GRO coalesce test
https://git.kernel.org/netdev/net-next/c/7d1575014a63 - [net-next,2/2] selftests/net: toeplitz test https://git.kernel.org/netdev/net-next/c/5ebfb4cc3048
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html