-
Notifications
You must be signed in to change notification settings - Fork 376
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
Antrea L7NetworkPolicies do not handle Service traffic correctly #6854
Comments
cc @tnqn @hongliangl @luolanzone for visibility |
Will take a look and evaluate. |
Currently, we use a CT mark To redirect reply packets to Suricata, all packets will go to table |
Do we need to use an additional ct zone for such packets (that need to be sent to Suricata), so we can identify reply packets earlier, or is there another solution? |
I struggled to find a simple and elegant solution to the issue but couldn't. After discussing it with @wenying, we identified a feasible fix. However, in my opinion, this solution is quite complex and may be difficult to explain. For the packets of a Serivce connection enforced by one L7 NetworkPolicy:
In the following context:
First request packetPhase 1This is the enhanced flow matching the
Phase 2For the
Phase 3These flows are to match the
Reply packetsPhase 1These flows are used to distinguish the
At first, all packets are resubmitted to table 100 to load register marks. The the reply packets in phase 1 will be loaded with
Phase 2Similar to the
Phase 3The
Subsequent request packetsPhase 1These flows are used to match the
Phase 2The
Phase 3The processs of |
That should be a simple way to fix the issue. I don't have a concrete idea about how to implement this, but it may case side effect to other connections not enforced by L7 NetworkPolicies, degrading the performance due to a new introduced ct zone. |
Describe the bug
Antrea L3/L4 policy rules handle Service traffic correctly: they are applied to traffic "post-DNAT", when the destination IP address has been rewritten to the endpoint IP.
I have observed that Service traffic is not handled correctly for policies with L7 rules: all the traffic is dropped by Suricata, independently of the rule contents.
To Reproduce
Install Antrea with the necessary configuration:
Use the following policy:
For the http-server application, you can use a Deployment running an nginx Pod, exposed by a Service.
http-server Deployment + Service
For the http-client application, you can use a Deployment running an antrea/toolbox Pod.
http-client Deployment
After creating everything, try to curl the http-server Service from the http-client Pod. It should hang.
However, if you curl the http-server Pod IP address directly, it will work as expected.
Expected
The policy should work correctly when the http-server application is accessed through the Service.
Actual behavior
The policy only work correctly when the http-server application is accessed directly using the Pod IP.
Versions:
Antrea v2.2.0, and top-of-tree
Additional context
This is the traffic captured on
antrea-l7-tap0
(ingress interface for Suricata engine), when accessing the http-server Service.10.10.2.16
is the IP address of the http-client Pod.10.96.226.29
is the ClusterIP address of the http-server Service.10.10.2.15
is the IP address of the http-server Pod.We can see that the client -> server traffic is forwarded to Suricata "post-DNAT" (destination IP is http-server Pod IP). However, the server -> client (reply) traffic appears to be forwarded to Suricata after the source IP has been rewritten pack to the original destination IP (i.e., the ClusterIP). Suricata has no way to identify this reply traffic as part of the same connection. The reply traffic (SYN-ACK in this case) is dropped (I assume by Suricata) and does not show up on
antrea-l7-tap0
(egress interface for Suricata engine).The Antrea datapath should be fixed so that the reply traffic is sent to Suricata prior rewriting the source IP ("un-DNAT").
The text was updated successfully, but these errors were encountered: