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

Add --filter-trace-only-bpf #469

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sachintiptur
Copy link

Add --filter-trace-only-bpf flag to trace only TC and XDP programs.
Fixes [#394 ]

Signed-off-by: Sachin Tiptur <coolsachints@gmail.com>
@sachintiptur sachintiptur marked this pull request as ready for review December 16, 2024 14:15
@sachintiptur sachintiptur requested a review from a team as a code owner December 16, 2024 14:15
@sachintiptur sachintiptur requested review from brb and removed request for a team December 16, 2024 14:15
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.

I don't think this achieved the goal. Running pwru --filter-trace-only-bpf 'dst host 1.1.1.1' built from this PR also outputs tracing results from normal skb functions. Unless I misunderstand the original issue #394, the expected behavior is to attach bpf programs only, rather than normal skb funcitons.

@sachintiptur
Copy link
Author

I don't think this achieved the goal. Running pwru --filter-trace-only-bpf 'dst host 1.1.1.1' built from this PR also outputs tracing results from normal skb functions. Unless I misunderstand the original issue #394, the expected behavior is to attach bpf programs only, rather than normal skb funcitons.

Ah ok, sorry I think I misunderstood the issue, will re-look.

@sachintiptur
Copy link
Author

sachintiptur commented Dec 18, 2024

From what I understood is that --filter-trace-xdp and --filter-trace-tc are tracing only respective bpf progs and hence i made the changes to enable both flags when --filter-trace-only-bpf is set .
@brb @jschwinger233 can you let me know if my understanding is correct?

@jschwinger233
Copy link
Member

@sachintiptur By default, pwru traces events from skb functions, such as ip_rcv. When setting --filter-trace-xdp, pwru also traces events from xdp bpf prog; when settings --filter-trace-tc, pwru also traces events from tc bpf prog.

Your PR that enables both flags makes pwru trace events from 1)skb functions + 2)xdp bpf + 3)tc bpf. The --filter-trace-only-bpf is supposed to trace 2)xdp bpf + 3)tc bpf only.

@sachintiptur
Copy link
Author

Thanks much for the explanation. So along with the PR changes, I added the below code and tested locally, no skb funcs are traced and also I don't see any bpf funcs too because I dont have any bpf programs to test. I hope this is expected.

if flags.FilterTraceOnlyBpf {
+               for i := 1; i <= 5; i++ {
+                       delete(bpfSpec.Programs, fmt.Sprintf("kprobe_skb_%d", i))
+                       delete(bpfSpec.Programs, fmt.Sprintf("kprobe_multi_skb_%d", i))
+               }
+               delete(bpfSpec.Programs, "kprobe_skb_by_stackid")
+       }

Signed-off-by: Sachin Tiptur <coolsachints@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants