From: sashiko-bot@kernel.org
To: "Vladimir Vdovin" <deliran@verdict.gg>
Cc: bpf@vger.kernel.org
Subject: Re: [RFC PATCH bpf-next v1 1/7] xdp: let XDP programs assert the RX checksum over redirect
Date: Tue, 30 Jun 2026 19:31:07 +0000 [thread overview]
Message-ID: <20260630193108.32CC21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260630191510.81402-2-deliran@verdict.gg>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The XDP_FLAGS_RX_CSUM_UNNECESSARY flag is lost when an AF_XDP zero-copy buffer is converted to an xdp_frame during XDP_REDIRECT.
--
commit ba787c7855bcf7d5c0ecdc2fe7e6a11cde6a4c00
Author: Vladimir Vdovin <deliran@verdict.gg>
xdp: let XDP programs assert the RX checksum over redirect
This patch adds a non-dev-bound kfunc, bpf_xdp_assert_rx_csum(), allowing XDP
programs to assert that an L4 checksum is correct. It sets a new flag on the
buffer, XDP_FLAGS_RX_CSUM_UNNECESSARY, which is translated to
CHECKSUM_UNNECESSARY when an skb is built out of the frame.
> diff --git a/net/core/xdp.c b/net/core/xdp.c
> index 9890a30584ba7..63ee36ec93de2 100644
> --- a/net/core/xdp.c
> +++ b/net/core/xdp.c
[ ... ]
> @@ -961,6 +964,31 @@ __bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
> return -EOPNOTSUPP;
> }
>
> +/**
> + * bpf_xdp_assert_rx_csum - Assert the packet's L4 checksum is correct.
> + * @ctx: XDP context pointer.
> + *
> + * Mark the frame so that an skb later built out of it (e.g. on the cpumap
> + * redirect path, see __xdp_build_skb_from_frame()) is set to
> + * CHECKSUM_UNNECESSARY instead of being validated in software when it enters
> + * the stack.
> + *
> + * This is an assertion made by the XDP program: the kernel cannot verify it.
> + * The program takes responsibility for the checksum being correct, the same
> + * way it is already trusted to rewrite arbitrary packet contents. If the
> + * program modifies L4 data after calling this kfunc the assertion may no
> + * longer hold.
> + *
> + * Return: 0.
> + */
> +__bpf_kfunc int bpf_xdp_assert_rx_csum(struct xdp_md *ctx)
> +{
> + struct xdp_buff *xdp = (struct xdp_buff *)ctx;
> +
> + xdp->flags |= XDP_FLAGS_RX_CSUM_UNNECESSARY;
[Severity: Medium]
Does this flag get lost when an AF_XDP zero-copy buffer is redirected?
Looking at xdp_convert_zc_to_xdp_frame() in net/core/xdp.c, it initializes
the new frame with memset() but does not copy the flags from the original
xdp_buff:
net/core/xdp.c:xdp_convert_zc_to_xdp_frame() {
...
memset(xdpf, 0, sizeof(*xdpf));
...
xdpf->frame_sz = PAGE_SIZE;
xdpf->mem_type = MEM_TYPE_PAGE_ORDER0;
xsk_buff_free(xdp);
return xdpf;
}
Should xdp_convert_zc_to_xdp_frame() be updated to copy xdp->flags to
xdpf->flags so the RX checksum assertion survives redirect for zero-copy
frames?
> + return 0;
> +}
> +
> __bpf_kfunc_end_defs();
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630191510.81402-1-deliran@verdict.gg?part=1
next prev parent reply other threads:[~2026-06-30 19:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 19:15 [RFC PATCH bpf-next v1 0/7] xdp: RX checksum metadata hint and checksum assertion over redirect Vladimir Vdovin
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 1/7] xdp: let XDP programs assert the RX checksum " Vladimir Vdovin
2026-06-30 19:31 ` sashiko-bot [this message]
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 2/7] selftests/bpf: add test for bpf_xdp_assert_rx_csum over cpumap Vladimir Vdovin
2026-06-30 19:27 ` sashiko-bot
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 3/7] xdp: add bpf_xdp_metadata_rx_csum() RX metadata kfunc Vladimir Vdovin
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 4/7] net/mlx5e: support the rx_csum XDP metadata hint Vladimir Vdovin
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 5/7] ice: " Vladimir Vdovin
2026-06-30 19:27 ` sashiko-bot
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 6/7] veth: " Vladimir Vdovin
2026-06-30 19:27 ` sashiko-bot
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 7/7] selftests/bpf: cover bpf_xdp_metadata_rx_csum in xdp_metadata Vladimir Vdovin
2026-06-30 19:27 ` sashiko-bot
2026-06-30 21:18 ` [RFC PATCH bpf-next v1 0/7] xdp: RX checksum metadata hint and checksum assertion over redirect Stanislav Fomichev
2026-06-30 22:16 ` Lorenzo Bianconi
2026-07-01 17:10 ` Vladimir Vdovin
2026-07-02 14:52 ` Lorenzo Bianconi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260630193108.32CC21F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=deliran@verdict.gg \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox