Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make disabling TX checksum for Antrea gateway #3957

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe name it as disableTXChecksumOffload?
You mentioned when changing disableTXChecksumOffload from true back to false, TX checksum offload of Antrea gateway will not be enabled automatically, If user changes disableTXChecksumOffload in the config file, I assume Antrea agent need to be restarted? then I think we can check and enable it again automatically in codes?

Btw, you need re-base the codes and add more test cases for code coverage improvement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe name it as disableTXChecksumOffload?

There is variable of Initializer which is named disableTXChecksumOffload

Btw, you need re-base the codes and add more test cases for code coverage improvement.

Rebased, and could you provide some examples about such test?

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
}