fix: remove multiple MTU reductions

fixes cloudnativelabs#1033
This commit is contained in:
Aaron U'Ren 2022-06-11 12:15:36 -05:00 committed by Aaron U'Ren
parent c93178df28
commit f97eb7cc1a
3 changed files with 4 additions and 11 deletions

View File

@ -2347,7 +2347,7 @@ func NewNetworkServicesController(clientset kubernetes.Interface,
return nil, err
}
nsc.nodeIP = NodeIP
automtu, err := utils.GetMTUFromNodeIP(nsc.nodeIP, config.EnableOverlay)
automtu, err := utils.GetMTUFromNodeIP(nsc.nodeIP)
if err != nil {
return nil, err
}

View File

@ -234,7 +234,7 @@ func (nrc *NetworkRoutingController) Run(healthChan chan<- *healthcheck.Controll
}
if nrc.autoMTU {
mtu, err := utils.GetMTUFromNodeIP(nrc.nodeIP, nrc.enableOverlays)
mtu, err := utils.GetMTUFromNodeIP(nrc.nodeIP)
if err != nil {
klog.Errorf("Failed to find MTU for node IP: %s for intelligently setting the kube-bridge MTU "+
"due to %s.", nrc.nodeIP, err.Error())
@ -401,7 +401,7 @@ func (nrc *NetworkRoutingController) updateCNIConfig() {
}
func (nrc *NetworkRoutingController) autoConfigureMTU() error {
mtu, err := utils.GetMTUFromNodeIP(nrc.nodeIP, nrc.enableOverlays)
mtu, err := utils.GetMTUFromNodeIP(nrc.nodeIP)
if err != nil {
return fmt.Errorf("failed to generate MTU: %s", err.Error())
}
@ -701,10 +701,6 @@ func (nrc *NetworkRoutingController) setupOverlayTunnel(tunnelName string, nextH
if err = netlink.LinkSetUp(link); err != nil {
return nil, errors.New("Failed to bring tunnel interface " + tunnelName + " up due to: " + err.Error())
}
// reduce the MTU by 20 bytes to accommodate ipip tunnel overhead
if err = netlink.LinkSetMTU(link, link.Attrs().MTU-utils.IPInIPHeaderLength); err != nil {
return nil, errors.New("Failed to set MTU of tunnel interface " + tunnelName + " up due to: " + err.Error())
}
} else {
klog.V(1).Infof(
"Tunnel interface: " + tunnelName + " for the node " + nextHop.String() + " already exists.")

View File

@ -63,7 +63,7 @@ func GetNodeIP(node *apiv1.Node) (net.IP, error) {
}
// GetMTUFromNodeIP returns the MTU by detecting it from the IP on the node and figuring in tunneling configurations
func GetMTUFromNodeIP(nodeIP net.IP, overlayEnabled bool) (int, error) {
func GetMTUFromNodeIP(nodeIP net.IP) (int, error) {
links, err := netlink.LinkList()
if err != nil {
return 0, errors.New("failed to get list of links")
@ -76,9 +76,6 @@ func GetMTUFromNodeIP(nodeIP net.IP, overlayEnabled bool) (int, error) {
for _, addr := range addresses {
if addr.IPNet.IP.Equal(nodeIP) {
linkMTU := link.Attrs().MTU
if overlayEnabled {
return linkMTU - IPInIPHeaderLength, nil // -20 to accommodate IPIP header
}
return linkMTU, nil
}
}