Skip to content

Comments

bpf: Remove OUTPUT_SKB&HAS_KPROBE_MULTI macros#455

Merged
brb merged 4 commits intocilium:mainfrom
Asphaltt:feat/simplify-build
Nov 19, 2024
Merged

bpf: Remove OUTPUT_SKB&HAS_KPROBE_MULTI macros#455
brb merged 4 commits intocilium:mainfrom
Asphaltt:feat/simplify-build

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 force-pushed the feat/simplify-build branch from 5b56b72 to 3a05678 Compare November 10, 2024 06:06
@Asphaltt Asphaltt changed the title bpf: Remove unnecessary OUTPUT_SKB macro bpf: Remove OUTPUT_SKB&HAS_KPROBE_MULTI macros Nov 10, 2024
@Asphaltt Asphaltt force-pushed the feat/simplify-build branch from 2571b11 to 3d447f8 Compare November 10, 2024 07:24
@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.

@Asphaltt Asphaltt force-pushed the feat/simplify-build branch from 194dbff to 2ca47fc Compare November 13, 2024 15:19
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 force-pushed the feat/simplify-build branch from 2ca47fc to 34fcd87 Compare November 13, 2024 15:21
@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
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!

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