mirror of
https://github.com/netdata/libbpf.git
synced 2026-11-08 10:50:15 +08:00
libbpf: Add support for associating BPF program with struct_ops
Add low-level wrapper and libbpf API for BPF_PROG_ASSOC_STRUCT_OPS command in the bpf() syscall. Signed-off-by: Amery Hung <ameryhung@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20251203233748.668365-4-ameryhung@gmail.com
This commit is contained in:
1 parent
1a41b12b4f
commit
5635185147
5 files changed
+89
No files matched your search
@@ -1397,3 +1397,22 @@ int bpf_prog_stream_read(int prog_fd, __u32 stream_id, void *buf, __u32 buf_len,
|
||||
err = sys_bpf(BPF_PROG_STREAM_READ_BY_FD, &attr, attr_sz);
|
||||
return libbpf_err_errno(err);
|
||||
}
|
||||
|
||||
int bpf_prog_assoc_struct_ops(int prog_fd, int map_fd,
|
||||
struct bpf_prog_assoc_struct_ops_opts *opts)
|
||||
{
|
||||
const size_t attr_sz = offsetofend(union bpf_attr, prog_assoc_struct_ops);
|
||||
union bpf_attr attr;
|
||||
int err;
|
||||
|
||||
if (!OPTS_VALID(opts, bpf_prog_assoc_struct_ops_opts))
|
||||
return libbpf_err(-EINVAL);
|
||||
|
||||
memset(&attr, 0, attr_sz);
|
||||
attr.prog_assoc_struct_ops.map_fd = map_fd;
|
||||
attr.prog_assoc_struct_ops.prog_fd = prog_fd;
|
||||
attr.prog_assoc_struct_ops.flags = OPTS_GET(opts, flags, 0);
|
||||
|
||||
err = sys_bpf(BPF_PROG_ASSOC_STRUCT_OPS, &attr, attr_sz);
|
||||
return libbpf_err_errno(err);
|
||||
}
|
||||
Reference in new issue
Block a user