History

bpf: add bpf_skb_change_tail helper

This work adds a bpf_skb_change_tail() helper for tc BPF programs. The basic idea is to expand or shrink the skb in a controlled manner. The eBPF program can then rewrite the rest via helpers like bpf_skb_store_bytes(), bpf_lX_csum_replace() and others rather than passing a raw buffer for writing here. bpf_skb_change_tail() is really a slow path helper and intended for replies with f.e. ICMP control messages. Concept is similar to other helpers like bpf_skb_change_proto() helper to keep the helper without protocol specifics and let the BPF program mangle the remaining parts. A flags field has been added and is reserved for now should we extend the helper in future.

Daniel Borkmann committed 10 years ago

Commit 5293efe1 parent 45c7fff3 files · +150 −4Browse files

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

Unified · Split

include/uapi/linux/bpf.h+11−0
@@ -386,6 +386,17 @@ enum bpf_func_id { · 385 unmodified lines
386386 */
387387 BPF_FUNC_current_task_under_cgroup,
388388
389+ /**
390+ * bpf_skb_change_tail(skb, len, flags)
391+ * The helper will resize the skb to the given new size,
392+ * to be used f.e. with control messages.
393+ * @skb: pointer to skb
394+ * @len: new skb length
395+ * @flags: reserved
396+ * Return: 0 on success or negative error
397+ */
398+ BPF_FUNC_skb_change_tail,
399+
389400 __BPF_FUNC_MAX_ID,
390401 };
391402

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