diff options
author | Martin Kelly <martin.kelly@crowdstrike.com> | 2023-09-26 00:50:34 +0300 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2023-09-26 02:22:42 +0300 |
commit | 1c97f6afd73934881ae8514c51efc8e162b4b406 (patch) | |
tree | ddb46398ee77cdddd56d4ca5380a8694141856bb /tools/lib/bpf/ringbuf.c | |
parent | ef3b82003e6ca9554a144a9f42e7239ba39f0b97 (diff) | |
download | linux-1c97f6afd73934881ae8514c51efc8e162b4b406.tar.xz |
libbpf: Add ring_buffer__ring
Add a new function ring_buffer__ring, which exposes struct ring * to the
user, representing a single ringbuffer.
Signed-off-by: Martin Kelly <martin.kelly@crowdstrike.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230925215045.2375758-4-martin.kelly@crowdstrike.com
Diffstat (limited to 'tools/lib/bpf/ringbuf.c')
-rw-r--r-- | tools/lib/bpf/ringbuf.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/lib/bpf/ringbuf.c b/tools/lib/bpf/ringbuf.c index 94d11fb44a49..efde453395b0 100644 --- a/tools/lib/bpf/ringbuf.c +++ b/tools/lib/bpf/ringbuf.c @@ -330,6 +330,14 @@ int ring_buffer__epoll_fd(const struct ring_buffer *rb) return rb->epoll_fd; } +struct ring *ring_buffer__ring(struct ring_buffer *rb, unsigned int idx) +{ + if (idx >= rb->ring_cnt) + return errno = ERANGE, NULL; + + return rb->rings[idx]; +} + static void user_ringbuf_unmap_ring(struct user_ring_buffer *rb) { if (rb->consumer_pos) { |