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: Remove OUTPUT_SKB&HAS_KPROBE_MULTI macros #455

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

Conversation

Asphaltt
Copy link
Contributor

When call set_skb_btf() or set_shinfo_btf(), these functions are protected by constant CFG.

Then, while loading kprobe_pwru into kernel, if no --output-skb/--output-skb-shared-info, set_skb_btf()/set_shinfo_btf() won't be verified. Next, these unreachable code will be eliminated by verifier.

@Asphaltt Asphaltt changed the title bpf: Remove unnecessary OUTPUT_SKB macro bpf: Remove OUTPUT_SKB&HAS_KPROBE_MULTI macros Nov 10, 2024
@jschwinger233
Copy link
Member

Just for the record:

  1. 6.1 and bpf-next see pwru --backend kprobe-multi broken while --backend kprobe stil works.
  2. 5.4 fails due to CO-RE issues on sk_buff. My guess is some members are deleted / renamed between 5.4 and 5.15.

@Asphaltt Asphaltt force-pushed the feat/simplify-build branch 2 times, most recently from f93ebd2 to 194dbff Compare November 12, 2024 14:57
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.

Always love to see code simplification! Left some comments to discuss.

internal/pwru/btf.go Show resolved Hide resolved
bpf/features.c Outdated Show resolved Hide resolved
bpf/features.c Outdated Show resolved Hide resolved
It's to avoid the following issue for next commit, especially on Ubuntu
20.04:

 ; instruction poisoned by CO-RE
 938: (85) call unknown#195896080
 invalid func unknown#195896080
 processed 519 insns (limit 1000000) max_states_per_insn 0 total_states 29 peak_states 29 mark_read 27

Signed-off-by: Leon Hwang <[email protected]>
When call set_skb_btf() or set_shinfo_btf(), these functions are
protected by constant CFG.

Then, while loading kprobe_pwru into kernel, if no
--output-skb/--output-skb-shared-info, set_skb_btf()/set_shinfo_btf()
won't be verified. Next, these unreachable code will be eliminated by
verifier.

Signed-off-by: Leon Hwang <[email protected]>
Simplify bpf code.

And use Go to determine loading kprobe or kprobe.multi bpf prog.

Signed-off-by: Leon Hwang <[email protected]>
Fix this panic:

$ sudo ./pwru --output-tuple 'dst host 1.0.0.1 and port 8080'
2024/11/12 13:58:41 Attaching kprobes (via kprobe)...
102 / 1255 [---------->_________________________________________________________________________________________________________________________] 8.13% 96 p/s
231 / 1255 [----------------------->__________________________________________________________________________________________________________] 18.41% 120 p/s
2024/11/12 13:58:43 Listening for events..
SKB                CPU PROCESS          NETNS      MARK/x        IFACE       PROTO  MTU   LEN   TUPLE FUNC
2024/11/12 13:58:43 Received signal, exiting program..
2024/11/12 13:58:43 Detaching kprobes...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x6675d8]

goroutine 1 [running]:
github.com/cilium/pwru/internal/pwru.(*kprober).DetachKprobes(0x0)
	/root/Projects/leonhwang/pwru/internal/pwru/kprobe.go:130 +0xb8
main.main()
	/root/Projects/leonhwang/pwru/main.go:322 +0x2013

Signed-off-by: Leon Hwang <[email protected]>
@Asphaltt Asphaltt marked this pull request as ready for review November 14, 2024 02:31
@Asphaltt Asphaltt requested a review from a team as a code owner November 14, 2024 02:31
@Asphaltt Asphaltt requested review from brb and removed request for a team November 14, 2024 02:31
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