Skip to content

Commit

Permalink
Add verifier constraint for Helper function bpf_ringbuf_reserve (#83)
Browse files Browse the repository at this point in the history
The verifier has hard constraints for some helper functions.
bpf_ringbuf_reserve_dynptr has it's constraint documented, so adding the
relevant constraint for bpf_ringbuf_reserve and one for generic maps.
  • Loading branch information
MahnurA authored Nov 14, 2024
1 parent 215e0c0 commit 471a339
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/linux/concepts/maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct {

It is common for maps to be declared in the eBPF program, but maps are ultimately created from userspace. Most loader libraries pick up the map declarations from the compiled ELF file and create them automatically for the user.

However, it is also possible for users to manually create maps using the [BPF_MAP_CREATE](../syscall/BPF_MAP_CREATE.md) command of the BPF syscall or to use a loader library with such capabilities.
However, it is also possible for users to manually create maps using the [BPF_MAP_CREATE](../syscall/BPF_MAP_CREATE.md) command of the BPF syscall or to use a loader library with such capabilities. System wide there is no limit to the number of maps that can be created provided enough memory exists, however, a limit of 64 maps per program is enforced, that is, an eBPF program can interact with a maximum of 64 maps.

### Libbpf

Expand Down
2 changes: 1 addition & 1 deletion docs/linux/helper-function/bpf_ringbuf_reserve.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The `rinfbuf` argument must be a pointer to a ring buffer definition. The `size`

This function is generally used in combination with a `struct` that defines the structure of the data stored in the ring buffer. Hence, in this case, the `size` argument would be set to the size of the struct. The function returns a pointer to the reserved memory, which can be used to write data to the ring buffer. See the example below for more details.

Also check [`bpf_ringbuf_submit`](./bpf_ringbuf_submit.md) and [`bpf_ringbuf_discard`](./bpf_ringbuf_discard.md) for more information on how to handle the reserved memory in the ring buffer.
The verifier enforces the constraint that for every call to `bpf_ringbuf_reserve`, a subsequent [`bpf_ringbuf_submit`](./bpf_ringbuf_submit.md) or [`bpf_ringbuf_discard`](./bpf_ringbuf_discard.md) must be called. Check [`bpf_ringbuf_submit`](./bpf_ringbuf_submit.md) and [`bpf_ringbuf_discard`](./bpf_ringbuf_discard.md) for more information.

### Program types

Expand Down

0 comments on commit 471a339

Please sign in to comment.