summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/net/lib/py/utils.py
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2025-02-26 05:31:07 +0300
committerJakub Kicinski <kuba@kernel.org>2025-02-26 05:31:08 +0300
commit13f7e99943be0187eac0e234898cec82e64602fc (patch)
treeb3bd24168191dadf96d753d871fdada0b149f841 /tools/testing/selftests/net/lib/py/utils.py
parentad530283d3c8bb926a08bb1a14c8aa053de4bc2c (diff)
parentda87cabaf87702d43a016d255f11be5379892b6a (diff)
downloadlinux-13f7e99943be0187eac0e234898cec82e64602fc.tar.xz
Merge branch 'symmetric-or-xor-rss-hash'
Gal Pressman says: ==================== Symmetric OR-XOR RSS hash Add support for a new type of input_xfrm: Symmetric OR-XOR. Symmetric OR-XOR performs hash as follows: (SRC_IP | DST_IP, SRC_IP ^ DST_IP, SRC_PORT | DST_PORT, SRC_PORT ^ DST_PORT) Configuration is done through ethtool -x/X command. For mlx5, the default is already symmetric hash, this patch now exposes this to userspace and allows enabling/disabling of the feature. v5: https://lore.kernel.org/20250220113435.417487-1-gal@nvidia.com v4: https://lore.kernel.org/20250216182453.226325-1-gal@nvidia.com v3: https://lore.kernel.org/20250205135341.542720-1-gal@nvidia.com v2: https://lore.kernel.org/20250203150039.519301-1-gal@nvidia.com ==================== Link: https://patch.msgid.link/20250224174416.499070-1-gal@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/testing/selftests/net/lib/py/utils.py')
-rw-r--r--tools/testing/selftests/net/lib/py/utils.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
index d879700ef2b9..34470d65d871 100644
--- a/tools/testing/selftests/net/lib/py/utils.py
+++ b/tools/testing/selftests/net/lib/py/utils.py
@@ -185,20 +185,13 @@ def ethtool(args, json=None, ns=None, host=None):
return tool('ethtool', args, json=json, ns=ns, host=host)
-def rand_port():
+def rand_port(type=socket.SOCK_STREAM):
"""
- Get a random unprivileged port, try to make sure it's not already used.
+ Get a random unprivileged port.
"""
- for _ in range(1000):
- port = random.randint(10000, 65535)
- try:
- with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:
- s.bind(("", port))
- return port
- except OSError as e:
- if e.errno != errno.EADDRINUSE:
- raise
- raise Exception("Can't find any free unprivileged port")
+ with socket.socket(socket.AF_INET6, type) as s:
+ s.bind(("", 0))
+ return s.getsockname()[1]
def wait_port_listen(port, proto="tcp", ns=None, host=None, sleep=0.005, deadline=5):