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: nodeport: update TTL / hop-limit on redirect #27299

Merged
merged 4 commits into from Aug 8, 2023

Conversation

julianwiedmann
Copy link
Member

@julianwiedmann julianwiedmann commented Aug 5, 2023

#23884 and #24422 introduced some inconsistencies and bugs in how the TTL / hop-limit field is updated when a packet is redirected from the ingress path to a remote destination. Fix them by adding ipv*_l3() calls, or shuffling the existing calls into the correct place.

Fix several paths in the North-South load-balancer where the TTL / hop-limit field of a forwarded packet was not updated.

When forwarding from the XDP LB to a remote NAT backend,
tail_nodeport_nat_egress_ipv4() potentially adds outer tunnel headers to
the packet. The call to fib_redirect_v4() then decrements outer header's
TTL, not the inner IPv4 header.

Fix this by manually updating the TTL, and open-coding the redirect.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
When forwarding from the LB to a remote NAT backend,
tail_nodeport_nat_egress_ipv6() uses fib_redirect() to pick the egress
interface (we can't use fib_redirect_v6() as the packet might have been
converted to IPv4, or tunnel-encapsulated in XDP). Thus the hop-limit
currently doesn't get updated.

Do so manually, before potentially adding the tunnel encapsulation.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
When forwarding replies from the LB (or EgressGW replies) back to the
client, rev_nodeport_lb4() potentially adds outer tunnel headers to the
packet. The call to fib_redirect_v4() then decrements outer header's TTL,
not the inner IPv4 header.

Fix this by manually updating the TTL, and open-coding the redirect.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
When forwarding replies from the LB back to the client, rev_nodeport_lb6()
uses fib_redirect() to pick the egress interface (we can't use
fib_redirect_v6() as the packet might have been converted to IPv4, or
tunnel-encapsulated in XDP). Thus the hop-limit currently doesn't get
updated.

Do so manually.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
@julianwiedmann julianwiedmann added kind/bug This is a bug in the Cilium logic. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. release-note/bug This PR fixes an issue in a previous release of Cilium. area/loadbalancing Impacts load-balancing and Kubernetes service implementations labels Aug 5, 2023
@julianwiedmann
Copy link
Member Author

/test

@julianwiedmann julianwiedmann added the needs-backport/1.14 This PR / issue needs backporting to the v1.14 branch label Aug 7, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from main in 1.14.1 Aug 7, 2023
@julianwiedmann julianwiedmann changed the title 1.15 bpf nodeport ttl bpf: nodeport: update TTL / hop-limit on redirect Aug 7, 2023
@julianwiedmann julianwiedmann marked this pull request as ready for review August 7, 2023 08:41
@julianwiedmann julianwiedmann requested a review from a team as a code owner August 7, 2023 08:41
@julianwiedmann julianwiedmann added the backport/author The backport will be carried out by the author of the PR. label Aug 7, 2023
Copy link
Member

@jschwinger233 jschwinger233 left a comment

Choose a reason for hiding this comment

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

One question for the first commit "fix TTL update for XDP in IPv4 NAT Egress path", thanks 😨

bpf/lib/nodeport.h Show resolved Hide resolved
@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 Aug 8, 2023
@julianwiedmann julianwiedmann merged commit 9e29ea6 into cilium:main Aug 8, 2023
60 checks passed
@julianwiedmann julianwiedmann deleted the 1.15-bpf-nodeport-ttl branch August 8, 2023 09:00
@julianwiedmann julianwiedmann added backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. and removed needs-backport/1.14 This PR / issue needs backporting to the v1.14 branch labels Aug 9, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from main to Backport pending to v1.14 in 1.14.1 Aug 9, 2023
@nebril nebril removed this from Backport pending to v1.14 in 1.14.1 Aug 10, 2023
@nebril nebril added this to Backport pending to v1.14 in 1.14.2 Aug 10, 2023
@ti-mo ti-mo added backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. and removed backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. labels Aug 16, 2023
@joestringer joestringer moved this from Backport pending to v1.14 to Backport done to v1.14 in 1.14.2 Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/loadbalancing Impacts load-balancing and Kubernetes service implementations backport/author The backport will be carried out by the author of the PR. backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. kind/bug This is a bug in the Cilium logic. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/bug This PR fixes an issue in a previous release of Cilium. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages.
Projects
No open projects
1.14.2
Backport done to v1.14
Development

Successfully merging this pull request may close these issues.

None yet

3 participants