Skip to content

feat(agent): make the TCP capture listener transparent (038, ahead of the CNI change) - #946

Merged
bpalermo merged 5 commits into
mainfrom
feat/tproxy-pr2-transparent-listener
Sep 26, 2026
Merged

bpalermo merged 5 commits into
mainfrom
feat/tproxy-pr2-transparent-listener

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

PR 2 of the TPROXY plan. Adds transparent: true to the per-pod TCP capture listener and nothing else — and lands before the CNI rules change, on purpose. Refs #916.

Why first

nft tproxy assigns a packet only to a socket that has IP_TRANSPARENT; to any other socket it is a no-op and the packet finds nothing. So the CNI's divert rules (PR 3) without this listener would break all captured TCP.

Under today's REDIRECT the option is harmless — original_dst still tries SO_ORIGINAL_DST first (utility.cc:361-376) and the conntrack NAT entry is there. Flipping transparent also makes Envoy treat the socket options as incompatible, so it creates new per-worker sockets and drains the old listener for every pod, with both socket sets briefly in one SO_REUSEPORT group. That restart bakes under REDIRECT rather than coinciding with the rule switch.

What it deliberately does not do

use_original_dst and the original_dst filter stay, first in the list. On a diverted flow SO_ORIGINAL_DST still succeeds — the flow is tracked, just not NATed; the Phase 0b spike measured 10.250.0.7:8080 — and original_dst is what sets localAddressRestored(), which the ORIGINAL_DST passthrough cluster requires. A future "transparent makes original_dst redundant" would silently break the passthrough. The envoy_validate test asserts the two as a pair for that reason.

Gates, each seen red before commit

gate red state
capture_test.go pins transparent beside use_original_dst transparent set (038) on a false probe
TestCaptureTCPListenerIsTransparentAndKeepsOriginalDst (envoy_validate) tproxy will not assign to a non-transparent socket
//charts/aether:aether_proxy_net_admin_test red on NET_ADMIN → NET_RAW

Worth noting: the envoy_validate test's first draft had the wrong package name (envoyvalidate vs envoy_validate), so gazelle left it out of the target and the first probe passed vacuously. Caught because the unit pin went red while this one stayed green — fixed, re-proven.

The chart gate exists because IP_TRANSPARENT is checked as CAP_NET_ADMIN in the userns owning the pod netns, and Envoy's supportsIpTransparent() probe runs once in the host netns; both fail silently without the grant.

Verification

bazel test //... all pass, lint clean, three gates red-then-green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 5 commits September 26, 2026 07:02
… the CNI change)

PR 2 of the TPROXY plan. Adds `transparent: true` to the per-pod TCP capture
listener and nothing else. Lands BEFORE the CNI rules change, on purpose.

WHY FIRST. nft `tproxy` assigns a packet only to a socket that has
IP_TRANSPARENT; to any other socket it is a no-op and the packet finds nothing.
So the CNI's divert rules (PR 3) without this listener would break all captured
TCP. Under today's REDIRECT the option is harmless: original_dst still tries
SO_ORIGINAL_DST first (Envoy utility.cc:361-376) and the conntrack NAT entry is
there. Flipping `transparent` also makes Envoy treat the socket options as
incompatible, so it creates new per-worker sockets and drains the old listener
for every pod -- with both socket sets briefly in one SO_REUSEPORT group. That
restart must bake under REDIRECT, not coincide with the rule switch.

WHAT IT DOES NOT DO. use_original_dst and the original_dst listener filter stay,
first in the filter list. On a diverted flow SO_ORIGINAL_DST still succeeds (the
flow is tracked, just not NATed -- e2e/spike/tproxy-phase0b.py T1 measured
10.250.0.7:8080) and original_dst is what sets localAddressRestored(), which
the ORIGINAL_DST passthrough cluster requires. A future "transparent makes
original_dst redundant" would silently break the passthrough.

GATES, each seen red before commit:
  - capture_test.go pins transparent beside use_original_dst ("transparent set
    (038)" on a false probe).
  - test/envoy_validate TestCaptureTCPListenerIsTransparentAndKeepsOriginalDst
    asserts the PAIR on the fixture stock Envoy validates. Its first draft had
    the wrong package name, so gazelle left it out of the target and the probe
    passed vacuously -- fixed, and the red state re-proven ("tproxy will not
    assign to a non-transparent socket").
  - //charts/aether:aether_proxy_net_admin_test pins the NET_ADMIN grant against
    the packaged chart (red on NET_ADMIN -> NET_RAW). IP_TRANSPARENT is checked
    as CAP_NET_ADMIN in the userns owning the pod netns, and Envoy's
    supportsIpTransparent() probe runs once in the host netns; both fail
    SILENTLY without it.

Refs #916

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
charts/aether/BUILD.bazel gained a helm_template_test; the chart-version-bump
gate requires a Chart.yaml bump for any charts/ change.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…lermo/aether into feat/tproxy-pr2-transparent-listener
@bpalermo
bpalermo merged commit 3584b72 into main Sep 26, 2026
23 checks passed
@bpalermo
bpalermo deleted the feat/tproxy-pr2-transparent-listener branch September 26, 2026 10:21
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.

1 participant