-
Notifications
You must be signed in to change notification settings - Fork 3.4k
bpf: service loopback for ipv6 #39594
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
base: main
Are you sure you want to change the base?
bpf: service loopback for ipv6 #39594
Conversation
c6b7c0b
to
1052f70
Compare
b91865f
to
62fa8cf
Compare
b16a408
to
f056282
Compare
31b0c2e
to
cb050e5
Compare
@jrife I have changed to serivce_loopback_ipv6. If you have free time, can you have a look at it?. Currently, I am stuck at the condition in which source ip is not translated back to the service cluster IP. I think that the reverse NAT for the reply path is not being applied correctly. But, I have no idea which is going wrong. The logs show multiple SYN packets from [fd00:10:244:1::dc8e]:53060 to [fd00:10:96::cd54]:80, indicating that the client is retransmitting SYN packets, likely because it is not receiving properly formatted replies. $ k exec -ti -n kube-system cilium-qz7tt -- cilium-dbg monitor --related-to 542 Listening for events on 8 CPUs with 64x4096 of shared memory |
Off the top of my head, I'm not sure. I may have some time later this week to look at it in a bit more detail. In the meantime, I left a few comments. I'd recommend fixing whatever unit tests and checkpatch checks are failing and try testing again. The checkpatch stuff is likely similar to some of the formatting stuff I commented on. |
cb050e5
to
0850415
Compare
c617e76
to
79d7a22
Compare
/test |
79d7a22
to
48dbbe7
Compare
/test |
48dbbe7
to
16ee0b4
Compare
/test |
16ee0b4
to
f0c02ac
Compare
/test |
f0c02ac
to
3c2f808
Compare
Are you able to see the output of the checkpatch workflow? You have some lines >100 chars which is causing it to fail. |
3c2f808
to
97641e7
Compare
I have fixed some warnings. But, I think the warning in node.h cannot be solved. |
This edit would make checkpatch happy diff --git a/bpf/include/bpf/config/node.h b/bpf/include/bpf/config/node.h
index 8f4d647cbe..048fde6229 100644
--- a/bpf/include/bpf/config/node.h
+++ b/bpf/include/bpf/config/node.h
@@ -15,10 +15,16 @@
/* Legacy node config rendered at agent runtime. */
#include <node_config.h>
-NODE_CONFIG(union v4addr, service_loopback_ipv4, "IPv4 source address used for SNAT when a Pod talks to itself over a Service")
-NODE_CONFIG(union v6addr, router_ipv6, "Internal IPv6 router address assigned to the cilium_host interface")
+NODE_CONFIG(union v4addr, service_loopback_ipv4,
+ "IPv4 source address used for SNAT when a Pod talks to itself over a Service")
+NODE_CONFIG(union v6addr, service_loopback_ipv6,
+ "IPv6 source address used for SNAT when a Pod talks to itself over a Service")
+NODE_CONFIG(union v6addr, router_ipv6,
+ "Internal IPv6 router address assigned to the cilium_host interface")
-NODE_CONFIG(__u32, trace_payload_len, "Length of payload to capture when tracing native packets.")
+NODE_CONFIG(__u32, trace_payload_len,
+ "Length of payload to capture when tracing native packets.")
#define TRACE_PAYLOAD_LEN CONFIG(trace_payload_len) /* Backwards compatibility */
-NODE_CONFIG(__u32, trace_payload_len_overlay, "Length of payload to capture when tracing overlay packets.")
+NODE_CONFIG(__u32, trace_payload_len_overlay,
+ "Length of payload to capture when tracing overlay packets.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for the agent-related work, it looks good 👍 I think a more detailed commit message, and even splitting the datapath and agent changes into separate commits, would be nice
61c6480
to
63b343b
Compare
NODE_CONFIG(__u32, trace_payload_len, "Length of payload to capture when tracing native packets.") | ||
NODE_CONFIG(union v4addr, service_loopback_ipv4, | ||
"IPv4 source address used for SNAT when a Pod talks to itself over a Service") | ||
NODE_CONFIG(union v6addr, service_loopback_ipv6, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: checkpatch would probably be happy if you just made this adjustment to the lines you added. My preference would be to only change what you need for this PR and leave reformatting the other lines for another patch, but not a blocker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it. I think that the current checkpatch failed because of unknown manifest issue related t checkpatch image.
/test |
@@ -773,6 +773,9 @@ const ( | |||
// ServiceLoopbackIPv4 is the address to use for service loopback SNAT | |||
ServiceLoopbackIPv4 = "ipv4-service-loopback-address" | |||
|
|||
// ServiceLoopbackIPv6 is the address to use for service loopback SNAT | |||
ServiceLoopbackIPv6 = "ipv6-service-loopback-address" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay on this comment. We prefer that all new config options are added to a hive cell, to begin the process of modularizing the related feature. If you take a look at the history on this file, you will see some recent example of refactors into cells. The initial refactor can be purely for the sake of config, with other modularlization coming later. Could you look into making this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it clear, I would like to confirm the cell file to which I need to move the current config. Is it ok to move to datapath/loader/cell.go? Or other file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logically, pkg/ipam/cell/cell.go seems like the right place, but given the breadth of changes that are required in this PR, that might not be feasible on the dependency graph. Could you give that a try and see if you run into any issues?
@joamaki is there a good way to visualize the dependency graph in order to make this type of decision, or any other advice that you would provide here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we already have ServiceLoopbackIPv4
here I'd be OK with adding it here for now and then moving them both into a saner place in another PR. It'd probably make sense to do that as part of a bigger refactoring that moves daemon/cmd/ipam.go
into pkg/ipam
. @cilium/sig-ipam any opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for config. Given the above discussion, it seems like a separate refactor would be the place to move the flag.
63b343b
to
2f3a33a
Compare
Add agent-side support to enable IPv6 service loopback handling so that connections to a service’s own ClusterIP from a backend pod loop back correctly. Summary of changes: - Extend service / LB logic to recognize and mark IPv6 loopback scenarios - Introduce service_loopback_ipv6 runtime variable for IPv6 service loopback support Signed-off-by: saiaunghlyanhtet <saiaunghlyanhtet2003@gmail.com>
Introduce datapath logic to support IPv6 service loopback so that packets originating from a pod targeting its own service ClusterIP are correctly short-circuited and subject to the standard LB/rev-NAT path without external detours. Summary of changes: - Adjust service lookup / backend selection and reverse NAT handling for IPv6 loopback - Add BPF selftests to cover IPv6 loopback Signed-off-by: saiaunghlyanhtet <saiaunghlyanhtet2003@gmail.com>
2f3a33a
to
2907909
Compare
Service Loopback IPv6
Fixes: #26733