Skip to contentSkip to conversation

How to attach a single bpf_program multiple times?

DISCUSSION Shuyi Cheng 2 participants 2 messages Sep 28, 2021 – Oct 1, 2021 BPF

lore
Share & tools
lore
#0 lore raw

Hi, everyone!

When the ebpf program is the same, but attach to a different kprobe function, I have to recompile the entire program. If the kprobe function of bpf_program attach can be specified dynamically, then there is no need to modify the original program.

Thanks!

#1 lore raw
Quoted 7 lines · Shuyi Cheng

Hi, everyone!

When the ebpf program is the same, but attach to a different kprobe function, I have to recompile the entire program. If the kprobe function of bpf_program attach can be specified dynamically, then there is no need to modify the original program.

With libbpf you can attach the same bpf_program to multiple kprobes. Use bpf_program__attach_kprobe() API multiple times with the same program instance, but different target functions.

Quoted 2 lines

Thanks!