]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Clarify role of BPF_F_RECOMPUTE_CSUM
authorPaul Chaignon <paul.chaignon@gmail.com>
Tue, 8 Apr 2025 09:00:04 +0000 (11:00 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 10 Apr 2025 03:07:31 +0000 (20:07 -0700)
BPF_F_RECOMPUTE_CSUM doesn't update the actual L3 and L4 checksums in
the packet, but simply updates skb->csum (according to skb->ip_summed).
This patch clarifies that to avoid confusions.

Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Link: https://lore.kernel.org/r/ff6895d42936f03dbb82334d8bcfd50e00c79086.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 07ee73cdf97b90051bc8628e1cc0ddbc346da01f..14ef3db844fa75b7ecabb654975f4d6b6c616c52 100644 (file)
@@ -1995,11 +1995,15 @@ union bpf_attr {
  * long bpf_skb_store_bytes(struct sk_buff *skb, u32 offset, const void *from, u32 len, u64 flags)
  *     Description
  *             Store *len* bytes from address *from* into the packet
- *             associated to *skb*, at *offset*. *flags* are a combination of
- *             **BPF_F_RECOMPUTE_CSUM** (automatically recompute the
- *             checksum for the packet after storing the bytes) and
- *             **BPF_F_INVALIDATE_HASH** (set *skb*\ **->hash**, *skb*\
- *             **->swhash** and *skb*\ **->l4hash** to 0).
+ *             associated to *skb*, at *offset*. The *flags* are a combination
+ *             of the following values:
+ *
+ *             **BPF_F_RECOMPUTE_CSUM**
+ *                     Automatically update *skb*\ **->csum** after storing the
+ *                     bytes.
+ *             **BPF_F_INVALIDATE_HASH**
+ *                     Set *skb*\ **->hash**, *skb*\ **->swhash** and *skb*\
+ *                     **->l4hash** to 0.
  *
  *             A call to this helper is susceptible to change the underlying
  *             packet buffer. Therefore, at load time, all checks on pointers
index 07ee73cdf97b90051bc8628e1cc0ddbc346da01f..14ef3db844fa75b7ecabb654975f4d6b6c616c52 100644 (file)
@@ -1995,11 +1995,15 @@ union bpf_attr {
  * long bpf_skb_store_bytes(struct sk_buff *skb, u32 offset, const void *from, u32 len, u64 flags)
  *     Description
  *             Store *len* bytes from address *from* into the packet
- *             associated to *skb*, at *offset*. *flags* are a combination of
- *             **BPF_F_RECOMPUTE_CSUM** (automatically recompute the
- *             checksum for the packet after storing the bytes) and
- *             **BPF_F_INVALIDATE_HASH** (set *skb*\ **->hash**, *skb*\
- *             **->swhash** and *skb*\ **->l4hash** to 0).
+ *             associated to *skb*, at *offset*. The *flags* are a combination
+ *             of the following values:
+ *
+ *             **BPF_F_RECOMPUTE_CSUM**
+ *                     Automatically update *skb*\ **->csum** after storing the
+ *                     bytes.
+ *             **BPF_F_INVALIDATE_HASH**
+ *                     Set *skb*\ **->hash**, *skb*\ **->swhash** and *skb*\
+ *                     **->l4hash** to 0.
  *
  *             A call to this helper is susceptible to change the underlying
  *             packet buffer. Therefore, at load time, all checks on pointers