mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-05 08:09:07 +08:00
libbpf: Add BPF token support to bpf_map_create() API
Add ability to provide token_fd for BPF_MAP_CREATE command through bpf_map_create() API. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20240124022127.2379740-14-andrii@kernel.org
This commit is contained in:
committed by
Andrii Nakryiko
parent
5cc8482fe2
commit
8002c052f3
@@ -169,8 +169,7 @@ int bpf_map_create(enum bpf_map_type map_type,
|
|||||||
__u32 max_entries,
|
__u32 max_entries,
|
||||||
const struct bpf_map_create_opts *opts)
|
const struct bpf_map_create_opts *opts)
|
||||||
{
|
{
|
||||||
const size_t attr_sz = offsetofend(union bpf_attr,
|
const size_t attr_sz = offsetofend(union bpf_attr, map_token_fd);
|
||||||
value_type_btf_obj_fd);
|
|
||||||
union bpf_attr attr;
|
union bpf_attr attr;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
@@ -200,6 +199,8 @@ int bpf_map_create(enum bpf_map_type map_type,
|
|||||||
attr.numa_node = OPTS_GET(opts, numa_node, 0);
|
attr.numa_node = OPTS_GET(opts, numa_node, 0);
|
||||||
attr.map_ifindex = OPTS_GET(opts, map_ifindex, 0);
|
attr.map_ifindex = OPTS_GET(opts, map_ifindex, 0);
|
||||||
|
|
||||||
|
attr.map_token_fd = OPTS_GET(opts, token_fd, 0);
|
||||||
|
|
||||||
fd = sys_bpf_fd(BPF_MAP_CREATE, &attr, attr_sz);
|
fd = sys_bpf_fd(BPF_MAP_CREATE, &attr, attr_sz);
|
||||||
return libbpf_err_errno(fd);
|
return libbpf_err_errno(fd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,9 +52,11 @@ struct bpf_map_create_opts {
|
|||||||
__u32 numa_node;
|
__u32 numa_node;
|
||||||
__u32 map_ifindex;
|
__u32 map_ifindex;
|
||||||
__s32 value_type_btf_obj_fd;
|
__s32 value_type_btf_obj_fd;
|
||||||
size_t:0;
|
|
||||||
|
__u32 token_fd;
|
||||||
|
size_t :0;
|
||||||
};
|
};
|
||||||
#define bpf_map_create_opts__last_field value_type_btf_obj_fd
|
#define bpf_map_create_opts__last_field token_fd
|
||||||
|
|
||||||
LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
|
LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
|
||||||
const char *map_name,
|
const char *map_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user