Skip to content

Commit

Permalink
Remove ovsDatapathType in openflow client structure
Browse files Browse the repository at this point in the history
Since now we no longer rely on the userspace datapath as mentioned in antrea-io#3591, then
related code can be removed.

Signed-off-by: Hongliang Liu <lhongliang@vmware.com>
  • Loading branch information
hongliangl committed Apr 21, 2022
1 parent 5905e98 commit 18af84b
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 44 deletions.
2 changes: 1 addition & 1 deletion cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func run(o *Options) error {
ovsDatapathType := ovsconfig.OVSDatapathType(o.config.OVSDatapathType)
ovsBridgeClient := ovsconfig.NewOVSBridge(o.config.OVSBridge, ovsDatapathType, ovsdbConnection)
ovsBridgeMgmtAddr := ofconfig.GetMgmtAddress(o.config.OVSRunDir, o.config.OVSBridge)
ofClient := openflow.NewClient(o.config.OVSBridge, ovsBridgeMgmtAddr, ovsDatapathType,
ofClient := openflow.NewClient(o.config.OVSBridge, ovsBridgeMgmtAddr,
features.DefaultFeatureGate.Enabled(features.AntreaProxy),
features.DefaultFeatureGate.Enabled(features.AntreaPolicy),
egressEnabled,
Expand Down
1 change: 0 additions & 1 deletion pkg/agent/openflow/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,6 @@ func (c *client) generatePipelines() {
c.ipProtocols,
c.nodeConfig,
c.networkConfig,
c.ovsDatapathType,
c.connectUplinkToBridge,
c.enableMulticast)
c.activatedFeatures = append(c.activatedFeatures, c.featurePodConnectivity)
Expand Down
14 changes: 7 additions & 7 deletions pkg/agent/openflow/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestIdempotentFlowInstallation(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
m := oftest.NewMockOFEntryOperations(ctrl)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, ovsconfig.OVSDatapathSystem, true, false, false, false, false, false, false)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, true, false, false, false, false, false, false)
client := ofClient.(*client)
client.cookieAllocator = cookie.NewAllocator(0)
client.ofEntryOperations = m
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestIdempotentFlowInstallation(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
m := oftest.NewMockOFEntryOperations(ctrl)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, ovsconfig.OVSDatapathSystem, true, false, false, false, false, false, false)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, true, false, false, false, false, false, false)
client := ofClient.(*client)
client.cookieAllocator = cookie.NewAllocator(0)
client.ofEntryOperations = m
Expand Down Expand Up @@ -186,7 +186,7 @@ func TestFlowInstallationFailed(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
m := oftest.NewMockOFEntryOperations(ctrl)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, ovsconfig.OVSDatapathSystem, true, false, false, false, false, false, false)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, true, false, false, false, false, false, false)
client := ofClient.(*client)
client.cookieAllocator = cookie.NewAllocator(0)
client.ofEntryOperations = m
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestConcurrentFlowInstallation(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
m := oftest.NewMockOFEntryOperations(ctrl)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, ovsconfig.OVSDatapathSystem, true, false, false, false, false, false, false)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, true, false, false, false, false, false, false)
client := ofClient.(*client)
client.cookieAllocator = cookie.NewAllocator(0)
client.ofEntryOperations = m
Expand Down Expand Up @@ -417,7 +417,7 @@ func Test_client_SendTraceflowPacket(t *testing.T) {
}

func prepareTraceflowFlow(ctrl *gomock.Controller) *client {
ofClient := NewClient(bridgeName, bridgeMgmtAddr, ovsconfig.OVSDatapathSystem, true, true, false, false, false, false, false)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, true, true, false, false, false, false, false)
c := ofClient.(*client)
c.cookieAllocator = cookie.NewAllocator(0)
c.nodeConfig = nodeConfig
Expand All @@ -443,7 +443,7 @@ func prepareTraceflowFlow(ctrl *gomock.Controller) *client {
}

func prepareSendTraceflowPacket(ctrl *gomock.Controller, success bool) *client {
ofClient := NewClient(bridgeName, bridgeMgmtAddr, ovsconfig.OVSDatapathSystem, true, true, false, false, false, false, false)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, true, true, false, false, false, false, false)
c := ofClient.(*client)
c.nodeConfig = nodeConfig
m := ovsoftest.NewMockBridge(ctrl)
Expand Down Expand Up @@ -531,7 +531,7 @@ func Test_client_setBasePacketOutBuilder(t *testing.T) {
}

func prepareSetBasePacketOutBuilder(ctrl *gomock.Controller, success bool) *client {
ofClient := NewClient(bridgeName, bridgeMgmtAddr, ovsconfig.OVSDatapathSystem, true, true, false, false, false, false, false)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, true, true, false, false, false, false, false)
c := ofClient.(*client)
m := ovsoftest.NewMockBridge(ctrl)
c.bridge = m
Expand Down
6 changes: 1 addition & 5 deletions pkg/agent/openflow/meters_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@ import (
"github.com/blang/semver"
"k8s.io/klog/v2"

"antrea.io/antrea/pkg/ovs/ovsconfig"
"antrea.io/antrea/pkg/util/runtime"
)

func ovsMetersAreSupported(ovsDatapathType ovsconfig.OVSDatapathType) bool {
if ovsDatapathType == ovsconfig.OVSDatapathNetdev {
return true
}
func ovsMetersAreSupported() bool {
// According to the OVS documentation, meters are supported in the kernel module since 4.15
// (https://docs.openvswitch.org/en/latest/faq/releases/). However, it turns out that
// because of a bug meters cannot be used with kernel versions older than 4.18, which is
Expand Down
6 changes: 1 addition & 5 deletions pkg/agent/openflow/meters_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@

package openflow

import (
"antrea.io/antrea/pkg/ovs/ovsconfig"
)

func ovsMetersAreSupported(ovsDatapathType ovsconfig.OVSDatapathType) bool {
func ovsMetersAreSupported() bool {
// TODO: revisit after Windows OVS supports OpenFlow meters.
return false
}
8 changes: 3 additions & 5 deletions pkg/agent/openflow/network_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
crdv1alpha1 "antrea.io/antrea/pkg/apis/crd/v1alpha1"
binding "antrea.io/antrea/pkg/ovs/openflow"
mocks "antrea.io/antrea/pkg/ovs/openflow/testing"
"antrea.io/antrea/pkg/ovs/ovsconfig"
ovsctltest "antrea.io/antrea/pkg/ovs/ovsctl/testing"
"antrea.io/antrea/pkg/util/ip"
)
Expand Down Expand Up @@ -519,7 +518,7 @@ func TestBatchInstallPolicyRuleFlows(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockOperations := oftest.NewMockOFEntryOperations(ctrl)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, ovsconfig.OVSDatapathSystem, false, true, false, false, false, false, false)
ofClient := NewClient(bridgeName, bridgeMgmtAddr, false, true, false, false, false, false, false)
c = ofClient.(*client)
c.cookieAllocator = cookie.NewAllocator(0)
c.ofEntryOperations = mockOperations
Expand Down Expand Up @@ -997,9 +996,8 @@ func prepareClient(ctrl *gomock.Controller, dualStack bool) *client {
ipProtocols = append(ipProtocols, binding.ProtocolIPv6)
}
c = &client{
bridge: bridge,
ovsDatapathType: ovsconfig.OVSDatapathNetdev,
ipProtocols: ipProtocols,
bridge: bridge,
ipProtocols: ipProtocols,
}
c.cookieAllocator = cookie.NewAllocator(0)
m := oftest.NewMockOFEntryOperations(ctrl)
Expand Down
9 changes: 2 additions & 7 deletions pkg/agent/openflow/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"antrea.io/antrea/pkg/agent/openflow/cookie"
"antrea.io/antrea/pkg/agent/types"
binding "antrea.io/antrea/pkg/ovs/openflow"
"antrea.io/antrea/pkg/ovs/ovsconfig"
"antrea.io/antrea/pkg/ovs/ovsctl"
"antrea.io/antrea/pkg/util/runtime"
"antrea.io/antrea/third_party/proxy"
Expand Down Expand Up @@ -416,8 +415,6 @@ type client struct {
networkConfig *config.NetworkConfig
egressConfig *config.EgressConfig
serviceConfig *config.ServiceConfig
// ovsDatapathType is the type of the datapath used by the bridge.
ovsDatapathType ovsconfig.OVSDatapathType
// ovsMetersAreSupported indicates whether the OVS datapath supports OpenFlow meters.
ovsMetersAreSupported bool
// packetInHandlers stores handler to process PacketIn event. Each packetin reason can have multiple handlers registered.
Expand Down Expand Up @@ -2107,7 +2104,7 @@ func (f *featureNetworkPolicy) dnsPacketInFlow(conjunctionID uint32) binding.Flo
func (f *featurePodConnectivity) localProbeFlow() []binding.Flow {
cookieID := f.cookieAllocator.Request(f.category).Raw()
var flows []binding.Flow
if runtime.IsWindowsPlatform() || f.ovsDatapathType == ovsconfig.OVSDatapathNetdev {
if runtime.IsWindowsPlatform() {
for ipProtocol, gatewayIP := range f.gatewayIPs {
flows = append(flows, IngressSecurityClassifierTable.ofTable.BuildFlow(priorityHigh).
Cookie(cookieID).
Expand Down Expand Up @@ -2654,7 +2651,6 @@ func (f *featureMulticast) externalMulticastReceiverFlow() binding.Flow {
// NewClient is the constructor of the Client interface.
func NewClient(bridgeName string,
mgmtAddr string,
ovsDatapathType ovsconfig.OVSDatapathType,
enableProxy bool,
enableAntreaPolicy bool,
enableEgress bool,
Expand All @@ -2675,8 +2671,7 @@ func NewClient(bridgeName string,
pipelines: make(map[binding.PipelineID]binding.Pipeline),
packetInHandlers: map[uint8]map[string]PacketInHandler{},
ovsctlClient: ovsctl.NewClient(bridgeName),
ovsDatapathType: ovsDatapathType,
ovsMetersAreSupported: ovsMetersAreSupported(ovsDatapathType),
ovsMetersAreSupported: ovsMetersAreSupported(),
}
c.ofEntryOperations = c
return c
Expand Down
5 changes: 0 additions & 5 deletions pkg/agent/openflow/pod_connectivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"antrea.io/antrea/pkg/agent/config"
"antrea.io/antrea/pkg/agent/openflow/cookie"
binding "antrea.io/antrea/pkg/ovs/openflow"
"antrea.io/antrea/pkg/ovs/ovsconfig"
"antrea.io/antrea/pkg/util/runtime"
)

Expand All @@ -37,8 +36,6 @@ type featurePodConnectivity struct {
nodeIPs map[binding.Protocol]net.IP
nodeConfig *config.NodeConfig
networkConfig *config.NetworkConfig
// ovsDatapathType is the type of the datapath used by the bridge.
ovsDatapathType ovsconfig.OVSDatapathType

connectUplinkToBridge bool
ctZoneSrcField *binding.RegField
Expand All @@ -57,7 +54,6 @@ func newFeaturePodConnectivity(
ipProtocols []binding.Protocol,
nodeConfig *config.NodeConfig,
networkConfig *config.NetworkConfig,
ovsDatapathType ovsconfig.OVSDatapathType,
connectUplinkToBridge bool,
enableMulticast bool) *featurePodConnectivity {
ctZones := make(map[binding.Protocol]int)
Expand Down Expand Up @@ -96,7 +92,6 @@ func newFeaturePodConnectivity(
nodeIPs: nodeIPs,
nodeConfig: nodeConfig,
networkConfig: networkConfig,
ovsDatapathType: ovsDatapathType,
connectUplinkToBridge: connectUplinkToBridge,
ipCtZoneTypeRegMarks: ipCtZoneTypeRegMarks,
ctZoneSrcField: getZoneSrcField(connectUplinkToBridge),
Expand Down
16 changes: 8 additions & 8 deletions test/integration/agent/openflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestConnectivityFlows(t *testing.T) {
antrearuntime.WindowsOS = runtime.GOOS
}

c = ofClient.NewClient(br, bridgeMgmtAddr, ovsconfig.OVSDatapathNetdev, true, false, true, false, false, false, false)
c = ofClient.NewClient(br, bridgeMgmtAddr, true, false, true, false, false, false, false)
err := ofTestUtils.PrepareOVSBridge(br)
require.Nil(t, err, fmt.Sprintf("Failed to prepare OVS bridge: %v", err))
defer func() {
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestAntreaFlexibleIPAMConnectivityFlows(t *testing.T) {
legacyregistry.Reset()
metrics.InitializeOVSMetrics()

c = ofClient.NewClient(br, bridgeMgmtAddr, ovsconfig.OVSDatapathNetdev, true, false, true, false, false, true, false)
c = ofClient.NewClient(br, bridgeMgmtAddr, true, false, true, false, false, true, false)
err := ofTestUtils.PrepareOVSBridge(br)
require.Nil(t, err, fmt.Sprintf("Failed to prepare OVS bridge: %v", err))
defer func() {
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestReplayFlowsConnectivityFlows(t *testing.T) {
legacyregistry.Reset()
metrics.InitializeOVSMetrics()

c = ofClient.NewClient(br, bridgeMgmtAddr, ovsconfig.OVSDatapathNetdev, true, false, true, false, false, false, false)
c = ofClient.NewClient(br, bridgeMgmtAddr, true, false, true, false, false, false, false)
err := ofTestUtils.PrepareOVSBridge(br)
require.Nil(t, err, fmt.Sprintf("Failed to prepare OVS bridge: %v", err))

Expand Down Expand Up @@ -265,7 +265,7 @@ func TestReplayFlowsNetworkPolicyFlows(t *testing.T) {
legacyregistry.Reset()
metrics.InitializeOVSMetrics()

c = ofClient.NewClient(br, bridgeMgmtAddr, ovsconfig.OVSDatapathNetdev, true, false, false, false, false, false, false)
c = ofClient.NewClient(br, bridgeMgmtAddr, true, false, false, false, false, false, false)
err := ofTestUtils.PrepareOVSBridge(br)
require.Nil(t, err, fmt.Sprintf("Failed to prepare OVS bridge: %v", err))

Expand Down Expand Up @@ -442,7 +442,7 @@ func TestNetworkPolicyFlows(t *testing.T) {
legacyregistry.Reset()
metrics.InitializeOVSMetrics()

c = ofClient.NewClient(br, bridgeMgmtAddr, ovsconfig.OVSDatapathNetdev, true, false, false, false, false, false, false)
c = ofClient.NewClient(br, bridgeMgmtAddr, true, false, false, false, false, false, false)
err := ofTestUtils.PrepareOVSBridge(br)
require.Nil(t, err, fmt.Sprintf("Failed to prepare OVS bridge %s", br))

Expand Down Expand Up @@ -556,7 +556,7 @@ func TestIPv6ConnectivityFlows(t *testing.T) {
legacyregistry.Reset()
metrics.InitializeOVSMetrics()

c = ofClient.NewClient(br, bridgeMgmtAddr, ovsconfig.OVSDatapathNetdev, true, false, true, false, false, false, false)
c = ofClient.NewClient(br, bridgeMgmtAddr, true, false, true, false, false, false, false)
err := ofTestUtils.PrepareOVSBridge(br)
require.Nil(t, err, fmt.Sprintf("Failed to prepare OVS bridge: %v", err))

Expand Down Expand Up @@ -604,7 +604,7 @@ func TestProxyServiceFlows(t *testing.T) {
legacyregistry.Reset()
metrics.InitializeOVSMetrics()

c = ofClient.NewClient(br, bridgeMgmtAddr, ovsconfig.OVSDatapathNetdev, true, false, false, false, false, false, false)
c = ofClient.NewClient(br, bridgeMgmtAddr, true, false, false, false, false, false, false)
err := ofTestUtils.PrepareOVSBridge(br)
require.Nil(t, err, fmt.Sprintf("Failed to prepare OVS bridge %s", br))

Expand Down Expand Up @@ -1632,7 +1632,7 @@ func TestEgressMarkFlows(t *testing.T) {
legacyregistry.Reset()
metrics.InitializeOVSMetrics()

c = ofClient.NewClient(br, bridgeMgmtAddr, ovsconfig.OVSDatapathNetdev, false, false, true, false, false, false, false)
c = ofClient.NewClient(br, bridgeMgmtAddr, false, false, true, false, false, false, false)
err := ofTestUtils.PrepareOVSBridge(br)
require.Nil(t, err, fmt.Sprintf("Failed to prepare OVS bridge %s", br))

Expand Down

0 comments on commit 18af84b

Please sign in to comment.