Skip to content

Commit 8694138

Browse files
nimrod-orenkuba-moo
authored andcommitted
selftests: drv-net: wait for iperf client to stop sending
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: 847aa55 ("selftests: drv-net: rss_ctx: factor out send traffic and check") Signed-off-by: Nimrod Oren <[email protected]> Reviewed-by: Gal Pressman <[email protected]> Reviewed-by: Carolina Jubran <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 14822f7 commit 8694138

File tree

1 file changed

+18
-5
lines changed
  • tools/testing/selftests/drivers/net/lib/py

1 file changed

+18
-5
lines changed

tools/testing/selftests/drivers/net/lib/py/load.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
22

3+
import re
34
import time
45

56
from lib.py import ksft_pr, cmd, ip, rand_port, wait_port_listen
@@ -10,12 +11,11 @@ def __init__(self, env, port=None):
1011

1112
self.env = env
1213

13-
if port is None:
14-
port = rand_port()
15-
self._iperf_server = cmd(f"iperf3 -s -1 -p {port}", background=True)
16-
wait_port_listen(port)
14+
self.port = rand_port() if port is None else port
15+
self._iperf_server = cmd(f"iperf3 -s -1 -p {self.port}", background=True)
16+
wait_port_listen(self.port)
1717
time.sleep(0.1)
18-
self._iperf_client = cmd(f"iperf3 -c {env.addr} -P 16 -p {port} -t 86400",
18+
self._iperf_client = cmd(f"iperf3 -c {env.addr} -P 16 -p {self.port} -t 86400",
1919
background=True, host=env.remote)
2020

2121
# Wait for traffic to ramp up
@@ -56,3 +56,16 @@ def stop(self, verbose=None):
5656
ksft_pr(">> Server:")
5757
ksft_pr(self._iperf_server.stdout)
5858
ksft_pr(self._iperf_server.stderr)
59+
self._wait_client_stopped()
60+
61+
def _wait_client_stopped(self, sleep=0.005, timeout=5):
62+
end = time.monotonic() + timeout
63+
64+
live_port_pattern = re.compile(fr":{self.port:04X} 0[^6] ")
65+
66+
while time.monotonic() < end:
67+
data = cmd("cat /proc/net/tcp*", host=self.env.remote).stdout
68+
if not live_port_pattern.search(data):
69+
return
70+
time.sleep(sleep)
71+
raise Exception(f"Waiting for client to stop timed out after {timeout}s")

0 commit comments

Comments
 (0)