From 07bedfa64c6dc96ca9e8c880f3fc92d605ca225a Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Sun, 18 Oct 2026 12:58:43 +0300 Subject: [PATCH] tests: parent_ports tells an ephemeral port from the window by several On Linux the port windows lie within net.ipv4.ip_local_port_range, as the kernel honours no other, so the ephemeral port of a request the range does not apply to falls into the 50-port window now and then (CI saw 34001 in 33968-34017). The case now makes five such requests and wants one of them outside the window: bound to it, all would be in. Co-Authored-By: Claude Opus 5.5 --- tests/cases/parent_ports.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/cases/parent_ports.py b/tests/cases/parent_ports.py index 97aae0e..df26241 100644 --- a/tests/cases/parent_ports.py +++ b/tests/cases/parent_ports.py @@ -107,10 +107,16 @@ def run(t): "peer.port") t.in_range(port, MLOW, MHIGH, "CONNECT uses the range its rule sets") - # a plain GET matches the later rule, which sets no range - port = int_field(t.http(origin + "/echo", proxy=method_proxy), "peer.port") - t.not_in_range(port, MLOW, MHIGH, - "a method outside that rule keeps an ephemeral port") + # a plain GET matches the later rule, which sets no range. On Linux the + # window lies within the ephemeral range, so an ephemeral port falls in + # it now and then by chance: bound to the window every port would, so + # one of a few outside it tells them apart. + ports = [int_field(t.http(origin + "/echo", proxy=method_proxy), "peer.port") + for _ in range(5)] + outside = [p for p in ports if isinstance(p, int) and not MLOW <= p <= MHIGH] + t.ok(f"a method outside that rule keeps an ephemeral port ({ports})") if outside else \ + t.fail("a method outside that rule keeps an ephemeral port", + f"some outside {MLOW}-{MHIGH}", ports) # --- a range the platform cannot honour -------------------------------- # Linux ignores a range outside net.ipv4.ip_local_port_range, and any