From: Mohsin Bashir <mohsin.bashr@gmail.com>
To: netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net-next 01/11] selftests: drv-net: Iperf3Runner: Support UDP and server side results
Date: Thu, 3 Dec 2026 16:05:11 -0800 [thread overview]
Message-ID: <20261204000521.3396802-2-mohsin.bashr@gmail.com> (raw)
In-Reply-To: <20261204000521.3396802-1-mohsin.bashr@gmail.com>
From: Mohsin Bashir <hmohsin@meta.com>
Iperf3Runner only runs TCP and reports results on the client. Tests that
rate limit traffic on the receive side need to send UDP at a given rate
and read the per-interval results on the server. Add a json option to
start_server() and udp_mbit, length and omit options to start_client().
The defaults keep the current command lines, so existing users are not
affected. start_server() now also stops the server if it does not start
listening in time.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Mohsin Bashir <hmohsin@meta.com>
---
.../selftests/drivers/net/lib/py/load.py | 49 ++++++++++++++-----
1 file changed, 36 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/lib/py/load.py b/tools/testing/selftests/drivers/net/lib/py/load.py
index f337b576c4b4..97d91f55e11f 100644
--- a/tools/testing/selftests/drivers/net/lib/py/load.py
+++ b/tools/testing/selftests/drivers/net/lib/py/load.py
@@ -2,7 +2,7 @@
import re
import time
-import json
+import json as _json
from dataclasses import dataclass
from lib.py import ksft_pr, cmd, ip, rand_port, wait_port_listen
@@ -26,39 +26,62 @@ class Iperf3Runner:
self.server_ip = server_ip
self.client_ip = client_ip
- def _build_server(self):
+ def _build_server(self, json):
cmdline = f"iperf3 -s -1 -p {self.port}"
if self.server_ip:
cmdline += f" -B {self.server_ip}"
+ if json:
+ cmdline += " -J"
return cmdline
- def _build_client(self, streams, duration, reverse):
+ def _build_client(self, streams, duration, reverse, udp_mbit, length,
+ omit):
host = self.env.addr if self.server_ip is None else self.server_ip
cmdline = f"iperf3 -c {host} -p {self.port} -P {streams} -t {duration} -J"
if self.client_ip:
cmdline += f" -B {self.client_ip}"
if reverse:
cmdline += " --reverse"
+ if udp_mbit is not None:
+ cmdline += f" -u -b {udp_mbit}M"
+ if length is not None:
+ cmdline += f" -l {length}"
+ if omit:
+ cmdline += f" -O {omit}"
return cmdline
- def start_server(self):
+ def start_server(self, json=None):
"""
- Starts an iperf3 server with optional bind IP.
+ Starts an iperf3 server with optional bind IP. With @json the
+ server prints its results as JSON when the client is done,
+ including the bytes it received in each interval, or sent if the
+ client runs with @reverse.
"""
- cmdline = self._build_server()
+ cmdline = self._build_server(json)
proc = cmd(cmdline, background=True)
- wait_port_listen(self.port)
+ try:
+ wait_port_listen(self.port)
+ except Exception:
+ # Do not leave a server behind that waits for a client
+ proc.process(terminate=True, fail=False)
+ raise
time.sleep(0.1)
return proc
- def start_client(self, background=False, streams=1, duration=10, reverse=False):
+ def start_client(self, background=False, streams=1, duration=10, reverse=False,
+ udp_mbit=None, length=None, omit=0):
"""
- Starts the iperf3 client with the configured options.
+ Starts the iperf3 client with the configured options. TCP is used
+ unless @udp_mbit gives the UDP rate to send at, in Mbit/s. The
+ rate applies to each of the @streams. @length is the read/write
+ buffer size (the UDP payload size) and @omit the number of seconds
+ to run before measuring.
"""
- cmdline = self._build_client(streams, duration, reverse)
+ cmdline = self._build_client(streams, duration, reverse, udp_mbit,
+ length, omit)
kwargs = {"background": background, "host": self.env.remote}
if not background:
- kwargs["timeout"] = duration + 5
+ kwargs["timeout"] = duration + omit + 5
return cmd(cmdline, **kwargs)
def measure(self, reverse=False):
@@ -73,8 +96,8 @@ class Iperf3Runner:
if result.ret != 0:
raise RuntimeError("iperf3 failed to run successfully")
try:
- out = json.loads(result.stdout)
- except json.JSONDecodeError as exc:
+ out = _json.loads(result.stdout)
+ except _json.JSONDecodeError as exc:
raise ValueError("Failed to parse iperf3 JSON output") from exc
intervals = out.get("intervals", [])
--
2.53.1-Meta
next prev parent reply other threads:[~2026-12-04 0:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 0:05 [PATCH net-next 00/11] selftests: drv-net: Test tc-flower police offload Mohsin Bashir
2026-12-04 0:05 ` Mohsin Bashir [this message]
2026-12-05 0:15 ` [PATCH net-next 01/11] selftests: drv-net: Iperf3Runner: Support UDP and server side results netdev-bot+sashiko
2026-12-04 0:05 ` [PATCH net-next 02/11] selftests: drv-net: Add tc-flower police offload test Mohsin Bashir
2026-12-05 0:15 ` netdev-bot+sashiko
2026-12-04 0:05 ` [PATCH net-next 03/11] selftests: drv-net: tc_flower_police: Test that rules do not leak Mohsin Bashir
2026-12-05 0:15 ` netdev-bot+sashiko
2026-12-04 0:05 ` [PATCH net-next 04/11] selftests: drv-net: tc_flower_police: Test the policed rate and its scope Mohsin Bashir
2026-12-05 0:15 ` netdev-bot+sashiko
2026-12-04 0:05 ` [PATCH net-next 05/11] selftests: drv-net: tc_flower_police: Test destination prefix rules Mohsin Bashir
2026-12-05 0:15 ` netdev-bot+sashiko
2026-12-04 0:05 ` [PATCH net-next 06/11] selftests: drv-net: tc_flower_police: Test police parameters Mohsin Bashir
2026-12-05 0:15 ` netdev-bot+sashiko
2026-12-04 0:05 ` [PATCH net-next 07/11] selftests: drv-net: tc_flower_police: Test multiple policers Mohsin Bashir
2026-12-05 0:15 ` netdev-bot+sashiko
2026-12-04 0:05 ` [PATCH net-next 08/11] selftests: drv-net: tc_flower_police: Test rule removal Mohsin Bashir
2026-12-05 0:15 ` netdev-bot+sashiko
2026-12-04 0:05 ` [PATCH net-next 09/11] selftests: drv-net: tc_flower_police: Test policing across reconfiguration Mohsin Bashir
2026-12-05 0:15 ` netdev-bot+sashiko
2026-12-04 0:05 ` [PATCH net-next 10/11] selftests: drv-net: tc_flower_police: Test policing with ntuple steering Mohsin Bashir
2026-12-05 0:15 ` netdev-bot+sashiko
2026-12-04 0:05 ` [PATCH net-next 11/11] selftests: drv-net: tc_flower_police: Test policing with RSS contexts Mohsin Bashir
2026-12-05 0:15 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204000521.3396802-2-mohsin.bashr@gmail.com \
--to=mohsin.bashr@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.