Skip to content

Commit

Permalink
fix: disable offload if geneve port exists
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Apr 1, 2021
1 parent a167992 commit fefcff2
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions pkg/daemon/ovs.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,6 @@ func configureNodeNic(portName, ip, gw string, macAddr net.HardwareAddr, mtu int
klog.Errorf("failed to disable checksum offload on ovn0, %v %q", err, output)
return err
}
output, err = exec.Command("ethtool", "-K", "genev_sys_6081", "tx", "off").CombinedOutput()
if err != nil {
klog.Errorf("failed to disable checksum offload on genev_sys_6081, %v %q", err, output)
return err
}

// ping ovn0 gw to activate the flow
output, err = ovn0Check(gw)
Expand All @@ -280,9 +275,27 @@ func configureNodeNic(portName, ip, gw string, macAddr net.HardwareAddr, mtu int
klog.Infof("ping gw result is: \n %s", output)

go loopOvn0Check(gw)
go loopDisableTunnelOffload()
return nil
}

func disableTunnelOffload() {
_, err := netlink.LinkByName("genev_sys_6081")
if err == nil {
output, err := exec.Command("ethtool", "-K", "genev_sys_6081", "tx", "off").CombinedOutput()
if err != nil {
klog.Errorf("failed to disable checksum offload on genev_sys_6081, %v %q", err, output)
}
}
}

func loopDisableTunnelOffload() {
for {
time.Sleep(5 * time.Second)
disableTunnelOffload()
}
}

// If OVS restart, the ovn0 port will down and prevent host to pod network,
// Restart the kube-ovn-cni when this happens
func loopOvn0Check(gw string) {
Expand All @@ -308,7 +321,7 @@ func ovn0Check(gw string) ([]byte, error) {
if protocol == kubeovnv1.ProtocolDual {
gws := strings.Split(gw, ",")
output, err := exec.Command("ping", "-w", "10", gws[0]).CombinedOutput()
klog.Infof("ping v4 gw result is: \n %s", output)
klog.V(3).Infof("ping v4 gw result is: \n %s", output)
if err != nil {
klog.Errorf("ovn0 failed to ping gw %s, %v", gws[0], err)
return output, err
Expand Down

0 comments on commit fefcff2

Please sign in to comment.