diff options
| author | Daniel Borkmann <daniel@iogearbox.net> | 2016-08-17 19:00:39 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2016-08-19 02:38:16 -0400 |
| commit | 5293efe62df81908f2e90c9820c7edcc8e61f5e9 (patch) | |
| tree | 6e3456c7bd339b1ebcfcebae0de6286635d44f33 /include/uapi/linux | |
| parent | 45c7fffaf72e77baab9fd8ff1655540a1d5bac9f (diff) | |
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.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/uapi/linux')
| -rw-r--r-- | include/uapi/linux/bpf.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 866d53c33298..e4c5a1baa993 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h | |||
| @@ -386,6 +386,17 @@ enum bpf_func_id { | |||
| 386 | */ | 386 | */ |
| 387 | BPF_FUNC_current_task_under_cgroup, | 387 | BPF_FUNC_current_task_under_cgroup, |
| 388 | 388 | ||
| 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 | |||
| 389 | __BPF_FUNC_MAX_ID, | 400 | __BPF_FUNC_MAX_ID, |
| 390 | }; | 401 | }; |
| 391 | 402 | ||
