Skip to content

Commit

Permalink
Make disabling TX checksum for Antrea gateway
Browse files Browse the repository at this point in the history
This is a supplement to PR #3832. When `disableTXChecksumOffload`
is true, TX checksum offload of Antrea gateway should be also
disabled, otherwise for the cases in which the datapath doesn't
support TX checksum offloading, packets sent from Antrea gateway
could be dropped due to bad checksum.

Note that, when changing `disableTXChecksumOffload` from true back
to false, TX checksum offload of Antrea gateway will not be enabled
automatically, and TX checksum offload can be enabled manually with
ethtool. Another way is to remove Antrea gateway interface before
updating `disableTXChecksumOffload`.

Signed-off-by: Hongliang Liu <[email protected]>
  • Loading branch information
hongliangl committed Sep 27, 2022
1 parent 0f77529 commit 4454d71
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 38 deletions.
3 changes: 2 additions & 1 deletion cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
81 changes: 44 additions & 37 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -717,6 +720,10 @@ func (i *Initializer) configureGatewayInterface(gatewayIface *interfacestore.Int
return err
}

if err := i.setTXChecksumOffload(); err != nil {
return err
}

return nil
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/agent/agent_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
4 changes: 4 additions & 0 deletions pkg/agent/agent_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,3 +499,7 @@ func (i *Initializer) installVMInitialFlows() error {
}
return nil
}

func (i *Initializer) setTXChecksumOffload() error {
return nil
}

0 comments on commit 4454d71

Please sign in to comment.