Skip to content

feat(mesh): divert mark + route table constants; ProxyTCPOutboundPort → ProxyL4OutboundPort - #945

Merged
bpalermo merged 2 commits into
mainfrom
feat/tproxy-pr1-constants
Sep 26, 2026
Merged

bpalermo merged 2 commits into
mainfrom
feat/tproxy-pr1-constants

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

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. Refs #916.

New constants

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
passthrough mark is a subset of the divert mark's bits

The rename

ProxyTCPOutboundPort → ProxyL4OutboundPort, value unchanged (18082). Under 038 D1 plaintext UDP dials the same number as raw TCP — one number, both transports, the way 18008 and 18009 are shared — so the name stopped being true. Mechanical across 7 files.

TestL4OutboundPortIsSharedAcrossTransports gates it the way #942 gates 18009: any transport-specific outbound port constant in the package must equal 18082. Seen red on a ProxyUDPOutboundPort = 18083 probe, naming it. Embeds *.go so the scan is real under Bazel's sandbox.

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 records that it never matches in practice — proxy egress is in the host netns, the rules in the pod netns.

Verification

bazel test //... 109/109. Lint clean. Both new gates proven red then restored.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 2 commits September 26, 2026 06:54
… -> ProxyL4OutboundPort

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

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 8c5dfcc into main Sep 26, 2026
23 checks passed
@bpalermo
bpalermo deleted the feat/tproxy-pr1-constants branch September 26, 2026 10:11
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