mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +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
|
@ -93,13 +93,7 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
|
|||
if (!dtab)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
/* mandatory map attributes */
|
||||
dtab->map.map_type = attr->map_type;
|
||||
dtab->map.key_size = attr->key_size;
|
||||
dtab->map.value_size = attr->value_size;
|
||||
dtab->map.max_entries = attr->max_entries;
|
||||
dtab->map.map_flags = attr->map_flags;
|
||||
dtab->map.numa_node = bpf_map_attr_numa_node(attr);
|
||||
bpf_map_init_from_attr(&dtab->map, attr);
|
||||
|
||||
/* make sure page count doesn't overflow */
|
||||
cost = (u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue