Repository navigation
net: hold a forward test's port on the wildcard address, so macOS binds the forward - #796
Merged
Merged
Conversation
…ds the forward Link::forward_on_a_held_port held 127.0.0.1:P with SO_REUSEADDR and the NAT forward then bound 127.0.0.1:P. Linux allows that while the hold is not listening; macOS refuses an identical second bind unless both sockets set SO_REUSEPORT, so the five NIC restart/drop port-forward tests failed there with "the forward never listened". Holding 0.0.0.0:P lets the forward bind 127.0.0.1:P on both systems, and the kernel still hands the held port to no other test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
steigr
marked this pull request as ready for review
November 20, 2026 15:06
Owner
|
join us on SGUG discord #emulation please. it would be nice to chat sometime. |
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.
On macOS, five port-forward tests fail every run with "the forward never listened":
dev::{bcm5701,daynaport,ioc3::eth,seeq8003}::tests::a_restart_keeps_the_port_forwardsdev::mec::tests::a_dropped_mec_frees_its_port_forwardsLink::forward_on_a_held_portheld127.0.0.1:Pwith SO_REUSEADDR, without listening, and the NAT forward then bound the same127.0.0.1:PwithTcpListener::bind, which sets SO_REUSEADDR only. Linux allows this while the hold isn't listening. macOS (like the BSDs) refuses a second bind of the identical address and port unless both sockets set SO_REUSEPORT, but does let a specific address share a port with a wildcard bind.The helper now holds
0.0.0.0:P. A socket probe shows macOS and Linux both accept the forward's127.0.0.1:Pbind next to that hold, and neither handed the held port to any of 20,000 binds to port 0. So other tests still can't take the port. The forward listener is unchanged: adding SO_REUSEPORT there would let a second emulator bind the same forward port.Also adds a short note in
clanker/net/and its entry inclanker/INDEX.md.Tested on macOS: the five tests pass, and
cargo test --lib -- --skip dev::kona::back::tilesreports 4865 passed, 0 failed. Linux was checked only with the socket probe, not by running cargo tests.🤖 Generated with Claude Code