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

Support tracing tc-bpf #271

Merged
merged 1 commit into from
Oct 23, 2023
Merged

Support tracing tc-bpf #271

merged 1 commit into from
Oct 23, 2023

Conversation

Asphaltt
Copy link
Contributor

@Asphaltt Asphaltt commented Oct 17, 2023

This PR supports tracing tc-bpf as discussion in #239 .

Its running result likes:

#  ./pwru --output-limit-lines 10  --output-meta --output-tuple --filter-trace-tc --filter-func '.*udp' icmp
2023/10/21 15:22:05 Attaching kprobes (via kprobe-multi)...
1 / 1 [------------------------------------------------------------------------------------------------------------] 100.00% ? p/s
2023/10/21 15:22:05 Attached (ignored 0)
2023/10/21 15:22:05 Listening for events..
               SKB    CPU          PROCESS                     FUNC
0xffff940944c67900      3        [<empty>]                    dummy netns=4026531840 mark=0x0 iface=2(enp0s1) proto=0x0800 mtu=1500 len=98 192.168.64.1:0->192.168.64.2:0(icmp)
0xffff940944c67c00      3           [pwru]                    dummy netns=4026531840 mark=0x0 iface=2(enp0s1) proto=0x0800 mtu=1500 len=98 192.168.64.1:0->192.168.64.2:0(icmp)
0xffff940944c67e00      3        [<empty>]                    dummy netns=4026531840 mark=0x0 iface=2(enp0s1) proto=0x0800 mtu=1500 len=98 192.168.64.1:0->192.168.64.2:0(icmp)
0xffff9408f1c97c00      3        [<empty>]                    dummy netns=4026531840 mark=0x0 iface=2(enp0s1) proto=0x0800 mtu=1500 len=98 192.168.64.1:0->192.168.64.2:0(icmp)
0xffff9408f1c97600      3        [<empty>]                    dummy netns=4026531840 mark=0x0 iface=2(enp0s1) proto=0x0800 mtu=1500 len=98 192.168.64.1:0->192.168.64.2:0(icmp)
0xffff940944c67700      3        [<empty>]                    dummy netns=4026531840 mark=0x0 iface=2(enp0s1) proto=0x0800 mtu=1500 len=98 192.168.64.1:0->192.168.64.2:0(icmp)
0xffff940944c67b00      3        [<empty>]                    dummy netns=4026531840 mark=0x0 iface=2(enp0s1) proto=0x0800 mtu=1500 len=98 192.168.64.1:0->192.168.64.2:0(icmp)
0xffff940944c67f00      3        [<empty>]                    dummy netns=4026531840 mark=0x0 iface=2(enp0s1) proto=0x0800 mtu=1500 len=98 192.168.64.1:0->192.168.64.2:0(icmp)
0xffff940944c67400      3        [<empty>]                    dummy netns=4026531840 mark=0x0 iface=2(enp0s1) proto=0x0800 mtu=1500 len=98 192.168.64.1:0->192.168.64.2:0(icmp)
0xffff940944c67900      3        [<empty>]                    dummy netns=4026531840 mark=0x0 iface=2(enp0s1) proto=0x0800 mtu=1500 len=98 192.168.64.1:0->192.168.64.2:0(icmp)
2023/10/21 15:22:08 Printed 10 events, exiting program..

@brb brb self-requested a review October 18, 2023 14:52
Copy link
Member

@brb brb left a comment

Choose a reason for hiding this comment

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

That's very nice! 🎉 Small nits.

main.go Show resolved Hide resolved
bpf/kprobe_pwru.c Show resolved Hide resolved
internal/pwru/bpf_prog.go Show resolved Hide resolved
internal/pwru/bpf_prog.go Show resolved Hide resolved
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.

Thanks so much! This really paves the way for bpf_helper_tracing and bpf_tailcall_tracing. I left a comment to understand if it's the new field is necessary.

bpf/kprobe_pwru.c Outdated Show resolved Hide resolved
@brb brb self-requested a review October 20, 2023 15:03
Add an option --filter-trace-tc to trace all tc-bpf progs on host by
fentry-ing on the progs.

To trace tc-bpf, we list all tc-bpf progs first. Then, for each prog, we
have to retrieve its entry function name as fentry attaching function.
Next, we do fentry on the prog.

Example:

    ... [<empty>]                 dummy

Signed-off-by: Leon Hwang <[email protected]>
@brb brb requested a review from jschwinger233 October 23, 2023 07:58
Copy link
Member

@brb brb 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 brb merged commit 2347755 into cilium:main Oct 23, 2023
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.

3 participants