Skip to content

fix(capture): preserve downstream protocol on the non-mesh passthrough upstream (#568) - #570

Merged
bpalermo merged 1 commit into
mainfrom
fix/568-h2c-passthrough
Jul 19, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/568-h2c-passthrough

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Fixes #568

Problem

A mesh pod under captureRedirectAllDefault: true sending OTLP gRPC (h2c) to a non-mesh ClusterIP (e.g. otel-collector:4317, a plain h2c-only gRPC server) got:

upstream connect error or disconnect/reset before headers. reset reason: protocol error

Root cause — which chain/cluster carried the broken traffic

  1. CNI redirect-all sends the h2c connection to the per-pod capture listener.
  2. Listener filters run: original_dst recovers the ClusterIP; http_inspector sniffs the stream as h2c (cleartext HTTP/2).
  3. Chain matching: no per-ClusterIP TCP floor chain matches (the collector is not a mesh service), and the L4 cap_passthrough DefaultFilterChain only catches TLS + non-HTTP raw TCP. The cap_http HCM chain matches — its FilterChainMatch is {transport_protocol: raw_buffer, application_protocols: [http/1.0, http/1.1, h2c]}, and h2c is in that list.
  4. Inside cap_http, the authority otel-collector:4317 is not a mesh authority and not a known target, so it hits the redirect-all catch-all's passthrough fallthrough → routes to the passthrough_original_dst ORIGINAL_DST cluster.
  5. That cluster had no TypedExtensionProtocolOptions, so Envoy defaulted the upstream dial to HTTP/1.1. The HCM spoke HTTP/1.1 to an h2-only server → reset before headers → the Envoy-injected protocol error gRPC status.

So: the broken traffic transited the cap_http HCM chain (not the L4 default chain) and terminated on the passthrough_original_dst cluster, which defaulted to HTTP/1.1 upstream.

Fix — option (a): preserve downstream protocol on the passthrough

Chosen option (a) (USE_DOWNSTREAM_PROTOCOL on the passthrough cluster). Rationale: the h2c connection is already inside the HCM because http_inspector legitimately detected it as HTTP; the HCM speaks HTTP to its upstream, so the upstream must mirror the downstream protocol. Option (b) — diverting non-mesh traffic off the HCM onto the TCP floor — is structurally wrong here: to bypass the HCM you'd have to stop matching h2c into cap_http, which would also break legitimate non-mesh cleartext HTTP/1.1 egress that correctly transits the HCM today.

  • New config.UseDownstreamProtocolOptions() builds HttpProtocolOptions with use_downstream_protocol_config and both HTTP/1 and HTTP/2 codec messages populated (so Envoy has concrete config for whichever protocol the downstream turns out to be).
  • NewPassthroughOriginalDstCluster() now carries it via TypedExtensionProtocolOptions. Result: h1 downstream → h1 upstream, h2c downstream → h2c upstream.

Mesh traffic handling (per-source mTLS, SNI demux, ODCDS, TCP floor) is byte-identical — only the non-mesh passthrough upstream protocol changes. Raw-TCP and TLS passthrough still hit the L4 cap_passthrough default chain via tcp_proxy, which ignores these HTTP-codec options.

Validation

  • Unit //agent/internal/xds/config:config_test — asserts the helper selects UseDownstreamProtocolConfig with both codecs + the 30s idle timeout.
  • Unit //agent/internal/xds/proxy:proxy_test — TestNewPassthroughOriginalDstCluster now asserts the passthrough cluster carries the use-downstream config with both h1 and h2c populated (h1 traffic unaffected).
  • Bootstrap validation //test/envoy_validate:envoy_validate_test — passes. Its capture bootstrap already builds NewPassthroughOriginalDstCluster(), so envoy --mode validate now confirms Envoy accepts an ORIGINAL_DST cluster carrying HTTP protocol options.
  • Full //agent/... (-integration) + //test/envoy_validate/...: 25/25 pass.

Follow-up (not in this PR)

  • e2e case: sending gRPC through redirect-all capture to a non-mesh h2c server needs new infra (an h2c echo-server image loaded into the kind cluster). Skipped tonight to avoid destabilizing the existing e2e jobs; should be added alongside upstreaming the capture.aether.io/exclude-outbound-ports: "4317" mitigation into the soak/test manifests.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR

…h upstream (#568)

Non-mesh traffic sniffed as cleartext HTTP by http_inspector (h2c OR
http/1.1) transits the cap_http HCM and is forwarded to the ORIGINAL_DST
passthrough_original_dst cluster via the redirect-all catch-all's
passthrough fallthrough. That cluster carried no upstream HTTP protocol
options, so Envoy defaulted the upstream dial to HTTP/1.1. An h2c gRPC
client to a non-mesh h2-only server (OTLP otel-collector on :4317) thus
got "reset reason: protocol error" — the HCM spoke HTTP/1.1 to an h2-only
upstream.

Add USE_DOWNSTREAM_PROTOCOL (use_downstream_protocol_config) typed
extension protocol options to the passthrough cluster so the upstream
mirrors the sniffed downstream protocol: h1 -> h1, h2c -> h2c. Both codec
messages are populated. Mesh traffic (mTLS, SNI demux, ODCDS) is byte
identical; only the non-mesh passthrough upstream protocol behavior
changes. Raw-TCP and TLS passthrough still hit the L4 cap_passthrough
default chain via tcp_proxy, which ignores these HTTP-codec options.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
@bpalermo
bpalermo merged commit 8f0fe2f into main Jul 19, 2026
14 checks passed
@bpalermo
bpalermo deleted the fix/568-h2c-passthrough branch July 19, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

capture: redirect-all breaks non-mesh gRPC (h2c) egress — protocol not preserved on passthrough

1 participant