Skip to content

KFunc bpf_dynptr_memset

v6.17

Fill dynptr memory with a constant byte.

Definition

Fills the size bytes of the memory area pointed to by p at offset with the constant byte val.

Parameters

p: Destination dynptr - where data will be filled

offset: Offset into the dynptr to start filling from

size: Number of bytes to fill

val: Constant byte to fill the memory with

Returns

Returns 0 on success; negative error, otherwise.

Signature

int bpf_dynptr_memset(struct bpf_dynptr *p, u64 offset, u64 size, u8 val)

Note

In v6.19 the signature of this kfunc changed from u32 to u64 types for offset and size. This may require CO-RE logic to select the correct kfunc.

Usage

This kfunc allows the filling of a dynptr with a value. This was technically possible with bpf_dynptr_write but that requires creating a variable on the stack and/or repeated calls. This kfunc does not have that drawback.

Program types

The following program types can make use of this kfunc:

Example

Docs could be improved

This part of the docs is incomplete, contributions are very welcome