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 committed Jul 31, 2024
1 parent 8a63e44 commit 72d03ac
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pkg/daemon/ovs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
Expand Down Expand Up @@ -210,11 +211,11 @@ func configureContainerNic(nicName, ifName, ipAddr, gateway string, isDefaultRou
if err = configureAdditionalNic(ifName, ipAddr); err != nil {
return err
}
if err = configureNic(nicName, ipAddr, macAddr, mtu, detectIPConflict); err != nil {
if err = configureNic(nicName, ipAddr, macAddr, mtu, detectIPConflict, false); err != nil {
return err
}
} else {
if err = configureNic(ifName, ipAddr, macAddr, mtu, detectIPConflict); err != nil {
if err = configureNic(ifName, ipAddr, macAddr, mtu, detectIPConflict, true); err != nil {
return err
}
}
Expand Down Expand Up @@ -376,7 +377,7 @@ func configureNodeNic(portName, ip, gw, joinCIDR string, macAddr net.HardwareAdd
return fmt.Errorf(raw)
}

if err = configureNic(util.NodeNic, ip, macAddr, mtu, false); err != nil {
if err = configureNic(util.NodeNic, ip, macAddr, mtu, false, false); err != nil {
return err
}

Expand Down Expand Up @@ -521,7 +522,7 @@ func configureMirrorLink(portName string, mtu 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 {
return fmt.Errorf("can not find nic %s: %v", link, err)
Expand Down Expand Up @@ -603,6 +604,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 72d03ac

Please sign in to comment.