diff --git a/cmd/antrea-agent/agent.go b/cmd/antrea-agent/agent.go index aec095bb99e..74172ca8ad5 100644 --- a/cmd/antrea-agent/agent.go +++ b/cmd/antrea-agent/agent.go @@ -247,7 +247,8 @@ func run(o *Options) error { o.config.ExternalNode.ExternalNodeNamespace, features.DefaultFeatureGate.Enabled(features.AntreaProxy), o.config.AntreaProxy.ProxyAll, - connectUplinkToBridge) + connectUplinkToBridge, + o.config.DisableTXChecksumOffload) err = agentInitializer.Initialize() if err != nil { return fmt.Errorf("error initializing agent: %v", err) diff --git a/pkg/agent/agent.go b/pkg/agent/agent.go index a122608c6a8..2c858ca11df 100644 --- a/pkg/agent/agent.go +++ b/pkg/agent/agent.go @@ -85,23 +85,24 @@ var otherConfigKeysForIPsecCertificates = []string{"certificate", "private_key", // Initializer knows how to setup host networking, OpenVSwitch, and Openflow. type Initializer struct { - client clientset.Interface - crdClient versioned.Interface - ovsBridgeClient ovsconfig.OVSBridgeClient - ofClient openflow.Client - routeClient route.Interface - wireGuardClient wireguard.Interface - ifaceStore interfacestore.InterfaceStore - ovsBridge string - hostGateway string // name of gateway port on the OVS bridge - mtu int - networkConfig *config.NetworkConfig - nodeConfig *config.NodeConfig - wireGuardConfig *config.WireGuardConfig - egressConfig *config.EgressConfig - serviceConfig *config.ServiceConfig - enableProxy bool - connectUplinkToBridge bool + client clientset.Interface + crdClient versioned.Interface + ovsBridgeClient ovsconfig.OVSBridgeClient + ofClient openflow.Client + routeClient route.Interface + wireGuardClient wireguard.Interface + ifaceStore interfacestore.InterfaceStore + ovsBridge string + hostGateway string // name of gateway port on the OVS bridge + mtu int + networkConfig *config.NetworkConfig + nodeConfig *config.NodeConfig + wireGuardConfig *config.WireGuardConfig + egressConfig *config.EgressConfig + serviceConfig *config.ServiceConfig + enableProxy bool + connectUplinkToBridge bool + disableTXChecksumOffload bool // networkReadyCh should be closed once the Node's network is ready. // The CNI server will wait for it before handling any CNI Add requests. proxyAll bool @@ -132,28 +133,30 @@ func NewInitializer( enableProxy bool, proxyAll bool, connectUplinkToBridge bool, + disableTXChecksumOffload bool, ) *Initializer { return &Initializer{ - ovsBridgeClient: ovsBridgeClient, - client: k8sClient, - crdClient: crdClient, - ifaceStore: ifaceStore, - ofClient: ofClient, - routeClient: routeClient, - ovsBridge: ovsBridge, - hostGateway: hostGateway, - mtu: mtu, - networkConfig: networkConfig, - wireGuardConfig: wireGuardConfig, - egressConfig: egressConfig, - serviceConfig: serviceConfig, - networkReadyCh: networkReadyCh, - stopCh: stopCh, - nodeType: nodeType, - externalNodeNamespace: externalNodeNamespace, - enableProxy: enableProxy, - proxyAll: proxyAll, - connectUplinkToBridge: connectUplinkToBridge, + ovsBridgeClient: ovsBridgeClient, + client: k8sClient, + crdClient: crdClient, + ifaceStore: ifaceStore, + ofClient: ofClient, + routeClient: routeClient, + ovsBridge: ovsBridge, + hostGateway: hostGateway, + mtu: mtu, + networkConfig: networkConfig, + wireGuardConfig: wireGuardConfig, + egressConfig: egressConfig, + serviceConfig: serviceConfig, + networkReadyCh: networkReadyCh, + stopCh: stopCh, + nodeType: nodeType, + externalNodeNamespace: externalNodeNamespace, + enableProxy: enableProxy, + proxyAll: proxyAll, + connectUplinkToBridge: connectUplinkToBridge, + disableTXChecksumOffload: disableTXChecksumOffload, } } @@ -717,6 +720,10 @@ func (i *Initializer) configureGatewayInterface(gatewayIface *interfacestore.Int return err } + if err := i.setTXChecksumOffload(); err != nil { + return err + } + return nil } diff --git a/pkg/agent/agent_linux.go b/pkg/agent/agent_linux.go index 790e41f195d..928e803d2b3 100644 --- a/pkg/agent/agent_linux.go +++ b/pkg/agent/agent_linux.go @@ -30,6 +30,7 @@ import ( "antrea.io/antrea/pkg/agent/config" "antrea.io/antrea/pkg/agent/interfacestore" "antrea.io/antrea/pkg/agent/util" + "antrea.io/antrea/pkg/agent/util/ethtool" "antrea.io/antrea/pkg/apis/crd/v1alpha1" utilip "antrea.io/antrea/pkg/util/ip" ) @@ -312,3 +313,12 @@ func (i *Initializer) prepareOVSBridgeForVM() error { func (i *Initializer) installVMInitialFlows() error { return nil } + +func (i *Initializer) setTXChecksumOffload() error { + if i.disableTXChecksumOffload { + if err := ethtool.EthtoolTXHWCsumOff(i.hostGateway); err != nil { + return fmt.Errorf("error when disabling TX checksum offload on %s: %v", i.hostGateway, err) + } + } + return nil +} diff --git a/pkg/agent/agent_windows.go b/pkg/agent/agent_windows.go index 615cf41d1e3..e6dcc46a5ee 100644 --- a/pkg/agent/agent_windows.go +++ b/pkg/agent/agent_windows.go @@ -499,3 +499,7 @@ func (i *Initializer) installVMInitialFlows() error { } return nil } + +func (i *Initializer) setTXChecksumOffload() error { + return nil +}