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 3/6] net: ice: Add xmo_rx_checksum callback
Date: Wed, 08 Jul 2026 20:43:00 +0000	[thread overview]
Message-ID: <20260708204300.F267C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708203410.45121-4-deliran@verdict.gg>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The XDP metadata getter `ice_xdp_rx_checksum` calls `ice_get_rx_csum`, which increments hardware statistics (`hw_csum_rx_error` and `hw_rx_eipe_error`). This violates the expectation that BPF metadata getters are stateless/idempotent, allowing an eBPF program to arbitrarily inflate these statistics by repeatedly querying the checksum, and causes double-counting when `XDP_PASS` is used.
--

--- Patch [3]: [PATCH bpf-next v4 3/6] net: ice: Add xmo_rx_checksum callback ---
commit 7b93052dd91e42401898b8ce9ae946cf9d0f21ec
Author: Lorenzo Bianconi <lorenzo@kernel.org>

net: ice: Add xmo_rx_checksum callback

This patch implements the xmo_rx_checksum callback in the ice driver to
report RX checksum results to eBPF programs. It introduces the
ice_get_rx_csum utility routine to make the checksum code reusable from
ice_rx_csum().

> diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> index e695a664e53d1..3aa82ff03d9e2 100644
> --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c

[ ... ]

> +static void
> +ice_get_rx_csum(const union ice_32b_rx_flex_desc *rx_desc, u16 ptype,
> +		struct ice_rx_ring *ring, enum xdp_checksum *ip_summed,
> +		u32 *cksum, u8 *cksum_level)
>  {

[ ... ]

>  	if (ipv4 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S)))) {
>  		ring->vsi->back->hw_rx_eipe_error++;
> -		return;
> +		goto checksum_none;
>  	}

[ ... ]

>  checksum_fail:
>  	ring->vsi->back->hw_csum_rx_error++;
> +checksum_none:
> +	*ip_summed = XDP_CHECKSUM_NONE;
> +	*cksum_level = 0;
> +	*cksum = 0;
> +}

[ ... ]

> +static int ice_xdp_rx_checksum(const struct xdp_md *ctx,
> +			       enum xdp_checksum *ip_summed,
> +			       u32 *cksum, u8 *cksum_level)
> +{
> +	const struct libeth_xdp_buff *xdp_ext = (void *)ctx;
> +	const union ice_32b_rx_flex_desc *rx_desc = xdp_ext->desc;
> +	struct ice_rx_ring *ring;
> +
> +	ring = libeth_xdp_buff_to_rq(xdp_ext, typeof(*ring), xdp_rxq);
> +	ice_get_rx_csum(rx_desc, ice_get_ptype(rx_desc), ring, ip_summed,
> +			cksum, cksum_level);

[Severity: Medium]
Will this lead to inflated hardware error statistics?

The XDP metadata getter ice_xdp_rx_checksum() calls ice_get_rx_csum(), which
increments hardware statistics like hw_csum_rx_error and hw_rx_eipe_error when
a checksum error is detected.

Since XDP metadata getters can be queried multiple times by an eBPF program,
could this cause the statistics to be incremented multiple times for a single
packet?

Additionally, if the program returns XDP_PASS, the normal SKB receive path
will call ice_rx_csum(), which again calls ice_get_rx_csum(). Does this lead
to double-counting the errors for the same packet? 

Could the statistics increments be decoupled from the metadata getter?

> +
> +	return 0;
> +}

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

  reply	other threads:[~2026-07-08 20:43 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
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 [this message]
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=20260708204300.F267C1F000E9@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