]> git.baikalelectronics.ru Git - kernel.git/commit
tc: bpf: add checksum helpers
authorAlexei Starovoitov <ast@plumgrid.com>
Thu, 2 Apr 2015 00:12:13 +0000 (17:12 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Apr 2015 20:42:35 +0000 (16:42 -0400)
commitc4ba484ac7022648931b863bbbf81c0b2cff9794
treeca92a811b501957c1e876290d305aaf81c8d9aff
parentf6fad64a02d686142502f23026633c009350e08b
tc: bpf: add checksum helpers

Commit be7d132cd57e ("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>
include/uapi/linux/bpf.h
net/core/filter.c
samples/bpf/Makefile
samples/bpf/bpf_helpers.h
samples/bpf/tcbpf1_kern.c [new file with mode: 0644]