BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: vladimir.oltean@nxp.com
Cc: bpf@vger.kernel.org, Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v3 net 5/7] net: enetc: pad short XDP frames coming from devmap
Date: Wed, 16 Sep 2026 22:28:05 +0000	[thread overview]
Message-ID: <20260916222805.9CCBB1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260915222735.1016937-6-vladimir.oltean@nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] net: double counting of dropped XDP frames
--

commit eb0b831b4274ed0cdbc903bad8f5a21c4a5499be
Author: Vladimir Oltean <vladimir.oltean@nxp.com>

net: enetc: pad short XDP frames coming from devmap

This patch adds length checks and padding for short XDP frames transmitted
through enetc_xdp_xmit(). It introduces xdp_frame_pad() to pad frames to
the minimum Ethernet size and drops frames that cannot be expanded.

> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index bbad942041f5a..8a9ba168eab1e 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> @@ -1838,15 +1838,23 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames,
>  	prefetchw(ENETC_TXBD(*tx_ring, tx_ring->next_to_use));
>  
>  	for (k = 0; k < num_frames; k++) {
[ ... ]
> +		if (unlikely(xdp_frame_pad(xdpf) ||
> +			     xdpf->len < ENETC_MIN_BUFF_SIZE)) {
> +			tx_ring->stats.xdp_tx_drops++;
> +			break;
> +		}
> +
>  		xdp_tx_bd_cnt = enetc_xdp_frame_to_xdp_tx_swbd(tx_ring,

[Severity: Medium]
Will this cause the dropped frame at index k to be counted twice?

When xdp_frame_pad() fails or the length is still below ENETC_MIN_BUFF_SIZE,
the drop counter is explicitly incremented before breaking out of the loop
in enetc_xdp_xmit().

However, looking at the end of enetc_xdp_xmit(), the function 
unconditionally evaluates the remainder of the frames:

    tx_ring->stats.xdp_tx += k;
    tx_ring->stats.xdp_tx_drops += num_frames - k;

Since k is the index of the frame that just failed, num_frames - k includes
this same frame again. As a result, the frame at index k appears to be
counted once inside the loop, and a second time at the end of the function.

Could we simply break out of the loop here and let the end of the function
handle adding it to the drop count, similar to how it handles the other
failure paths?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260915222735.1016937-1-vladimir.oltean@nxp.com?part=5

  reply	other threads:[~2026-09-16 22:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 22:27 [PATCH v3 net 0/7] Fix short frame transmission in enetc vladimir.oltean
2026-09-15 22:27 ` [PATCH v3 net 1/7] net: enetc: consistenly track dropped frames in enetc_xdp_xmit() vladimir.oltean
2026-09-16  2:16   ` Wei Fang
2026-09-18 10:27     ` Vladimir Oltean
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-15 22:27 ` [PATCH v3 net 2/7] net: enetc: ensure enetc_xdp_xmit() calls enetc_update_tx_ring_tail() vladimir.oltean
2026-09-16  2:20   ` Wei Fang
2026-09-16 22:28   ` sashiko-bot
2026-09-18 23:05     ` Vladimir Oltean
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-15 22:27 ` [PATCH v3 net 3/7] net: enetc: fix bogus TX ring consumer index after reinitialization vladimir.oltean
2026-09-15 22:27 ` [PATCH v3 net 4/7] net: enetc: pad short frames in software vladimir.oltean
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-17 10:11   ` David Laight
2026-09-21 11:29     ` Vladimir Oltean
2026-09-15 22:27 ` [PATCH v3 net 5/7] net: enetc: pad short XDP frames coming from devmap vladimir.oltean
2026-09-16 22:28   ` sashiko-bot [this message]
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-15 22:27 ` [PATCH v3 net 6/7] net: enetc: linearize PTP event packets with one-step TX timestamping vladimir.oltean
2026-09-16  1:59   ` Wei Fang
2026-09-16  9:50     ` Vladimir Oltean
2026-09-16 22:28   ` sashiko-bot
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-15 22:27 ` [PATCH v3 net 7/7] net: enetc: drain and cancel one-step TX tstamp queue when going down vladimir.oltean
2026-09-16 23:36   ` netdev-bot+sashiko

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=20260916222805.9CCBB1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vladimir.oltean@nxp.com \
    /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