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.
Showing the changes to tools/include/uapi/linux (1 of 3 files). Show all
Unified · Split
| @@ -5221,6 +5221,23 @@ union bpf_attr { · 5220 unmodified lines | |||
| 5221 | * 'bpf_ringbuf_discard'. | 5221 | * 'bpf_ringbuf_discard'. |
| 5222 | * Return | 5222 | * Return |
| 5223 | * Nothing. Always succeeds. | 5223 | * Nothing. Always succeeds. |
| 5224 | * | ||
| 5225 | * long bpf_dynptr_read(void *dst, u32 len, struct bpf_dynptr *src, u32 offset) | ||
| 5226 | * Description | ||
| 5227 | * Read *len* bytes from *src* into *dst*, starting from *offset* | ||
| 5228 | * into *src*. | ||
| 5229 | * Return | ||
| 5230 | * 0 on success, -E2BIG if *offset* + *len* exceeds the length | ||
| 5231 | * of *src*'s data, -EINVAL if *src* is an invalid dynptr. | ||
| 5232 | * | ||
| 5233 | * long bpf_dynptr_write(struct bpf_dynptr *dst, u32 offset, void *src, u32 len) | ||
| 5234 | * Description | ||
| 5235 | * Write *len* bytes from *src* into *dst*, starting from *offset* | ||
| 5236 | * into *dst*. | ||
| 5237 | * Return | ||
| 5238 | * 0 on success, -E2BIG if *offset* + *len* exceeds the length | ||
| 5239 | * of *dst*'s data, -EINVAL if *dst* is an invalid dynptr or if *dst* | ||
| 5240 | * is a read-only dynptr. | ||
| 5224 | */ | 5241 | */ |
| 5225 | #define __BPF_FUNC_MAPPER(FN) \ | 5242 | #define __BPF_FUNC_MAPPER(FN) \ |
| 5226 | FN(unspec), \ | 5243 | FN(unspec), \ |
| @@ -5424,6 +5441,8 @@ union bpf_attr { · 197 unmodified lines | |||
| 5424 | FN(ringbuf_reserve_dynptr), \ | 5441 | FN(ringbuf_reserve_dynptr), \ |
| 5425 | FN(ringbuf_submit_dynptr), \ | 5442 | FN(ringbuf_submit_dynptr), \ |
| 5426 | FN(ringbuf_discard_dynptr), \ | 5443 | FN(ringbuf_discard_dynptr), \ |
| 5444 | FN(dynptr_read), \ | ||
| 5445 | FN(dynptr_write), \ | ||
| 5427 | /* */ | 5446 | /* */ |
| 5428 | 5447 | ||
| 5429 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper | 5448 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |