diff mbox series

[bpf-next,v4,09/11] tools: bpftool: Add separate fd_array map support for light skeleton

Message ID 20210920141526.3940002-10-memxor@gmail.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series Support kernel module function calls from eBPF | expand

Checks

Context Check Description
bpf/vmtest-bpf-next fail VM_Test
bpf/vmtest-bpf-next-PR fail PR summary
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 7 maintainers not CCed: alastorze@fb.com lmb@cloudflare.com kpsingh@kernel.org john.fastabend@gmail.com cong.wang@bytedance.com liujian56@huawei.com quentin@isovalent.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff fail Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Kumar Kartikeya Dwivedi Sept. 20, 2021, 2:15 p.m. UTC
This prepares bpftool to pass fd_array_sz parameter, so that the map can
be created by bpf_load_and_run function to hold map and BTF fds.
---
 tools/bpf/bpftool/gen.c  | 3 ++-
 tools/bpf/bpftool/prog.c | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index e3ec47a6a612..5bd3650956a4 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -532,10 +532,11 @@  static int gen_trace(struct bpf_object *obj, const char *obj_name, const char *h
 
 	codegen("\
 		\n\
+			opts.fd_array_sz = %d;				    \n\
 			opts.insns_sz = %d;				    \n\
 			opts.insns = (void *)\"\\			    \n\
 		",
-		opts.insns_sz);
+		opts.fd_array_sz, opts.insns_sz);
 	print_hex(opts.insns, opts.insns_sz);
 	codegen("\
 		\n\
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 9c3e343b7d87..1d6286d727f4 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -1693,6 +1693,7 @@  static int try_loader(struct gen_loader_opts *gen)
 	opts.data_sz = gen->data_sz;
 	opts.insns = gen->insns;
 	opts.insns_sz = gen->insns_sz;
+	opts.fd_array_sz = gen->fd_array_sz;
 	fds_before = count_open_fds();
 	err = bpf_load_and_run(&opts);
 	fd_delta = count_open_fds() - fds_before;