mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-07 09:09:06 +08:00
bpf: Add bpf_dynptr_from_mem for local dynptrs
This patch adds a new api bpf_dynptr_from_mem: long bpf_dynptr_from_mem(void *data, u32 size, u64 flags, struct bpf_dynptr *ptr); which initializes a dynptr to point to a bpf program's local memory. For now only local memory that is of reg type PTR_TO_MAP_VALUE is supported. Signed-off-by: Joanne Koong <joannelkoong@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220523210712.3641569-3-joannelkoong@gmail.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
97009215cb
commit
c68a2738fd
@@ -5178,6 +5178,17 @@ union bpf_attr {
|
|||||||
* Dynamically cast a *sk* pointer to a *mptcp_sock* pointer.
|
* Dynamically cast a *sk* pointer to a *mptcp_sock* pointer.
|
||||||
* Return
|
* Return
|
||||||
* *sk* if casting is valid, or **NULL** otherwise.
|
* *sk* if casting is valid, or **NULL** otherwise.
|
||||||
|
*
|
||||||
|
* long bpf_dynptr_from_mem(void *data, u32 size, u64 flags, struct bpf_dynptr *ptr)
|
||||||
|
* Description
|
||||||
|
* Get a dynptr to local memory *data*.
|
||||||
|
*
|
||||||
|
* *data* must be a ptr to a map value.
|
||||||
|
* The maximum *size* supported is DYNPTR_MAX_SIZE.
|
||||||
|
* *flags* is currently unused.
|
||||||
|
* Return
|
||||||
|
* 0 on success, -E2BIG if the size exceeds DYNPTR_MAX_SIZE,
|
||||||
|
* -EINVAL if flags is not 0.
|
||||||
*/
|
*/
|
||||||
#define __BPF_FUNC_MAPPER(FN) \
|
#define __BPF_FUNC_MAPPER(FN) \
|
||||||
FN(unspec), \
|
FN(unspec), \
|
||||||
@@ -5377,6 +5388,7 @@ union bpf_attr {
|
|||||||
FN(kptr_xchg), \
|
FN(kptr_xchg), \
|
||||||
FN(map_lookup_percpu_elem), \
|
FN(map_lookup_percpu_elem), \
|
||||||
FN(skc_to_mptcp_sock), \
|
FN(skc_to_mptcp_sock), \
|
||||||
|
FN(dynptr_from_mem), \
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
/* 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