History

bpf: Add xdp dynptrs

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.

Joanne Koong committed 3 years ago

Commit 05421ae1 parent b5964b97 files · +76 −6Browse files

Showing the changes to include/uapi (1 of 7 files). Show all

Unified · Split

include/uapi/linux/bpf.h+1−1
@@ -5344,7 +5344,7 @@ union bpf_attr { · 5343 unmodified lines
5344 * *len* must be a statically known value. The returned data slice5344 * *len* must be a statically known value. The returned data slice
5345 * is invalidated whenever the dynptr is invalidated.5345 * is invalidated whenever the dynptr is invalidated.
5346 *5346 *
5347 * skb type dynptrs may not use bpf_dynptr_data. They should5347 * skb and xdp type dynptrs may not use bpf_dynptr_data. They should
5348 * instead use bpf_dynptr_slice and bpf_dynptr_slice_rdwr.5348 * instead use bpf_dynptr_slice and bpf_dynptr_slice_rdwr.
5349 * Return5349 * Return
5350 * Pointer to the underlying dynptr data, NULL if the dynptr is5350 * Pointer to the underlying dynptr data, NULL if the dynptr is

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t