mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 06:32:08 +00:00
bpf: add helper for copying attrs to struct bpf_map
All map types reimplement the field-by-field copy of union bpf_attr members into struct bpf_map. Add a helper to perform this operation. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
9328e0d1bc
commit
bd475643d7
8 changed files with 17 additions and 40 deletions
|
@ -88,14 +88,10 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
|
|||
if (cost >= U32_MAX - PAGE_SIZE)
|
||||
goto free_smap;
|
||||
|
||||
smap->map.map_type = attr->map_type;
|
||||
smap->map.key_size = attr->key_size;
|
||||
bpf_map_init_from_attr(&smap->map, attr);
|
||||
smap->map.value_size = value_size;
|
||||
smap->map.max_entries = attr->max_entries;
|
||||
smap->map.map_flags = attr->map_flags;
|
||||
smap->n_buckets = n_buckets;
|
||||
smap->map.pages = round_up(cost, PAGE_SIZE) >> PAGE_SHIFT;
|
||||
smap->map.numa_node = bpf_map_attr_numa_node(attr);
|
||||
|
||||
err = bpf_map_precharge_memlock(smap->map.pages);
|
||||
if (err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue