Skip to content

Commit f9933ac

Browse files
aspskanakryiko
authored andcommitted
libbpf: prog load: Allow to use fd_array_cnt
Add new fd_array_cnt field to bpf_prog_load_opts and pass it in bpf_attr, if set. Signed-off-by: Anton Protopopov <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 4d3ae29 commit f9933ac

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tools/lib/bpf/bpf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ int bpf_prog_load(enum bpf_prog_type prog_type,
238238
const struct bpf_insn *insns, size_t insn_cnt,
239239
struct bpf_prog_load_opts *opts)
240240
{
241-
const size_t attr_sz = offsetofend(union bpf_attr, prog_token_fd);
241+
const size_t attr_sz = offsetofend(union bpf_attr, fd_array_cnt);
242242
void *finfo = NULL, *linfo = NULL;
243243
const char *func_info, *line_info;
244244
__u32 log_size, log_level, attach_prog_fd, attach_btf_obj_fd;
@@ -311,6 +311,7 @@ int bpf_prog_load(enum bpf_prog_type prog_type,
311311
attr.line_info_cnt = OPTS_GET(opts, line_info_cnt, 0);
312312

313313
attr.fd_array = ptr_to_u64(OPTS_GET(opts, fd_array, NULL));
314+
attr.fd_array_cnt = OPTS_GET(opts, fd_array_cnt, 0);
314315

315316
if (log_level) {
316317
attr.log_buf = ptr_to_u64(log_buf);

tools/lib/bpf/bpf.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ struct bpf_prog_load_opts {
107107
*/
108108
__u32 log_true_size;
109109
__u32 token_fd;
110+
111+
/* if set, provides the length of fd_array */
112+
__u32 fd_array_cnt;
110113
size_t :0;
111114
};
112-
#define bpf_prog_load_opts__last_field token_fd
115+
#define bpf_prog_load_opts__last_field fd_array_cnt
113116

114117
LIBBPF_API int bpf_prog_load(enum bpf_prog_type prog_type,
115118
const char *prog_name, const char *license,

0 commit comments

Comments
 (0)