🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20582

Re: [PATCH v2 net 1/4] net: enetc: let core segment GSO skb when TSO would not fit the TX ring

#20582
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 00:28
142 lines
13098 bytes
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
Technical Details
Message-ID: <179539373276.3135.4544992671951430926@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368883-linux-kernel-netdev=dewy.ru
References: <20261118235055.1225115-2-vladimir.oltean@nxp.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368883-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179539373276.3135.4544992671951430926@kernel.org>
References: <20261118235055.1225115-2-vladimir.oltean@nxp.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3753404"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:6imLtZ8VBc4LiX0ocL3LAGX8U+o= sha256:BSB24Q6wQi6Et9H6iVrjTGbHsldo6XLKPn1Fo0r7a68=
	sha1:rxZ87mYYmSopPmpVJlDoDpehah4= sha256:FKbgQaQtAdzPO/bQ7zsRT0bs+T3Veyv4vtUroHypaPw=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 338DD125D5D; Mon, 23 Nov 2026 03:29:16 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id TA55zcGd5I3w;
	Mon, 23 Nov 2026 03:29:11 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368883-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id A1DEF125D89; Mon, 23 Nov 2026 03:29:03 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 077CB28372; Mon, 23 Nov 2026 00:29:01 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795393735;
	b=Z3xCN/+MT6ntzrI9HfPcEXFU5jYYccyCrjhsgtd24i1o3Ht7dIlMUp/4KobpFX9D2nZv
	 p7QvbeoiK9b9B35aRCzeW0GnmzJfKSvHe53mIJCafQOOFr80a4fnj07q3SUMSFqtyRT6Z
	 Bj7T5LEVCgAbUmIWMzEKhbFXVlkZr83n0g6mFWJrGTq1jbNZsQFGs/EMmbzYy0gitXNJO
	 bMrEX+vxcdUqGj3T9pJ6VVT2B67rl71PvLQlcP9Fqrdb0dkIQ3xMYawk9mcdIe1qqqTOG
	 rfPALbKoudtL0ySUPxZxHxY8cmGN4tsvas/JznlsGunLn4w4hkSemF37DQ0H/2XPlrQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795393735;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=U+HLN1k8lco5bdQT0KCTCsJjmlrsMySjcezfIG6VGqg=;
	b=avXZnFx9opOZrkg7EWAgftBjV3+ObzKSJg8WomXok1n/Zfz4u47OlwP8QakcOSEAqnZU
	 C5qKm0nCkh64R3n5eUFGvh/FDm6uDTOWjnbKxQBq9BtX2rYYuBwUqSzAosa+JauhpLxkS
	 d1gJHvZYqFNosZBSDA1YIiroqeSY6/11rEjkmXVO3uckAEO4rXFWTOygHNHKE9SzMDZct
	 ZsLvS+4LVa2L8rn03ONgXr0+1EjOkVVFYBO548bFS5g9FSv9pP9OXogBgV7rWLCsJCbsk
	 FIvLW6Pn5d7aQGC01b3e2iwX4EmOmbbX5ew+n2zKbBTOT5lUyygsyIO4iZNVH0vX1aQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=meQNc0ro;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id BF7D3606A333;
	Mon, 23 Nov 2026 00:28:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=meQNc0ro
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795393734;
	b=jYqelRX6Do3UTpXPZEWYFnnHNnXQJ+nQ4JL5qOJ388AD5Pv+tCLOsl5eF/nl9qbywPbb
	 9WpL0psIv2LEAXC4vuGRyG9Hb1St9MJopu5j+ScDzyPsvfxt2crS8B17uW+Io0fz7pKfD
	 kRlVw2zE15buSsUE4gENam5I4t8g28pU0Hp2cYgiib4UaScY60Qgr43YIDyVeo39olEnI
	 aL/cf2/5EIMDIKGEds3/RG7GHq6ED4Dj56MAj3bWcmOO7ztzg8/JjnBir47wib2+vs+jo
	 uX/tay4JkIAoG/mYOqAb4eAATpxexQWFJ38aTfK6e8SUA7ji5ZNoyL17lJ9k7NHu0Lg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795393734;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=U+HLN1k8lco5bdQT0KCTCsJjmlrsMySjcezfIG6VGqg=;
	b=YXYbXCu8yJe837wmJ73cQMaHwnDxCjNk/p6MvJKKBZciaDBH2xDQJC+iXD3aPq87/C+F
	 tMlQu2YgyIHjjMsoF+5N1zDPNG6Hjf0f3Sctg6o65o9OAkbCTABXzeiqov77iowdny595
	 LG1HeWLlni10mNsK58M66F5CnEkYXnjA01UK0c5Ne+hrYHoeE7Rdo6CHXwQMeM/XMfIWm
	 n+5uH7t5ptr7+2eH9LbxJigoWps1DTPxJdNu5rgGSUcpnRYUZdgeVklCfLeDGp670zASG
	 9UbydaJyhicXUvkDygaf4pRtiRj2ZKhQbM2GlasOmome9C5NHINoISY+jrxLq1Rt8dQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=meQNc0ro;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDAC4606A31A;
	Mon, 23 Nov 2026 00:28:54 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A7471F000CF;
	Mon, 23 Nov 2026 00:28:53 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795393734;
	bh=U+HLN1k8lco5bdQT0KCTCsJjmlrsMySjcezfIG6VGqg=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=meQNc0roy9IBNOVc+GZSaqQzt10PHUrvXHSjkaBJymAAglslM1DJrxqgzHLW1alQR
	 rbNygEMoXeb/uLZ8q6dEv8aQiraCbrjByuqaxJWbuWXbreVOHXaXVeULMjg5ooYmqF
	 dFdblTBt61n3VAeAaH7scPVqZqZOtEGvVbrMTz/cGEaUMMNLUsV/0XvaZDax+k9++B
	 pvBHYc1Nmy7/mUPvmhhr0ld5IodXbsHslKTCO+xkqrgoWEFzp4vwnogo7bi4UQwZy/
	 IRy4OfBSwH9m3Kc4nRFOSQ26yFDTxyVKy08sw0V52i9StM/zs5+DJ5VuoYUt3mXaaU
	 jtLgEi80DtAJw==
X-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
X-In-Reply-To: <20261118235055.1225115-2-vladimir.oltean@nxp.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list