Skip to content

Commit

Permalink
allow set vxlan nic tx off
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <[email protected]>
  • Loading branch information
bobz965 committed Sep 21, 2024
1 parent d38914a commit 85c83df
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/daemon/cniserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ func main() {
util.LogFatalAndExit(err, "failed to do the OS initialization")
}

if config.SetTxOff && config.NetworkType == util.NetworkTypeVxlan {
if err := setVxlanNicTxOff(); err != nil {
util.LogFatalAndExit(err, "failed to do the OS initialization for vxlan case")
}
}

ctrl.SetLogger(klog.NewKlogr())
ctx := signals.SetupSignalHandler()
stopCh := ctx.Done()
Expand Down
14 changes: 14 additions & 0 deletions cmd/daemon/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

const geneveLinkName = "genev_sys_6081"
const vxlanLinkName = "vxlan_sys_4789"

func printCaps() {
currentCaps := cap.GetProc()
Expand All @@ -30,3 +31,16 @@ func initForOS() error {
// disable checksum for genev_sys_6081 as default
return daemon.TurnOffNicTxChecksum(geneveLinkName)
}

func setVxlanNicTxOff() error {
if _, err := netlink.LinkByName(vxlanLinkName); err != nil {
if _, ok := err.(netlink.LinkNotFoundError); ok {
return nil
}
klog.Errorf("failed to get link %s: %v", vxlanLinkName, err)
return err
}

// disable checksum for vxlan_sys_4789 as default
return daemon.TurnOffNicTxChecksum(vxlanLinkName)
}
5 changes: 5 additions & 0 deletions cmd/daemon/init_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ func initForOS() error {

return nil
}

func setVxlanNicTxOff() error {
// TODO: implement this function
return nil
}
3 changes: 3 additions & 0 deletions pkg/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type Configuration struct {
UDPConnCheckPort int32
EnableTProxy bool
OVSVsctlConcurrency int32
SetTxOff bool
}

// ParseFlags will parse cmd args then init kubeClient and configuration
Expand Down Expand Up @@ -114,6 +115,7 @@ func ParseFlags() *Configuration {
argEnableTProxy = pflag.Bool("enable-tproxy", false, "enable tproxy for vpc pod liveness or readiness probe")
argOVSVsctlConcurrency = pflag.Int32("ovs-vsctl-concurrency", 100, "concurrency limit of ovs-vsctl")
argEnableOVNIPSec = pflag.Bool("enable-ovn-ipsec", false, "Whether to enable ovn ipsec")
argSetTxOff = pflag.Bool("set-tx-off", false, "Whether to set vxlan_sys_4789 tx off")
)

// mute info log for ipset lib
Expand Down Expand Up @@ -173,6 +175,7 @@ func ParseFlags() *Configuration {
UDPConnCheckPort: *argUDPConnectivityCheckPort,
EnableTProxy: *argEnableTProxy,
OVSVsctlConcurrency: *argOVSVsctlConcurrency,
SetTxOff: *argSetTxOff,
}
return config
}
Expand Down
1 change: 1 addition & 0 deletions pkg/daemon/ovs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,7 @@ func TurnOffNicTxChecksum(nicName string) error {
elapsed := float64((time.Since(start)) / time.Millisecond)
klog.V(4).Infof("command %s %s in %vms", "ethtool", strings.Join(args, " "), elapsed)
if err != nil {
klog.Error(err)
return fmt.Errorf("failed to turn off nic tx checksum, output %s, err %s", string(output), err.Error())
}
return nil
Expand Down

0 comments on commit 85c83df

Please sign in to comment.