mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-04 23:59:07 +08:00
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 <aspsk@isovalent.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20241213130934.1087929-6-aspsk@isovalent.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
266da73237
commit
48c771c4ce
@@ -238,7 +238,7 @@ int bpf_prog_load(enum bpf_prog_type prog_type,
|
|||||||
const struct bpf_insn *insns, size_t insn_cnt,
|
const struct bpf_insn *insns, size_t insn_cnt,
|
||||||
struct bpf_prog_load_opts *opts)
|
struct bpf_prog_load_opts *opts)
|
||||||
{
|
{
|
||||||
const size_t attr_sz = offsetofend(union bpf_attr, prog_token_fd);
|
const size_t attr_sz = offsetofend(union bpf_attr, fd_array_cnt);
|
||||||
void *finfo = NULL, *linfo = NULL;
|
void *finfo = NULL, *linfo = NULL;
|
||||||
const char *func_info, *line_info;
|
const char *func_info, *line_info;
|
||||||
__u32 log_size, log_level, attach_prog_fd, attach_btf_obj_fd;
|
__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,
|
|||||||
attr.line_info_cnt = OPTS_GET(opts, line_info_cnt, 0);
|
attr.line_info_cnt = OPTS_GET(opts, line_info_cnt, 0);
|
||||||
|
|
||||||
attr.fd_array = ptr_to_u64(OPTS_GET(opts, fd_array, NULL));
|
attr.fd_array = ptr_to_u64(OPTS_GET(opts, fd_array, NULL));
|
||||||
|
attr.fd_array_cnt = OPTS_GET(opts, fd_array_cnt, 0);
|
||||||
|
|
||||||
if (log_level) {
|
if (log_level) {
|
||||||
attr.log_buf = ptr_to_u64(log_buf);
|
attr.log_buf = ptr_to_u64(log_buf);
|
||||||
|
|||||||
@@ -107,9 +107,12 @@ struct bpf_prog_load_opts {
|
|||||||
*/
|
*/
|
||||||
__u32 log_true_size;
|
__u32 log_true_size;
|
||||||
__u32 token_fd;
|
__u32 token_fd;
|
||||||
|
|
||||||
|
/* if set, provides the length of fd_array */
|
||||||
|
__u32 fd_array_cnt;
|
||||||
size_t :0;
|
size_t :0;
|
||||||
};
|
};
|
||||||
#define bpf_prog_load_opts__last_field token_fd
|
#define bpf_prog_load_opts__last_field fd_array_cnt
|
||||||
|
|
||||||
LIBBPF_API int bpf_prog_load(enum bpf_prog_type prog_type,
|
LIBBPF_API int bpf_prog_load(enum bpf_prog_type prog_type,
|
||||||
const char *prog_name, const char *license,
|
const char *prog_name, const char *license,
|
||||||
|
|||||||
Reference in New Issue
Block a user