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 a012bb2 commit 9056aa0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/daemon/ovs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,12 @@ func configureContainerNic(nicName, ifName string, ipAddr, gateway string, isDef
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 @@ -621,7 +621,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 @@ -735,7 +735,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 @@ -822,6 +822,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 9056aa0

Please sign in to comment.