SK_SKB BPF programs are run from the socket/tcp context but early in the stack before much of the TCP metadata is needed in tcp_skb_cb. So we can use some unused fields to place BPF metadata needed for SK_SKB programs when implementing the redirect function. This allows us to drop the preempt disable logic. It does however require an API change so sk_redirect_map() has been updated to additionally provide ctx_ptr to skb. Note, we do however continue to disable/enable preemption around actual BPF program running to account for map updates.
Showing the changes to tools/include/uapi/linux (1 of 8 files). Show all
Unified · Split
| @@ -569,9 +569,10 @@ union bpf_attr { · 568 unmodified lines | ||
| 569 | 569 | * @flags: reserved for future use |
| 570 | 570 | * Return: 0 on success or negative error code |
| 571 | 571 | * |
| 572 | − * int bpf_sk_redirect_map(map, key, flags) | |
| 572 | + * int bpf_sk_redirect_map(skb, map, key, flags) | |
| 573 | 573 | * Redirect skb to a sock in map using key as a lookup key for the |
| 574 | 574 | * sock in map. |
| 575 | + * @skb: pointer to skb | |
| 575 | 576 | * @map: pointer to sockmap |
| 576 | 577 | * @key: key to lookup sock in map |
| 577 | 578 | * @flags: reserved for future use |