The TSO test occasionally fails with "No route to host" (EHOSTUNREACH) when connecting to the remote socat listener. This can happen when the neighbor resolution has not yet completed by the time the test attempts to connect, particularly in tunnel setups where neighbor entries may take slightly longer to establish.
Add a retry loop (up to 5 attempts with 0.5s delay) around the sock.connect() call to handle this transient condition gracefully. Signed-off-by: Xu Du <[email protected]> --- tools/testing/selftests/drivers/net/hw/tso.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/drivers/net/hw/tso.py b/tools/testing/selftests/drivers/net/hw/tso.py index bb675e3dac88..f792115adfb3 100755 --- a/tools/testing/selftests/drivers/net/hw/tso.py +++ b/tools/testing/selftests/drivers/net/hw/tso.py @@ -3,6 +3,7 @@ """Run the tools/testing/selftests/net/csum testsuite.""" +import errno import fcntl import socket import struct @@ -47,10 +48,20 @@ def run_one_stream(cfg, ipver, remote_v4, remote_v6, should_lso): if ipver == "4": sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect((remote_v4, port)) + sockaddr = (remote_v4, port) else: sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) - sock.connect((remote_v6, port)) + sockaddr = (remote_v6, port) + + for attempt in range(5): + try: + sock.connect(sockaddr) + break + except OSError as e: + if e.errno == errno.EHOSTUNREACH and attempt < 4: + time.sleep(0.5) + else: + raise # Small send to make sure the connection is working. sock.send("ping".encode()) -- 2.53.0

