Skip to content

cilium-cni: Add support for route/rules creation on Kubernetes IPAM#658

Merged
HadrienPatte merged 1 commit intov1.19-ddfrom
hadrien/1.19/oracle
Apr 1, 2026
Merged

cilium-cni: Add support for route/rules creation on Kubernetes IPAM#658
HadrienPatte merged 1 commit intov1.19-ddfrom
hadrien/1.19/oracle

Conversation

@HadrienPatte
Copy link
Copy Markdown
Member

Enable multi-VNIC routing for Kubernetes IPAM mode, targeting environments like Oracle Cloud where pods need per-interface routing rules (similar to what ENI/Azure modes already provide).

The change has three parts:

  1. hostScopeAllocator (pkg/ipam/hostscope.go): At allocator construction time, scan netlink interfaces to find one whose subnet contains the allocation CIDR. If found, cache its MAC, interface index, CIDR, and derived gateway IP. Stamp this routing info onto every AllocationResult, making it available to downstream consumers without per-allocation syscalls.

  2. infra_ip_allocation.go: Relax the routing-setup guards from explicit IPAM mode checks (ENI/AlibabaCloud/Azure) to presence checks on the routing fields (GatewayIP, PrimaryMAC, CIDRs). This is a no-op for ENI/Azure (their CRD allocator already populates these fields) but enables Kubernetes IPAM to configure the same per-interface routes and rules when routing info is available.

  3. cilium-cni cmd.go: Extend needsEndpointRoutingOnHost to also return true for Kubernetes IPAM when gateway and MAC are present, so the CNI plugin sets up endpoint routes on the host for multi-VNIC pods.

Enable multi-VNIC routing for Kubernetes IPAM mode, targeting environments
like Oracle Cloud where pods need per-interface routing rules (similar to
what ENI/Azure modes already provide).

The change has three parts:

1. hostScopeAllocator (pkg/ipam/hostscope.go): At allocator construction
   time, scan netlink interfaces to find one whose subnet contains the
   allocation CIDR. If found, cache its MAC, interface index, CIDR, and
   derived gateway IP. Stamp this routing info onto every AllocationResult,
   making it available to downstream consumers without per-allocation
   syscalls.

2. infra_ip_allocation.go: Relax the routing-setup guards from explicit
   IPAM mode checks (ENI/AlibabaCloud/Azure) to presence checks on the
   routing fields (GatewayIP, PrimaryMAC, CIDRs). This is a no-op for
   ENI/Azure (their CRD allocator already populates these fields) but
   enables Kubernetes IPAM to configure the same per-interface routes
   and rules when routing info is available.

3. cilium-cni cmd.go: Extend needsEndpointRoutingOnHost to also return
   true for Kubernetes IPAM when gateway and MAC are present, so the
   CNI plugin sets up endpoint routes on the host for multi-VNIC pods.

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
@HadrienPatte HadrienPatte marked this pull request as ready for review March 31, 2026 14:45
@41ks
Copy link
Copy Markdown

41ks commented Mar 31, 2026

Hope we can get this patch merged upstream without a lot of trouble. It seems pretty safe. Though, I don't know if there are potential edge cases in some random config that would break this. Hopefully not ...

@HadrienPatte HadrienPatte merged commit eb80fd0 into v1.19-dd Apr 1, 2026
27 checks passed
@HadrienPatte HadrienPatte deleted the hadrien/1.19/oracle branch April 1, 2026 15:52
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.

2 participants