Add xdp dynptrs, which are dynptrs whose underlying pointer points to a xdp_buff. The dynptr acts on xdp data. xdp dynptrs have two main benefits. One is that they allow operations on sizes that are not statically known at compile-time (eg variable-sized accesses). Another is that parsing the packet data through dynptrs (instead of through direct access of xdp->data and xdp->data_end) can be more ergonomic and less brittle (eg does not need manual if checking for being within bounds of data_end). For reads and writes on the dynptr, this includes reading/writing from/to and across fragments. Data slices through the bpf_dynptr_data API are not supported; instead bpf_dynptr_slice() and bpf_dynptr_slice_rdwr() should be used. For examples of how xdp dynptrs can be used, please see the attached selftests.
Showing the changes to include/uapi (1 of 7 files). Show all
Unified · Split
| @@ -5344,7 +5344,7 @@ union bpf_attr { · 5343 unmodified lines | ||
| 5344 | 5344 | * *len* must be a statically known value. The returned data slice |
| 5345 | 5345 | * is invalidated whenever the dynptr is invalidated. |
| 5346 | 5346 | * |
| 5347 | − * skb type dynptrs may not use bpf_dynptr_data. They should | |
| 5347 | + * skb and xdp type dynptrs may not use bpf_dynptr_data. They should | |
| 5348 | 5348 | * instead use bpf_dynptr_slice and bpf_dynptr_slice_rdwr. |
| 5349 | 5349 | * Return |
| 5350 | 5350 | * Pointer to the underlying dynptr data, NULL if the dynptr is |