Skip to content

Conversation

brb
Copy link
Member

@brb brb commented May 25, 2020

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.

@brb brb added pending-review area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. release-note/minor This PR changes functionality that users may find relevant to operating Cilium. labels May 25, 2020
@brb brb requested review from borkmann and a team May 25, 2020 13:37
@brb
Copy link
Member Author

brb commented May 25, 2020

retest-net-next

"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.")
Copy link
Member

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.

Copy link
Member

@borkmann borkmann May 25, 2020

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?

@coveralls
Copy link

coveralls commented May 25, 2020

Coverage Status

Coverage increased (+0.01%) to 36.899% when pulling 812c3d2 on pr/brb/session-affinity-fallback into 8fb2892 on master.

Copy link
Member

@borkmann borkmann left a 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.

@brb brb force-pushed the pr/brb/session-affinity-fallback branch from d009984 to 6c08db3 Compare May 25, 2020 14:38
@brb
Copy link
Member Author

brb commented May 25, 2020

retest-net-next

@brb brb requested a review from borkmann May 25, 2020 14:39
@brb brb force-pushed the pr/brb/session-affinity-fallback branch from 6c08db3 to 812c3d2 Compare May 26, 2020 08:48
@brb
Copy link
Member Author

brb commented May 26, 2020

test-me-please

@brb brb requested a review from aanm May 26, 2020 08:48
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>
@brb
Copy link
Member Author

brb commented May 26, 2020

retest-4.19

@brb
Copy link
Member Author

brb commented May 27, 2020

retest-4.19

@aanm aanm merged commit 4fa26a4 into master May 27, 2020
@aanm aanm deleted the pr/brb/session-affinity-fallback branch May 27, 2020 13:24
borkmann added a commit that referenced this pull request May 28, 2020
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. release-note/minor This PR changes functionality that users may find relevant to operating Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants