Skip to content

[GH-41867][Part-1][eBPF] Add support for hybrid routing in datapath#41868

Merged
YutaroHayakawa merged 1 commit intocilium:mainfrom
anubhabMajumdar:topic/anmajumdar/hybrid-routing-datapath
Nov 14, 2025
Merged

[GH-41867][Part-1][eBPF] Add support for hybrid routing in datapath#41868
YutaroHayakawa merged 1 commit intocilium:mainfrom
anubhabMajumdar:topic/anmajumdar/hybrid-routing-datapath

Conversation

@anubhabMajumdar
Copy link
Copy Markdown
Contributor

@anubhabMajumdar anubhabMajumdar commented Sep 24, 2025

Description

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

This is Part 1 of feature:

  • adds the subnet map in datapath
  • add lookup functions for getting subnet id
  • skip tunneling if IPs belong to same subnet ID
  • won't interfere with how datapath works today (allows checking this PR in as a standalone change)

For reference, here's a draft PR with the entire feature implemented - #41405 .

Overview

This feature would allow user to configure Cilium cluster(s) with multiple subnets, and benefit from both tunnel and native routing mode for maximum efficiency (no overhead of tunneling when not needed).

Motivation

  1. Given that tunneling can always route a packet as long as nodes have connectivity, the entire change is designed to use tunnel as default, with exceptions built in to skip tunneling when IPs belong to same subnet.
  2. I have tried to adhere to existing patterns that I could identify - the eBPF map and lookup function closely resembles the IPCache library.

Changes Overview

Datapath

This covers all the C code changes. Files edited/added:

  1. bpf/lib/subnet.h - This has the LPM trie based subnet map, similar to the IPCache map. Has functions for lookup.
  2. bpf_lxc.c - Added an extra check to skip_tunnel. Now, skip tunneling if IPs belong to same subnet.
  3. bpf_host.c - Added an extra check to skip_tunnel. Now, skip tunneling if IPs belong to same subnet.
  4. Added two debug keys - DBG_SUBNET_CHECK and DBG_TUNNEL_TRACE for debugging purposes. Will remove these before merging.

Testing Done

The full feature is tested using the change draft PR.
I tested this change against a cluster and verified:

  • the subnet map doesn't exist
  • all IPs return ID=0
  • No packet skips tunneling

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

Add support for hybrid routing in datapath

@anubhabMajumdar anubhabMajumdar requested a review from a team as a code owner September 24, 2025 01:13
@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 Sep 24, 2025
@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/hybrid-routing-datapath branch 2 times, most recently from 499e645 to 4d3d78b Compare September 24, 2025 01:47
@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/hybrid-routing-datapath branch from 4d3d78b to d215a8f Compare September 24, 2025 01:52
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/test

@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/hybrid-routing-datapath branch from d215a8f to 1952662 Compare September 24, 2025 01:54
Copy link
Copy Markdown
Member

@YutaroHayakawa YutaroHayakawa left a comment

Choose a reason for hiding this comment

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

Thanks! Made an initial review. I have some questions and nits.

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

anubhabMajumdar commented Oct 22, 2025

Thanks! Made an initial review. I have some questions and nits.

Thank you @YutaroHayakawa for your review. I have addressed your comments. Would appreciate another pass.
P.S. I had to rebase to remove style issues in the older commit.

@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/hybrid-routing-datapath branch 3 times, most recently from 2ab5cc6 to 34e78d4 Compare October 23, 2025 16:38
@anubhabMajumdar anubhabMajumdar requested a review from a team as a code owner October 23, 2025 16:38
@anubhabMajumdar anubhabMajumdar requested review from dylandreimerink and removed request for Andreagit97 October 23, 2025 16:38
@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/hybrid-routing-datapath branch 2 times, most recently from d5a70d1 to bdc686d Compare October 23, 2025 17:06
Copy link
Copy Markdown
Member

@YutaroHayakawa YutaroHayakawa left a comment

Choose a reason for hiding this comment

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

Thanks! Almost there.

Copy link
Copy Markdown
Member

@dylandreimerink dylandreimerink left a comment

Choose a reason for hiding this comment

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

Changes look good from the loader perspective. Will let Yutaro handle the datapath review.

Copy link
Copy Markdown
Member

@YutaroHayakawa YutaroHayakawa left a comment

Choose a reason for hiding this comment

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

@anubhabMajumdar Seems like you re-requested my review, but seems like there are some comments and suggestions which is not resolved yet. Let me request change. Please take a look whenever you have time.

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

@anubhabMajumdar Seems like you re-requested my review, but seems like there are some comments and suggestions which is not resolved yet. Let me request change. Please take a look whenever you have time.

Replied to the comment I missed. Let me know what you think. Thanks for your feedback.

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

Conversation around the pipeline failure - https://cilium.slack.com/archives/C7PE7V806/p1763051497549979
Based on suggestion, rebased the PR.

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/test

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/ci-ginkgo

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/ci-e2e-upgrade

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/ci-ginkgo

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/ci-ipsec-e2e

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

https://github.com/cilium/cilium/actions/runs/19340685839/job/55328009387

ci-ginkgo fails with provisioning LVH VMs.

Signed-off-by: Anubhab Majumdar <anmajumdar@microsoft.com>
@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/hybrid-routing-datapath branch from eebe5ae to b4044a8 Compare November 14, 2025 14:40
@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-ipsec-e2e

@YutaroHayakawa YutaroHayakawa added the release-note/minor This PR changes functionality that users may find relevant to operating Cilium. label Nov 14, 2025
@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 Nov 14, 2025
@YutaroHayakawa YutaroHayakawa added this pull request to the merge queue Nov 14, 2025
Merged via the queue into cilium:main with commit 368a5fa Nov 14, 2025
73 checks passed
@anubhabMajumdar anubhabMajumdar deleted the topic/anmajumdar/hybrid-routing-datapath branch November 14, 2025 19:11
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

@julianwiedmann Addressed your comments here - #43631 . Thanks!

@joestringer joestringer added release-note/misc This PR makes changes that have no direct user impact. and removed release-note/minor This PR changes functionality that users may find relevant to operating Cilium. labels Jan 21, 2026
@joestringer
Copy link
Copy Markdown
Member

FYI given that this is only a portion of the infrastructure required for the feature, I have changed the release note category to misc. Minor or above are intended to inform users about changes and improvements that they can actively use, but it seems like this cannot be actively used just yet. Probably when we get to the final PR for this feature series we can mark that one as release-note/major and ensure it gets sufficient spotlight in the corresponding release announcement :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. release-note/misc This PR makes changes that have no direct user impact.

Projects

No open projects
Status: Released

Development

Successfully merging this pull request may close these issues.

Add hybrid routing to Cilium

6 participants