Libbpf userspace function bpf_map_create
Low level wrapper around the BPF_MAP_CREATE
syscall command.
Definition
int bpf_map_create(enum bpf_map_type map_type, const char *map_name, __u32 key_size, __u32 value_size, __u32 max_entries, const struct bpf_map_create_opts *opts);
Parameters
map_type
: type of the map to createmap_name
: name of the mapkey_size
: size of the key in bytesvalue_size
: size of the value in bytesmax_entries
: maximum number of entries in the mapopts
: options for the map creation
struct bpf_map_create_opts
struct bpf_map_create_opts {
size_t sz; /* size of this struct for forward/backward compatibility */
__u32 btf_fd;
__u32 btf_key_type_id;
__u32 btf_value_type_id;
__u32 btf_vmlinux_value_type_id;
__u32 inner_map_fd;
__u32 map_flags;
__u64 map_extra;
__u32 numa_node;
__u32 map_ifindex;
__s32 value_type_btf_obj_fd;
__u32 token_fd;
size_t :0;
};
btf_fd
btf_key_type_id
btf_value_type_id
btf_vmlinux_value_type_id
inner_map_fd
map_flags
map_extra
numa_node
map_ifindex
value_type_btf_obj_fd
token_fd
Return
>=0
, file descriptor of the created map; <0
, on error.
Usage
This function should only be used if you need precise control over the map creation process. For most cases, map should be created via bpf_object__load
or similar high level APIs instead.
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome