Repository navigation
[Test] Pick spec ports outside the ephemeral port range - #291
Merged
Merged
Conversation
find_available_port bound to port 0, read the kernel-assigned ephemeral port and released it before the plugin bound to it. In the meantime the kernel could hand the same ephemeral port to another socket, making the plugin fail with "could not bind to 0.0.0.0:<port>; Address already in use" (seen in scheduled CI on PROXY protocol v1 spec, port 41141). Pick a random port below the Linux/macOS ephemeral ranges instead, retrying until one is bindable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Changelog and Version ManagementNo changelog or version changes detected. You can either update them manually or use a comment command to update them automatically on merge:
Omit the entry line to use the PR title. If multiple commands are posted, the last one wins. |
jsvd
marked this pull request as ready for review
November 4, 2026 11:50
jsvd
added a commit
that referenced
this pull request
Nov 4, 2026
get_port picked a random port in 10000..65535, checked it was free and
released it before the plugin bound it. Ports above 32767 are in the
kernel's ephemeral range, so in between another socket could be handed
the same port ("could not bind ... Address already in use").
Pick from 10000..32767 instead, below both the Linux (32768-60999) and
macOS (49152-65535) ephemeral ranges.
Equivalent of the main-branch fix in #291, adapted to 6.x's get_port.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
find_available_portbound port 0, read the assigned port and released it; the plugin bound it later. That port is in the kernel's ephemeral range, so in between it could be handed to another socket (could not bind to 0.0.0.0:41141; Address already in use).The spec helper now picks a random port in 1024..32767 (below both the Linux and macOS ephemeral ranges) and retries until one binds. Spec-only change.
How to test this PR locally
./gradlew vendor && bundle exec rspec. Not reproducible on macOS (different ephemeral range); the PROXY v1 spec and other pipeline specs pass consistently. Two specs (:413,:895) fail locally on macOS on unmodified main too and are unrelated.Related issues
Scheduled CI on main (9.current): https://github.com/logstash-plugins/logstash-input-tcp/actions/runs/37903569094
Note: #238 also touches
find_available_portand may conflict textually.🤖 Generated with Claude Code