linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] selftests: drv-net: wait for iperf client to stop sending
@ 2025-07-22 12:26 Nimrod Oren
  2025-07-23 15:37 ` Simon Horman
  2025-07-24  2:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Nimrod Oren @ 2025-07-22 12:26 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Shuah Khan, Willem de Bruijn, netdev,
	linux-kselftest
  Cc: Nimrod Oren, Gal Pressman, Carolina Jubran

A few packets may still be sent out during the termination of iperf
processes. These late packets cause failures in rss_ctx.py when they
arrive on queues expected to be empty.

Example failure observed:

  Check failed 2 != 0 traffic on inactive queues (context 1):
    [0, 0, 1, 1, 386385, 397196, 0, 0, 0, 0, ...]

  Check failed 4 != 0 traffic on inactive queues (context 2):
    [0, 0, 0, 0, 2, 2, 247152, 253013, 0, 0, ...]

  Check failed 2 != 0 traffic on inactive queues (context 3):
    [0, 0, 0, 0, 0, 0, 1, 1, 282434, 283070, ...]

To avoid such failures, wait until all client sockets for the requested
port are either closed or in the TIME_WAIT state.

Fixes: 847aa551fa78 ("selftests: drv-net: rss_ctx: factor out send traffic and check")
Signed-off-by: Nimrod Oren <noren@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Carolina Jubran <cjubran@nvidia.com>
---
Changelog:
v2:
- Replace fixed sleep with logic that waits for client sockets to close.
- Update commit title and message to reflect new approach.
v1: https://lore.kernel.org/all/20250629111812.644282-1-noren@nvidia.com/
---
 .../selftests/drivers/net/lib/py/load.py      | 23 +++++++++++++++----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/drivers/net/lib/py/load.py b/tools/testing/selftests/drivers/net/lib/py/load.py
index d9c10613ae67..44151b7b1a24 100644
--- a/tools/testing/selftests/drivers/net/lib/py/load.py
+++ b/tools/testing/selftests/drivers/net/lib/py/load.py
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
+import re
 import time
 
 from lib.py import ksft_pr, cmd, ip, rand_port, wait_port_listen
@@ -10,12 +11,11 @@ class GenerateTraffic:
 
         self.env = env
 
-        if port is None:
-            port = rand_port()
-        self._iperf_server = cmd(f"iperf3 -s -1 -p {port}", background=True)
-        wait_port_listen(port)
+        self.port = rand_port() if port is None else port
+        self._iperf_server = cmd(f"iperf3 -s -1 -p {self.port}", background=True)
+        wait_port_listen(self.port)
         time.sleep(0.1)
-        self._iperf_client = cmd(f"iperf3 -c {env.addr} -P 16 -p {port} -t 86400",
+        self._iperf_client = cmd(f"iperf3 -c {env.addr} -P 16 -p {self.port} -t 86400",
                                  background=True, host=env.remote)
 
         # Wait for traffic to ramp up
@@ -56,3 +56,16 @@ class GenerateTraffic:
             ksft_pr(">> Server:")
             ksft_pr(self._iperf_server.stdout)
             ksft_pr(self._iperf_server.stderr)
+        self._wait_client_stopped()
+
+    def _wait_client_stopped(self, sleep=0.005, timeout=5):
+        end = time.monotonic() + timeout
+
+        live_port_pattern = re.compile(fr":{self.port:04X} 0[^6] ")
+
+        while time.monotonic() < end:
+            data = cmd("cat /proc/net/tcp*", host=self.env.remote).stdout
+            if not live_port_pattern.search(data):
+                return
+            time.sleep(sleep)
+        raise Exception(f"Waiting for client to stop timed out after {timeout}s")
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] selftests: drv-net: wait for iperf client to stop sending
  2025-07-22 12:26 [PATCH net v2] selftests: drv-net: wait for iperf client to stop sending Nimrod Oren
@ 2025-07-23 15:37 ` Simon Horman
  2025-07-24  2:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-07-23 15:37 UTC (permalink / raw)
  To: Nimrod Oren
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Shuah Khan, Willem de Bruijn, netdev,
	linux-kselftest, Gal Pressman, Carolina Jubran

On Tue, Jul 22, 2025 at 03:26:55PM +0300, Nimrod Oren wrote:
> A few packets may still be sent out during the termination of iperf
> processes. These late packets cause failures in rss_ctx.py when they
> arrive on queues expected to be empty.
> 
> Example failure observed:
> 
>   Check failed 2 != 0 traffic on inactive queues (context 1):
>     [0, 0, 1, 1, 386385, 397196, 0, 0, 0, 0, ...]
> 
>   Check failed 4 != 0 traffic on inactive queues (context 2):
>     [0, 0, 0, 0, 2, 2, 247152, 253013, 0, 0, ...]
> 
>   Check failed 2 != 0 traffic on inactive queues (context 3):
>     [0, 0, 0, 0, 0, 0, 1, 1, 282434, 283070, ...]
> 
> To avoid such failures, wait until all client sockets for the requested
> port are either closed or in the TIME_WAIT state.
> 
> Fixes: 847aa551fa78 ("selftests: drv-net: rss_ctx: factor out send traffic and check")
> Signed-off-by: Nimrod Oren <noren@nvidia.com>
> Reviewed-by: Gal Pressman <gal@nvidia.com>
> Reviewed-by: Carolina Jubran <cjubran@nvidia.com>
> ---
> Changelog:
> v2:
> - Replace fixed sleep with logic that waits for client sockets to close.
> - Update commit title and message to reflect new approach.
> v1: https://lore.kernel.org/all/20250629111812.644282-1-noren@nvidia.com/

Thanks, I believe that this addresses the review of v1
using the wait logic mentioned above.

Reviewed-by: Simon Horman <horms@kernel.org>

> ---
>  .../selftests/drivers/net/lib/py/load.py      | 23 +++++++++++++++----
>  1 file changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/drivers/net/lib/py/load.py b/tools/testing/selftests/drivers/net/lib/py/load.py
> index d9c10613ae67..44151b7b1a24 100644
> --- a/tools/testing/selftests/drivers/net/lib/py/load.py
> +++ b/tools/testing/selftests/drivers/net/lib/py/load.py
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0
>  
> +import re
>  import time
>  
>  from lib.py import ksft_pr, cmd, ip, rand_port, wait_port_listen
> @@ -10,12 +11,11 @@ class GenerateTraffic:
>  
>          self.env = env
>  
> -        if port is None:
> -            port = rand_port()
> -        self._iperf_server = cmd(f"iperf3 -s -1 -p {port}", background=True)
> -        wait_port_listen(port)
> +        self.port = rand_port() if port is None else port
> +        self._iperf_server = cmd(f"iperf3 -s -1 -p {self.port}", background=True)
> +        wait_port_listen(self.port)
>          time.sleep(0.1)
> -        self._iperf_client = cmd(f"iperf3 -c {env.addr} -P 16 -p {port} -t 86400",
> +        self._iperf_client = cmd(f"iperf3 -c {env.addr} -P 16 -p {self.port} -t 86400",
>                                   background=True, host=env.remote)
>  
>          # Wait for traffic to ramp up
> @@ -56,3 +56,16 @@ class GenerateTraffic:
>              ksft_pr(">> Server:")
>              ksft_pr(self._iperf_server.stdout)
>              ksft_pr(self._iperf_server.stderr)
> +        self._wait_client_stopped()
> +
> +    def _wait_client_stopped(self, sleep=0.005, timeout=5):
> +        end = time.monotonic() + timeout
> +
> +        live_port_pattern = re.compile(fr":{self.port:04X} 0[^6] ")

I do have a concern about false positives with this pattern,
given that it may match anywhere on a line.

But it is a start and I don't think that concern needs to block progress.

> +
> +        while time.monotonic() < end:
> +            data = cmd("cat /proc/net/tcp*", host=self.env.remote).stdout
> +            if not live_port_pattern.search(data):
> +                return
> +            time.sleep(sleep)
> +        raise Exception(f"Waiting for client to stop timed out after {timeout}s")

+1 for the timeout mechanism.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] selftests: drv-net: wait for iperf client to stop sending
  2025-07-22 12:26 [PATCH net v2] selftests: drv-net: wait for iperf client to stop sending Nimrod Oren
  2025-07-23 15:37 ` Simon Horman
@ 2025-07-24  2:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-24  2:00 UTC (permalink / raw)
  To: Nimrod Oren
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, shuah, willemb,
	netdev, linux-kselftest, gal, cjubran

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 22 Jul 2025 15:26:55 +0300 you wrote:
> A few packets may still be sent out during the termination of iperf
> processes. These late packets cause failures in rss_ctx.py when they
> arrive on queues expected to be empty.
> 
> Example failure observed:
> 
>   Check failed 2 != 0 traffic on inactive queues (context 1):
>     [0, 0, 1, 1, 386385, 397196, 0, 0, 0, 0, ...]
> 
> [...]

Here is the summary with links:
  - [net,v2] selftests: drv-net: wait for iperf client to stop sending
    https://git.kernel.org/netdev/net/c/869413825088

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-24  1:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22 12:26 [PATCH net v2] selftests: drv-net: wait for iperf client to stop sending Nimrod Oren
2025-07-23 15:37 ` Simon Horman
2025-07-24  2:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).