-
Notifications
You must be signed in to change notification settings - Fork 3.4k
datapath: Enable session affinity for older kernels #11678
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
Conversation
retest-net-next |
daemon/cmd/daemon_main.go
Outdated
"Disabling sessionAffinity for cases when a service is accessed from a cluster.") | ||
log.Warnf("sessionAffinity for host reachable services needs kernel 5.7.0 or newer " + | ||
"to work properly: the same service endpoint will be selected from all network " + | ||
"namespaces on the host.") |
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.
Looks good overall. I think here this needs a bit of rewrite. It may not be clear to the user that this is for E-W traffic-only but not for N-S one.
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.
Another idea to improve this for older kernels:
- Given ClusterIP is non-routable, we leave this as-is what you have here for ClusterIP
- For everything else we route the traffic to the front-end node, meaning E-W traffic would be service-processed similar way as N-S traffic through bpf_host NodePort LB
For the latter, this means that in the service map for services with sessionAffinity we reroute e.g. 127.0.0.1:NodePort (the surrogate svc entries) to the front-end tuple instead of backend. (Downside is potentially one extra hop but potentially better traffic balancing.)
Wdyt?
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.
As discussed offline. ACK with the updated warn msg.
d009984
to
6c08db3
Compare
retest-net-next |
6c08db3
to
812c3d2
Compare
test-me-please |
Instead of disabling sessionAffinity for E-W traffic (via bpf_sock) when running on < 5.7 kernel, enable it with a non-ideal functionality: the same service (annotated with "sessionAffinity") endpoint will be selected from all network namespaces on the host, because the same netns cookie (="0") will be returned for all namespaces. Signed-off-by: Martynas Pumputis <m@lambda.lt>
retest-4.19 |
retest-4.19 |
This reverts commit 4fa26a4 ("datapath: Enable sessionAffinity for older kernels"). On 4.19 it causes the following verifier error: msg="+ tc exec bpf pin /sys/fs/bpf/tc/globals/cilium_cgroups_connect6 obj bpf_sock.o type sockaddr attach_type connect6 sec connect6" subsys=datapath-loader subsys=datapath-loader msg="Prog section 'connect6' rejected: Invalid argument (22)!" subsys=datapath-loader msg=" - Type: 18" subsys=datapath-loader msg=" - Attach Type: 11" subsys=datapath-loader msg=" - Instructions: 740 (0 over limit)" subsys=datapath-loader msg=" - License: GPL" subsys=datapath-loader subsys=datapath-loader msg="Verifier analysis:" subsys=datapath-loader subsys=datapath-loader msg="back-edge from insn 624 to 570" subsys=datapath-loader subsys=datapath-loader msg="Error fetching program/map!" subsys=datapath-loader PR #11678's CI run on 4.19 was broken as well, so it seems it was merged accidentally. We need a different workaround for this kernel, one that the verifier can deal with. Fixes: #11731 Reported-by: Paul Chaignon <paul@cilium.io> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Instead of disabling sessionAffinity for E-W traffic (via bpf_sock) when running on < 5.7 kernel, enable it with a non-ideal functionality: the same service (annotated with "sessionAffinity") endpoint will be selected from all network namespaces on the host, because the same netns cookie (="0") will be returned for all namespaces.
The documentation update will follow soon with the session affinity docs.