Skip to content

TLSRoute SNI chains carry no destination_port, so 037's per-port floor chains shadow them on :18082 and the primary port #911

Closed

Description

@bpalermo

Found while writing #868's TLSRoute e2e leg. Filing separately per one-issue-per-finding — this is a control-plane reachability limit, not test debt.

This is a code-read conclusion, not an observation: the harness that would confirm it (#868's T2 leg) has not been run against a cluster yet. It is filed now because it determined a design decision in that harness, and because the Phase 4 coupling below is the kind of thing that is cheap to notice now and expensive to notice later.

What the code does

BuildCaptureTLSRouteFilterChains (agent/internal/xds/proxy/l4route.go:121-157) gives each SNI chain a match of prefix_ranges: <ClusterIP>/32 + server_names — and no destination_port.

Proposal 037 Phase 2 then gave every TCP-primary service destination_port-qualified floor chains (tcpPrimaryFloorChains, agent/internal/xds/proxy/capture.go:514):

  • cap_tcp_<svc>_18082 — the well-known TCP mesh port;
  • cap_tcp_<svc>_<primaryPort> — the service's own port;
  • cap_tcp_anyport_<svc> — portless, the deprecation shim.

Envoy resolves destination_port first and falls back to the portless bucket only when no chain claims the exact port. The repo says so itself, in buildCaptureTCPPortFilterChain: "Envoy evaluates destination_port ahead of prefix_ranges".

So for a service with a TLSRoute attached:

the client dials chain selected
VIP:18082 cap_tcp_<svc>_18082 — the floor. SNI chains never considered.
VIP:<primaryPort> cap_tcp_<svc>_<primaryPort> — the floor. SNI chains never considered.
VIP:<any other port> portless bucket → SNI chain wins on server_names, else the any-port shim

Why it matters

  1. TLSRoute does not work on the mesh's own spellings. :18082 is the well-known TCP spelling proposal 037 introduced precisely so a raw-TCP client has an unambiguous address, and a service's primary port is the other obvious one. A TLSRoute is accepted, gets Accepted=True, produces correct filter chains — and is inert for both. Silent on both sides, like UDPRoute ignores backend weights and collapses multiple services onto one cluster #873.
  2. TLSRoute's only working path today is a shim that is scheduled for removal. cap_tcp_anyport_<svc> is 037's deprecation shim, and Phase 4 is gated on tcp.cap_tcp_anyport_<svc>.downstream_cx_total reading zero across a release. Any TLSRoute traffic increments that counter, so TLSRoute usage both depends on the shim and corrupts the evidence for removing it. If Phase 4 lands as specified, TLSRoute stops working entirely.

Fix direction

Port-qualify the SNI chains the same way tcpPrimaryFloorChains qualifies the floor: emit cap_tls_<svc>_<port>_<i> for :18082 and the primary port alongside (or instead of) the portless spelling. qualifyChainByPort already exists and already clones rather than mutates, so the shape is there.

Worth settling at the same time: whether a TLSRoute should serve :18082 at all, or whether SNI routing is only meaningful on the service's own port.

Acceptance

Related: #868 (the e2e that surfaced it; its T2 leg deliberately dials an unclaimed port and says why in the script header), #897 / #900 (037 Phase 3 and the any-port shim), #873 (the UDP sibling: accepted, projected, silently inert).

Activity

  1. bpalermo commented on Sep 23, 2026

    @bpalermo
    OwnerAuthor

    Confirmed by code read, and it is a regression introduced by proposal 037

    I verified both halves on main:

    • BuildCaptureTLSRouteFilterChains (agent/internal/xds/proxy/l4route.go:122) builds a FilterChainMatch with PrefixRanges (ClusterIP/32) + ServerNames and nothing else. No DestinationPort.
    • qualifyChainByPort (agent/internal/xds/proxy/capture.go, 037 Phase 2) sets FilterChainMatch.DestinationPort on the floor chains it emits for :18082 and the service's primary port.

    Envoy resolves destination_port first, ahead of prefix_ranges, server_names, transport_protocol and application_protocols. That ordering is stated in proposal 037 itself — it is the whole reason the per-port design works — and it is exactly what breaks TLSRoute here.

    Before 037 the floor chain was portless, so the SNI chain (prefix_ranges + server_names) was strictly more specific and won. After 037 the port-qualified floor chains outrank it at both mesh spellings. So a TLSRoute is Accepted, generates correct-looking chains, and is inert on :18082 and on the primary port.

    The comment above the chain assembly in capture.go still says the SNI chains are "inserted first so Envoy evaluates server_names+IP before the destination-IP-only TCP floor chain". That was true when written and is now misleading twice over: filter-chain selection is by specificity, not position, and the floor chain is no longer destination-IP-only.

    The Phase 4 coupling is the worse half

    Your observation that TLSRoute's only surviving path is the any-port shim is correct, and it contaminates proposal 037's Phase 4 gate. Phase 4 deletes the portless floor chain once cap_tcp_anyport_<svc>.downstream_cx_total reads zero across a release. If TLSRoute traffic lands there, then:

    • a zero on that counter no longer means only "no legacy clients"; it also means "no TLSRoute users", and the two are indistinguishable from the counter alone;
    • deleting the portless chain would take TLSRoute's last working path with it.

    The rev234 measurement itself stands — talos-main has no TLSRoute objects, so nothing could have incremented the counter by this path, and the 8h reading of zero (against three sanctioned chains carrying ~23,700 connections each) is still a valid measurement of what it measured. But the gate's meaning has to be restated: it is only evidence about legacy spellings on a cluster with no TLSRoutes. That qualification was not in the Phase 4 criterion and needs to be.

    Fix direction

    Give the SNI chains the same destination_port qualification the floor chains got — one chain per (SNI, sanctioned port) — so they outrank the floor at :18082 and the primary port instead of losing to it. That restores TLSRoute on both mesh spellings and takes it out of the shim's bucket, which decouples Phase 4's gate again.

    Worth pinning with an envoy_validate case as well as the e2e, since the failure is a silent precedence change in generated config rather than an error.

    Filed against my own work: 037's Phase 2 shipped the port-qualified floor chains without checking what else matched on that VIP.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions