Repository navigation
test(e2e): run the PortReservation child-bind tests off Linux - #2795
Merged
Merged
Conversation
child_binds_a_reservation and child_rebinds_a_reservation_after_a_restart now run off Linux too. On macOS they fail if PortReservation holds its socket, which blocks the child's SO_REUSEADDR bind there. A new test, bind_to_port_zero_never_lands_below_ephemeral_low, checks the premise UdpPortClaim rests on: the kernel's bind(…:0) never hands out a port below ephemeral_low(). The test module takes Ipv4Addr, SocketAddr and the socket2 types from `use super::*`, so no import needs a cfg gate. Part of #2787. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
…rt docs udp_bind_to_port_zero_never_lands_below_ephemeral_low makes UDP binds only. UdpPortClaim's premise is about UDP, and macOS hands out TCP ports in sequence (net.inet.tcp.randomize_ports is 0), so the TCP binds added little. The ZERO_BINDS doc gives the detection numbers. The ports module doc and the PortReservation doc say that only Linux holds a reserved TCP port. On macOS a held socket blocks the child's SO_REUSEADDR bind, so off Linux the reservation releases it. The child-bind tests run off Linux too: child_binds_a_held_reservation and held_reservation_survives_a_child_restart are named child_binds_a_reservation and child_rebinds_a_reservation_after_a_restart. The CHANGELOG entry says which two tests run off Linux. Part of #2787. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust, Solidity Rust / code-coverage/cargo-llvm-cov
View coverage of the 3 most impacted files.
Solidity / code-coverage/forge
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Gas snapshotNo gas changes vs base. |
thiras
approved these changes
Oct 31, 2026
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.
Part of #2787: items 1, 2 and 3b. 3a stays open.
1.
PortReservationis tested off Linux.child_binds_a_reservationandchild_rebinds_a_reservation_after_a_restart(formerlychild_binds_a_held_reservationandheld_reservation_survives_a_child_restart) were Linux-only. They now run off Linux too. Off Linux,PortReservation::tcp()releases its socket when it is made (ports.rs:75). On macOS that release is required, because a held socket blocks the child'sSO_REUSEADDRbind. Before, changing that line to hold the socket passed every test and broke every macOS anvil-e2e journey. Theportsmodule doc and thePortReservationdoc now say that only Linux holds a reserved TCP port.held_reservation_is_never_an_ephemeral_bindandreservation_refuses_a_plain_bindstay Linux-only, because they check the Linux hold.2.
ephemeral_low()is checked against the kernel.udp_bind_to_port_zero_never_lands_below_ephemeral_lowmakes 1,000 UDPbind(127.0.0.1:0)calls and fails if any port is belowephemeral_low(). That is the premiseUdpPortClaimrests on. Off Linux,ephemeral_low()is a fixed 49152. On a host whose range starts 100 ports lower, a run lands below it about six times. On Linux the test checks the/procread. UDP only, because the premise is about UDP and macOS hands out TCP ports in sequence.3b. The imports are trimmed.
use super::*already brings inIpv4Addr,SocketAddrand the socket2 types, so the header isuse std::net::{TcpListener, UdpSocket};with no cfg gates. OnlyEPHEMERAL_PICKSstays Linux-only.Not in this PR. 3a (the UDP-exhaustion and
/procread-failure error paths) stays open on #2787. 3c is settled without a macOS CI job: the macOScargo-clippypre-commit hook guards this file.Verified on macOS (aarch64-apple-darwin):
cargo nextest run -p decdn-e2e -E 'binary(decdn_e2e)': 52/52 pass.ports.rs:75changed to_socket: Some(socket), both child-bind tests fail withEADDRINUSE(errno 48). With the change reverted, they pass.env CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targetsandcargo fmt -- --checkpass, and both commits ran every pre-commit hook.clippyandtestCI jobs cover it.🤖 Generated with Claude Code