From 289f5ee8d6dc6b3ab912fe034a26b7c6e9b2b637 Mon Sep 17 00:00:00 2001 From: Zhecheng Li Date: Mon, 9 Nov 2020 10:51:33 +0800 Subject: [PATCH] [IPv6] Fix issues * remove Github Actions integration test, Jenkins: jenkins-integration -> Integration tests * remove nodeRouteInfo * go fmt * add FlowProtocl() to interface Flow * remove extra lines when rebasing for an octant commit * TestIPv6RoutesAndNeighbors: routeClient.Initialize --- .github/workflows/integration.yml | 27 ---------- ci/jenkins/jobs/projects.yaml | 2 +- .../noderoute/node_route_controller.go | 7 --- pkg/agent/openflow/client.go | 8 +-- pkg/agent/openflow/pipeline.go | 52 +++++++++---------- pkg/agent/route/route_windows_test.go | 2 + pkg/ovs/openflow/interfaces.go | 1 + pkg/ovs/openflow/ofctrl_flow.go | 4 ++ pkg/ovs/openflow/testing/mock_openflow.go | 14 +++++ plugins/octant/go.mod | 4 -- test/integration/agent/route_test.go | 2 +- 11 files changed, 54 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/integration.yml diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml deleted file mode 100644 index a9e78115817..00000000000 --- a/.github/workflows/integration.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Integration -on: - pull_request: - branches: - - master - - release-* - push: - branches: - - master - - release-* -jobs: - test-integration: - name: Integration tests - runs-on: [ubuntu-18.04] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v1 - with: - go-version: 1.15 - - name: Run integration tests - run: make docker-test-integration - - name: Code coverage - uses: codecov/codecov-action@v1 - with: - file: .coverage/coverage-integration.txt - flags: integration-tests - name: codecov-integration-test diff --git a/ci/jenkins/jobs/projects.yaml b/ci/jenkins/jobs/projects.yaml index 715cfbb2127..37c7df386ce 100644 --- a/ci/jenkins/jobs/projects.yaml +++ b/ci/jenkins/jobs/projects.yaml @@ -131,7 +131,7 @@ - nobody123_nobody123_ only_trigger_phrase: false trigger_permit_all: true - status_context: jenkins-integration + status_context: Integration tests status_url: null success_status: Build finished. failure_status: Failed. diff --git a/pkg/agent/controller/noderoute/node_route_controller.go b/pkg/agent/controller/noderoute/node_route_controller.go index 8f89ffe72bf..cec8bae407a 100644 --- a/pkg/agent/controller/noderoute/node_route_controller.go +++ b/pkg/agent/controller/noderoute/node_route_controller.go @@ -114,13 +114,6 @@ func NewNodeRouteController( return controller } -// nodeRouteInfo is the route related information extracted from corev1.Node. -type nodeRouteInfo struct { - podCIDR *net.IPNet - nodeIP net.IP - gatewayIP net.IP -} - // enqueueNode adds an object to the controller work queue // obj could be a *corev1.Node, or a DeletionFinalStateUnknown item. func (c *Controller) enqueueNode(obj interface{}) { diff --git a/pkg/agent/openflow/client.go b/pkg/agent/openflow/client.go index 589426c7bb6..f1750e6689c 100644 --- a/pkg/agent/openflow/client.go +++ b/pkg/agent/openflow/client.go @@ -779,10 +779,12 @@ func (c *client) InstallTraceflowFlows(dataplaneTag uint8) error { flows = []binding.Flow{} for _, ctx := range c.globalConjMatchFlowCache { if ctx.dropFlow != nil { + copyFlowBuilder := ctx.dropFlow.CopyToBuilder(priorityNormal+2, false) + if ctx.dropFlow.FlowProtocol() == "" { + copyFlowBuilder = copyFlowBuilder.MatchProtocol(binding.ProtocolIP) + } flows = append( - flows, - ctx.dropFlow.CopyToBuilder(priorityNormal+2, false). - MatchIPDscp(dataplaneTag). + flows, copyFlowBuilder.MatchIPDscp(dataplaneTag). SetHardTimeout(300). Action().SendToController(uint8(PacketInReasonTF)). Done()) diff --git a/pkg/agent/openflow/pipeline.go b/pkg/agent/openflow/pipeline.go index c6806f816fc..7acccea0dbc 100644 --- a/pkg/agent/openflow/pipeline.go +++ b/pkg/agent/openflow/pipeline.go @@ -35,33 +35,33 @@ import ( const ( // Flow table id index - ClassifierTable binding.TableIDType = 0 - uplinkTable binding.TableIDType = 5 - spoofGuardTable binding.TableIDType = 10 - arpResponderTable binding.TableIDType = 20 - ipv6Table binding.TableIDType = 21 - serviceHairpinTable binding.TableIDType = 29 - conntrackTable binding.TableIDType = 30 - conntrackStateTable binding.TableIDType = 31 - sessionAffinityTable binding.TableIDType = 40 - dnatTable binding.TableIDType = 40 - serviceLBTable binding.TableIDType = 41 - endpointDNATTable binding.TableIDType = 42 - AntreaPolicyEgressRuleTable binding.TableIDType = 45 - DefaultTierEgressRuleTable binding.TableIDType = 49 - EgressRuleTable binding.TableIDType = 50 - EgressDefaultTable binding.TableIDType = 60 - EgressMetricTable binding.TableIDType = 61 - l3ForwardingTable binding.TableIDType = 70 - l2ForwardingCalcTable binding.TableIDType = 80 + ClassifierTable binding.TableIDType = 0 + uplinkTable binding.TableIDType = 5 + spoofGuardTable binding.TableIDType = 10 + arpResponderTable binding.TableIDType = 20 + ipv6Table binding.TableIDType = 21 + serviceHairpinTable binding.TableIDType = 29 + conntrackTable binding.TableIDType = 30 + conntrackStateTable binding.TableIDType = 31 + sessionAffinityTable binding.TableIDType = 40 + dnatTable binding.TableIDType = 40 + serviceLBTable binding.TableIDType = 41 + endpointDNATTable binding.TableIDType = 42 + AntreaPolicyEgressRuleTable binding.TableIDType = 45 + DefaultTierEgressRuleTable binding.TableIDType = 49 + EgressRuleTable binding.TableIDType = 50 + EgressDefaultTable binding.TableIDType = 60 + EgressMetricTable binding.TableIDType = 61 + l3ForwardingTable binding.TableIDType = 70 + l2ForwardingCalcTable binding.TableIDType = 80 AntreaPolicyIngressRuleTable binding.TableIDType = 85 - DefaultTierIngressRuleTable binding.TableIDType = 89 - IngressRuleTable binding.TableIDType = 90 - IngressDefaultTable binding.TableIDType = 100 - IngressMetricTable binding.TableIDType = 101 - conntrackCommitTable binding.TableIDType = 105 - hairpinSNATTable binding.TableIDType = 106 - L2ForwardingOutTable binding.TableIDType = 110 + DefaultTierIngressRuleTable binding.TableIDType = 89 + IngressRuleTable binding.TableIDType = 90 + IngressDefaultTable binding.TableIDType = 100 + IngressMetricTable binding.TableIDType = 101 + conntrackCommitTable binding.TableIDType = 105 + hairpinSNATTable binding.TableIDType = 106 + L2ForwardingOutTable binding.TableIDType = 110 // Flow priority level priorityHigh = uint16(210) diff --git a/pkg/agent/route/route_windows_test.go b/pkg/agent/route/route_windows_test.go index f83840b75f6..df0f92d0955 100644 --- a/pkg/agent/route/route_windows_test.go +++ b/pkg/agent/route/route_windows_test.go @@ -45,6 +45,7 @@ func TestRouteOperation(t *testing.T) { peerNodeIP1 := net.ParseIP("10.0.0.2") peerNodeIP2 := net.ParseIP("10.0.0.3") gwIP1 := net.ParseIP("192.168.2.1") + _, podIPv4CIDR, _ := net.ParseCIDR("192.168.1.0/24") _, destCIDR1, _ := net.ParseCIDR("192.168.2.0/24") dest2 := "192.168.3.0/24" gwIP2 := net.ParseIP("192.168.3.1") @@ -56,6 +57,7 @@ func TestRouteOperation(t *testing.T) { client, err := NewClient(serviceCIDR, &config.NetworkConfig{}, false) require.Nil(t, err) nodeConfig := &config.NodeConfig{ + PodIPv4CIDR: podIPv4CIDR, GatewayConfig: &config.GatewayConfig{ Name: hostGateway, LinkIndex: gwLink, diff --git a/pkg/ovs/openflow/interfaces.go b/pkg/ovs/openflow/interfaces.go index 7026a52d30a..b000e9f35a9 100644 --- a/pkg/ovs/openflow/interfaces.go +++ b/pkg/ovs/openflow/interfaces.go @@ -157,6 +157,7 @@ type Flow interface { OFEntry // Returns the flow priority associated with OFEntry FlowPriority() uint16 + FlowProtocol() Protocol MatchString() string // CopyToBuilder returns a new FlowBuilder that copies the matches of the Flow. // It copies the original actions of the Flow only if copyActions is set to true, and diff --git a/pkg/ovs/openflow/ofctrl_flow.go b/pkg/ovs/openflow/ofctrl_flow.go index 2969cf86118..00246f8339b 100644 --- a/pkg/ovs/openflow/ofctrl_flow.go +++ b/pkg/ovs/openflow/ofctrl_flow.go @@ -93,6 +93,10 @@ func (f *ofFlow) FlowPriority() uint16 { return f.Match.Priority } +func (f *ofFlow) FlowProtocol() Protocol { + return f.protocol +} + func (f *ofFlow) GetBundleMessage(entryOper OFOperation) (ofctrl.OpenFlowModMessage, error) { var operation int switch entryOper { diff --git a/pkg/ovs/openflow/testing/mock_openflow.go b/pkg/ovs/openflow/testing/mock_openflow.go index b65afd8caae..0f8d9c137b1 100644 --- a/pkg/ovs/openflow/testing/mock_openflow.go +++ b/pkg/ovs/openflow/testing/mock_openflow.go @@ -447,6 +447,20 @@ func (mr *MockFlowMockRecorder) FlowPriority() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FlowPriority", reflect.TypeOf((*MockFlow)(nil).FlowPriority)) } +// FlowProtocol mocks base method +func (m *MockFlow) FlowProtocol() openflow.Protocol { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FlowProtocol") + ret0, _ := ret[0].(openflow.Protocol) + return ret0 +} + +// FlowProtocol indicates an expected call of FlowProtocol +func (mr *MockFlowMockRecorder) FlowProtocol() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FlowProtocol", reflect.TypeOf((*MockFlow)(nil).FlowProtocol)) +} + // GetBundleMessage mocks base method func (m *MockFlow) GetBundleMessage(arg0 openflow.OFOperation) (ofctrl.OpenFlowModMessage, error) { m.ctrl.T.Helper() diff --git a/plugins/octant/go.mod b/plugins/octant/go.mod index 454d746b134..af383a7216b 100644 --- a/plugins/octant/go.mod +++ b/plugins/octant/go.mod @@ -10,11 +10,7 @@ require ( ) replace ( -<<<<<<< HEAD github.com/contiv/ofnet => github.com/wenyingd/ofnet v0.0.0-20201109024835-6fd225d8c8d1 -======= - github.com/contiv/ofnet => github.com/wenyingd/ofnet v0.0.0-20200728094531-d5b4d75f2cc3 ->>>>>>> 964affb ([IPv6] Change openflow pipeline for L2 Pod networking (#1040)) github.com/vmware-tanzu/antrea => ../../ // Octant v0.13.1 and Antrea use different versions of github.com/googleapis/gnostic. // Octant v0.13.1 uses v0.4.1 and Antrea uses v0.1.0. diff --git a/test/integration/agent/route_test.go b/test/integration/agent/route_test.go index 119ae3fbb6f..8d58ac9f331 100644 --- a/test/integration/agent/route_test.go +++ b/test/integration/agent/route_test.go @@ -507,7 +507,7 @@ func TestIPv6RoutesAndNeighbors(t *testing.T) { NodeIPAddr: nodeIP, GatewayConfig: dualGWConfig, } - err = routeClient.Initialize(dualNodeConfig) + err = routeClient.Initialize(dualNodeConfig, func() {}) assert.Nil(t, err) tcs := []struct {