test.py: Keep the ad hoc tests' ports below Linux's ephemeral ports

With offsets of up to 30000, a port net/adhoc/limits listened on could
be one an outgoing connection was using, and the listen failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-30 11:53:44 +01:00
1 parent a0669ffbe4
commit d12e19ed35
1 file changed
+3 -2
+3 -2
View File
@@ -757,8 +757,9 @@ def flags_for(test):
return test_flags[test]
if test.startswith("net/adhoc/"):
# A new port offset each run: a connection the last run made with the same ports is still in TCP
# TIME_WAIT for a while, and connecting again fails.
return ADHOC_FLAGS + ["--port-offset=%d" % random.randrange(10000, 30000)]
# TIME_WAIT for a while, and connecting again fails. The tests' ports go up to 31000 (game mode's), and
# have to stay below Linux's ephemeral ports (32768 and up), which outgoing connections hold.
return ADHOC_FLAGS + ["--port-offset=%d" % random.randrange(1, 1700)]
return None
def is_pair_test(test):