Repository navigation
feat(proxy): pin the east-west gateway to ONE port number for TCP and QUIC - #942
Merged
Merged
Conversation
… QUIC A design constraint recorded where it will be read, with a gate so it cannot drift: when east-west QUIC lands, it binds UDP on DefaultEastWestTunnelPort (18009) beside the TCP tunnel -- never a new port. WHY ONE NUMBER TCP and UDP are independent socket families, so two listeners coexist on one port the way HTTP/3 runs TCP+QUIC on :443. The edge already works this way: BuildEdgeGatewayHTTP3Listener binds UDP on the SAME internalPort as the TCP HTTPS listener, and alt-svc advertises that one port (gatewayH3ExternalPort). The capture port states the same principle (ProxyCapturePort in common/constants/mesh). This makes the east-west gateway consistent with both. 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 exact split that produced #916 (REDIRECT giving working traffic with lost routing information). THE GATE TestEastWestPortIsSharedAcrossTransports scans this package's constants for any name that says east-west AND quic/h3/http3/udp AND port, and requires its value to equal DefaultEastWestTunnelPort. Today no such constant exists; the test is green now and turns red on the exact commit that would violate the rule, naming the offender. A written constraint with no gate is a wish (#853). Red state proven before commit: a probe constant `DefaultEastWestQuicPort = 18010` failed it with DefaultEastWestQuicPort = 18010: east-west QUIC/UDP must bind the SAME port as the TCP tunnel (18009), like the edge's H3 listener; a second number splits capture (#916) The scan embeds `*.go` via //go:embed + embedsrcs (the seed-policy test's mechanism) because Bazel's sandbox gives the test a cwd with no sources -- the first draft used filepath.Glob and its anti-vacuity check caught the empty scan before it could pass for the wrong reason. A glob rather than a named file, so a constant added in a NEW file is still seen. Refs #916 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 26, 2026
…hole (#943) * docs(038): fold east-west QUIC in as a requirement and reassess the whole The proposal carried QUIC as a "does NOT deliver" appendix, deferred on a security-model objection that upstream has since resolved in the direction that preserves aether's invariant (envoyproxy/envoy #47076, in the pinned snapshot). A capture path that is the foundation for a second, identity-bearing traffic class is a different proposal from one that only fixes plaintext selection, so this restructures rather than appends. WHAT CHANGES Requirements section (R1-R6). Two traffic classes on one path -- plaintext per-service UDP and the QUIC mesh transport -- with the destination port class as the discriminator, so a plaintext datagram can never be offered to a QUIC chain or vice versa. The mesh ports are constants; the service ports come from the registry's PORT_PROTOCOL_UDP (#933/#934), so the CNI rule set is derived from declared facts. Phases 4 and 5 added. Phase 4 is the QUIC transport itself: inbound QUIC on UDP:18008 beside TCP:18008 with require_client_certificate and the SAME validation_context and SDS secrets as the TCP inbound; an HTTP/3 upstream that presents the source's client cert; the east-west gateway on UDP:18009 last. Resumption and early data off, gated, until the pin passes #47219. Phase 5 is TCP capture moving to TPROXY, gated on the 0xae7e mark analysis and on Phase 4 being on in a soak -- not for symmetry, because TCP and QUIC on two capture mechanisms is the split that produced #916. Phase 1 now builds the rule set with a capture-mode parameter (R6) so Phase 5 is a flag flip, and must choose a divert mark disjoint from 0xae7e. Two decisions flagged rather than made (D1 the plaintext dial spelling -- recommendation: the application port, with :18081 kept one release; D2 the divert mark) and four open questions, the sharpest being Q2: whether transport_socket_matches selects a QUIC upstream transport, which decides if Phase 4's outbound is one cluster or one per source. Alternatives gains "a separate port for QUIC" (rejected, R3, pinned by #942) and "QUIC via HBONE/CONNECT-UDP" (rejected on 031's grounds). "Do nothing" is downgraded from legitimate to weaker-now: #931 showed the plaintext path had been silently broken for its whole life. Refs #916 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * docs(038): plaintext UDP dials :18082, the L4 spelling shared with raw TCP Folds the one-number-both-transports rule (R3) one level down, which decides D1 and simplifies two phases. A client dials <svc>.<ns>.<mesh-domain>:18082 for a UDP service exactly as it does for a raw-TCP one; only the transport differs. That gives plaintext UDP exactly ONE dialed port, so: - Phase 2 collapses from "one transparent listener per distinct UDP service port" to ONE listener on UDP:18082 per pod, matcher on destination IP. Listener count no longer scales with services or ports. - Phase 1's rule set becomes three literals (18082, 18008, 18009). No declared-port-set plumbing. - Q1 (how the CNI learns the declared UDP port set) is dissolved. - The CNI never needs to know which application ports UDP services bind; UDPLoadAssignment already rewrites the udp: cluster to the app port, which is exactly how tcp: clusters reach a raw-TCP backend from the shared :18082. This is the TCP floor's shape under 037, transport for transport. The 09-23 draft's "distinct UDP port set is small" reasoning is preserved in the text as history; the folded rule makes that set exactly one. :18081/udp stays captured and routed to the plaintext class for one release. ProxyTCPOutboundPort's name and the CNI's "18082 is a TCP spelling" comment go stale under this rule; Phase 1 corrects the comment and may rename the constant. The east-west port gate extends to 18082 in Phase 1 and 18008 in Phase 4. Refs #916 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * docs(038): decide D2, restate Q2 against the real mechanism, add the PR plan D2 decided: CaptureDivertFwMark = 0xae71, same 0xae7x family as the passthrough mark so they read as related, a distinct value so neither rule matches the other's traffic, disjoint from kube-proxy's masked marks. Phase 1 pins both. Q2 restated. The first phrasing asked whether transport_socket_matches selects a QUIC upstream transport -- but aether retired that shape in #842. Per-source identity is ONE upstream TLS socket whose custom_tls_certificate_selector (the filter_state_override cert mapper) resolves the client cert per connection from a hashable filter-state key, which also partitions the pool per (host, source identity). So the real questions are Q2a (does QuicUpstreamTransport honour the mapper) and Q2b (does the HTTP/3 pool fold the hashable key). Q2b=no would re-open the #831 leak class on QUIC, which fails open. Asked of the Envoy tree; the plan carries both branches. Plan added: 12 PRs across Phases 1-5 with sizes and gates, every gate named as something that must be seen red. Notable: Phase 2a must extend TestUDPCaptureListenerResolvesAgainstCDS by hand because the #895 chain->CDS gate cannot see a connection-less listener; Phase 4a's envoy_validate gate must FAIL a chain missing the two resumption falses; Phase 4b's //test/mtlspool gains a QUIC arm. Phase 4 must not merge before Phase 3a's selection assertion exists, or the two traffic classes share a path with no e2e proving they stay apart. Refs #916 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * docs(038): Q2 answered from source — Phase 4b is one QUIC cluster per source SA Q2a = no, Q2b = yes, established at 13144fb and verified against the file at that commit. Q2a: QuicClientTransportSocketFactory::create rejects a certificate selector at config load (quic_client_transport_socket_factory.cc:93-94, UnimplementedError "Client certificate selector not supported on QUIC"). The client cert is installed once per crypto config via SSL_CTX_set_chain_and_key on the shared QUICHE SSL_CTX (line 80), not per connection, because the QUICHE handshaker needs direct access to the private key. Loud, not silent. Q2b: the HTTP pool key is protocol-agnostic (ClusterEntry::httpConnPool calls transportSocketFactory().hashKey), and QuicClientTransportSocketFactory inherits CommonUpstreamTransportSocketFactory::hashKey, so HTTP/3 pools partition per (host, source identity) exactly as h2 pools do. Net: pooling does not reopen #831, but partitioning alone does not give per-source identity because the presented certificate is the cluster's. So Phase 4b is one QUIC cluster per source ServiceAccount -- the pre-#842 shape, for QUIC only, bounded by local ServiceAccounts rather than mesh services and never touching the TCP clusters. The mtlspool QUIC arm still matters: the pooling guarantee is real even though the cert is per cluster. D3 added: whether to pursue a per-connection selector for QUIC upstream in Envoy. It is an Envoy limitation, not a design constraint, and if landed Phase 4b collapses back to one cluster. Unsized; Bruno's call; the plan does not depend on it. Refs #916 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Sep 26, 2026
… -> ProxyL4OutboundPort (#945) PR 1 of the TPROXY plan (proposal 038, revised). Constants and names only -- no behaviour changes -- so the CNI and agent PRs that follow have a vocabulary to build against. CaptureDivertFwMark = 0xae71 and CaptureDivertRouteTable = 100 join CapturePassthroughFwMark = 0xae7e. The divert mark is what the CNI's OUTPUT rule will set; a policy-routing rule delivers marked packets locally with the IP header INTACT and a prerouting tproxy hands them to the transparent capture socket. Same 0xae7x family as the passthrough mark so the two read as related in `nft list ruleset`; a distinct value, and neither is a bitmask superset of the other, so the passthrough accept can never match a diverted packet. TestCaptureMarksAreDisjoint pins that (seen red on a 0xae7e == 0xae7e probe: "the passthrough accept would swallow every diverted packet"). ProxyTCPOutboundPort -> ProxyL4OutboundPort, value unchanged. Under 038 D1 plaintext UDP dials the same 18082 as raw TCP -- one number, both transports, the way 18008 and 18009 are shared -- so the name stopped being true. TestL4OutboundPortIsSharedAcrossTransports gates it the way #942 gates 18009: any transport-specific outbound port constant in this package must equal 18082 (seen red on a `ProxyUDPOutboundPort = 18083` probe, naming it). Comments corrected where the rename made them false: ProxyCapturePort no longer claims "both TCP and UDP bind" it (UDP binds the dialed port, because a datagram reply's source port is the socket's bound port and cannot be rewritten); the CNI's UDP-18081 REDIRECT is marked stale-by-design and points at 038; the passthrough mark's comment now records that it never matches in practice (proxy egress is in the host netns, rules in the pod netns). Refs #916 Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
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.
A design constraint recorded where it will be read, with a gate so it cannot drift: when east-west QUIC lands, it binds UDP on
DefaultEastWestTunnelPort(18009) beside the TCP tunnel — never a new port.Why one number
TCP and UDP are independent socket families, so two listeners coexist on one port the way HTTP/3 runs TCP+QUIC on
:443. The edge already works this way —BuildEdgeGatewayHTTP3Listenerbinds UDP on the sameinternalPortas the TCP HTTPS listener, and alt-svc advertises that one port (gatewayH3ExternalPort). The capture port states the same principle (ProxyCapturePort). This brings the east-west gateway in line with both.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 exact split that produced #916 — REDIRECT giving working traffic with lost routing information, invisible for months.
The gate
TestEastWestPortIsSharedAcrossTransportsscans this package's constants for any name matching east-west ∧ (quic|h3|http3|udp) ∧ port, and requires its value to equalDefaultEastWestTunnelPort. No such constant exists today: green now, red on the exact commit that would violate the rule, naming the offender.Red state proven before commit. A probe constant
DefaultEastWestQuicPort = 18010failed it with:One thing the first draft got wrong, caught by its own check
It used
filepath.Glob("*.go"). Under Bazel's sandbox the test's cwd carries no package sources, so the scan was empty — and the anti-vacuityrequire.NotEmptyfired instead of letting an empty scan pass for the wrong reason. Now embeds*.govia//go:embed+embedsrcs, the same mechanism as cachemetrics' seed-policy test. A glob rather than a named file, so a constant added in a new file is still seen.Verification
bazel test //...— 109/109. Lint clean. Refs #916.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr