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:

committed by
Daniel Borkmann

parent
9328e0d1bc
commit
bd475643d7
@@ -513,13 +513,7 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr)
|
||||
if (!stab)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
/* mandatory map attributes */
|
||||
stab->map.map_type = attr->map_type;
|
||||
stab->map.key_size = attr->key_size;
|
||||
stab->map.value_size = attr->value_size;
|
||||
stab->map.max_entries = attr->max_entries;
|
||||
stab->map.map_flags = attr->map_flags;
|
||||
stab->map.numa_node = bpf_map_attr_numa_node(attr);
|
||||
bpf_map_init_from_attr(&stab->map, attr);
|
||||
|
||||
/* make sure page count doesn't overflow */
|
||||
cost = (u64) stab->map.max_entries * sizeof(struct sock *);
|
||||
|
Reference in New Issue
Block a user