]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Prepare light skeleton for the kernel.
authorAlexei Starovoitov <ast@kernel.org>
Wed, 9 Feb 2022 23:19:58 +0000 (15:19 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 10 Feb 2022 22:31:51 +0000 (23:31 +0100)
commite6644509716d4b676078dce889630ad4ecec9f8f
tree3ce3bc5eba4cef9417e0416db1cfec1fc1f24c8e
parente3eda4e0668514c3d5491a8e8f40af307d257c44
libbpf: Prepare light skeleton for the kernel.

Prepare light skeleton to be used in the kernel module and in the user space.
The look and feel of lskel.h is mostly the same with the difference that for
user space the skel->rodata is the same pointer before and after skel_load
operation, while in the kernel the skel->rodata after skel_open and the
skel->rodata after skel_load are different pointers.
Typical usage of skeleton remains the same for kernel and user space:
skel = my_bpf__open();
skel->rodata->my_global_var = init_val;
err = my_bpf__load(skel);
err = my_bpf__attach(skel);
// access skel->rodata->my_global_var;
// access skel->bss->another_var;

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220209232001.27490-3-alexei.starovoitov@gmail.com
tools/lib/bpf/gen_loader.c
tools/lib/bpf/skel_internal.h