diff options
author | Alexei Starovoitov <ast@plumgrid.com> | 2015-04-01 17:12:13 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-04-06 16:42:35 -0400 |
commit | 91bc4822c3d61b9bb7ef66d3b77948a4f9177954 (patch) | |
tree | ca92a811b501957c1e876290d305aaf81c8d9aff /samples/bpf/bpf_helpers.h | |
parent | 5888b93b750609680735d6b8b737703083ef40ff (diff) | |
download | linux-91bc4822c3d61b9bb7ef66d3b77948a4f9177954.tar.gz linux-91bc4822c3d61b9bb7ef66d3b77948a4f9177954.tar.bz2 linux-91bc4822c3d61b9bb7ef66d3b77948a4f9177954.zip |
tc: bpf: add checksum helpers
Commit 608cd71a9c7c ("tc: bpf: generalize pedit action") has added the
possibility to mangle packet data to BPF programs in the tc pipeline.
This patch adds two helpers bpf_l3_csum_replace() and bpf_l4_csum_replace()
for fixing up the protocol checksums after the packet mangling.
It also adds 'flags' argument to bpf_skb_store_bytes() helper to avoid
unnecessary checksum recomputations when BPF programs adjusting l3/l4
checksums and documents all three helpers in uapi header.
Moreover, a sample program is added to show how BPF programs can make use
of the mangle and csum helpers.
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples/bpf/bpf_helpers.h')
-rw-r--r-- | samples/bpf/bpf_helpers.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/samples/bpf/bpf_helpers.h b/samples/bpf/bpf_helpers.h index ca0333146006..72540ec1f003 100644 --- a/samples/bpf/bpf_helpers.h +++ b/samples/bpf/bpf_helpers.h @@ -37,4 +37,11 @@ struct bpf_map_def { unsigned int max_entries; }; +static int (*bpf_skb_store_bytes)(void *ctx, int off, void *from, int len, int flags) = + (void *) BPF_FUNC_skb_store_bytes; +static int (*bpf_l3_csum_replace)(void *ctx, int off, int from, int to, int flags) = + (void *) BPF_FUNC_l3_csum_replace; +static int (*bpf_l4_csum_replace)(void *ctx, int off, int from, int to, int flags) = + (void *) BPF_FUNC_l4_csum_replace; + #endif |