-
Notifications
You must be signed in to change notification settings - Fork 146
Add a dynptr type for skb metadata for TC BPF #9335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: bpf-next_base
Are you sure you want to change the base?
Conversation
Upstream branch: 42be23e |
ffefc6d
to
4ccf98a
Compare
Upstream branch: 42be23e |
967fe32
to
0c7292d
Compare
4ccf98a
to
95edab2
Compare
Upstream branch: 95993dc |
0c7292d
to
e532590
Compare
Upstream branch: 95993dc |
e532590
to
c1327ad
Compare
Upstream branch: 95993dc |
c1327ad
to
f25cebd
Compare
Add a dynptr type, similar to skb dynptr, but for the skb metadata access. The dynptr provides an alternative to __sk_buff->data_meta for accessing the custom metadata area allocated using the bpf_xdp_adjust_meta() helper. More importantly, it abstracts away the fact where the storage for the custom metadata lives, which opens up the way to persist the metadata by relocating it as the skb travels through the network stack layers. A notable difference between the skb and the skb_meta dynptr is that writes to the skb_meta dynptr don't invalidate either skb or skb_meta dynptr slices, since they cannot lead to a skb->head reallocation. skb_meta dynptr ops are stubbed out and implemented by subsequent changes. Only the program types which can access __sk_buff->data_meta today are allowed to create a dynptr for skb metadata at the moment. We need to modify the network stack to persist the metadata across layers before opening up access to other BPF hooks. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Make it possible to read from skb metadata area using the bpf_dynptr_read() BPF helper. This prepares ground for access to skb metadata from all BPF hooks which operate on __sk_buff context. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Make it possible to write to skb metadata area using the bpf_dynptr_write() BPF helper. This prepares ground for access to skb metadata from all BPF hooks which operate on __sk_buff context. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Make it possible to read from or write to skb metadata area using the dynptr slices creates with bpf_dynptr_slice() or bpf_dynptr_slice_rdwr(). This prepares ground for access to skb metadata from all BPF hooks which operate on __sk_buff context. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
dynptr for skb metadata behaves the same way as the dynptr for skb data with one exception - writes to skb_meta dynptr don't invalidate existing skb and skb_meta slices. Duplicate those the skb dynptr tests which we can, since bpf_dynptr_from_skb_meta kfunc can be called only from TC BPF, to cover the skb_meta dynptr verifier checks. Also add a couple of new tests (skb_data_valid_*) to ensure we don't invalidate the slices in the mentioned case, which are specific to skb_meta dynptr. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Prepare for parametrizing the xdp_context tests. The assert_test_result helper doesn't need the whole skeleton. Pass just what it needs. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
We want to add more test cases to cover different ways to access the metadata area. Prepare for it. Pull up the skeleton management. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Exercise reading from SKB metadata area in two new ways: 1. indirectly, with bpf_dynptr_read(), and 2. directly, with bpf_dynptr_slice(). Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Add tests what exercise writes to skb metadata in two ways: 1. indirectly, using bpf_dynptr_write helper, 2. directly, using a read-write dynptr slice. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Exercise r/w access to skb metadata through an offset-adjusted dynptr, read/write helper with an offset argument, and a slice starting at an offset. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Upstream branch: 95993dc |
f25cebd
to
3d45961
Compare
Pull request for series with
subject: Add a dynptr type for skb metadata for TC BPF
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=984288