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

bpf: minor LB cleanups #25061

Merged
merged 4 commits into from Apr 24, 2023

Conversation

julianwiedmann
Copy link
Member

@julianwiedmann julianwiedmann commented Apr 22, 2023

A few small LB cleanups that have accumulated. Ideally the first two three will make review of a pending fix a bit easier.

@julianwiedmann julianwiedmann added sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. release-note/misc This PR makes changes that have no direct user impact. labels Apr 22, 2023
@julianwiedmann julianwiedmann requested a review from a team as a code owner April 22, 2023 16:51
@julianwiedmann
Copy link
Member Author

julianwiedmann commented Apr 22, 2023

/test

Job 'Cilium-PR-K8s-1.25-kernel-5.4' failed:

Click to show.

Test Name

K8sDatapathConfig Host firewall With VXLAN and endpoint routes

Failure Output

FAIL: Error deleting resource /home/jenkins/workspace/Cilium-PR-K8s-1.25-kernel-5.4/src/github.com/cilium/cilium/test/k8s/manifests/host-policies.yaml: Cannot retrieve "cilium-mv92f"'s policy revision: cannot get policy revision: ""

Jenkins URL: https://jenkins.cilium.io/job/Cilium-PR-K8s-1.25-kernel-5.4/89/

If it is a flake and a GitHub issue doesn't already exist to track it, comment /mlh new-flake Cilium-PR-K8s-1.25-kernel-5.4 so I can create one.

ct_create*() can result in CT-related DROP reasons. Return those to the
caller, instead of a generic DROP_NO_SERVICE.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
CT_RELATED is only relevant for CT tuples that have TUPLE_F_RELATED set.
The LB code doesn't build such tuples - it uses ct_lb_lookup(), and hence
never passes through the relevant ICMP code in ct_lookup().

So treat this as unexpected condition, and drop the packet.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
A CT lookup with CT_SERVICE scope will only look up in the reverse
direction, and thus __ct_lookup*() never returns CT_REOPENED or
CT_ESTABLISHED (they would always get translated to CT_REPLY).

So treat these two as invalid result.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
Hide the details of managing the csum_offset struct. It's just something
we need when actually re-writing the packet.

For lb4_rev_nat(), we now consistently apply the micro-optimization to only
initialize the struct for packets with a L4 header.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
@julianwiedmann
Copy link
Member Author

/test

Copy link
Contributor

@gentoo-root gentoo-root left a comment

Choose a reason for hiding this comment

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

Looks good to me.

__be32 old_sip, new_sip, sum = 0;
int ret;

cilium_dbg_lb(ctx, DBG_LB4_REVERSE_NAT, nat->address, nat->port);

if (has_l4_header)
csum_l4_offset_and_flags(tuple->nexthdr, &csum_off);
Copy link
Contributor

Choose a reason for hiding this comment

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

Offtopic question: why don't we set off->offset for IPPROTO_ICMP in csum_l4_offset_and_flags?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've wondered about that myself recently while poking around the NAT code :) (as it requires us to set the offset manually ...). Best I could come up with was that we didn't need it in the pure LB paths.

So one option would be to declare the existing helpers as LB-specific, and introduce generic variants that do handle ICMP.

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Apr 24, 2023
@julianwiedmann julianwiedmann merged commit ad91f28 into cilium:main Apr 24, 2023
56 checks passed
@julianwiedmann julianwiedmann deleted the 1.14-bpf-lb-cleanups-v2 branch April 24, 2023 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants