mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-07 09:09:06 +08:00
bpf: Add bpf_dynptr_read and bpf_dynptr_write
This patch adds two helper functions, bpf_dynptr_read and bpf_dynptr_write: long bpf_dynptr_read(void *dst, u32 len, struct bpf_dynptr *src, u32 offset); long bpf_dynptr_write(struct bpf_dynptr *dst, u32 offset, void *src, u32 len); The dynptr passed into these functions must be valid dynptrs that have been initialized. Signed-off-by: Joanne Koong <joannelkoong@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220523210712.3641569-5-joannelkoong@gmail.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
1a0f5d1c87
commit
7ed5bf8f4c
@@ -5221,6 +5221,23 @@ union bpf_attr {
|
|||||||
* 'bpf_ringbuf_discard'.
|
* 'bpf_ringbuf_discard'.
|
||||||
* Return
|
* Return
|
||||||
* Nothing. Always succeeds.
|
* Nothing. Always succeeds.
|
||||||
|
*
|
||||||
|
* long bpf_dynptr_read(void *dst, u32 len, struct bpf_dynptr *src, u32 offset)
|
||||||
|
* Description
|
||||||
|
* Read *len* bytes from *src* into *dst*, starting from *offset*
|
||||||
|
* into *src*.
|
||||||
|
* Return
|
||||||
|
* 0 on success, -E2BIG if *offset* + *len* exceeds the length
|
||||||
|
* of *src*'s data, -EINVAL if *src* is an invalid dynptr.
|
||||||
|
*
|
||||||
|
* long bpf_dynptr_write(struct bpf_dynptr *dst, u32 offset, void *src, u32 len)
|
||||||
|
* Description
|
||||||
|
* Write *len* bytes from *src* into *dst*, starting from *offset*
|
||||||
|
* into *dst*.
|
||||||
|
* Return
|
||||||
|
* 0 on success, -E2BIG if *offset* + *len* exceeds the length
|
||||||
|
* of *dst*'s data, -EINVAL if *dst* is an invalid dynptr or if *dst*
|
||||||
|
* is a read-only dynptr.
|
||||||
*/
|
*/
|
||||||
#define __BPF_FUNC_MAPPER(FN) \
|
#define __BPF_FUNC_MAPPER(FN) \
|
||||||
FN(unspec), \
|
FN(unspec), \
|
||||||
@@ -5424,6 +5441,8 @@ union bpf_attr {
|
|||||||
FN(ringbuf_reserve_dynptr), \
|
FN(ringbuf_reserve_dynptr), \
|
||||||
FN(ringbuf_submit_dynptr), \
|
FN(ringbuf_submit_dynptr), \
|
||||||
FN(ringbuf_discard_dynptr), \
|
FN(ringbuf_discard_dynptr), \
|
||||||
|
FN(dynptr_read), \
|
||||||
|
FN(dynptr_write), \
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
|
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
|
||||||
|
|||||||
Reference in New Issue
Block a user