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

Fix the issue of local probe bypassing flows on Windows #3510

Merged
merged 1 commit into from Apr 22, 2022

Conversation

hongliangl
Copy link
Contributor

@hongliangl hongliangl commented Mar 23, 2022

When proxyAll is enabled, kube-proxy can be replaced by AntreaProxy, then
Service traffic and non-Service traffic can be distinguished by ServiceCTMark
and NotServiceCTMark. Service traffic with ServiceCTMark should not bypass
Network Policies, and non-Service traffic generated by kubelet with
NotServiceCTMark should bypass Network Policies.

This PR also fixes the issue that the reply packets of Pod -> local Antrea gateway
bypasses EgressMetricTable.

Signed-off-by: Hongliang Liu lhongliang@vmware.com

pkg/agent/openflow/pipeline.go Outdated Show resolved Hide resolved
pkg/agent/openflow/pipeline.go Outdated Show resolved Hide resolved
@hongliangl hongliangl force-pushed the fix-bypassing-local-probe-flows branch from 3cb947c to 863b6ba Compare March 24, 2022 00:15
@codecov-commenter
Copy link

codecov-commenter commented Mar 24, 2022

Codecov Report

Merging #3510 (5fc6a24) into main (5905e98) will decrease coverage by 7.24%.
The diff coverage is 61.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3510      +/-   ##
==========================================
- Coverage   64.66%   57.41%   -7.25%     
==========================================
  Files         278      392     +114     
  Lines       39363    54837   +15474     
==========================================
+ Hits        25454    31485    +6031     
- Misses      11939    20906    +8967     
- Partials     1970     2446     +476     
Flag Coverage Δ
e2e-tests 50.25% <61.53%> (?)
integration-tests 38.45% <ø> (?)
kind-e2e-tests 52.31% <61.53%> (-0.03%) ⬇️
unit-tests 43.81% <15.38%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/ovs/openflow/ofctrl_builder.go 59.26% <0.00%> (-0.41%) ⬇️
pkg/agent/openflow/pipeline.go 75.11% <61.11%> (-0.40%) ⬇️
pkg/agent/openflow/client.go 73.13% <100.00%> (+0.99%) ⬆️
pkg/agent/openflow/pod_connectivity.go 68.62% <100.00%> (+0.31%) ⬆️
pkg/agent/controller/networkpolicy/fqdn.go 75.51% <0.00%> (-2.60%) ⬇️
pkg/agent/route/route_linux.go 48.22% <0.00%> (-1.58%) ⬇️
pkg/ipam/poolallocator/allocator.go 53.49% <0.00%> (-0.97%) ⬇️
...gent/controller/networkpolicy/status_controller.go 81.51% <0.00%> (-0.85%) ⬇️
pkg/ovs/ovsctl/appctl.go 41.86% <0.00%> (-0.78%) ⬇️
pkg/agent/controller/egress/egress_controller.go 74.35% <0.00%> (-0.52%) ⬇️
... and 131 more

Cookie(cookieID).
MatchProtocol(ipProtocol).
MatchSrcIP(gatewayIP).
Action().GotoStage(stageConntrack).
MatchSrcIP(gatewayIP)
Copy link
Contributor

Choose a reason for hiding this comment

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

From my side, I would prefer to match gw port as the in_port or match the fromSource reg instead of gatewayIP, because ingress stage is after post routing stage, I am not sure if SNAT is taken for no Service IP in future. Matching in_port or source reg is more compatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For request packets of non-Service connections, FromGatewayRegMark && NotServiceCTMark -> stageConntrack

  • ✅ client is the local Node, destination is a local Pod
  • ❎ client is a remote Pod or remote Node, destination is a local Pod (Windows noEncap mode, remote traffic from remote Pod CIDR is sent to local Pod CIDR via Antrea gateway, not uplink)

I think the packets of the second case should not bypass ingress rules.

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sense.

Copy link
Contributor

@wenyingd wenyingd Mar 25, 2022

Choose a reason for hiding this comment

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

You remind me, we should add state -rpl+trk to avoid impact on reply packets , since reply packets are possible to goto Metric table for statistics collection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated.

@hongliangl hongliangl force-pushed the fix-bypassing-local-probe-flows branch from 863b6ba to a43fdc9 Compare March 25, 2022 02:32
wenyingd
wenyingd previously approved these changes Mar 25, 2022
Copy link
Contributor

@wenyingd wenyingd left a comment

Choose a reason for hiding this comment

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

LGTM

@hongliangl
Copy link
Contributor Author

/test-all-features-conformance
/test-conformance
/test-e2e
/test-flexible-ipam-e2e
/test-ipv6-conformance
/test-ipv6-e2e
/test-ipv6-networkpolicy
/test-ipv6-only-conformance
/test-ipv6-only-e2e
/test-ipv6-only-networkpolicy
/test-multicluster-e2e
/test-networkpolicy
/test-windows-conformance
/test-windows-e2e
/test-windows-networkpolicy
/test-windows-proxyall-e2e
/test-integration

@hongliangl
Copy link
Contributor Author

/test-windows-conformance
/test-ipv6-only-e2e
/test-integration
/test-ipv6-only-e2e

@hongliangl
Copy link
Contributor Author

/test-multicluster-e2e

@hongliangl
Copy link
Contributor Author

/test-all-features-conformance
/test-conformance
/test-e2e
/test-flexible-ipam-e2e
/test-multicluster-e2e
/test-networkpolicy
/test-windows-conformance
/test-windows-e2e
/test-windows-networkpolicy
/test-windows-proxyall-e2e

jianjuns
jianjuns previously approved these changes Apr 14, 2022
@hongliangl
Copy link
Contributor Author

/test-integration
/test-ipv6-conformance
/test-ipv6-e2e
/test-ipv6-networkpolicy
/test-ipv6-only-conformance
/test-ipv6-only-e2e
/test-ipv6-only-networkpolicy
/test-windows-networkpolicy
/test-multicluster-e2e

@hongliangl
Copy link
Contributor Author

/test-integration
/test-ipv6-conformance
/test-ipv6-e2e
/test-windows-networkpolicy
/test-multicluster-e2e

@hongliangl
Copy link
Contributor Author

/test-flexible-ipam-e2e

@hongliangl
Copy link
Contributor Author

/test-integration

1 similar comment
@jianjuns
Copy link
Contributor

/test-integration

@jianjuns
Copy link
Contributor

You need to fix the integration test:

table=IngressSecurityClassifier, priority=210,ct_state=-rpl+trk,ip,nw_src=192.168.1.1 actions=goto_table:ConntrackCommit

@hongliangl
Copy link
Contributor Author

/test-multicluster-e2e

@hongliangl
Copy link
Contributor Author

/test-ipv6-only-e2e
/test-ipv6-e2e

@hongliangl
Copy link
Contributor Author

/test-ipv6-e2e

@hongliangl
Copy link
Contributor Author

You need to fix the integration test:

table=IngressSecurityClassifier, priority=210,ct_state=-rpl+trk,ip,nw_src=192.168.1.1 actions=goto_table:ConntrackCommit

Fixed, and I think there is something wrong with test ipv6-e2e and multicluster-e2e since other PRs always get failed for these two tests.

jianjuns
jianjuns previously approved these changes Apr 18, 2022
@jianjuns
Copy link
Contributor

/test-e2e

@hongliangl
Copy link
Contributor Author

/test-networkpolicy

wenyingd
wenyingd previously approved these changes Apr 19, 2022
Copy link
Contributor

@wenyingd wenyingd left a comment

Choose a reason for hiding this comment

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

LGTM

@jianjuns
Copy link
Contributor

/test-e2e

1 similar comment
@hongliangl
Copy link
Contributor Author

/test-e2e

@hongliangl hongliangl added the action/release-note Indicates a PR that should be included in release notes. label Apr 20, 2022
@jianjuns
Copy link
Contributor

/test-e2e
/test-networkpolicy

@hongliangl hongliangl dismissed stale reviews from wenyingd and jianjuns via 23560c1 April 20, 2022 23:41
@hongliangl hongliangl force-pushed the fix-bypassing-local-probe-flows branch from 3153e42 to 23560c1 Compare April 20, 2022 23:41
When proxyAll is enabled, kube-proxy can be replaced by AntreaProxy, then
Service traffic and non-Service traffic can be distinguished by ServiceCTMark
and NotServiceCTMark. Service traffic with ServiceCTMark should not bypass
Network Policies, and non-Service traffic generated by kubelet with
NotServiceCTMark should bypass Network Policies.

Signed-off-by: Hongliang Liu <lhongliang@vmware.com>
@hongliangl hongliangl force-pushed the fix-bypassing-local-probe-flows branch from 23560c1 to 5fc6a24 Compare April 20, 2022 23:51
@hongliangl
Copy link
Contributor Author

/test-all-features-conformance
/test-conformance
/test-e2e
/test-flexible-ipam-e2e
/test-ipv6-conformance
/test-ipv6-e2e
/test-ipv6-networkpolicy
/test-ipv6-only-conformance
/test-ipv6-only-e2e
/test-ipv6-only-networkpolicy
/test-multicluster-e2e
/test-networkpolicy
/test-windows-conformance
/test-windows-e2e
/test-windows-networkpolicy
/test-windows-proxyall-e2e
/test-integration

@hongliangl
Copy link
Contributor Author

/test-all-features-conformance
/test-ipv6-e2e
/test-networkpolicy
/test-windows-networkpolicy to
t /test-windows-proxyall-e2e to re-tr

@hongliangl
Copy link
Contributor Author

/test-hw-offload

@hongliangl
Copy link
Contributor Author

/test-flexible-ipam-e2e

@hongliangl
Copy link
Contributor Author

/test-windows-networkpolicy
/test-ipv6-e2e
/test-all-features-conformance

@hongliangl
Copy link
Contributor Author

/test-networkpolicy
/test-windows-networkpolicy
/test-all-features-conformance

@jianjuns
Copy link
Contributor

/test-networkpolicy

1 similar comment
@hongliangl
Copy link
Contributor Author

/test-networkpolicy

// a local gateway IP to bypass Network Policies. See https://github.com/antrea-io/antrea/issues/280.
// TODO: Fix it after replacing kube-proxy with AntreaProxy.
func (f *featurePodConnectivity) localProbeFlow() []binding.Flow {
// When proxyAll is disabled, the probe packets are identified by matching the source IP is the Antrea gateway IP;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

holder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/release-note Indicates a PR that should be included in release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants