Skip to content

fix: Merge BGPAdvertisement prefixes across shared containers - #284

Merged
privateip merged 1 commit into
mainfrom
pr3c-merge-advertisement-prefixes
Aug 6, 2026
Merged

fix: Merge BGPAdvertisement prefixes across shared containers#284
privateip merged 1 commit into
mainfrom
pr3c-merge-advertisement-prefixes

Conversation

@privateip

Copy link
Copy Markdown
Contributor

Summary

A single BGPAdvertisement CRD is keyed by (vpc, vpcAttachment) alone, so multiple containers attaching under the same VPCAttachment on a node — a second pod, or a second interface reusing it — share one CRD. publishBGPStateK8s was building Spec.Prefixes from only the container currently being processed, so a second container's CNI ADD would silently drop the first still-live container's already-published prefix from the spec.

allAdvertisedPrefixes fixes this by recomputing Spec.Prefixes from every subnet annotation currently present on the CRD (each container's durable per-container record) instead of just the one being processed, so every live container's prefix stays present regardless of ADD order.

Independent of the eBPF uSID datapath work landing in a separate stack — no shared imports or call-site overlap beyond this file's existing publishBGPStateK8s.

Test plan

  • go build ./...
  • go vet ./internal/cni/...
  • go test ./internal/cni/... (new TestAllAdvertisedPrefixes* cases, including the multi-container regression case)
  • task lint (0 issues)

A single BGPAdvertisement CRD is keyed by (vpc, vpcAttachment) alone,
so multiple containers attaching under the same VPCAttachment on a
node -- a second pod, or a second interface reusing it -- share one
CRD. publishBGPStateK8s was building Spec.Prefixes from only the
container currently being processed, so a second container's ADD
would clobber the first still-live container's already-published
prefix out of the spec.

allAdvertisedPrefixes recomputes Spec.Prefixes from every subnet
annotation currently present on the CRD instead, so each container's
own durable annotation record keeps its prefix present regardless of
ADD order.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
privateip added a commit that referenced this pull request Aug 5, 2026
Removes the legacy per-route netlink SRv6 ingress mechanism
(srv6.RouteIngressAdd/Del, srv6.go) entirely and replaces it with
registration against the eBPF uSID datapath's pinned maps (attach,
usidmap -- #283): the eBPF/TC-BPF datapath is now the only ingress/decap
path for both veth and tap attachments, so there's no dual-path
coexistence to maintain.

ComputeSID (internal/plumbing/srv6/usid.go) is rewritten onto the
shared uFMT 48+16 bit layout (internal/plumbing/ebpf/uformat -- #281)
instead of its previous ad hoc NodeID/VRFID/Function suffix, so the BGP
control plane and the eBPF dataplane can never drift on bit positions.

The CNI ADD path no longer derives the VRFID straight from the
VPCAttachment identifier (vrfIDFromAttachment); it now allocates a
12-bit uFMT Argument per-node from live BGPVRFInstance CRD state
(allocateArgument), with a collision check (checkArgumentCollision)
covering the allocate-then-create race between two concurrent ADDs.
registerEBPFDatapath/unregisterEBPFDatapath write and roll back the
three eBPF map entries (locator_table, function_table, vrf_table) for
each attachment.

Stacked on #283 (eBPF datapath control-plane packages) and #284
(BGPAdvertisement prefix-merge fix, needed for this PR's
publishBGPStateK8s changes to apply cleanly).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@privateip
privateip marked this pull request as ready for review August 5, 2026 01:59
@privateip
privateip requested a review from a team as a code owner August 5, 2026 01:59

@ecv ecv left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

seems legit. we should do a pass pulling all the comments out into design docs later

@privateip
privateip merged commit 8a21e5f into main Aug 6, 2026
9 checks passed
@privateip
privateip deleted the pr3c-merge-advertisement-prefixes branch August 6, 2026 12:16
privateip added a commit that referenced this pull request Aug 6, 2026
Removes the legacy per-route netlink SRv6 ingress mechanism
(srv6.RouteIngressAdd/Del, srv6.go) entirely and replaces it with
registration against the eBPF uSID datapath's pinned maps (attach,
usidmap -- #283): the eBPF/TC-BPF datapath is now the only ingress/decap
path for both veth and tap attachments, so there's no dual-path
coexistence to maintain.

ComputeSID (internal/plumbing/srv6/usid.go) is rewritten onto the
shared uFMT 48+16 bit layout (internal/plumbing/ebpf/uformat -- #281)
instead of its previous ad hoc NodeID/VRFID/Function suffix, so the BGP
control plane and the eBPF dataplane can never drift on bit positions.

The CNI ADD path no longer derives the VRFID straight from the
VPCAttachment identifier (vrfIDFromAttachment); it now allocates a
12-bit uFMT Argument per-node from live BGPVRFInstance CRD state
(allocateArgument), with a collision check (checkArgumentCollision)
covering the allocate-then-create race between two concurrent ADDs.
registerEBPFDatapath/unregisterEBPFDatapath write and roll back the
three eBPF map entries (locator_table, function_table, vrf_table) for
each attachment.

Stacked on #283 (eBPF datapath control-plane packages) and #284
(BGPAdvertisement prefix-merge fix, needed for this PR's
publishBGPStateK8s changes to apply cleanly).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
privateip added a commit that referenced this pull request Aug 6, 2026
Removes the legacy per-route netlink SRv6 ingress mechanism
(srv6.RouteIngressAdd/Del, srv6.go) entirely and replaces it with
registration against the eBPF uSID datapath's pinned maps (attach,
usidmap -- #283): the eBPF/TC-BPF datapath is now the only ingress/decap
path for both veth and tap attachments, so there's no dual-path
coexistence to maintain.

ComputeSID (internal/plumbing/srv6/usid.go) is rewritten onto the
shared uFMT 48+16 bit layout (internal/plumbing/ebpf/uformat -- #281)
instead of its previous ad hoc NodeID/VRFID/Function suffix, so the BGP
control plane and the eBPF dataplane can never drift on bit positions.

The CNI ADD path no longer derives the VRFID straight from the
VPCAttachment identifier (vrfIDFromAttachment); it now allocates a
12-bit uFMT Argument per-node from live BGPVRFInstance CRD state
(allocateArgument), with a collision check (checkArgumentCollision)
covering the allocate-then-create race between two concurrent ADDs.
registerEBPFDatapath/unregisterEBPFDatapath write and roll back the
three eBPF map entries (locator_table, function_table, vrf_table) for
each attachment.

Stacked on #283 (eBPF datapath control-plane packages) and #284
(BGPAdvertisement prefix-merge fix, needed for this PR's
publishBGPStateK8s changes to apply cleanly).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
privateip added a commit that referenced this pull request Aug 6, 2026
Removes the legacy per-route netlink SRv6 ingress mechanism
(srv6.RouteIngressAdd/Del, srv6.go) entirely and replaces it with
registration against the eBPF uSID datapath's pinned maps (attach,
usidmap -- #283): the eBPF/TC-BPF datapath is now the only ingress/decap
path for both veth and tap attachments, so there's no dual-path
coexistence to maintain.

ComputeSID (internal/plumbing/srv6/usid.go) is rewritten onto the
shared uFMT 48+16 bit layout (internal/plumbing/ebpf/uformat -- #281)
instead of its previous ad hoc NodeID/VRFID/Function suffix, so the BGP
control plane and the eBPF dataplane can never drift on bit positions.

The CNI ADD path no longer derives the VRFID straight from the
VPCAttachment identifier (vrfIDFromAttachment); it now allocates a
12-bit uFMT Argument per-node from live BGPVRFInstance CRD state
(allocateArgument), with a collision check (checkArgumentCollision)
covering the allocate-then-create race between two concurrent ADDs.
registerEBPFDatapath/unregisterEBPFDatapath write and roll back the
three eBPF map entries (locator_table, function_table, vrf_table) for
each attachment.

Stacked on #283 (eBPF datapath control-plane packages) and #284
(BGPAdvertisement prefix-merge fix, needed for this PR's
publishBGPStateK8s changes to apply cleanly).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

5 participants