Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: vladimir.oltean@nxp.com
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, claudiu.manoil@nxp.com, wei.fang@nxp.com,
	xiaoning.wang@nxp.com, ioana.ciornei@nxp.com,
	willemdebruijn.kernel@gmail.com, imx@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 net 1/4] net: enetc: let core segment GSO skb when TSO would not fit the TX ring
Date: Mon, 23 Nov 2026 00:28:52 +0000	[thread overview]
Message-ID: <179539373276.3135.4544992671951430926@kernel.org> (raw)
In-Reply-To: <20261118235055.1225115-2-vladimir.oltean@nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] enetc_features_check()
  (drivers/net/ethernet/freescale/enetc/enetc.c:1106-1122) decides…

--

net: enetc: let core segment GSO skb when TSO would not fit the TX ring

This patch adds an ndo_features_check() to enetc. For skbs that take the
software TSO path, it clears the GSO features when the descriptor estimate
is at least the TX ring size, so the core segments those skbs before
ndo_start_xmit(). The goal is to stop the TX queue from stalling on skbs
that could never fit in the ring.

> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index c6571b5cc8425..1606ac57016f3 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c

[ ... ]

> @@ -1098,6 +1103,24 @@ netdev_tx_t enetc_xmit(struct sk_buff *skb, struct net_device *ndev)
>  }
>  EXPORT_SYMBOL_GPL(enetc_xmit);
>  
> +netdev_features_t enetc_features_check(struct sk_buff *skb,
> +				       struct net_device *ndev,
> +				       netdev_features_t features)
> +{
> +	struct enetc_ndev_priv *priv = netdev_priv(ndev);
> +
> +	features = vlan_features_check(skb, features);
> +
> +	if (!skb_is_gso(skb) || enetc_skb_uses_lso(priv, skb))
> +		return features;
> +
> +	if (tso_count_descs(skb) >= priv->tx_bd_count)
> +		features &= ~NETIF_F_GSO_MASK;

[Severity: High]
Can SKB_GSO_DODGY skbs get past this check, given that their gso_segs is
still 0 when enetc_features_check() runs?

tso_count_descs() is computed from skb_shinfo(skb)->gso_segs.
virtio_net_hdr_to_skb() clears that field for untrusted skbs, for example
those sent by af_packet with PACKET_VNET_HDR:

include/linux/virtio_net.h:virtio_net_hdr_to_skb() {
    ...
			shinfo->gso_type |= SKB_GSO_DODGY;
			shinfo->gso_segs = 0;
    ...
}

With PACKET_QDISC_BYPASS, nothing recomputes gso_segs before the features
check. qdisc_pkt_len_segs_init() is only called from __dev_queue_xmit():

packet_xmit()
  dev_direct_xmit()
    __dev_direct_xmit()
      validate_xmit_skb_list()
        validate_xmit_skb()
          enetc_features_check()   <- gso_segs == 0, GSO features kept

The estimate is therefore just nr_frags, and NETIF_F_GSO_MASK stays set.
enetc does not advertise NETIF_F_GSO_ROBUST, so the skb goes through
__skb_gso_segment(), and tcp_gso_segment() takes this branch:

net/ipv4/tcp_offload.c:tcp_gso_segment() {
    ...
	if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) {
		/* Packet is from an untrusted source, reset gso_segs. */

		skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss);
    ...
}

This returns NULL, so the original unsegmented skb is passed on, now with
its real gso_segs. With gso_size as small as 8 and a ~64KB payload, that
is roughly 8000 segments, or about 16000 BDs for a 2048-entry ring.

enetc_bd_unused() is at most bd_count - 1, so this check in
enetc_start_xmit() can never become false:

		} else {
			if (enetc_bd_unused(tx_ring) < tso_count_descs(skb)) {
				netif_stop_subqueue(ndev, tx_ring->index);
				return NETDEV_TX_BUSY;
			}

dev_direct_xmit() frees the skb, but the subqueue stays stopped. The only
place that wakes it is enetc_clean_tx_ring(), and that needs completed
frames:

	if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) &&
		     __netif_subqueue_stopped(ndev, tx_ring->index) &&
		     ...
		netif_wake_subqueue(ndev, tx_ring->index);

If the ring is idle when this happens, and with no ndo_tx_timeout, does
that TX queue stay stopped until the interface is bounced? That would be
the same stall the commit message describes as triggerable "from any
source that can craft gso_segs".

A tc egress BPF program can probably reach the same state as well.
bpf_skb_adjust_room() and similar helpers set gso_segs = 0 together with
SKB_GSO_DODGY, and sch_handle_egress() runs after
qdisc_pkt_len_segs_init().

The af_packet UDP_L4 case does not seem to trigger this, because
virtio_net_hdr_to_skb() caps it at UDP_MAX_SEGMENTS. The TCP case does
trigger it.

Later patches in the series do not appear to change this. At the end of
the series, enetc_features_check() still goes through
enetc_tso_count_descs(), which reads skb_shinfo(skb)->gso_segs.

Would it work to derive the segment count from skb->len, the header length
and gso_size here, at least for SKB_GSO_DODGY skbs? Another option would be
for enetc_start_xmit() to drop, instead of returning NETDEV_TX_BUSY for,
any skb whose estimate is >= tx_ring->bd_count.

> +
> +	return features;
> +}
> +EXPORT_SYMBOL_GPL(enetc_features_check);

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118235055.1225115-1-vladimir.oltean%40nxp.com

  reply	other threads:[~2026-11-23  0:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 23:50 [PATCH v2 net 0/4] ENETC GSO fixes Vladimir Oltean
2026-11-18 23:50 ` [PATCH v2 net 1/4] net: enetc: let core segment GSO skb when TSO would not fit the TX ring Vladimir Oltean
2026-11-23  0:28   ` netdev-bot+sashiko [this message]
2026-11-18 23:50 ` [PATCH v2 net 2/4] net: enetc: reserve VLAN extension BDs for software TSO Vladimir Oltean
2026-11-23  0:28   ` netdev-bot+sashiko
2026-11-18 23:50 ` [PATCH v2 net 3/4] net: enetc: fall back to software TX csum for too long L3 headers Vladimir Oltean
2026-11-23  0:28   ` netdev-bot+sashiko
2026-11-18 23:50 ` [PATCH v2 net 4/4] net: enetc: let core segment GSO skb when headers exceed TSO_HEADER_SIZE Vladimir Oltean
2026-11-19  0:03   ` Eric Dumazet
2026-11-19  8:44     ` Vladimir Oltean
2026-11-19  9:38       ` Eric Dumazet
2026-11-19  9:43         ` Vladimir Oltean
2026-11-23  0:28   ` netdev-bot+sashiko
2026-11-19  9:42 ` [PATCH v2 net 0/4] ENETC GSO fixes Eric Dumazet

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=179539373276.3135.4544992671951430926@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=ioana.ciornei@nxp.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=wei.fang@nxp.com \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=xiaoning.wang@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