Repository navigation
Description
Split out of #873. That issue asked for two things; this is the half that cannot be fixed in the control plane, and #873's suggested direction does not work.
#873 proposed: "Envoy's udp_proxy supports matcher-based route selection (and weighted clusters via the matcher API) in current versions; the comment's premise that it is unavailable predates the version now in use."
Verified against Envoy v1.39.0 source while fixing the other half (#914). Both clauses are wrong.
1. There is no weighted route action for udp_proxy, in any version
UdpProxyConfig.route_specifier is a oneof of cluster (deprecated) and matcher. The matcher's terminal action is udp_proxy.v3.Route — a message with exactly one field, cluster. The action registry is keyed on udp_proxy's private RouteActionContext (router_impl.cc:30) and contains that single action; the HTTP router's weighted route_list lives in a disjoint registry and is unreachable from here.
tcp_proxy.weighted_clusters simply has no udp_proxy counterpart. Switching to the matcher specifier buys nothing today and costs a field still marked work_in_progress in 1.39.
2. Per-service selection is blocked one layer below the control plane
This is the part #873 does not mention, and it is what makes the matcher suggestion moot. Behind the CNI's nftables redirect, the UDP capture listener cannot know which service a datagram was addressed to:
- A datagram listener's only addressing cmsg is
IP_PKTINFO(listener_impl.cc:776-780), soDestinationIPInputreads the post-DNAT header. The ClusterIP is already gone. - Envoy never reads
IP_RECVORIGDSTADDR/IP_ORIGDSTADDRanywhere in the tree, andoriginal_dstis structurally TCP-only —OriginalDstFilterimplementsNetwork::ListenerFilter, notUdpListenerFilter, and LDS hard-rejects it on a UDP listener. DestinationPortInputis not packet-derived at all. The port is stamped from the listening socket's own port (io_socket_handle_impl.cc:258-281), so it is the constantProxyCapturePort. This one is genuinely counter-intuitive and is worth remembering before anyone designs against it.- Only five inputs exist for
Network::UdpMatchingData— source/dest IP and port, plusnetwork_namespace(alwaysnullopthere). There is noServerNameInputand noFilterStateInput.
The TCP path does not have this problem because use_original_dst recovers the pre-REDIRECT address, which is exactly what UDP lacks.
What it would take
Either:
- TPROXY capture for UDP instead of REDIRECT, preserving the original destination — a CNI change; or
- a listener per service on its own port, so the listening socket's port identifies the service — also a CNI change, and it multiplies listeners per pod.
Both are data-path changes in cni/internal/plugin/capture.go, not xDS work. Neither should be attempted as a drive-by.
Current behaviour (after #914)
One service wins per pod — the heaviest live backend, ties broken by cluster name for determinism (#135). weight: 0 is honoured as a drain. The discarded shapes are reported, not faked: UnsupportedUDPRouteShapes plus the aether.agent.l4route.udp_unsupported counter, which is now seeded (#882/#905) so its zero is meaningful.
docs/conformance/gateway-api-features.md and docs/getting-started.md now state the limit rather than claiming UDPRoute is simply "Supported".
Note
UDP rides the mesh in plaintext by design — mTLS is a TCP/TLS construct and there is no DTLS here — so none of this is a security regression. It is a routing-expressiveness limit.
🤖 Generated with Claude Code
Activity
bpalermo commentedon Sep 23, 2026
P0 spike result: GO on the Envoy/kernel question
Ran the experiment rather than reasoning further. Same Envoy, same
udp_proxymatcher (DestinationIPInputexact-match10.96.99.99→ cluster A,on_no_match→ cluster B). Only the nft rule differs:ip route local)10.96.99.99A:probe, source10.96.99.99:5300on_no_matchB:probe— still works, via conntrack un-DNATWhat this settles
transparent: truegenuinely binds on a UDP listener — 20 sockets on0.0.0.0:5300, no rejection.addressFromMessagereadsinfo->ipi_addr— the IP header'sdaddr— notipi_spec_dst. TPROXY does not rewrite the header; REDIRECT does. SoDestinationIPInputsees the ClusterIP and per-service matching works.destination_ipdisambiguating services that share one. Much cheaper than the listener-per-service fallback.The status quo is worse than this issue states
REDIRECT produces working traffic with lost routing information, because conntrack un-DNATs the reply. Nothing ever failed visibly, which is why this went unnoticed until #873.
Design correction from the source review
sendmsgsets onlyipi_spec_dstfrom the local IP —self_ip->port()is never read — so a reply's source port is always the socket's bound port. A port-rewriting tproxy would therefore give working matching and silently one-way traffic. Preserve the dport and bind the listener on it.Caveats, stated rather than buried
1.40.0-dev.20260904.13144fb. (proxy/MODULE.bazel:22— earlier notes on this issue and UDPRoute ignores backend weights and collapses multiple services onto one cluster #873 said "v1.39.0", which was wrong.) The load-bearing files were diffed byte-identical across v1.39.0, the dev pin, and main.localroute rather than nft'stproxystatement, because that statement is prerouting-only and aether captures locally-originated traffic inside the pod netns. Arguably more representative of the real path, not less.UdpProxyConfig.matcheriswork_in_progress— a warning plus aserver.wip_protoscounter, not a reject.Remaining P0, Talos-only
ip rule/ip route localpersistence across a Talos config re-apply, and the mixed TCP-REDIRECT + UDP-TPROXY ruleset incni/internal/plugin/capture.go.NET_ADMINis already granted on the proxy container (agent-proxy-daemonset.yaml:224), so that unknown is closed.Proposal 038 to follow once the Talos half is answered.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
docs(proposal): TPROXY capture for UDP (038) (#923)
bpalermo commentedon Sep 26, 2026
Phase 0 of proposal 038 is settled on a node. The answer is YES, and Phase 1 is unblocked. PR #940.
Run 2026-09-25 on
main-worker-04, kernel 6.18.34-talos.A transparent socket created inside a pod netns via
setnsand read from another netns does observe the pre-TPROXY destination — which is aether's real shape, since the proxy ishostNetworkand binds capture listeners into each pod's netns vianetwork_namespace_filepath.C2 is why MAIN is believable. It proves
ipi_addrreports the real post-NAT header rather than echoing the address that was sent; C3 only shows that delivery needs a rule. The 2026-09-23 attempt was unusable precisely because its control agreed with its negative result, and the first run of this script lost C2 the same way —redirectis terminal in nftables, so a trailingcounterinvalidated the rule and C2 silently became a duplicate of C3 while still passing its own assertion. The rig now aborts rather than measuring with an unverified ruleset.Two scope notes so this is not over-read:
transparent: trueon a datagram socket and Envoy's read ofipi_addrwere already established in 038; the open question was thesetnsinteraction, and isolating it kept Envoy's config surface out of the result.tproxyis prerouting-only so locally-originated egress uses mark-and-divert, which does not rewrite the destination port — a listener on any other port receives nothing. That is the constraint forcing listener-per-port in Phase 2.Also worth separating from today's other work: the #931 series (#933–#938) made one UDP service work end to end — it did not touch this issue. #916 is telling two apart, which is still Phase 1 (CNI TPROXY rules, behind a flag) and Phase 2 (one transparent listener per distinct UDP service port,
matcheronDestinationIPInput).The spike is checked in at
e2e/spike/so it can be re-run rather than taken on trust.docs(038): Phase 0 is settled — the netns-bound transparent socket se…
bpalermo commentedon Sep 26, 2026
Reassessment: QUIC changes 038's endgame, and the TCP/UDP capture question with it
Two things were asked after Phase 0 landed: should TCP and UDP capture be normalized onto TPROXY, and does the recent QUIC mTLS work on Envoy change that. Facts first, then the verdict.
The QUIC premise, verified
038 deferred east-west QUIC on a security-model objection: "QUIC brings its own TLS 1.3, which is a different model from the per-source mTLS H2 invariant proposal 031 settled on." That objection is now largely dissolved upstream. A five-PR series in envoyproxy/envoy (facts from the
envoysession, PR numbers/dates/SHAs verified against GitHub):c982e14d3ca954913a99require_client_certificateon a QUIC filter chain requests and validates the client cert through the sameCertValidatoras TCP —trusted_ca,match_typed_subject_alt_names, the SPIFFE validator; identity reaches XFCC, RBAC and access logs4c7a07550denable_resumption/enable_early_datadefault off when a client cert is requiredc2eed43cdab6a6137a6eOur pin is
1.40.0-dev.20260904.13144fb— 2026-09-04 — and the envoy bazel-registry publishes exactly one version, so the two load-bearing PRs are already in the binary we ship and there is no later resolvable snapshot as of 2026-09-26.The
envoysession measured #47076 directly with a quic-go client: trusted cert → 200 with the SPIFFE URI SAN in XFCC; no cert →certificate required; self-signed →unknown CA. SDS works through the sameonSecretUpdatedpath as TCP, so SPIRE-delivered certs and bundles carry over. Connection migration does not re-handshake, so identity persists across a path change the way a TCP connection keeps its identity.So QUIC can carry the per-source mTLS identity invariant rather than replacing it. The accurate framing for 038 is: QUIC's TLS 1.3 handshake carries client certificates in Envoy since #47076, validated through the same
validation_contextas TCP — provided resumption and early data are disabled on the filter chain.The one caveat that is a hard requirement at our pin
QUIC never re-verifies the client certificate on a resumed session — a resumed session carries the identity from the original handshake without touching the trust bundle again. #47219 makes the safe default automatic, but it is not in our snapshot. So until the pin moves past 2026-09-09, every mTLS QUIC filter chain must set
enable_resumption: falseandenable_early_data: falseexplicitly, and a validate-gate should assert it. With those set, every connection does a full handshake and the model matches 031's invariant. Without them, an SVID revocation would not take effect on resumed sessions — the exact class of silent identity drift #829 was about.Also at our pin: required mode only (optional mTLS is #47341), and none of the extra peer-cert fields.
What this changes for 038
QUIC moves from "deferred pending an architecture decision that should not arrive as a side effect of a CNI change" to a planned requirement. The decision that was deferred has been made upstream in the direction that preserves aether's invariant. That in turn changes the normalization question.
Normalize TCP and UDP capture onto TPROXY?
Not now, and not for symmetry. Yes, eventually, and QUIC is the reason.
Why not now:
envoy.filters.listener.original_dstreadsSO_ORIGINAL_DSTfrom conntrack, andpassthrough_original_dstis built on it. REDIRECT loses nothing for TCP. The absence of a UDP equivalent (OriginalDstFilteris aNetwork::ListenerFilter, not aUdpListenerFilter) is the entire motivation for 038.redirect-alldepends onCapturePassthroughFwMark = 0xae7e: Envoy stamps it viaSO_MARKonpassthrough_original_dst's upstream sockets, andpassthroughMarkAcceptExprsRETURNs on it ahead of the redirect so the proxy's own forwarded egress is never re-captured. TPROXY is also mark-driven (mark →ip rule→ip route local). Two mark mechanisms on one path, where one of them is the only thing preventing an infinite capture loop on all mesh TCP traffic. This is the gating analysis for any TCP move, QUIC or not.ip rule/ip route localplumbing on the critical path, and the CNI has no route/rule capability today (038 Phase 1 adds it plus a dependency).Why eventually, and why QUIC decides it: TCP and QUIC sharing a port with two different capture mechanisms underneath is exactly the split that produced this issue in the first place — REDIRECT giving "working traffic with lost routing information", invisible for months because conntrack repaired the reply. With QUIC now a planned requirement rather than a maybe, the mixed state has an expiry date.
The middle path, which I recommend Phase 1 take
Normalize the code, not the deployed behaviour.
captureRedirectExprs(proto, meshPort, capturePort)is already protocol-parameterised — one builder serves TCP and UDP because the transport dport offset is identical. Phase 1 should extend that to a capture-mode parameter (redirect|tproxy) rather than grow a second parallel rule path. That buys most of the comprehension benefit and makes the eventual TCP switch a flag flip with a tested code path behind it, at zero runtime risk today.Sequencing
enable_resumption: false+enable_early_data: falsegated in//test/envoy_validateuntil the pin passes #47219. HTTP/3 exists only at the edge today (BuildEdgeGatewayH3Listener, 029) and never traverses capture; east-west is a different path with no existing code.0xae7emark-collision analysis as the gate.The two design questions from the previous comment still stand and precede Phase 1: which UDP ports the CNI diverts, and whether the dial spelling leaves
:18081.docs(038): QUIC is a planned requirement now, not a deferred decision (…
bpalermo commentedon Sep 26, 2026
Design constraint for the east-west QUIC follow-on, pinned in code: one port number for both transports. PR #942.
When east-west QUIC lands it binds UDP on
DefaultEastWestTunnelPort(18009) beside the TCP tunnel — never a new port. The edge already does exactly this:BuildEdgeGatewayHTTP3Listenerbinds UDP on the sameinternalPortas the TCP HTTPS listener withEnableReusePort, and alt-svc advertises that one port. The capture port (ProxyCapturePort) states the same principle.A second number would need a second CNI rule, a second Service port, a second cross-cluster "must match" agreement, and a second capture path — and TCP and QUIC on different capture mechanisms is the split that produced this issue.
Gated by
TestEastWestPortIsSharedAcrossTransports, which scans the proxy package's constants and fails on any east-west QUIC/H3/UDP port constant whose value isn't 18009. Green today; red-state proven with a probe constant before commit. So the QUIC proposal cannot quietly allocate18010— the test names it.bpalermo commentedon Sep 26, 2026
038 reassessed with QUIC folded in as a requirement — PR #943. Summary of what changed and where the verdicts landed.
Shape. It was a proposal to fix plaintext UDP selection with QUIC as a "does NOT deliver" appendix. It is now a proposal for one UDP capture path carrying two traffic classes with different security properties — plaintext per-service UDP (R1) and an identity-bearing QUIC mesh transport under the unchanged 031 invariant (R2). The discriminator is the destination port class: 18008/18009 → QUIC chain with
require_client_certificateand the samevalidation_contextas TCP; a declaredPORT_PROTOCOL_UDPservice port →udp_proxymatcher on destination IP; anything else uncaptured. Separated at the port, before any matcher runs, so the classes cannot bleed (R5).Phases. 0 done · 1 CNI mark-and-divert for exactly two port sets, built with a capture-mode parameter (R6) and a divert mark disjoint from
0xae7e· 2 agent per-port transparent listeners · 3 e2e turns delivery into selection, on a floor that only started working on 2026-09-25 · 4 QUIC transport — inbound on UDP:18008 beside TCP:18008, HTTP/3 upstream presenting the source cert, east-west gw on UDP:18009 last, resumption/early-data off and gated (R4) · 5 TCP → TPROXY, gated on the mark analysis and a soak with Phase 4 on.Normalization verdict, revised. Was "not now, eventually, QUIC is the reason". Now it has a slot and a gate: Phase 5, after Phase 4 soaks, on a written
0xae7eanalysis. Not for symmetry — TCP loses nothing under REDIRECT — but because TCP and QUIC on two capture mechanisms is the split that produced this issue, and R6 makes it a flag flip.Flagged rather than decided.
:18081today; the design implies the service's application port. Recommendation: adopt it, keep:18081one release.transport_socket_matchesselect a QUIC upstream transport the way it selects a TLS one? Decides one cluster vs one per source in Phase 4."Do nothing" downgraded. It was legitimate on 09-23. #931 showed the plaintext path had been silently broken for its whole life, and QUIC mTLS is now in the pinned binary — the cost of not acting is no longer just a documented limit.
D1 and D2 need a call before Phase 1 writes nft rules.
docs(038): plaintext UDP dials :18082, the L4 spelling shared with ra…
bpalermo commentedon Sep 26, 2026
D1 decided: plaintext UDP dials
:18082, the L4 spelling shared with raw TCP. Folded into #943 as a second commit.Applying the one-number-both-transports rule one level down. A client dials
<svc>.<ns>.<mesh-domain>:18082for a UDP service exactly as for a raw-TCP one; only the transport differs. R3 now reads:This is more than a naming decision — it simplifies the design:
UDPLoadAssignmentalready rewrites theudp:cluster to the app port, which is exactly howtcp:clusters reach a raw-TCP backend from the shared:18082today.It is the TCP floor's shape under 037, transport for transport.
:18081/udpstays captured for one release. The east-west port gate (#942) extends to 18082 in Phase 1 and 18008 in Phase 4;ProxyTCPOutboundPort's name and the CNI's "18082 is a TCP spelling" comment go stale and Phase 1 corrects them.Still open: D2 (the divert mark value) and Q2 (does
transport_socket_matchesselect a QUIC upstream transport — one cluster vs one per source in Phase 4).feat(proxy): pin the east-west gateway to ONE port number for TCP and…
docs(038): decide D2, restate Q2 against the real mechanism, add the …
docs(038): Q2 answered from source — Phase 4b is one QUIC cluster per…
bpalermo commentedon Sep 26, 2026
Q2 answered from source: Q2a = no, Q2b = yes. Phase 4b is one QUIC cluster per source ServiceAccount. Folded into #943.
Facts from the
envoysession, the decisive line verified againstquic_client_transport_socket_factory.ccat our pinned13144fb:QuicClientTransportSocketFactory::createrejects a certificate selector at config load (lines 93–94:UnimplementedError("Client certificate selector not supported on QUIC")). Loud, not silent. The client cert is installed once per crypto config on the shared QUICHESSL_CTXviaSSL_CTX_set_chain_and_key(line 80), because the QUICHE handshaker needs direct access to the private key. It changes only when SDS rotates the context.ClusterEntry::httpConnPool→transportSocketFactory().hashKey), and the QUIC factory inheritsCommonUpstreamTransportSocketFactory::hashKey, which folds hashable filter state. HTTP/3 pools partition per (host, source identity) exactly as h2 pools do.Net. Pooling does not reopen #831 — two identities never share a QUIC connection. But partitioning alone does not give per-source identity, because the certificate presented is the cluster's regardless of partition. So Phase 4b's outbound is one QUIC cluster per source ServiceAccount — the pre-#842 shape, for QUIC only. The identity-set re-push cost #842 removed returns for those clusters only: bounded by local ServiceAccounts, not mesh services, and never touching the TCP clusters.
//test/mtlspoolstill gains a QUIC arm, because the pooling guarantee is real even though the cert is per cluster.D3 (new, Bruno's call): whether to pursue a per-connection client-certificate selector for QUIC upstream in envoyproxy/envoy — running the selector before the chain is installed on a per-connection
SSLinstead of the sharedSSL_CTX. Unsized. If landed, Phase 4b collapses back to one cluster and #842's invariance returns for QUIC. The plan does not depend on it; per-source clusters are correct meanwhile. Recorded so the per-source shape reads as a workaround with a known exit, not a design.With this the ADR has no open contingencies: D1 and D2 decided, Q1 dissolved, Q2 answered, Q3/Q4 are verification items inside Phase 4. Only D3 is open, and it is optional.
docs(038): fold east-west QUIC in as a requirement and reassess the w…
feat(mesh): divert mark + route table constants; ProxyTCPOutboundPort…
feat(agent): make the TCP capture listener transparent (038, ahead of…
bpalermo commentedon Sep 26, 2026
Delivered by the TPROXY ladder (#944–#949), which took the first of the two directions this issue named: the CNI now marks and diverts UDP to a transparent listener on :18082 that keeps the original destination (VIP) intact, and
GenerateUDPCaptureListenerbuilds oneudp_proxymatcher arm per UDPRoute-parent ClusterIP (DestinationIPInput→ that service'sudp:cluster). Per-service UDP routing is proven bye2e/l4routes.shT3.3 (two parents, per-VIP selection, #948) and by the rev239 8h soak's UDP leg (2026-09-26).What remains is the other half this issue already called an Envoy limit:
udp_proxyhas no weighted route action, so a UDPRoute with multiple weighted backends still collapses to one cluster. That is surfaced by #874'sudp_unsupportedcounter/log rather than hidden, and it is an upstream feature request if it ever matters, not an aether issue.