History

bpf: avoid preempt enable/disable in sockmap using tcp_skb_cb region

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.

John Fastabend committed 9 years ago

Commit 34f79501 parent 435bf0d8 files · +36 −30Browse files

Showing the changes to tools/include/uapi/linux (1 of 8 files). Show all

Unified · Split

tools/include/uapi/linux/bpf.h+2−1
@@ -569,9 +569,10 @@ union bpf_attr { · 568 unmodified lines
569569 * @flags: reserved for future use
570570 * Return: 0 on success or negative error code
571571 *
572− * int bpf_sk_redirect_map(map, key, flags)
572+ * int bpf_sk_redirect_map(skb, map, key, flags)
573573 * Redirect skb to a sock in map using key as a lookup key for the
574574 * sock in map.
575+ * @skb: pointer to skb
575576 * @map: pointer to sockmap
576577 * @key: key to lookup sock in map
577578 * @flags: reserved for future use

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