bpf: add map_lookup_elem_sys_only for lookups from syscall side
authorDaniel Borkmann <daniel@iogearbox.net>
Mon, 13 May 2019 23:18:55 +0000 (01:18 +0200)
committerCosmin Tanislav <demonsingur@gmail.com>
Thu, 16 May 2024 07:58:22 +0000 (10:58 +0300)
commiteffc63a8147d3da04c39508d6c635f8d2062e2b9
tree69fe7fafb140b0d59c04f8c43bd0f8ed22746870
parent17ae338fa47bad52d32e0452b945feb221724d99
bpf: add map_lookup_elem_sys_only for lookups from syscall side

commit c6110222c6f49ea68169f353565eb865488a8619 upstream.

Add a callback map_lookup_elem_sys_only() that map implementations
could use over map_lookup_elem() from system call side in case the
map implementation needs to handle the latter differently than from
the BPF data path. If map_lookup_elem_sys_only() is set, this will
be preferred pick for map lookups out of user space. This hook is
used in a follow-up fix for LRU map, but once development window
opens, we can convert other map types from map_lookup_elem() (here,
the one called upon BPF_MAP_LOOKUP_ELEM cmd is meant) over to use
the callback to simplify and clean up the latter.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/bpf.h
kernel/bpf/syscall.c