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

Match dstIP in Classifier to address windows promiscuous mode issue #6528

Merged
merged 1 commit into from
Aug 8, 2024
Merged
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
5 changes: 2 additions & 3 deletions pkg/agent/openflow/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -2967,9 +2967,8 @@ func (f *featurePodConnectivity) hostBridgeLocalFlows() []binding.Flow {
cookieID := f.cookieAllocator.Request(f.category).Raw()
return []binding.Flow{
// This generates the flow to forward the packets from uplink port to bridge local port.
ClassifierTable.ofTable.BuildFlow(priorityNormal).
Cookie(cookieID).
MatchInPort(f.uplinkPort).
f.matchUplinkInPortInClassifierTable(ClassifierTable.ofTable.BuildFlow(priorityNormal).
Cookie(cookieID)).
Action().Output(f.hostIfacePort).
Done(),
// This generates the flow to forward the packets from bridge local port to uplink port.
Expand Down
4 changes: 4 additions & 0 deletions pkg/agent/openflow/pipeline_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
binding "antrea.io/antrea/pkg/ovs/openflow"
)

func (f *featurePodConnectivity) matchUplinkInPortInClassifierTable(flowBuilder binding.FlowBuilder) binding.FlowBuilder {
return flowBuilder.MatchInPort(f.uplinkPort)
}

// 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
Expand Down
5 changes: 5 additions & 0 deletions pkg/agent/openflow/pipeline_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ import (
binding "antrea.io/antrea/pkg/ovs/openflow"
)

// matchUplinkInPortInClassifierTable matches dstIP field to prevent unintended forwarding when promiscuous mode is enabled on Windows.
func (f *featurePodConnectivity) matchUplinkInPortInClassifierTable(flowBuilder binding.FlowBuilder) binding.FlowBuilder {
return flowBuilder.MatchInPort(f.uplinkPort).MatchProtocol(binding.ProtocolIP).MatchDstIP(f.nodeConfig.NodeTransportIPv4Addr.IP)
}

// hostBridgeUplinkFlows generates the flows that forward traffic between the bridge local port and the uplink port to
// support the host traffic with outside.
func (f *featurePodConnectivity) hostBridgeUplinkFlows() []binding.Flow {
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/openflow/pod_connectivity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func podConnectivityInitFlows(
flows = append(flows,
"cookie=0x1010000000000, table=ARPSpoofGuard, priority=200,in_port=32770 actions=output:4294967294",
"cookie=0x1010000000000, table=ARPSpoofGuard, priority=200,in_port=4294967294 actions=output:32770",
"cookie=0x1010000000000, table=Classifier, priority=200,in_port=32770 actions=output:4294967294",
"cookie=0x1010000000000, table=Classifier, priority=200,ip,in_port=32770,nw_dst=192.168.77.100 actions=output:4294967294",
"cookie=0x1010000000000, table=Classifier, priority=200,in_port=4294967294 actions=output:32770",
"cookie=0x1010000000000, table=IngressSecurityClassifier, priority=210,ct_state=-rpl+trk,ip,nw_src=10.10.0.1 actions=goto_table:ConntrackCommit",
)
Expand Down Expand Up @@ -161,7 +161,7 @@ func podConnectivityInitFlows(
"cookie=0x1010000000000, table=ARPSpoofGuard, priority=200,in_port=32770 actions=output:4294967294",
"cookie=0x1010000000000, table=ARPSpoofGuard, priority=200,in_port=4294967294 actions=output:32770",
"cookie=0x1010000000000, table=Classifier, priority=210,ip,in_port=32770,nw_dst=10.10.0.0/24 actions=set_field:0x4/0xf->reg0,set_field:0x200/0x200->reg0,goto_table:UnSNAT",
"cookie=0x1010000000000, table=Classifier, priority=200,in_port=32770 actions=output:4294967294",
"cookie=0x1010000000000, table=Classifier, priority=200,ip,in_port=32770,nw_dst=192.168.77.100 actions=output:4294967294",
"cookie=0x1010000000000, table=Classifier, priority=200,in_port=4294967294 actions=output:32770",
"cookie=0x1010000000000, table=SpoofGuard, priority=200,ip,in_port=32769 actions=goto_table:UnSNAT",
"cookie=0x1010000000000, table=ConntrackZone, priority=200,ip actions=ct(table=ConntrackState,zone=65520,nat)",
Expand Down