Skip to content

Commit

Permalink
fix: remove auto checksums
Browse files Browse the repository at this point in the history
After some investigation the performance effect of disable checksum is not clear and might be dependent with network card features. So leave it as a user define option.
  • Loading branch information
oilbeater committed Apr 1, 2020
1 parent b8b00ef commit b6967f5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
2 changes: 1 addition & 1 deletion dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ spec:
- /kube-ovn/start-cniserver.sh
args:
- --enable-mirror=true
- --checksum-offload=auto
- --encap-checksum=true
- --service-cluster-ip-range=$SVC_CIDR
- --iface=
securityContext:
Expand Down
1 change: 1 addition & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ You can use `--default-cidr` flags below to config default Pod CIDR or create a
--enable-mirror: Enable traffic mirror, default: false
--mirror-iface: The mirror nic name that will be created by kube-ovn, default: mirror0
--service-cluster-ip-range: The kubernetes service cluster ip range, default: 10.96.0.0/12
--encap-checksum: Enable encapsulation checksums, default: true
--kubeconfig: Path to kubeconfig file with authorization and master location information. If not set use the inCluster token
```
Expand Down
32 changes: 7 additions & 25 deletions pkg/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Configuration struct {
NodeName string
ServiceClusterIPRange string
NodeLocalDNSIP string
ChecksumOffload string
EncapChecksum bool
PprofPort int
}

Expand All @@ -52,7 +52,7 @@ func ParseFlags() (*Configuration, error) {
argKubeConfigFile = pflag.String("kubeconfig", "", "Path to kubeconfig file with authorization and master location information. If not set use the inCluster token.")
argServiceClusterIPRange = pflag.String("service-cluster-ip-range", "10.96.0.0/12", "The kubernetes service cluster ip range, default: 10.96.0.0/12")
argNodeLocalDnsIP = pflag.String("node-local-dns-ip", "", "If use nodelocaldns the local dns server ip should be set here, default empty.")
argChecksumOffload = pflag.String("checksum-offload", "auto", "Enable checksum offload (auto, true, false) default: auto")
argEncapChecksum = pflag.Bool("encap-checksum", true, "Enable checksum, default: true")
argPprofPort = pflag.Int("pprof-port", 10665, "The port to get profiling data, default: 10665")
)

Expand Down Expand Up @@ -93,7 +93,7 @@ func ParseFlags() (*Configuration, error) {
NodeName: nodeName,
ServiceClusterIPRange: *argServiceClusterIPRange,
NodeLocalDNSIP: *argNodeLocalDnsIP,
ChecksumOffload: *argChecksumOffload,
EncapChecksum: *argEncapChecksum,
}

if err := config.initNicConfig(); err != nil {
Expand Down Expand Up @@ -126,8 +126,8 @@ func (config *Configuration) initNicConfig() error {
config.MTU = iface.MTU - util.GeneveHeaderLength
}

if config.ChecksumOffload == "true" || config.ChecksumOffload == "auto" && nicCanOffload(config.Iface) {
if err := setChecksumOffload(); err != nil {
if !config.EncapChecksum {
if err := disableChecksum(); err != nil {
klog.Errorf("failed to set checksum offload, %v", err)
}
}
Expand Down Expand Up @@ -211,27 +211,9 @@ func setEncapIP(ip string) error {
return nil
}

func nicCanOffload(nic string) bool {
raw, err := exec.Command("ethtool", "-k", nic).CombinedOutput()
if err != nil {
klog.Errorf("failed to get nic attributes, %v", err)
return false
}
tx, rx := false, false
for _, line := range strings.Split(string(raw), "\n") {
if strings.Contains(line, "rx-checksumming") && strings.Contains(line, "on") {
rx = true
}
if strings.Contains(line, "tx-checksumming") && strings.Contains(line, "on") {
tx = true
}
}
return tx && rx
}

func setChecksumOffload() error {
func disableChecksum() error {
raw, err := exec.Command(
"ovs-vsctl", "set", "open", ".", fmt.Sprintf("external-ids:ovn-encap-csum=false")).CombinedOutput()
"ovs-vsctl", "set", "open", ".", "external-ids:ovn-encap-csum=false").CombinedOutput()
if err != nil {
return fmt.Errorf("failed to set ovn-encap-csum, %s", string(raw))
}
Expand Down

0 comments on commit b6967f5

Please sign in to comment.