summaryrefslogtreecommitdiffstats
path: root/kernel/bpf/cpumap.c
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2018-01-11 20:29:06 -0800
committerDaniel Borkmann <daniel@iogearbox.net>2018-01-14 23:36:29 +0100
commitbd475643d74e8ed78bfd36d941053b0e45974e8e (patch)
tree30fdfb7335e61f5d34c864f2abce9bf74f0f89ad /kernel/bpf/cpumap.c
parent9328e0d1bc09e96bd7dc85374f5c2a1e0e04e539 (diff)
downloadlinux-stable-bd475643d74e8ed78bfd36d941053b0e45974e8e.tar.gz
linux-stable-bd475643d74e8ed78bfd36d941053b0e45974e8e.tar.bz2
linux-stable-bd475643d74e8ed78bfd36d941053b0e45974e8e.zip
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>
Diffstat (limited to 'kernel/bpf/cpumap.c')
-rw-r--r--kernel/bpf/cpumap.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index ce5b669003b2..192151ec9d12 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c
@@ -94,13 +94,7 @@ static struct bpf_map *cpu_map_alloc(union bpf_attr *attr)
if (!cmap)
return ERR_PTR(-ENOMEM);
- /* mandatory map attributes */
- cmap->map.map_type = attr->map_type;
- cmap->map.key_size = attr->key_size;
- cmap->map.value_size = attr->value_size;
- cmap->map.max_entries = attr->max_entries;
- cmap->map.map_flags = attr->map_flags;
- cmap->map.numa_node = bpf_map_attr_numa_node(attr);
+ bpf_map_init_from_attr(&cmap->map, attr);
/* Pre-limit array size based on NR_CPUS, not final CPU check */
if (cmap->map.max_entries > NR_CPUS) {