Skip to content

KFunc bpf_dynptr_slice

v6.4

Get a pointer to dynptr data up to len bytes for read only access.

Definition

This function can handle both contiguous and non-contiguous data of len. If the dynptr doesn't have data up to len bytes for BPF_PROG_TYPE_SK_SKB, return NULL. buffer__opt stores all the data after copying. If the dynptr has some data in page buffer for BPF_PROG_TYPE_SK_SKB, return buffer__opt not NULL .
If the dynptr doesn't have data up to len bytes for BPF_PROG_TYPE_XDP, return buffer__opt not NULL.

Signature

void *bpf_dynptr_slice(const struct bpf_dynptr *p, u32 offset, void *buffer__opt, u32 buffer__szk)

Note

The pointer returned by the kfunc may be NULL. Hence, it forces the user to do a NULL check on the pointer returned from the kfunc before making use of it (dereferencing or passing to another helper).

Usage

Docs could be improved

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

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