Skip to content

Commit

Permalink
cni-server: disable udp-fragmentation-offload (#4342)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian authored Jul 30, 2024
1 parent fa42912 commit 386732c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkg/daemon/ovs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,12 @@ func (csh cniServerHandler) configureContainerNic(podName, podNamespace, nicName
klog.Error(err)
return err
}
if err = configureNic(nicName, ipAddr, macAddr, mtu, detectIPConflict); err != nil {
if err = configureNic(nicName, ipAddr, macAddr, mtu, detectIPConflict, false); err != nil {
klog.Error(err)
return err
}
} else {
if err = configureNic(ifName, ipAddr, macAddr, mtu, detectIPConflict); err != nil {
if err = configureNic(ifName, ipAddr, macAddr, mtu, detectIPConflict, true); err != nil {
klog.Error(err)
return err
}
Expand Down Expand Up @@ -587,7 +587,7 @@ func configureNodeNic(portName, ip, gw, joinCIDR string, macAddr net.HardwareAdd
}
}

if err = configureNic(util.NodeNic, ip, macAddr, mtu, false); err != nil {
if err = configureNic(util.NodeNic, ip, macAddr, mtu, false, false); err != nil {
klog.Error(err)
return err
}
Expand Down Expand Up @@ -768,7 +768,7 @@ func configureNodeGwNic(portName, ip, gw string, macAddr net.HardwareAddr, mtu i
klog.V(3).Infof("node external nic %q already in ns %s", util.NodeGwNic, util.NodeGwNsPath)
}
return ns.WithNetNSPath(gwNS.Path(), func(_ ns.NetNS) error {
if err = configureNic(util.NodeGwNic, ip, macAddr, mtu, true); err != nil {
if err = configureNic(util.NodeGwNic, ip, macAddr, mtu, true, false); err != nil {
klog.Errorf("failed to configure node gw nic %s, %v", util.NodeGwNic, err)
return err
}
Expand Down Expand Up @@ -1018,7 +1018,7 @@ func configureMirrorLink(portName string, _ int) error {
return nil
}

func configureNic(link, ip string, macAddr net.HardwareAddr, mtu int, detectIPConflict bool) error {
func configureNic(link, ip string, macAddr net.HardwareAddr, mtu int, detectIPConflict, setUfoOff bool) error {
nodeLink, err := netlink.LinkByName(link)
if err != nil {
klog.Error(err)
Expand Down Expand Up @@ -1111,6 +1111,14 @@ func configureNic(link, ip string, macAddr net.HardwareAddr, mtu int, detectIPCo
}
}

if setUfoOff {
cmd := fmt.Sprintf("if ethtool -k %s | grep -q ^udp-fragmentation-offload; then ethtool -K %s ufo off; fi", link, link)
if output, err := exec.Command("sh", "-xc", cmd).CombinedOutput(); err != nil {
klog.Error(err)
return fmt.Errorf("failed to disable udp-fragmentation-offload feature of device %s to off: %w, %s", link, err, output)
}
}

return nil
}

Expand Down

0 comments on commit 386732c

Please sign in to comment.