Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion felix/routetable/route_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ func (r *RouteTable) recalculateDesiredKernelRoute(routeKey RouteKey) {
Ifindex: bestIfaceIdx,
OnLink: bestTarget.Flags()&unix.RTNH_F_ONLINK != 0,
Protocol: proto,
MTU: bestTarget.MTU,
Comment thread
fasaxc marked this conversation as resolved.
}
if len(bestTarget.MultiPath) > 0 {
for _, nh := range bestTarget.MultiPath {
Expand All @@ -793,7 +794,6 @@ func (r *RouteTable) recalculateDesiredKernelRoute(routeKey RouteKey) {
} else {
kernRoute.GW = bestTarget.GW
kernRoute.Ifindex = bestIfaceIdx
kernRoute.MTU = bestTarget.MTU
}
if log.IsLevelEnabled(log.DebugLevel) && !reflect.DeepEqual(oldDesiredRoute, kernRoute) {
r.logCxt.WithFields(log.Fields{
Expand Down
65 changes: 65 additions & 0 deletions felix/routetable/route_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,71 @@ var _ = Describe("RouteTable", func() {
Expect(dataplane.RouteKeyToRoute[mainRouteKey("10.0.0.0/24")]).To(BeZero(),
"Route should be removed when one interface deleted")
})
It("Should program MTU on a multi-path route and correct an incorrect MTU on resync", func() {
By("Creating interfaces")
addLink := dataplane.AddIface(6, "cali6", true, true)
addLink2 := dataplane.AddIface(7, "cali7", true, true)

By("Setting a multi-path route with MTU")
rt.SetRoutes(RouteClassLocalWorkload, InterfaceNone, []Target{{
Type: TargetTypeVXLAN,
RouteKey: RouteKey{
CIDR: ip.MustParseCIDROrIP("10.0.0.0/24"),
Priority: routePriorityForTest,
},
MTU: 1400,
MultiPath: []NextHop{
{
IfaceName: addLink.LinkAttrs.Name,
Gw: ip.FromString("10.0.0.6"),
},
{
IfaceName: addLink2.LinkAttrs.Name,
Gw: ip.FromString("10.0.0.7"),
},
},
}})
err := rt.Apply()
Expect(err).ToNot(HaveOccurred())

expectedRoute := netlink.Route{
Family: unix.AF_INET,
Dst: mustParseCIDR("10.0.0.0/24"),
Type: syscall.RTN_UNICAST,
Protocol: deviceRouteProtocol,
Scope: netlink.SCOPE_UNIVERSE,
Table: unix.RT_TABLE_MAIN,
Flags: syscall.RTNH_F_ONLINK,
MTU: 1400,
MultiPath: []*netlink.NexthopInfo{
{
LinkIndex: addLink.LinkAttrs.Index,
Gw: net.ParseIP("10.0.0.6").To4(),
Flags: syscall.RTNH_F_ONLINK,
},
{
LinkIndex: addLink2.LinkAttrs.Index,
Gw: net.ParseIP("10.0.0.7").To4(),
Flags: syscall.RTNH_F_ONLINK,
},
},
Priority: routePriorityForTest,
}
Expect(dataplane.RouteKeyToRoute[mainRouteKey("10.0.0.0/24")]).To(Equal(expectedRoute),
"MTU should be programmed on the multi-path route")

By("Corrupting the MTU in the dataplane behind the RouteTable's back")
corrupted := expectedRoute
corrupted.MTU = 9000
dataplane.RouteKeyToRoute[mainRouteKey("10.0.0.0/24")] = corrupted

By("Triggering a resync")
rt.QueueResync()
err = rt.Apply()
Expect(err).ToNot(HaveOccurred())
Expect(dataplane.RouteKeyToRoute[mainRouteKey("10.0.0.0/24")]).To(Equal(expectedRoute),
"resync should have corrected the incorrect MTU on the multi-path route")
})
It("Should add multiple routes with a protocol", func() {
// Route that needs to be added
addLink := dataplane.AddIface(6, "cali6", true, true)
Expand Down
Loading