]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Clarify the meaning of BPF_F_PSEUDO_HDR
authorPaul Chaignon <paul.chaignon@gmail.com>
Tue, 8 Apr 2025 09:00:51 +0000 (11:00 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 10 Apr 2025 03:07:31 +0000 (20:07 -0700)
In the bpf_l4_csum_replace helper, the BPF_F_PSEUDO_HDR flag should only
be set if the modified header field is part of the pseudo-header.

If you modify for example the UDP ports and pass BPF_F_PSEUDO_HDR,
inet_proto_csum_replace4 will update skb->csum even though it shouldn't
(the port and the UDP checksum updates null each other).

Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Link: https://lore.kernel.org/r/5126ef84ba75425b689482cbc98bffe75e5d8ab0.1744102490.git.paul.chaignon@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/uapi/linux/bpf.h
tools/include/uapi/linux/bpf.h

index 14ef3db844fa75b7ecabb654975f4d6b6c616c52..71d5ac83cf5da220aadf339decd2052c18f3195e 100644 (file)
@@ -2055,7 +2055,7 @@ union bpf_attr {
  *             untouched (unless **BPF_F_MARK_ENFORCE** is added as well), and
  *             for updates resulting in a null checksum the value is set to
  *             **CSUM_MANGLED_0** instead. Flag **BPF_F_PSEUDO_HDR** indicates
- *             the checksum is to be computed against a pseudo-header.
+ *             that the modified header field is part of the pseudo-header.
  *
  *             This helper works in combination with **bpf_csum_diff**\ (),
  *             which does not update the checksum in-place, but offers more
index 14ef3db844fa75b7ecabb654975f4d6b6c616c52..71d5ac83cf5da220aadf339decd2052c18f3195e 100644 (file)
@@ -2055,7 +2055,7 @@ union bpf_attr {
  *             untouched (unless **BPF_F_MARK_ENFORCE** is added as well), and
  *             for updates resulting in a null checksum the value is set to
  *             **CSUM_MANGLED_0** instead. Flag **BPF_F_PSEUDO_HDR** indicates
- *             the checksum is to be computed against a pseudo-header.
+ *             that the modified header field is part of the pseudo-header.
  *
  *             This helper works in combination with **bpf_csum_diff**\ (),
  *             which does not update the checksum in-place, but offers more