[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250216182453.226325-5-gal@nvidia.com>
Date: Sun, 16 Feb 2025 20:24:52 +0200
From: Gal Pressman <gal@...dia.com>
To: "David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>
CC: <netdev@...r.kernel.org>, Eric Dumazet <edumazet@...gle.com>, Paolo Abeni
<pabeni@...hat.com>, Simon Horman <horms@...nel.org>, Jonathan Corbet
<corbet@....net>, Tony Nguyen <anthony.l.nguyen@...el.com>, Przemek Kitszel
<przemyslaw.kitszel@...el.com>, Andrew Lunn <andrew+netdev@...n.ch>, "Tariq
Toukan" <tariqt@...dia.com>, Edward Cree <ecree.xilinx@...il.com>, Ahmed Zaki
<ahmed.zaki@...el.com>, <linux-doc@...r.kernel.org>, Gal Pressman
<gal@...dia.com>, Nimrod Oren <noren@...dia.com>
Subject: [PATCH net-next v3 4/5] selftests: drv-net: Introduce a function that checks whether a port is available on remote host
Add a function that checks whether a port is available on the remote
host, this will be used downstream to verify that ports that were
allocated locally are also available on the remote side.
Reviewed-by: Nimrod Oren <noren@...dia.com>
Signed-off-by: Gal Pressman <gal@...dia.com>
---
tools/testing/selftests/net/lib/py/utils.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
index 5a13f4fd3784..903cc042ed0e 100644
--- a/tools/testing/selftests/net/lib/py/utils.py
+++ b/tools/testing/selftests/net/lib/py/utils.py
@@ -123,6 +123,13 @@ def ethtool(args, json=None, ns=None, host=None):
return tool('ethtool', args, json=json, ns=ns, host=host)
+def check_port_available_remote(port, host):
+ """
+ Check if a port is available on remote host.
+ Raise exception if not available.
+ """
+ cmd(f"python3 -c 'import socket; s=socket.socket(socket.AF_INET6, socket.SOCK_STREAM); s.bind((\"\", {port}))'", host=host)
+
def rand_port():
"""
Get a random unprivileged port.
--
2.40.1
Powered by blists - more mailing lists