BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vladimir Vdovin" <deliran@verdict.gg>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 2/6] net: veth: Add xmo_rx_checksum callback to veth driver
Date: Wed, 08 Jul 2026 20:54:31 +0000	[thread overview]
Message-ID: <20260708205432.448C11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708203410.45121-3-deliran@verdict.gg>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The XDP CHECKSUM_COMPLETE value returned by veth_xdp_rx_checksum lacks the MAC header contribution, causing XDP programs to compute incorrect checksums.
- [High] veth_xdp_rx_checksum incorrectly maps CHECKSUM_PARTIAL to XDP_CHECKSUM_NONE, causing XDP programs to drop valid locally generated traffic.
--

--- Patch [2]: [PATCH bpf-next v4 2/6] net: veth: Add xmo_rx_checksum callback to veth driver ---
commit 5a562d33c7a2a6e1ab983df15c58e768727ee475
Author: Lorenzo Bianconi <lorenzo@kernel.org>
Date:   Wed Jul 8 20:34:06 2026 +0000

    net: veth: Add xmo_rx_checksum callback to veth driver
    
    Implement xmo_rx_checksum callback in veth driver to report RX checksum
    result to the eBPF program bounded to the veth device.

> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index 1c51421491753..498d894d043da 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c

[ ... ]

> +static int veth_xdp_rx_checksum(const struct xdp_md *ctx,
> +				enum xdp_checksum *ip_summed,
> +				u32 *cksum, u8 *cksum_level)
> +{
> +	const struct veth_xdp_buff *_ctx = (void *)ctx;
> +	const struct sk_buff *skb = _ctx->skb;
> +
> +	if (!skb)
> +		return -ENODATA;
> +
> +	switch (skb->ip_summed) {
> +	case CHECKSUM_COMPLETE:
> +		*ip_summed = XDP_CHECKSUM_COMPLETE;
> +		*cksum = skb->csum;

[Severity: High]
Does this return a checksum that is out of sync with the packet data exposed
to the XDP program?

When the packet enters veth_xdp_rcv_skb(), the MAC header is pushed back
into the packet data so it is visible to the XDP program:

drivers/net/veth.c:veth_xdp_rcv_skb() {
    ...
    __skb_push(skb, skb->data - skb_mac_header(skb));
    ...
}

However, it doesn't look like skb_postpush_rcsum() is called to update the
checksum. Since the earlier eth_type_trans() subtracted the MAC header from
skb->csum, returning skb->csum here means the XDP program will receive a
checksum that lacks the MAC header contribution, which might lead to a
checksum mismatch when the program validates the packet.

> +		*cksum_level = 0;
> +		break;
> +	case CHECKSUM_UNNECESSARY:
> +		*ip_summed = XDP_CHECKSUM_UNNECESSARY;
> +		*cksum_level = skb->csum_level;
> +		*cksum = 0;
> +		break;
> +	default:

[Severity: High]
Will CHECKSUM_PARTIAL fall through to this default case and be reported as
XDP_CHECKSUM_NONE?

Locally generated traffic transmitted through a veth device defaults to
skb->ip_summed == CHECKSUM_PARTIAL because veth advertises NETIF_F_HW_CSUM.

If this falls through to XDP_CHECKSUM_NONE, strict XDP firewalls might try
to manually validate the checksum. Since the payload checksum hasn't been
populated by hardware yet, the validation will fail and valid local
traffic will be incorrectly dropped. Should this explicitly handle
CHECKSUM_PARTIAL?

> +		*ip_summed = XDP_CHECKSUM_NONE;
> +		*cksum_level = 0;
> +		*cksum = 0;
> +		break;
> +	}
> +
> +	return 0;
> +}

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260708203410.45121-1-deliran@verdict.gg?part=2

  reply	other threads:[~2026-07-08 20:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 20:34 [PATCH bpf-next v4 0/6] Add the capability to load HW RX checksum in eBPF programs Vladimir Vdovin
2026-07-08 20:34 ` [PATCH bpf-next v4 1/6] netlink: specs: Add XDP RX checksum capability to XDP metadata specs Vladimir Vdovin
2026-07-08 20:43   ` sashiko-bot
2026-07-10 10:09   ` Loktionov, Aleksandr
2026-07-10 19:05   ` Stanislav Fomichev
2026-07-08 20:34 ` [PATCH bpf-next v4 2/6] net: veth: Add xmo_rx_checksum callback to veth driver Vladimir Vdovin
2026-07-08 20:54   ` sashiko-bot [this message]
2026-07-10 10:09   ` Loktionov, Aleksandr
2026-07-08 20:34 ` [PATCH bpf-next v4 3/6] net: ice: Add xmo_rx_checksum callback Vladimir Vdovin
2026-07-08 20:43   ` sashiko-bot
2026-07-10 10:10   ` Loktionov, Aleksandr
2026-07-08 20:34 ` [PATCH bpf-next v4 4/6] selftests/bpf: Add selftest support for bpf_xdp_metadata_rx_checksum Vladimir Vdovin
2026-07-08 20:34 ` [PATCH bpf-next v4 5/6] selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog Vladimir Vdovin
2026-07-08 20:45   ` sashiko-bot
2026-07-10 10:11   ` Loktionov, Aleksandr
2026-07-08 20:34 ` [PATCH bpf-next v4 6/6] selftests: drv-net: add XDP RX checksum metadata tests Vladimir Vdovin
2026-07-08 20:41   ` sashiko-bot
2026-07-10 10:12   ` Loktionov, Aleksandr

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=20260708205432.448C11F000E9@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