Repository navigation
docs(proposal): TPROXY capture for UDP (038) - #923
Merged
Merged
Conversation
A pod may have at most one UDP service routed to it. #914 made that choice principled — heaviest live backend, weight:0 honoured as drain, the discarded shapes counted rather than dropped — but the limit itself is unchanged, and it is not fixable in the control plane. The cause is that the capture path destroys the information needed to tell one service from another. TCP recovers the pre-DNAT destination via use_original_dst; UDP has no equivalent. Envoy never reads IP_RECVORIGDSTADDR, original_dst is structurally TCP-only, DestinationPortInput is the listening socket's own port, and the five UdpMatchingData inputs cannot distinguish two services behind a REDIRECT. So #873's suggested fix does not work on either half: udp_proxy has no weighted route action in any version (its matcher's terminal action has exactly one field, `cluster`), and switching to `matcher` buys nothing while the input carries no service identity. This proposes TPROXY instead, which leaves the IP header intact so ipi_addr still carries the ClusterIP. Three of four premises were verified by experiment before writing this, in a netns with no aether code: TPROXY -> matcher arm A (saw the ClusterIP), reply delivered REDIRECT -> matcher arm B, reply delivered VIA CONNTRACK UN-DNAT TPROXY with the listener off the service port -> nothing delivered The REDIRECT row is the control that makes the first row mean something, and it also explains why this was never noticed: REDIRECT produces working traffic with lost routing information, because conntrack repairs the reply. The third row forces the design. Envoy's sendmsg never reads self_ip->port(), so a reply's source port is always the bound port, and a connected UDP client drops anything else — a port-rewriting TPROXY would give matching that works and traffic that silently fails one way. Hence: preserve the dport, one transparent listener per distinct UDP service port, destination_ip disambiguating within it. The fourth premise is NOT established and Phase 0 exists to settle it: aether binds capture listeners INTO the pod netns via network_namespace_filepath, and the spike could not test that — the rig gave contradictory results for the same nominal config, so neither reading is usable, and a rootless user namespace cannot host the test at all. If Phase 0 says no, the proposal stops and #916 stands as a documented limit. Also recorded: the Talos-host persistence risk flagged earlier is superseded. The rules live in the POD netns, created at pod setup and dying with it, so machine config never touches them. Refs #916, #873 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
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.
Refs #916, #873.
Why this exists
A pod may have at most one UDP service routed to it. #914 made that choice principled — heaviest live backend,
weight: 0honoured as drain, discarded shapes counted rather than silently dropped — but the limit itself is unchanged, and it is not fixable in the control plane.The capture path destroys the information needed to tell services apart. TCP recovers the pre-DNAT destination via
use_original_dst; UDP has no equivalent. Envoy never readsIP_RECVORIGDSTADDR,original_dstis structurally TCP-only,DestinationPortInputis the listening socket's port, and none of the fiveUdpMatchingDatainputs can distinguish two services behind a REDIRECT.So #873's stated fix direction is wrong on both halves, and the proposal says so:
udp_proxyhas no weighted route action in any version (the matcher's terminal action is a message with exactly one field,cluster), and adoptingmatcherbuys nothing while its input carries no service identity.Verified before writing, not asserted
Run in a network namespace with no aether code. Same Envoy, same matcher, only the nftables rule differing:
<ClusterIP>:<service port>on_no_matchRow 2 is the control that makes row 1 meaningful — arm B is reachable, so arm A wasn't a matcher that always picks its first branch. It also explains why this went unnoticed: REDIRECT gives working traffic with lost routing, because conntrack repairs the reply.
Row 3 forces the design.
sendmsgnever readsself_ip->port(), so a reply's source port is always the bound port and a connected client drops anything else — a port-rewriting TPROXY would produce matching that works and traffic that silently fails one way. Hence: preserve the dport, one transparent listener per distinct UDP service port,destination_ipdisambiguating within it. Cheaper than listener-per-service, which was the obvious fallback.What is NOT established
aether binds capture listeners into the pod netns via
network_namespace_filepath(hostNetwork: trueproxy). The spike could not settle whether a transparent listener bound that way sees the ClusterIP: in-netns gave arm A reproducibly, via-filepath gave arm B — but so did the control, i.e. the in-netns shape that reliably gives A elsewhere. Two rigs disagreeing on one config means the rig is at fault and neither reading is usable. A rootless user namespace cannot host the test (setns()back needsCAP_SYS_ADMINin the original netns's user ns).Phase 0 exists to settle exactly that, on a node. If it says no, the proposal stops and #916 stands as a documented limit — a legitimate outcome, and far cheaper than discovering it in Phase 2.
Corrections this records
mdlayher/netlink, indirect viagoogle/nftables) — Phase 1 adds one, and a dependency.tcp_proxy, and a connection-less UDP listener has none.Scope discipline
It does not deliver east-west QUIC, and Phase 0 passing should not be read as QUIC being approved. TPROXY is necessary for it — HTTP/3 today is edge-only and never traverses capture — but QUIC also needs a security-model decision (UDP rides the mesh in plaintext; QUIC brings its own TLS 1.3, which differs from proposal 031's per-source mTLS H2 invariant). That shouldn't arrive as a side effect of a CNI change.
Alternatives considered records the three rejected designs with reasons, including do nothing, which remains legitimate.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr