lkml.org 
[lkml]   [2022]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH bpf-next] samples/bpf: Fix sockex3: missing BPF prog type
Date
From: Rong Tao <rongtao@cestc.cn>

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, set "socket/xxx" to SOCKET_FILTER
solves 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>
---
samples/bpf/sockex3_user.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/samples/bpf/sockex3_user.c b/samples/bpf/sockex3_user.c
index cd6fa79df900..dc79c17ad195 100644
--- a/samples/bpf/sockex3_user.c
+++ b/samples/bpf/sockex3_user.c
@@ -39,6 +39,9 @@ int main(int argc, char **argv)
return 0;
}

+ bpf_object__for_each_program(prog, obj)
+ bpf_program__set_type(prog, BPF_PROG_TYPE_SOCKET_FILTER);
+
/* load BPF program */
if (bpf_object__load(obj)) {
fprintf(stderr, "ERROR: loading BPF object file failed\n");
--
2.31.1
\
 
 \ /
  Last update: 2022-10-29 09:53    [W:0.079 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site