Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

samples/bpf: Fix tracex2 error: No such file or directory

since commit c504e5c2f964("net: skb: introduce kfree_skb_reason()")
kfree_skb() is replaced by kfree_skb_reason() and kfree_skb() is set to
the inline function. So, we replace kprobe/kfree_skb with
kprobe/kfree_skb_reason to solve the tracex2 error.

$ cd samples/bpf
$ sudo ./tracex2
libbpf: prog 'bpf_prog2': failed to create kprobe 'kfree_skb+0x0' perf event: No such file or directory
ERROR: bpf_program__attach failed

Signed-off-by: Rong Tao <rongtao@cestc.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/tencent_0F0DAE84C0B3C42E0B550E5E9F47A9114D09@qq.com

authored by

Rong Tao and committed by
Andrii Nakryiko
1baa7e38 2e20f50f

+4 -3
+2 -2
samples/bpf/tracex2_kern.c
··· 22 22 /* kprobe is NOT a stable ABI. If kernel internals change this bpf+kprobe 23 23 * example will no longer be meaningful 24 24 */ 25 - SEC("kprobe/kfree_skb") 25 + SEC("kprobe/kfree_skb_reason") 26 26 int bpf_prog2(struct pt_regs *ctx) 27 27 { 28 28 long loc = 0; 29 29 long init_val = 1; 30 30 long *value; 31 31 32 - /* read ip of kfree_skb caller. 32 + /* read ip of kfree_skb_reason caller. 33 33 * non-portable version of __builtin_return_address(0) 34 34 */ 35 35 BPF_KPROBE_READ_RET_IP(loc, ctx);
+2 -1
samples/bpf/tracex2_user.c
··· 146 146 signal(SIGINT, int_exit); 147 147 signal(SIGTERM, int_exit); 148 148 149 - /* start 'ping' in the background to have some kfree_skb events */ 149 + /* start 'ping' in the background to have some kfree_skb_reason 150 + * events */ 150 151 f = popen("ping -4 -c5 localhost", "r"); 151 152 (void) f; 152 153