-
Notifications
You must be signed in to change notification settings - Fork 346
/
pipeline_other.go
88 lines (81 loc) · 3.31 KB
/
pipeline_other.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//go:build !windows
// +build !windows
// package openflow is needed by antctl which is compiled for macOS too.
// Copyright 2021 Antrea Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package openflow
import (
"net"
binding "antrea.io/antrea/pkg/ovs/openflow"
)
// hostBridgeUplinkFlows generates the flows that forward traffic between the bridge local port and the uplink port to
// support the host traffic.
// TODO(gran): sync latest changes from pipeline_windows.go
func (f *featurePodConnectivity) hostBridgeUplinkFlows() []binding.Flow {
// outputToBridgeRegMark marks that the output interface is OVS bridge.
outputToBridgeRegMark := binding.NewRegMark(TargetOFPortField, f.hostIfacePort)
cookieID := f.cookieAllocator.Request(f.category).Raw()
flows := f.hostBridgeLocalFlows()
flows = append(flows,
// This generates the flow to forward ARP packets from uplink port in normal way since uplink port is set to enable
// flood.
ARPSpoofGuardTable.ofTable.BuildFlow(priorityHigh).
Cookie(cookieID).
MatchInPort(f.uplinkPort).
MatchProtocol(binding.ProtocolARP).
Action().Normal().
Done(),
// This generates the flow to forward ARP from bridge local port in normal way since bridge port is set to enable
// flood.
ARPSpoofGuardTable.ofTable.BuildFlow(priorityHigh).
Cookie(cookieID).
MatchInPort(f.hostIfacePort).
MatchProtocol(binding.ProtocolARP).
Action().Normal().
Done(),
// Handle packet to Node.
// Must use a separate flow to Output(config.BridgeOFPort), otherwise OVS will drop the packet:
// output:NXM_NX_REG1[]
// >> output port 4294967294 is out of range
// Datapath actions: drop
// TODO(gran): support Traceflow
L2ForwardingCalcTable.ofTable.BuildFlow(priorityNormal).
Cookie(cookieID).
MatchDstMAC(f.nodeConfig.UplinkNetConfig.MAC).
Action().LoadToRegField(TargetOFPortField, f.hostIfacePort).
Action().LoadRegMark(OFPortFoundRegMark).
Action().GotoStage(stageConntrack).
Done(),
L2ForwardingOutTable.ofTable.BuildFlow(priorityHigh).
Cookie(cookieID).
MatchProtocol(binding.ProtocolIP).
MatchRegMark(outputToBridgeRegMark, OFPortFoundRegMark).
Action().Output(f.hostIfacePort).
Done(),
// Handle outgoing packet from AntreaFlexibleIPAM Pods. Broadcast is not supported.
L2ForwardingCalcTable.ofTable.BuildFlow(priorityLow).
Cookie(cookieID).
MatchRegMark(AntreaFlexibleIPAMRegMark).
Action().LoadToRegField(TargetOFPortField, f.uplinkPort).
Action().LoadRegMark(OFPortFoundRegMark).
Action().GotoStage(stageConntrack).
Done())
return flows
}
func (f *featurePodConnectivity) l3FwdFlowToRemoteViaRouting(localGatewayMAC net.HardwareAddr,
remoteGatewayMAC net.HardwareAddr,
peerIP net.IP,
peerPodCIDR *net.IPNet) []binding.Flow {
return []binding.Flow{f.l3FwdFlowToRemoteViaGW(localGatewayMAC, *peerPodCIDR)}
}