bpf: Define new BPF_MAP_TYPE_USER_RINGBUF map type
authorDavid Vernet <void@manifault.com>
Tue, 20 Sep 2022 00:00:57 +0000 (19:00 -0500)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 21 Sep 2022 23:24:17 +0000 (16:24 -0700)
commit583c1f420173f7d84413a1a1fbf5109d798b4faa
tree7c2afbcc69ba4b64cca3e34719837e2fa518c826
parent3a74904ceff3ecdb9d6cc0844ed67df417968eb6
bpf: Define new BPF_MAP_TYPE_USER_RINGBUF map type

We want to support a ringbuf map type where samples are published from
user-space, to be consumed by BPF programs. BPF currently supports a
kernel -> user-space circular ring buffer via the BPF_MAP_TYPE_RINGBUF
map type.  We'll need to define a new map type for user-space -> kernel,
as none of the helpers exported for BPF_MAP_TYPE_RINGBUF will apply
to a user-space producer ring buffer, and we'll want to add one or
more helper functions that would not apply for a kernel-producer
ring buffer.

This patch therefore adds a new BPF_MAP_TYPE_USER_RINGBUF map type
definition. The map type is useless in its current form, as there is no
way to access or use it for anything until we one or more BPF helpers. A
follow-on patch will therefore add a new helper function that allows BPF
programs to run callbacks on samples that are published to the ring
buffer.

Signed-off-by: David Vernet <void@manifault.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220920000100.477320-2-void@manifault.com
include/linux/bpf_types.h
include/uapi/linux/bpf.h
kernel/bpf/ringbuf.c
kernel/bpf/verifier.c
tools/bpf/bpftool/Documentation/bpftool-map.rst
tools/bpf/bpftool/map.c
tools/include/uapi/linux/bpf.h
tools/lib/bpf/libbpf.c