]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: allow bpf_csum_diff to feed bpf_l3_csum_replace as well
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 4 Mar 2016 14:15:02 +0000 (15:15 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 8 Mar 2016 18:55:15 +0000 (13:55 -0500)
commit24f5d381e8724c3c887782bc510787c2cc1b1d93
tree2fd53b4ddbff894e5bb3db8ce8e3f952b79cc77d
parent5a879801ea5e95414cc00746e1f15b46758cd894
bpf: allow bpf_csum_diff to feed bpf_l3_csum_replace as well

Commit 639005963148 ("bpf: add generic bpf_csum_diff helper") added a
generic checksum diff helper that can feed bpf_l4_csum_replace() with
a target __wsum diff that is to be applied to the L4 checksum. This
facility is very flexible, can be cascaded, allows for adding, removing,
or diffing data, or for calculating the pseudo header checksum from
scratch, but it can also be reused for working with the IPv4 header
checksum.

Thus, analogous to bpf_l4_csum_replace(), add a case for header field
value of 0 to change the checksum at a given offset through a new helper
csum_replace_by_diff(). Also, in addition to that, this provides an
easy to use interface for feeding precalculated diffs f.e. coming from
a map. It nicely complements bpf_l3_csum_replace() that currently allows
only for csum updates of 2 and 4 byte diffs.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/checksum.h
net/core/filter.c