Repository navigation
PMTUD DF cleanup, PMTUD tick lock, and UDP header-only ICMP quotes - #176
Merged
Merged
Conversation
RFC 792 only requires routers to quote 8 bytes past the IP header, which for a UDP probe is the header alone, without the payload carrying the probe id. Those replies were dropped. Recover the sequence from the quoted UDP checksum instead: every other byte it covers is known, and the one's-complement sum is linear in the sequence word.
On Linux and Windows ordinary IPv6 probes share the PMTUD probe's send socket, and the DONTFRAG option set for the size probe stayed on for them. set_dont_fragment now takes an on/off flag and the PMTUD send clears it again where the socket is shared. The per-tick PMTUD readiness check took the session write lock (which bumps the TUI render generation) just to read the phase; it now reads first and writes only when the search starts.
This was referenced Nov 13, 2026
# Conflicts: # CHANGELOG.md
lance0
marked this pull request as ready for review
November 14, 2026 20:25
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.
Three items deferred from #171: PMTUD Don't Fragment handling, the PMTUD per-tick write lock, and UDP quotes that contain only the transport header.
UDP replies that quote only the 8-byte UDP header
Symptom. RFC 792 only requires a router to quote the IP header plus 8 bytes of the original datagram. For a UDP probe that is the UDP header alone. The probe id lives in the payload (sequence plus
TTLmagic), so every UDP parser required at least 14 bytes past the IP header and dropped these replies. The hop showed as a timeout. This affected IPv4 raw, IPv4 DGRAM and IPv6.Fix. The quoted UDP checksum still covers the payload. Every other byte it covers is known: the pseudo-header from the quoted IP header, the ports and length from the quoted UDP header, and the fixed payload pattern for that length. The one's-complement sum is linear, so
sequence = ~quoted_checksum +' checksum(sequence = 0). The result is checked by recomputing the checksum, and against any payload bytes the router did quote. Quotes with 14 bytes or more still go through the existing magic-byte path unchanged. A quoted checksum of 0 (IPv4 "no checksum") is rejected.Known limit (marked with a
ponytail:comment). A short quote has no magic bytes, so a header-only quote of another program's UDP also decodes to some sequence. It is credited only if it matches a pending probe. With one target and a source port outside ttl's flow range, the receiver's fallbacks leave the sequence as the only filter, so the chance is roughly the number of in-flight probes out of 65536 per stray quote. A stray quote whose destination is a target is also logged as a late reply in recordings. A per-run payload nonce, or checking the quoted destination port against the decoded TTL, would close that gap if it ever matters. RFC 4884 routers that pad a short quote to 128 bytes with zeros are still dropped, because the magic check sees zeros there.PMTUD left
IPV6_DONTFRAGon the shared send socketVerified on master.
IP_HDRINCLheader and ordinary probes do not (see the live check below).set_dont_fragmentwas never undone, so every ordinary probe after the first PMTUD probe went out withIPV6_DONTFRAG=1. In practice the impact was small: IPv6 has no on-wire DF bit, and--sizeconflicts with--pmtud, so ordinary probes stay small. It was still state leaking into probes that never asked for it.Fix.
set_dont_fragmentnow takes an on/off flag on every platform.send_pmtud_probe_icmpclears the flag right after the send, on both the success and error paths. The clear is limited tocfg(not(per_probe_send)), so the BSDs keep their current behavior and are not exposed to their asynchronous-send behavior.PMTUD write-locked the session every tick
check_pmtud_readytookstate.write()every tick, even when only reading the phase or with no destination yet. Each write guard bumpsrender_generation. The tick's own sent counters also write, so the visible cost was small, but the check now reads first and takes the write lock only for the WaitingForDestination to Searching transition. It rechecksdest_ttland the phase under the write lock in case a stats reset ran in between.Tests (each fails on the pre-fix code)
probe::correlate::tests::udp_quote_of_header_only_correlates: builds real probes withbuild_udp_payload_sized, usingbuild_udp_datagramfor IPv4 and a kernel-style checksum for IPv6. It covers payload lengths 8, 32, 33 (odd) and 1472, and ProbeIds including (1,0) and (255,255). It quotes only the 8-byte header and parses via IPv4 raw, IPv4 DGRAM and IPv6. On master it panics at the first case (dropped).trace::engine::tests::check_pmtud_ready_writes_only_on_phase_change:render_generationmust not move for no-destination, Searching or Complete, and the search must still start. On master it fails with "WaitingForDestination took a write lock".trace::engine::tests::pmtud_probe_leaves_shared_socket_without_dontfrag(Linux): an unprivileged IPv6 UDP socket stands in for the shared socket, andgetsockopt(IPV6_DONTFRAG)must be 0 after a PMTUD send. Without the clear it fails with "IPV6_DONTFRAG left set on the shared send socket".Live check (Docker,
NET_RAW, master vs branch release builds,--pmtud -c 10 -i 0.3)IPv4 to 1.1.1.1, tcpdump of outgoing echo requests (identical on master and branch, so IPv4 was not affected):
IPv6 to 2606:4700:4700::1111,
strace -e setsockopt:The IPv6
--pmtud --jsonresults are the same on both builds (dest_ttl 8, same search bounds).Gates
cargo fmt --check,cargo clippy --all-targets -- -D warnings, the same with--no-default-features, the same withRUSTFLAGS='--cfg per_probe_send',RUSTDOCFLAGS=-D warnings cargo doc, andcargo test(all passing).Not verified here
set_dont_fragmentsignature change. They cannot be cross-compiled locally (C dependencies), so CI is the check. NetBSD has no CI runner, and its change is a one-lineonflag.