Skip to content

Commit 7228ca7

Browse files
NihaNallappagaripchaigno
authored andcommitted
Fix: Update ipv6 default route with interface index
The changes introduced in PR: This change allows the IPAM plugin to use the "interfaces" field to pass uplink interface information to Cilium, so Cilium can set up host routes for Pods based on that info. While the "interfaces" field is defined in the CNI spec it hasn’t been used by IPAM plugins yet. With this approach, Cilium can better support environments with multiple uplinks in native routing mode without cloud-specific logic, maintaining full control over Pod traffic routing. Why is this PR change required: The kernel determines which interface (e.g., eth0, eth1) to use based on the index provided with the default route. When the gateway belongs to the pod subnet, the kernel can identify the correct interface without this index. However, in this case, the gateway is a link-local address, which is not tied to a specific interface. As a result, the kernel cannot determine which interface to use for the gateway and raises an error. The fix is a single-line change: passing the interface index to the default route, similar to how it is handled for IPv6 routes. This allows the kernel to correctly associate the route with the appropriate interface Fixes: [c90aed4](Support IPv6 for delegated IPAM) Signed-off-by: NihaNallappagari <nihan@microsoft.com>
1 parent 6f417f7 commit 7228ca7

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

pkg/datapath/linux/routing/routing.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,20 @@ func (info *RoutingInfo) gatewayRoutes(ifindex, tableID int) []*netlink.Route {
201201
}
202202

203203
// IPv6 routes
204+
defaultIpv6Route := &netlink.Route{
205+
Dst: &net.IPNet{IP: net.IPv6zero, Mask: net.CIDRMask(0, 128)},
206+
Table: tableID,
207+
Gw: info.Gateway,
208+
Protocol: linux_defaults.RTProto,
209+
}
210+
211+
// Only set LinkIndex for link-local gateways. The kernel needs the interface
212+
// index to route to link-local addresses since they're not tied to a specific
213+
// interface
214+
if info.Gateway.IsLinkLocalUnicast() {
215+
defaultIpv6Route.LinkIndex = ifindex
216+
}
217+
204218
return []*netlink.Route{
205219
{
206220
LinkIndex: ifindex,
@@ -209,13 +223,7 @@ func (info *RoutingInfo) gatewayRoutes(ifindex, tableID int) []*netlink.Route {
209223
Table: tableID,
210224
Protocol: linux_defaults.RTProto,
211225
},
212-
213-
{
214-
Dst: &net.IPNet{IP: net.IPv6zero, Mask: net.CIDRMask(0, 128)},
215-
Table: tableID,
216-
Gw: info.Gateway,
217-
Protocol: linux_defaults.RTProto,
218-
},
226+
defaultIpv6Route,
219227
}
220228

221229
}

0 commit comments

Comments
 (0)