Files
kernel_google_wahoo/include/uapi/linux
Daniel Borkmann 4d8a79bd32 bpf: add generic bpf_csum_diff helper
For L4 checksums, we currently have bpf_l4_csum_replace() helper. It's
currently limited to handle 2 and 4 byte changes in a header and feeds the
from/to into inet_proto_csum_replace{2,4}() helpers of the kernel. When
working with IPv6, for example, this makes it rather cumbersome to deal
with, similarly when editing larger parts of a header.

Instead, extend the API in a more generic way: For bpf_l4_csum_replace(),
add a case for header field mask of 0 to change the checksum at a given
offset through inet_proto_csum_replace_by_diff(), and provide a helper
bpf_csum_diff() that can generically calculate a from/to diff for arbitrary
amounts of data.

This can be used in multiple ways: for the bpf_l4_csum_replace() only
part, this even provides us with the option to insert precalculated diffs
from user space f.e. from a map, or from bpf_csum_diff() during runtime.

bpf_csum_diff() has a optional from/to stack buffer input, so we can
calculate a diff by using a scratchbuffer for scenarios where we're
inserting (from is NULL), removing (to is NULL) or diffing (from/to buffers
don't need to be of equal size) data. Also, bpf_csum_diff() allows to
feed a previous csum into csum_partial(), so the function can also be
cascaded.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
2022-03-04 20:16:32 +01:00
..
2015-10-13 17:42:34 +02:00
2016-03-22 11:04:51 -07:00
2015-10-05 03:16:46 -07:00
2017-12-05 11:22:51 +01:00
2022-03-04 20:16:32 +01:00
2015-08-25 14:41:50 -05:00
2016-03-22 11:10:20 -07:00
2018-04-12 09:58:05 -07:00
2016-03-22 11:07:51 -07:00
2018-04-29 07:50:02 +02:00
2015-08-03 17:30:00 -07:00
2016-04-13 11:12:20 -07:00
2015-07-21 10:39:05 -07:00
2016-03-22 11:08:56 -07:00
2016-03-22 11:07:51 -07:00
2017-05-22 23:19:33 -07:00
2015-08-27 19:44:53 -04:00
2015-07-20 14:58:46 -04:00
2017-05-22 23:19:33 -07:00
2015-09-17 21:09:07 -07:00
2016-03-23 19:57:25 -07:00
2016-03-23 19:57:25 -07:00
2016-08-20 19:04:33 -07:00
2016-03-22 11:09:38 -07:00
2016-04-22 11:57:49 -07:00
2016-03-22 11:04:51 -07:00
2016-03-22 11:04:51 -07:00
2018-02-21 15:40:47 +00:00
2016-03-22 11:08:58 -07:00
2015-05-24 12:49:16 -07:00
2015-06-11 23:37:37 +02:00
2015-10-27 18:55:31 -07:00
2015-12-04 08:38:42 -07:00
2015-10-16 10:44:02 +02:00