Skip to content

feat(datapath): Serve one service address from several producers - #1093

Merged
privateip merged 2 commits into
fix/issue-1086-apifrom
fix/issue-1086-datapath
Oct 25, 2026
Merged

privateip merged 2 commits into
fix/issue-1086-apifrom
fix/issue-1086-datapath

Conversation

@privateip

@privateip privateip commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A node-local private service route sends each consumer to exactly one producer interface.

The datapath now also accepts a route whose producers live in a separate set: each TCP connection stays with the producer that took its first packet, each UDP request picks an eligible producer at random, and replies are accepted from any producer in the set.

Existing maps keep their layout, so loading this datapath recreates no pinned map and revokes no service access. Nothing writes these routes until the next layer.

Test plan

  • Requests from one UDP socket reach both producers, and a draining producer gets no new request
  • A TCP connection keeps its producer while that producer drains, new connections avoid it, and only its connections move when it leaves
  • A route with no set, no eligible producer, or a replaced producer interface drops the packet and pins nothing
  • Lint, unit and root kernel suites pass

Second of three, on the API in #1092. Next is the router in #1094.

Fixes #1086

🤖 Generated with Claude Code

A node-local private service route redirects a consumer to exactly one producer interface, so the datapath cannot deliver one service address from several producers on the same node.

A new route mode, LocalSet, reads its producers from service_producer_set_table under the route's own key: up to 16 members, each fenced by its attachment identity token, and the subset that takes new flows. usid_egress pins each TCP flow, keyed by its forward tuple on the consumer interface, to the member that took its first packet in the LRU service_flow_table, and keeps it there while that member stays in the set, so a member that only stops taking new flows keeps its connections. A new TCP flow takes an eligible member by its FNV-1a hash and a UDP datagram takes one at random, so the requests of one socket spread too. Replies, and the reclaim of a colliding reverse row, accept any member of the route's set. A route with no set, no eligible member, or a member whose interface was replaced fails closed.

Every existing struct and map keeps its layout, so loading this datapath recreates no pinned map and revokes no service authorization. The router's service route programmer counts the new map among the ones it watches and treats its absence as a datapath that predates LocalSet routes, so a router can run ahead of the CNI or behind it. Nothing writes LocalSet routes yet.

Related to #1086

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@privateip privateip changed the title feat(datapath): Deliver one service address from several producers on a node feat(datapath): Serve one service address from several producers Oct 25, 2026
@privateip privateip self-assigned this Oct 25, 2026
galactic-cni's credential-refresh container creates the datapath's maps and its memory cgroup pays for them, under a 128Mi limit (#808). An LRU map is always preallocated, so the 131072-entry service_flow_table added 18Mi: the maps grew from 58Mi to 76Mi on a 12-CPU node, leaving the container needing 116Mi of its 128Mi, and the figure grows with CPU count.

The table now holds 32768 pins, which brings the maps to 63Mi and the container's need to 103Mi. A pin covers only a TCP flow to a Spread endpoint, and a flow whose pin is evicted takes the producer its hash picks, which is the same one while the endpoint's producer set is unchanged. The galactic-cni README's memory figure, which still said 35Mi, now gives the measured size.

Related to #1086

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@privateip

Copy link
Copy Markdown
Contributor Author

Two independent reviews ran on this PR, and the second pass returned merge from both on head bd9ae8a, with nothing left above a nit.

CI is green on this head, including the root kernel and end-to-end jobs.

This is the middle of stack #1096, which merges as a whole with gh stack merge 1096 --merge once approved.

@privateip
privateip requested a review from a team as a code owner October 25, 2026 15:47

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve.

The datapath half is sound: a LocalSet route fails closed (drop) when the producer set, an eligible member or a member's interface identity is missing, and Single routes take the unchanged mode 1 path. Nothing deploys on merge, and the new maps are only written by the router in #1094.

  • usid.c service_select_producer: a TCP pin is honoured only while its producer is still a member with a matching identity, so a draining producer keeps its connections and replies, and a removed one loses only its own flows. The covering test (TestUsidServiceEgress_LocalSetPinsTCPFlows) exercises drain, removal and replies.
  • service_install_reverse and the reply path now accept any set member (draining included) through service_local_route_has_producer, so replies from a draining producer still pass. This is the right widening and stays bound to the consumer token.
  • table.go OpenPinned: a missing service_producer_set_table is tolerated and RegisterProducerSet/RegisterLocalSetRoute refuse, so an older datapath keeps serving every Single route. mapSetIDs treats the map appearing as a map-set change, which reopens handles correctly.
  • Cleanup: SweepPolicy and Clear now remove producer sets that are not in the snapshot, so a Spread to Single switch or a deleted endpoint leaves no set behind. Stale service_flow_table rows are harmless (consulted only for LocalSet routes) and age out by LRU or the flow timeout.
  • service_flow_table adds about 28Mi of preallocated eBPF memory to the galactic-cni cgroup (the README now says about 63Mi on 12 CPUs, growing with CPU count); the existing memory-limit test guards it, but the margin on large nodes is worth watching at rollout.

Follow-ups:

  • A TCP pin lost to LRU eviction (32768 flows per node) or the idle timeout rehashes with hash % eligible, so the connection can land on a different producer and reset. Same when the eligible count changed since the pin was made. Consider a larger table or a consistent-hash/rendezvous pick so hash stability survives set changes.
  • UDP picks a random producer per packet, so multi-packet UDP exchanges (QUIC, DTLS) are split across producers. Fine for DNS-style request/reply; document it for Spread users.

@privateip
privateip merged commit f143176 into main Oct 25, 2026
18 checks passed
@privateip
privateip deleted the fix/issue-1086-datapath branch October 25, 2026 16:05
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.

Share private-service traffic across healthy servers

2 participants