AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 15 Bitcoin

test: use IP_PORTRANGE_HIGH on FreeBSD for dynamic port allocation

Public commit record

What the developer wrote

Authored by woltx

100/100 · Strong
test: use IP_PORTRANGE_HIGH on FreeBSD for dynamic port allocation

On FreeBSD, the default ephemeral port range (10000-65535) overlaps
with the test framework's static port range (11000-26000), causing
intermittent "address already in use" failures when tests use dynamic
port allocation (port=0).

Add a helper function that sets the IP_PORTRANGE/IPV6_PORTRANGE socket
option to IP_PORTRANGE_HIGH before binding, which requests ports from
the high range (49152-65535) instead. This range does not overlap with
the test framework's static ports.

Constants from FreeBSD's netinet/in.h and netinet6/in6.h:
- IP_PORTRANGE = 19 (for IPv4 sockets)
- IPV6_PORTRANGE = 14 (for IPv6 sockets)
- IP_PORTRANGE_HIGH = 1

Fixes: bitcoin/bitcoin#34331

Co-Authored-By: Vasil Dimov <vd@FreeBSD.org>
Co-Authored-By: MarcoFalke <*~=\`'#}+{/-|&$^_@721217.xyz>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a flaky test problem on FreeBSD. When Bitcoin Core's test software asked the operating system for any available network port, FreeBSD could hand back a port number that the test framework already planned to use elsewhere, causing 'address already in use' failures. The change tells FreeBSD to pick ports only from the high-numbered range (49152-65535), which does not overlap with the test framework's reserved ports. It is a test-only reliability improvement, not a security fix.

Recommended action

No security action needed. Treat as a normal test-framework reliability patch. FreeBSD CI/test runners may benefit from this change to reduce intermittent port-collision failures.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 15/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/15
Confidence 10/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.