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: Add missing packet trace in handle_nat_fwd #19158

Merged
merged 2 commits into from
May 6, 2022

Conversation

YutaroHayakawa
Copy link
Member

Please see the commit message for more details.

Fixes: #18909

Add missing packet trace for some non-NodePort SNAT egress

@YutaroHayakawa YutaroHayakawa 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. area/monitor Impacts monitoring, access logging, flow logging, visibility of datapath traffic. release-note/bug This PR fixes an issue in a previous release of Cilium. needs-backport/1.11 labels Mar 16, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.11.3 Mar 16, 2022
@YutaroHayakawa
Copy link
Member Author

/test

@aanm aanm added this to Needs backport from master in 1.11.4 Mar 26, 2022
@aanm aanm removed this from Needs backport from master in 1.11.3 Mar 26, 2022
@YutaroHayakawa YutaroHayakawa force-pushed the issue-18909 branch 2 times, most recently from 7a93b6b to ccf987b Compare April 6, 2022 12:27
@YutaroHayakawa YutaroHayakawa marked this pull request as ready for review April 6, 2022 13:30
@YutaroHayakawa YutaroHayakawa requested review from a team, joamaki and brb April 6, 2022 13:30
bpf/lib/nodeport.h Outdated Show resolved Hide resolved
bpf/lib/nodeport.h Outdated Show resolved Hide resolved
@joestringer joestringer added this to Needs backport from master in 1.11.5 Apr 15, 2022
@joestringer joestringer removed this from Needs backport from master in 1.11.4 Apr 15, 2022
src_id variable in to_netdev in bpf_host.c is always zero, so safe to
delete.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
In to-netdev in bpf_host.c, the packet tracing is missing when the
handle_nat_fwd uses tailcall. This PR adds new packet tracing inside the
handle_nat_fwd, but there were two complicated issue in here.

1. handle_nat_fwd is called from to-netdev as well as to-overlay

There are two possible caller for this function, so we needed to use
IS_BPF_OVERLAY macro to make sure where it is called.

2. handle_nat_fwd does not always tailcalls

Internally, it uses conditional tailcall. When it returns without
tailcall, we will hit the packet tracing hook at the bottom of the
to_netdev and have duplicated packet trace. We need to make sure whether
we already trace the packet or not and skip it.

Below is an example of simple ICMP Echo to outside of Pod network

Before the fix (with tailcall)
```
<- endpoint ... 10.0.1.185 -> 1.1.1.1 EchoRequest
-> stack ... 10.0.1.185 -> 1.1.1.1 EchoRequest
["-> network" is missing here]
<- network ... 1.1.1.1 -> 172.18.0.3 EchoReply
<- host ... 1.1.1.1 -> 10.0.1.185 EchoReply
-> endpoint ... 1.1.1.1 -> 10.0.1.185 EchoReply
```

Before the fix (without tailcall)
```
<- endpoint ... 10.0.1.185 -> 1.1.1.1 EchoRequest
-> stack ... 10.0.1.185 -> 1.1.1.1 EchoRequest
-> network ... 172.18.0.3 -> 1.1.1.1 EchoRequest
<- network ... 1.1.1.1 -> 172.18.0.3 EchoReply
<- host ... 1.1.1.1 -> 10.0.1.185 EchoReply
-> endpoint ... 1.1.1.1 -> 10.0.1.185 EchoReply
[no problem]
```

After the fix (with tailcall)
```
<- endpoint ... 10.0.1.185 -> 1.1.1.1 EchoRequest
-> stack ... 10.0.1.185 -> 1.1.1.1 EchoRequest
-> network ... 172.18.0.3 -> 1.1.1.1 EchoRequest
<- network ... 1.1.1.1 -> 172.18.0.3 EchoReply
<- host ... 1.1.1.1 -> 10.0.1.185 EchoReply
-> endpoint ... 1.1.1.1 -> 10.0.1.185 EchoReply
[no problem]
```

After the fix (without tailcall)
```
<- endpoint ... 10.0.1.185 -> 1.1.1.1 EchoRequest
-> stack ... 10.0.1.185 -> 1.1.1.1 EchoRequest
-> network ... 172.18.0.3 -> 1.1.1.1 EchoRequest
<- network ... 1.1.1.1 -> 172.18.0.3 EchoReply
<- host ... 1.1.1.1 -> 10.0.1.185 EchoReply
-> endpoint ... 1.1.1.1 -> 10.0.1.185 EchoReply
[no duplicated trace, no problem]
```

Fixes: cilium#18909

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

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

Thanks!

@brb
Copy link
Member

brb commented Apr 29, 2022

/test

Job 'Cilium-PR-K8s-GKE' has 1 failure but they might be new flake since it also hit 1 known flake: #17628 (93.58)

@YutaroHayakawa
Copy link
Member Author

All failing tests are hitting known flakes. Making this ready-to-merge.

ConformanceAKS: #19472
gke-stable: Hitting #19689
k8s-1.23-kernel-net-next: Hitting #17628

@YutaroHayakawa YutaroHayakawa added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label May 6, 2022
@kaworu kaworu merged commit 322510d into cilium:master May 6, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from master to Backport pending to v1.10 in 1.11.5 May 9, 2022
@aanm aanm added backport-done/1.11 The backport for Cilium 1.11.x for this PR is done. and removed backport-pending/1.11 labels May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/monitor Impacts monitoring, access logging, flow logging, visibility of datapath traffic. backport-done/1.11 The backport for Cilium 1.11.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.11.5
Backport pending to v1.10
Development

Successfully merging this pull request may close these issues.

datapath: to-netdev does not recirculate back after SNAT handling
6 participants