Skip to content

bpf_host: emit '-> network' traces for egress packets#13485

Closed
ti-mo wants to merge 5 commits intocilium:masterfrom
ti-mo:pr/tb/host-firewall-monitor
Closed

bpf_host: emit '-> network' traces for egress packets#13485
ti-mo wants to merge 5 commits intocilium:masterfrom
ti-mo:pr/tb/host-firewall-monitor

Conversation

@ti-mo
Copy link
Copy Markdown
Contributor

@ti-mo ti-mo commented Oct 9, 2020

Fixes: #12561

See the issue above for the full context. The caveat is, this program is only attached to the native device egress if either the host firewall or BPF NodePort is enabled, so there still won't be any TRACE_TO_NETWORK visibility if that's not the case.

I've had to move the trace to fire before nodeport_nat_fwd() is called, since that function tail calls on the happy path, and there's no CT context available downstream from there. This could likely be improved when/if we adopt BTF and get rid of tail calls on kernels that support it.

I've also added handle_to_netdev_ipv4() to clean up to_netdev() a bit, to bring it on par with the ipv6 handling.

bpf_host: emit '-> network' traces for packets leaving the node when Host Firewall or BPF NodePort are enabled

@ti-mo ti-mo requested a review from a team October 9, 2020 12:39
@maintainer-s-little-helper maintainer-s-little-helper Bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Oct 9, 2020
@ti-mo ti-mo force-pushed the pr/tb/host-firewall-monitor branch 4 times, most recently from d74332d to 7e0b197 Compare October 9, 2020 14:27
@joestringer joestringer added the release-note/minor This PR changes functionality that users may find relevant to operating Cilium. label Oct 9, 2020
@maintainer-s-little-helper maintainer-s-little-helper Bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Oct 9, 2020
Copy link
Copy Markdown
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

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

Nice, I think this is quite close to what I had in mind.

Some feedback below on the main open topic, where to execute the trace_notify for these programs.

Comment thread bpf/bpf_host.c Outdated
Comment thread bpf/lib/trace.h Outdated
@ti-mo ti-mo force-pushed the pr/tb/host-firewall-monitor branch 3 times, most recently from 105d8c6 to 0e4192a Compare October 12, 2020 14:03
Copy link
Copy Markdown
Contributor Author

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

Another question I had: I recall seeing a test (suite) that checks for particular trace messages being emitted under certain packet scenarios. Could someone point me in the right direction? Should we add some tests to cover this PR as well?

Comment thread bpf/bpf_host.c Outdated
Comment thread bpf/lib/nodeport.h Outdated
Comment thread bpf/lib/nodeport.h Outdated
@pchaigno pchaigno requested a review from brb October 12, 2020 14:32
@aanm aanm added needs/triage This issue requires triaging to establish severity and next steps. priority/low This is considered nice to have. priority/release-blocker release-priority/best-effort The project for target version is not a hard requirement. and removed needs/triage This issue requires triaging to establish severity and next steps. priority/low This is considered nice to have. priority/release-blocker labels Oct 13, 2020
@ti-mo ti-mo force-pushed the pr/tb/host-firewall-monitor branch 5 times, most recently from 2505041 to 534d460 Compare October 14, 2020 11:42
@ti-mo ti-mo marked this pull request as draft October 14, 2020 11:42
@ti-mo ti-mo force-pushed the pr/tb/host-firewall-monitor branch 2 times, most recently from 1dcb9eb to 42c843d Compare October 14, 2020 13:33
@pchaigno pchaigno added the dont-merge/needs-rebase This PR needs to be rebased because it has merge conflicts. label Nov 12, 2020
@joestringer
Copy link
Copy Markdown
Member

This seems to need a rebase, so I'll mark it as draft so it disappears from assignee review queues. Feel free to mark ready for review again when you are looking for further review/feedback.

@joestringer joestringer marked this pull request as draft November 18, 2020 20:32
For cilium#12561.

To be able to send aggregated traces from 'to_netdev()', the monitor
variable needs to be declared there and passed to the datapath as an
argument. This is the IPv6 path, IPv4 will follow separately as it
moves some logic to a func.

checkpatch.pl trips over srcID, so that was changed to src_id.

Signed-off-by: Timo Beckers <timo@isovalent.com>
For cilium#12561.

Moved ipv4 egress srcid resolution to 'handle_to_netdev_ipv4' for parity
with how ipv6 is handled.

Also plumbs the aggregation monitor through to the ipv4 datapath.

Signed-off-by: Timo Beckers <timo@isovalent.com>
…rt are enabled

For cilium#12561.

Also adds monitor aggregation to the TRACE_TO_NETWORK observation point,
which has the side effect of enabling it by default.

Signed-off-by: Timo Beckers <timo@isovalent.com>
Also added `CB_CT_MONITOR` to store monitor aggregation value.

Signed-off-by: Timo Beckers <timo@isovalent.com>
For cilium#12561.

Store monitor in skb->cb for use in nodeport tail calls.

Signed-off-by: Timo Beckers <timo@isovalent.com>
@ti-mo ti-mo force-pushed the pr/tb/host-firewall-monitor branch from 1815a51 to 9b9689a Compare November 19, 2020 09:29
@ti-mo
Copy link
Copy Markdown
Contributor Author

ti-mo commented Nov 19, 2020

test-me-please

@stale
Copy link
Copy Markdown

stale Bot commented Dec 20, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Dec 20, 2020
@stale
Copy link
Copy Markdown

stale Bot commented Jan 10, 2021

This issue has not seen any activity since it was marked stale. Closing.

@stale stale Bot closed this Jan 10, 2021
navarrothiago added a commit to navarrothiago/cilium that referenced this pull request May 26, 2021
See the issue below for the full context. The caveat is, this program is
only attached to the native device egress if the host firewall is
enabled, so there still won't be any TRACE_TO_NETWORK visibility if
that's not the case.

bpf_host: emit '-> network' traces for packets leaving the node when
Host Firewall are enabled

Based on: cilium#13485
Fixes: cilium#12561

Co-authored-by: Thiago Navarro <navarro@accuknox.com>
Signed-off-by: Timo Beckers <timo@isovalent.com>
Signed-off-by: Thiago Navarro <navarro@accuknox.com>
aanm pushed a commit that referenced this pull request May 28, 2021
See the issue below for the full context. The caveat is, this program is
only attached to the native device egress if the host firewall is
enabled, so there still won't be any TRACE_TO_NETWORK visibility if
that's not the case.

bpf_host: emit '-> network' traces for packets leaving the node when
Host Firewall are enabled

Based on: #13485
Fixes: #12561

Co-authored-by: Thiago Navarro <navarro@accuknox.com>
Signed-off-by: Timo Beckers <timo@isovalent.com>
Signed-off-by: Thiago Navarro <navarro@accuknox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dont-merge/needs-rebase This PR needs to be rebased because it has merge conflicts. release-note/minor This PR changes functionality that users may find relevant to operating Cilium. stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Monitor Aggregation for connections does not work with host firewall

5 participants