diff options
author | Rong Tao <rongtao@cestc.cn> | 2022-11-05 09:48:00 +0300 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2022-11-08 04:13:35 +0300 |
commit | e5659e4e19e49f1eac58bb07ce8bc2d78a89fe65 (patch) | |
tree | 48fd4f7279c5948d2f489a45e60d4a73db0f7f5e /tools/bpf/bpftool/gen.c | |
parent | e8f50c4f0c14214b6430b8b3493654a286681a2b (diff) | |
download | linux-e5659e4e19e49f1eac58bb07ce8bc2d78a89fe65.tar.xz |
samples/bpf: Fix sockex3 error: Missing BPF prog type
since commit 450b167fb9be("libbpf: clean up SEC() handling"),
sec_def_matches() does not recognize "socket/xxx" as "socket", therefore,
the BPF program type is not recognized.
Instead of sockex3_user.c parsing section names to get the BPF program fd.
We use the program array map to assign a static index to each BPF program
(get inspired by selftests/bpf progs/test_prog_array_init.c).
Therefore, use SEC("socket") as section name instead of SEC("socket/xxx"),
so that the BPF program is parsed to SOCKET_FILTER type. The "missing BPF
prog type" problem is solved.
How to reproduce this error:
$ cd samples/bpf
$ sudo ./sockex3
libbpf: prog 'bpf_func_PARSE_IP': missing BPF prog type, check ELF section name 'socket/3'
libbpf: prog 'bpf_func_PARSE_IP': failed to load: -22
libbpf: failed to load object './sockex3_kern.o'
ERROR: loading BPF object file failed
Signed-off-by: Rong Tao <rongtao@cestc.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/tencent_EBA3C18864069E42175946973C2ACBAF5408@qq.com
Diffstat (limited to 'tools/bpf/bpftool/gen.c')
0 files changed, 0 insertions, 0 deletions