Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program MTU on vxlan routes #10103

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 2 additions & 0 deletions felix/dataplane/linux/int_dataplane.go
Original file line number Diff line number Diff line change
@@ -668,6 +668,7 @@ func NewIntDataplaneDriver(config Config) *InternalDataplane {
config,
dp.loopSummarizer,
4,
config.VXLANMTU,
)
dp.vxlanParentC = make(chan string, 1)
go dp.vxlanManager.KeepVXLANDeviceInSync(context.Background(), config.VXLANMTU, dataplaneFeatures.ChecksumOffloadBroken, 10*time.Second, dp.vxlanParentC)
@@ -1130,6 +1131,7 @@ func NewIntDataplaneDriver(config Config) *InternalDataplane {
config,
dp.loopSummarizer,
6,
config.VXLANMTUV6,
)
dp.vxlanParentCV6 = make(chan string, 1)
go dp.vxlanManagerV6.KeepVXLANDeviceInSync(context.Background(), config.VXLANMTUV6, dataplaneFeatures.ChecksumOffloadBroken, 10*time.Second, dp.vxlanParentCV6)
11 changes: 10 additions & 1 deletion felix/dataplane/linux/vxlan_mgr.go
Original file line number Diff line number Diff line change
@@ -76,6 +76,7 @@ type vxlanManager struct {
vxlanID int
vxlanPort int
ipVersion uint8
mtu int

// Indicates if configuration has changed since the last apply.
routesDirty bool
@@ -104,6 +105,7 @@ func newVXLANManager(
dpConfig Config,
opRecorder logutils.OpRecorder,
ipVersion uint8,
mtu int,
) *vxlanManager {
nlHandle, _ := netlinkshim.NewRealNetlink()
return newVXLANManagerWithShims(
@@ -115,6 +117,7 @@ func newVXLANManager(
opRecorder,
nlHandle,
ipVersion,
mtu,
)
}

@@ -127,6 +130,7 @@ func newVXLANManagerWithShims(
opRecorder logutils.OpRecorder,
nlHandle netlinkHandle,
ipVersion uint8,
mtu int,
) *vxlanManager {
logCtx := logrus.WithField("ipVersion", ipVersion)
return &vxlanManager{
@@ -147,6 +151,7 @@ func newVXLANManagerWithShims(
vxlanID: dpConfig.RulesConfig.VXLANVNI,
vxlanPort: dpConfig.RulesConfig.VXLANPort,
ipVersion: ipVersion,
mtu: mtu,
externalNodeCIDRs: dpConfig.ExternalNodesCidrs,
routesDirty: true,
vtepsDirty: true,
@@ -531,7 +536,10 @@ func (m *vxlanManager) tunneledRoute(cidr ip.CIDR, r *proto.RouteUpdate) *routet
if isRemoteTunnelRoute(r) {
// We treat remote tunnel routes as directly connected. They don't have a gateway of
// the VTEP because they ARE the VTEP!
return &routetable.Target{CIDR: cidr}
return &routetable.Target{
CIDR: cidr,
MTU: m.mtu,
}
}

// Extract the gateway addr for this route based on its remote VTEP.
@@ -548,6 +556,7 @@ func (m *vxlanManager) tunneledRoute(cidr ip.CIDR, r *proto.RouteUpdate) *routet
Type: routetable.TargetTypeVXLAN,
CIDR: cidr,
GW: ip.FromString(vtepAddr),
MTU: m.mtu,
}
}

14 changes: 12 additions & 2 deletions felix/dataplane/linux/vxlan_mgr_test.go
Original file line number Diff line number Diff line change
@@ -157,6 +157,7 @@ var _ = Describe("VXLANManager", func() {
ipVersion: 4,
},
4,
4444,
)

managerV6 = newVXLANManagerWithShims(
@@ -179,6 +180,7 @@ var _ = Describe("VXLANManager", func() {
ipVersion: 6,
},
6,
6666,
)
})

@@ -478,7 +480,11 @@ var _ = Describe("VXLANManager", func() {

// Expect a directly connected route to the borrowed IP.
Expect(rt.currentRoutes[dataplanedefs.VXLANIfaceNameV4]).To(HaveLen(1))
Expect(rt.currentRoutes[dataplanedefs.VXLANIfaceNameV4][0]).To(Equal(routetable.Target{CIDR: ip.MustParseCIDROrIP("10.0.1.1/32")}))
Expect(rt.currentRoutes[dataplanedefs.VXLANIfaceNameV4][0]).To(Equal(
routetable.Target{
CIDR: ip.MustParseCIDROrIP("10.0.1.1/32"),
MTU: 4444,
}))

// Delete the route.
manager.OnUpdate(&proto.RouteRemove{
@@ -508,7 +514,11 @@ var _ = Describe("VXLANManager", func() {

// Expect a directly connected route to the borrowed IP.
Expect(rt.currentRoutes[dataplanedefs.VXLANIfaceNameV6]).To(HaveLen(1))
Expect(rt.currentRoutes[dataplanedefs.VXLANIfaceNameV6][0]).To(Equal(routetable.Target{CIDR: ip.MustParseCIDROrIP("fc00:10:244::1/112")}))
Expect(rt.currentRoutes[dataplanedefs.VXLANIfaceNameV6][0]).To(Equal(
routetable.Target{
CIDR: ip.MustParseCIDROrIP("fc00:10:244::1/112"),
MTU: 6666,
}))

// Delete the route.
managerV6.OnUpdate(&proto.RouteRemove{
1 change: 1 addition & 0 deletions felix/routetable/defs.go
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@ type Target struct {
DestMAC net.HardwareAddr
Protocol netlink.RouteProtocol
MultiPath []NextHop
MTU int
}

func (t Target) Equal(t2 Target) bool {
17 changes: 16 additions & 1 deletion felix/routetable/route_table.go
Original file line number Diff line number Diff line change
@@ -749,6 +749,7 @@ func (r *RouteTable) recalculateDesiredKernelRoute(cidr ip.CIDR) {
} 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{
@@ -1285,6 +1286,7 @@ func (r *RouteTable) netlinkRouteToKernelRoute(route *netlink.Route) (kernKey ke
Src: ip.FromNetIP(route.Src),
OnLink: route.Flags&unix.RTNH_F_ONLINK != 0,
Protocol: route.Protocol,
MTU: route.MTU,
}

if len(route.MultiPath) > 0 {
@@ -1421,6 +1423,7 @@ func (r *RouteTable) applyUpdates(attempt int) error {
LinkIndex: kRoute.Ifindex,
Protocol: kRoute.Protocol,
Flags: flags,
MTU: kRoute.MTU,
}
for _, nh := range kRoute.NextHops {
nlRoute.MultiPath = append(nlRoute.MultiPath, &netlink.NexthopInfo{
@@ -1754,6 +1757,7 @@ type kernelRoute struct {
// NextHops should be specified (for a multi-path route).
GW ip.Addr
Ifindex int
MTU int

NextHops []kernelNextHop
}
@@ -1785,6 +1789,9 @@ func (r kernelRoute) Equals(b kernelRoute) bool {
if r.Ifindex != b.Ifindex {
return false
}
if r.MTU != b.MTU {
return false
}
if len(r.NextHops) != len(b.NextHops) {
return false
}
@@ -1833,8 +1840,16 @@ func (r kernelRoute) String() string {
nextHopPart = fmt.Sprintf("GW=%s, Ifindex=%d", gwStr, r.Ifindex)
}

return fmt.Sprintf("kernelRoute{Type=%d, Scope=%d, Src=%s, Protocol=%v, OnLink=%v, %s}",
str := fmt.Sprintf("kernelRoute{Type=%d, Scope=%d, Src=%s, Protocol=%v, OnLink=%v, %s",
r.Type, r.Scope, srcStr, r.Protocol, r.OnLink, nextHopPart)

if r.MTU != 0 {
str += fmt.Sprintf(", mtu %d", r.MTU)
}

str += "}"

return str
}

type kernelNextHop struct {