Skip to content

[41867] Part 3: Add subnet config watcher with stateDB and BPF map sync#43438

Merged
joamaki merged 5 commits intocilium:mainfrom
anubhabMajumdar:topic/anmajumdar/hybrid-routing-subnet
Jan 30, 2026
Merged

[41867] Part 3: Add subnet config watcher with stateDB and BPF map sync#43438
joamaki merged 5 commits intocilium:mainfrom
anubhabMajumdar:topic/anmajumdar/hybrid-routing-subnet

Conversation

@anubhabMajumdar
Copy link
Copy Markdown
Contributor

@anubhabMajumdar anubhabMajumdar commented Dec 18, 2025

Description

The motivation behind adding a new routing mode is discussed in this CFP .

Part-1 : #41868
Part-2 : #43631

This PR introduces subnet-to-identity mapping infrastructure in control plane to support hybrid
routing mode in Cilium. We introduce a StateDB for caching and reconciliation, with a
Kubernetes ConfigMap-driven configuration model. The stateDB data is sync'd to already introduce eBPF map.

Key Changes

This PR adds infrastructure for subnet-to-identity mapping in hybrid routing mode:

  • Add RoutingModeHybrid constant to routing mode options
  • Implement cilium_subnet_map under pkg/maps
    • Support for both IPv4 and IPv6 address families
    • SubnetMapKey/SubnetMapValue structures synced with bpf/lib/subnet.h
  • Add subnet-identities StateDB table to cache subnet topology
    • Register reconciler to sync table entries to BPF map
    • Integration with maps cell module
  • Implement subnet ConfigMap watcher in pkg/subnet
    • Parse and validate subnet configuration from ConfigMap
    • Automatic propagation of changes to StateDB
  • Add script commands for map dumping and debugging

Testing Done

  • Unit tests for BPF map key/value serialization and operations
  • E2e script-based tests validating full flow: ConfigMap → StateDB → BPF map
  • Verified subnet entry reconciliation and status tracking manually
  • Tested both IPv4 and IPv6 subnet configurations
$ PRIVILEGED_TESTS=true go test -v -exec "sudo -E" ./pkg/subnet
=== RUN   TestPrivilegedScript
=== RUN   TestPrivilegedScript/subnet.txtar
...
--- PASS: TestPrivilegedScript (0.00s)
    --- PASS: TestPrivilegedScript/subnet.txtar (0.05s)
PASS
ok      github.com/cilium/cilium/pkg/subnet     0.092s

Please ensure your pull request adheres to the following guidelines:

  • For first time contributors, read Submitting a pull request
  • All code is covered by unit and/or runtime tests where feasible.
  • All commits contain a well written commit description including a title,
    description and a Fixes: #XXX line if the commit addresses a particular
    GitHub issue.
  • If your commit description contains a Fixes: <commit-id> tag, then
    please add the commit author[s] as reviewer[s] to this issue.
  • All commits are signed off. See the section Developer’s Certificate of Origin
  • Provide a title or release-note blurb suitable for the release notes.
  • Are you a user of Cilium? Please add yourself to the Users doc
  • Thanks for contributing!

Fixes: #41867

@anubhabMajumdar anubhabMajumdar requested review from a team as code owners December 18, 2025 23:28
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Dec 18, 2025
@anubhabMajumdar anubhabMajumdar marked this pull request as draft December 18, 2025 23:28
@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/hybrid-routing-subnet branch 2 times, most recently from 489d3dc to bdd65e2 Compare December 19, 2025 17:26
@anubhabMajumdar anubhabMajumdar marked this pull request as ready for review December 19, 2025 18:07
@anubhabMajumdar anubhabMajumdar requested a review from a team as a code owner December 19, 2025 18:07
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

Hey @gandro Thanks for your review on #41405 . I have incorporated all your feedback here. Would love to get your feedback on this PR. Thanks!

@anubhabMajumdar anubhabMajumdar changed the title [41867] Part 2: Implement subnet-based identity routing for hybrid mode [41867] Part 2: Add subnet config watcher with stateDB and BPF map sync Dec 19, 2025
@julianwiedmann
Copy link
Copy Markdown
Member

👋 mind addressing the test gaps in the datapath first, so that we can chase down bugs without needing the whole controlplane / e2e tests?

@julianwiedmann julianwiedmann added the dont-merge/blocked Another PR must be merged before this one. label Dec 22, 2025
@qmonnet qmonnet added the release-note/major This PR introduces major new functionality to Cilium. label Jan 5, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jan 5, 2026
@qmonnet qmonnet added release-note/minor This PR changes functionality that users may find relevant to operating Cilium. and removed release-note/major This PR introduces major new functionality to Cilium. labels Jan 5, 2026
@joestringer joestringer added the dont-merge/wait-until-release Freeze window for current release is blocking non-bugfix PRs label Jan 9, 2026
@anubhabMajumdar anubhabMajumdar changed the title [41867] Part 2: Add subnet config watcher with stateDB and BPF map sync [41867] Part 3: Add subnet config watcher with stateDB and BPF map sync Jan 9, 2026
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

👋 mind addressing the test gaps in the datapath first, so that we can chase down bugs without needing the whole controlplane / e2e tests?

#43631 adds the bpf tests. Thanks!

Copy link
Copy Markdown
Member

@gandro gandro left a comment

Choose a reason for hiding this comment

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

Thanks! Overall looks okay to me, some minor things that I noticed in a first pass through.

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

@gandro Thanks for the review; addressed your comments and left one open for discussion.

Signed-off-by: Anubhab Majumdar <anmajumdar@microsoft.com>
@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/hybrid-routing-subnet branch 2 times, most recently from 2a3e61f to 5b0bc35 Compare January 28, 2026 01:45
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/test

…ting

- Implement SubnetMapKey and SubnetMapValue for LPM trie lookups
- Support both IPv4 and IPv6 address families
- Add comprehensive unit tests for key/value operations
- Add subnet/map-dump command for script testing and debugging
- Map types synced with bpf/lib/subnet.h

Signed-off-by: Anubhab Majumdar <anmajumdar@microsoft.com>
- Add subnet-identities stateDB table to store CIDR->Identity mappings
- Register reconciler to sync table entries to bpf map (cilium_subnet_map)
- Introduce maps/subnet cell

Signed-off-by: Anubhab Majumdar <anmajumdar@microsoft.com>
- Introduce subnet-map config to supply underlying subnet configuration
- Implement a watcher for above config that parse and adds the entries into subnet-identities stateDB
- Provide a cell for pkg/subnet

Signed-off-by: Anubhab Majumdar <anmajumdar@microsoft.com>
Add script based tests to verify subnet configuration flows
configmap to stateDB to bpf map.

Signed-off-by: Anubhab Majumdar <anmajumdar@microsoft.com>
@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/hybrid-routing-subnet branch from 5b0bc35 to 262bade Compare January 29, 2026 00:05
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/test

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/ci-gateway-api

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/ci-ginkgo

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

anubhabMajumdar commented Jan 29, 2026

The ci-ginkgo test seems to fail due to different reason unrelated to this change.

Copy link
Copy Markdown
Contributor

@smagnani96 smagnani96 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks 💯
Left one conversation open just to make sure we're not causing disruptions.
(In case, I expect we will catch it in subsequent PRs where we will test this in CI).

@smagnani96 smagnani96 added the area/agent Cilium agent related. label Jan 30, 2026
@joamaki joamaki added this pull request to the merge queue Jan 30, 2026
Merged via the queue into cilium:main with commit e4021bf Jan 30, 2026
78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Cilium agent related. release-note/minor This PR changes functionality that users may find relevant to operating Cilium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add hybrid routing to Cilium