Repository navigation
[release/17.0] Reject occupied loopback ports during endpoint allocation - #22037
Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
Mitch Denny (mitchdenny) wants to merge 1 commit into
Conversation
<!-- issue-pr-loop --> ## Description On macOS, `ProxylessEndpointPortAllocator.TryProbePort` reports an occupied loopback TCP port as available. An existing listener bound to `127.0.0.1:<port>` with `ReuseAddress` enabled does not prevent the allocator's exclusive wildcard bind to `0.0.0.0:<port>`. A later workload binding that exact loopback address fails with `Address already in use`; a proxy may meanwhile reach the existing listener. Probe both wildcard and loopback addresses in IPv4 and IPv6. Release the wildcard sockets before probing loopback to avoid detecting the probe's own sockets. Keep the existing best-effort error handling, allocation range, reservation tracking and disposal behavior. The regression holds an OS-assigned loopback socket open throughout the assertion, with TCP/UDP and IPv4/IPv6 coverage. No fixed port, timing margin, retry or test serialization is needed. Validation selected before execution: - Before the fix, `ProbeRejectsOccupiedLoopbackPorts` fails for TCP: expected unavailable, actual available. UDP control passes. - After the fix, `ProxylessEndpointPortAllocatorTests`: **15/15 passed**, zero skips; **2.24s wall / 0.0272 command vCPU-minutes**. Includes production free-port allocation and dependent reservation/exclusion tests. - Ran the exact source-linked allocator, `PortRange`, and test class on .NET 10.0.14 in an isolated net10.0 harness using xUnit v3 4.0.2 and shipped public endpoint types. Only internal `DcpOptions` range properties were shimmed. The repository-wide .NET 11 RC SDK is unavailable locally, so the original test-project build and full AppHost scenario remain for CI; these are not claimed validated. - Full diff reviewed for reuse, quality, efficiency and cleanup. Whitespace check passes. Test output swept: no unexpected exceptions or runtime errors. ## Checklist - Is this feature complete? - [x] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - [x] No (cherry picked from commit f02c7f8)
14 tasks
This comment has been minimized.
This comment has been minimized.
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-39-pr21961
branch
from
November 10, 2026 04:23
a5ae1e9 to
292a98d
Compare
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22037Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22037" |
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-39-pr21961
branch
from
November 10, 2026 04:25
292a98d to
a5ae1e9
Compare
Mitch Denny (mitchdenny)
marked this pull request as ready for review
November 10, 2026 05:10
Member
Author
|
Approved for inclusion in release/17.0. Do not merge yet. |
Contributor
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-39-pr21961
branch
from
November 10, 2026 06:06
a5ae1e9 to
6122bae
Compare
This comment has been minimized.
This comment has been minimized.
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-39-pr21961
branch
from
November 10, 2026 06:31
6122bae to
a5ae1e9
Compare
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-39-pr21961
branch
from
November 10, 2026 07:49
a5ae1e9 to
6122bae
Compare
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-39-pr21961
branch
from
November 10, 2026 08:41
6122bae to
a5ae1e9
Compare
Contributor
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
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.
Description
Backport of #21961 to
release/17.0(cherry-picked from f02c7f8 with no modifications).Layer 39 of 55 in the release/17.0 backport stack; stacked on #22036.
Backport recommendation: Yes — macOS could hand out a port already in use on loopback.
Validation: Stable patch IDs match. Builds/tests not run for this unchanged cherry-pick.
Backport of #21961
Checklist
<remarks />and<code />elements on your triple slash comments?