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

Add L7 Antrea native NetworkPolicy datapath support #4410

Merged
merged 1 commit into from
Dec 22, 2022

Conversation

hongliangl
Copy link
Contributor

@hongliangl hongliangl commented Nov 23, 2022

This PR depends on #4380 #4406

Signed-off-by: Hongliang Liu [email protected]

@codecov
Copy link

codecov bot commented Nov 23, 2022

Codecov Report

Merging #4410 (4771389) into main (721fc9e) will decrease coverage by 2.46%.
The diff coverage is 75.78%.

❗ Current head 4771389 differs from pull request most recent head dc97f1f. Consider uploading reports for the commit dc97f1f to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4410      +/-   ##
==========================================
- Coverage   67.91%   65.44%   -2.47%     
==========================================
  Files         403      402       -1     
  Lines       57698    58411     +713     
==========================================
- Hits        39187    38229     -958     
- Misses      15788    17435    +1647     
- Partials     2723     2747      +24     
Flag Coverage Δ *Carryforward flag
integration-tests 34.74% <56.94%> (+0.10%) ⬆️
kind-e2e-tests 46.38% <52.87%> (-1.27%) ⬇️ Carriedforward from 22489ad
unit-tests 51.04% <51.11%> (-5.67%) ⬇️ Carriedforward from 22489ad

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
cmd/antrea-agent/agent.go 0.00% <0.00%> (ø)
pkg/agent/agent_linux.go 4.65% <ø> (ø)
pkg/agent/agent_windows.go 1.20% <ø> (ø)
pkg/agent/config/node_config.go 76.19% <ø> (-19.81%) ⬇️
pkg/agent/controller/networkpolicy/allocator.go 83.18% <ø> (ø)
pkg/agent/types/networkpolicy.go 65.45% <ø> (-24.29%) ⬇️
pkg/agent/controller/networkpolicy/reconciler.go 70.27% <60.00%> (-0.31%) ⬇️
pkg/agent/openflow/pipeline.go 77.96% <61.53%> (-13.11%) ⬇️
...ntroller/networkpolicy/networkpolicy_controller.go 73.34% <63.63%> (ø)
pkg/ovs/openflow/ofctrl_action.go 80.91% <71.42%> (-7.64%) ⬇️
... and 78 more

@hongliangl hongliangl force-pushed the 20221109-l7-policy-dp branch 3 times, most recently from 8dee680 to b04d745 Compare December 1, 2022 14:06
@hongliangl
Copy link
Contributor Author

Could you help review this PR? @tnqn @qiyueyao I have polished the code and I'll add e2e tests in this PR later.

@vicky-liu vicky-liu added this to the Antrea v1.10 release milestone Dec 2, 2022
@hongliangl hongliangl force-pushed the 20221109-l7-policy-dp branch 5 times, most recently from 71b4a77 to f126a6b Compare December 5, 2022 13:46
pkg/agent/agent_linux.go Outdated Show resolved Hide resolved
pkg/agent/config/node_config.go Outdated Show resolved Hide resolved
pkg/agent/config/node_config.go Outdated Show resolved Hide resolved
pkg/agent/controller/networkpolicy/cache.go Outdated Show resolved Hide resolved
pkg/agent/openflow/fields.go Outdated Show resolved Hide resolved
pkg/controller/networkpolicy/networkpolicy_controller.go Outdated Show resolved Hide resolved
pkg/agent/agent_linux.go Outdated Show resolved Hide resolved
pkg/agent/agent.go Show resolved Hide resolved
pkg/agent/config/node_config.go Outdated Show resolved Hide resolved
pkg/agent/controller/networkpolicy/cache.go Outdated Show resolved Hide resolved
@hongliangl hongliangl force-pushed the 20221109-l7-policy-dp branch 4 times, most recently from a821312 to 28c1399 Compare December 6, 2022 17:21
pkg/agent/controller/networkpolicy/l7engine/reconciler.go Outdated Show resolved Hide resolved
pkg/agent/controller/networkpolicy/l7engine/reconciler.go Outdated Show resolved Hide resolved
pkg/agent/controller/networkpolicy/l7engine/reconciler.go Outdated Show resolved Hide resolved
pkg/controller/networkpolicy/networkpolicy_controller.go Outdated Show resolved Hide resolved
pkg/agent/openflow/network_policy.go Outdated Show resolved Hide resolved
pkg/agent/openflow/network_policy.go Outdated Show resolved Hide resolved
pkg/agent/controller/networkpolicy/l7engine/reconciler.go Outdated Show resolved Hide resolved
pkg/agent/controller/networkpolicy/l7engine/reconciler.go Outdated Show resolved Hide resolved
pkg/agent/config/node_config.go Outdated Show resolved Hide resolved
@hongliangl hongliangl force-pushed the 20221109-l7-policy-dp branch 5 times, most recently from 5cf3651 to 8dddc0e Compare December 13, 2022 10:52
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

not finished, publishing comments so far

pkg/agent/agent_linux.go Outdated Show resolved Hide resolved
pkg/agent/agent_linux.go Outdated Show resolved Hide resolved
pkg/agent/agent_linux.go Outdated Show resolved Hide resolved
pkg/agent/agent_linux.go Outdated Show resolved Hide resolved
pkg/agent/config/node_config.go Outdated Show resolved Hide resolved
pkg/controller/networkpolicy/networkpolicy_controller.go Outdated Show resolved Hide resolved
pkg/agent/controller/networkpolicy/allocator_test.go Outdated Show resolved Hide resolved
// - to match VLAN ID 0 only, the mask should be 0x1fff (openflow15.OFPVID_PRESENT | protocol.VID_MASK)
// - to match all VLAN IDs, the mask should be 0x1000 (openflow15.OFPVID_PRESENT)
// When VLAN ID is not 0, the mask can be nil or 0x1fff, and patch it to 0x1fff
if !nonVLAN && vlanID != 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

vlanID != 0 && vlanMaks == nil {
}

@@ -42,8 +43,27 @@ func (b *ofFlowBuilder) MatchTunMetadata(index int, data uint32) FlowBuilder {

// MatchVLAN matches the VLAN VID. It holds the VLAN VID in its least significant 12 bits.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add some comments about how to use this interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Match a specific VLAN
Match all VLANs
Not match any VLAN

mask = *vlanMask
}
var matchStr string
if (mask & defaultVLANMask) == defaultVLANMask {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
if (mask & defaultVLANMask) == defaultVLANMask {
if mask == defaultVLANMask {

if (mask & (protocol.VID_MASK | openflow15.OFPVID_PRESENT)) == (protocol.VID_MASK | openflow15.OFPVID_PRESENT) {
return fmt.Sprintf("dl_vlan=%d", value&protocol.VID_MASK)
}
return fmt.Sprintf("vlan_tci=0x%04x/0x%04x", value&openflow15.OFPVID_PRESENT, mask&openflow15.OFPVID_PRESENT)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
return fmt.Sprintf("vlan_tci=0x%04x/0x%04x", value&openflow15.OFPVID_PRESENT, mask&openflow15.OFPVID_PRESENT)
return fmt.Sprintf("vlan_tci=0x%04x/0x%04x", value&openflow15.OFPVID_PRESENT, openflow15.OFPVID_PRESENT)

}
require.NoError(t, data.podWaitForRunning(defaultTimeout, clientPodName, data.testNamespace))

serverPodName := "test-l7-http-server"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add some comments about the priority of Policies

assert.NotNil(t, err)

// Non-HTTP connections should be rejected by Suricata.
if ip.To4() != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why IPv6 not drop?

@hongliangl hongliangl force-pushed the 20221109-l7-policy-dp branch 4 times, most recently from 7bbfd6f to c8ac822 Compare December 21, 2022 06:18
pkg/agent/controller/networkpolicy/l7engine/reconciler.go Outdated Show resolved Hide resolved
pkg/agent/controller/networkpolicy/l7engine/reconciler.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_builder.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_builder.go Outdated Show resolved Hide resolved
test/e2e/l7networkpolicy_test.go Outdated Show resolved Hide resolved
test/e2e/l7networkpolicy_test.go Outdated Show resolved Hide resolved
tnqn
tnqn previously approved these changes Dec 21, 2022
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

I found two problems when testing it:

  1. suricata became unresponsive after running a while, no traffic is forwarded, no suricatasc command is responding; this may be related to how suricata instance is started
  2. restarting agent doesn't re-install existing rules, which should be handled in syncRules

@tnqn
Copy link
Member

tnqn commented Dec 22, 2022

/test-all

@tnqn
Copy link
Member

tnqn commented Dec 22, 2022

/test-all

Copy link
Contributor

@qiyueyao qiyueyao left a comment

Choose a reason for hiding this comment

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

Looks great, I don't have further comments for now, and I believe the above unclosed conversations have been resolved in the latest commit.

@tnqn
Copy link
Member

tnqn commented Dec 22, 2022

/skip-all which have succeeded

@tnqn tnqn merged commit 7a0b581 into antrea-io:main Dec 22, 2022

// prepareL7NetworkPolicyInterfaces creates two OVS internal ports. An application-aware engine will connect to OVS
// through these two ports.
func (i *Initializer) prepareL7NetworkPolicyInterfaces() error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a

GraysonWu pushed a commit to GraysonWu/antrea that referenced this pull request Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants