Repository navigation
IPv6: per-probe sockets on FreeBSD/NetBSD; remove the inter-probe delay (#12) - #98
Merged
Merged
Conversation
…ay floor Extend the per-probe send-socket strategy (previously macOS-only) to FreeBSD and NetBSD for the IPv6 path, so a fast BSD host can no longer collapse an IPv6 trace to a single hop the way macOS could (issue #12). There is no IPv4-style IP_HDRINCL for IPv6, so a fresh socket per probe is the deterministic fix. The platform set is now a single source of truth: a new build.rs defines the `per_probe_send` cfg (macOS/FreeBSD/NetBSD), replacing the scattered cfg(target_os = "macos") gates in run_icmp/run_udp/run_tcp and the UDP SO_REUSEADDR gate. Linux keeps one shared socket (its sendto never raced). With IPv4 on IP_HDRINCL and IPv6 per-probe across all BSD-derived platforms, every send path is deterministic by construction, so the 500us apply_rate_limit floor is removed entirely; only the explicit --rate delay remains, and apply_rate_limit_explicit is folded back into apply_rate_limit. Validation: builds + clippy -D warnings on Linux (per_probe_send off) and with per_probe_send forced on (type-checks the BSD path locally); 227 unit tests pass; FreeBSD/macOS CI build+clippy+the raw-socket runtime test cover the per_probe_send platforms. A live IPv6 trace on FreeBSD/NetBSD is the recommended pre-release check.
There was a problem hiding this comment.
Pull request overview
This PR completes the IPv6 send-path fix for issue #12 by extending the per-probe socket strategy (previously macOS-only) to FreeBSD/NetBSD, and removes the interim 500µs inter-probe delay now that all send paths are intended to be deterministic.
Changes:
- Introduces a
per_probe_sendcfg (macOS/FreeBSD/NetBSD) to gate per-probe socket creation for IPv6 sends. - Updates the IPv6 ICMP/UDP/TCP loops to use per-probe sockets under
per_probe_send, and removes the 500µs platform floor fromapply_rate_limit. - Updates UDP socket binding behavior (
SO_REUSEADDR) and documentation (ROADMAP/CHANGELOG) to reflect the new strategy.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/trace/engine.rs | Switches IPv6 send loops to per_probe_send per-probe sockets and removes the old 500µs floor delay. |
| src/probe/udp.rs | Gates SO_REUSEADDR on per_probe_send to support rapid per-probe port rebinds. |
| build.rs | Adds build-script-defined per_probe_send cfg intended to be the single source of truth for per-probe send platforms. |
| ROADMAP.md | Marks the IPv6 determinism work and delay removal as completed. |
| CHANGELOG.md | Documents deterministic send behavior across IPv4 (HDRINCL) and IPv6 (per-probe sockets on BSD-derived platforms) and the removal of the 500µs delay. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+11
to
+15
| println!("cargo::rustc-check-cfg=cfg(per_probe_send)"); | ||
| let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); | ||
| if matches!(target_os.as_str(), "macos" | "freebsd" | "netbsd") { | ||
| println!("cargo::rustc-cfg=per_probe_send"); | ||
| } |
The IPv6 PMTUD probe still sends on the shared ICMP socket (a single isolated probe per round, so not subject to the back-to-back stale-TTL race). Reword the CHANGELOG and ROADMAP so "deterministic / race-free" describes the rapid probe sweeps rather than literally every send.
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.
Summary
Completes the #12 send-path work on the IPv6 side. IPv4 is already race-free via
IP_HDRINCL(#97); this extends the per-probe send-socket strategy — previously macOS-only — to FreeBSD and NetBSD for IPv6, so a fast BSD host can no longer collapse an IPv6 trace to a single hop. There is no IPv4-styleIP_HDRINCLfor IPv6, so sending each probe from a fresh socket (one datagram, one hop limit) is the deterministic fix.With this, every send path is deterministic by construction — IPv4 via
IP_HDRINCL, IPv6 via per-probe sockets on all BSD-derived platforms — so the interim 500µs delay is removed.What changed
build.rsdefines aper_probe_sendcfg (macOS/FreeBSD/NetBSD) as the single source of truth for "platforms whose asyncsendtoneeds a fresh socket per probe." It replaces the scatteredcfg(target_os = "macos")gates inrun_icmp/run_udp/run_tcpand the UDPSO_REUSEADDRgate. Linux is excluded — itssendtonever exhibited the race — and keeps one shared socket.SO_REUSEADDRfor rapid re-bind).apply_rate_limitfloor. No path needs it anymore; only the explicit--ratedelay remains.apply_rate_limit_explicitis folded back intoapply_rate_limit.--source-ipfail-fast bind and correlation behavior are unchanged.Validation
per_probe_sendoff → shared path, unchanged): build,clippy --all-targets -D warnings, fmt, 227 tests.RUSTFLAGS='--cfg per_probe_send'— the FreeBSD/NetBSD per-probe blocks compile and lint clean against the cross-platform socket APIs.per_probe_sendpath on those real toolchains; the FreeBSD job also runs the existing privileged raw-socket runtime test, confirming raw sends work in that environment.cfgextension of the proven macOS path, but a real IPv6 trace is the final confirmation. I couldn't runtime-test IPv6 loopback reliably in CI VMs without risking false failures.Notes
This is the last of the three pre-release send-path follow-ups; the ROADMAP section is now fully checked off. Ready for review — not auto-merged.