bpf: add map_alloc_check callback
.map_alloc callbacks contain a number of checks validating user- -provided map attributes against constraints of a particular map type. For offloaded maps we will need to check map attributes without actually allocating any memory on the host. Add a new callback for validating attributes before any memory is allocated. This callback can be selectively implemented by map types for sharing code with offloads, or simply to separate the logical steps of validation and allocation. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:

committed by
Daniel Borkmann

parent
fdde5f3b6b
commit
1110f3a9bc
@@ -25,6 +25,7 @@ struct bpf_map;
|
||||
/* map is generic key/value storage optionally accesible by eBPF programs */
|
||||
struct bpf_map_ops {
|
||||
/* funcs callable from userspace (via syscall) */
|
||||
int (*map_alloc_check)(union bpf_attr *attr);
|
||||
struct bpf_map *(*map_alloc)(union bpf_attr *attr);
|
||||
void (*map_release)(struct bpf_map *map, struct file *map_file);
|
||||
void (*map_free)(struct bpf_map *map);
|
||||
|
Reference in New Issue
Block a user