🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20635

Re: [PATCH net-next v2 4/9] net: state the "XDP excludes HW-GRO" rule in the core

#20635
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 01:33
218 lines
15677 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

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

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).

- [Medium] In dev_xdp_attach() (net/core/dev.c), dev->xdp_pending is set
  and dev_xdp_clear_rx_agg() runs before dev_xdp_install() validates the…
- [Medium] dev_xdp_clear_rx_agg() turns the old warn-and-proceed
  behaviour into a hard failure for every XDP attach mode, generic (SKB)…
- [Low] The commit message describes concrete user-visible bugs that this
  patch fixes, but there is no Fixes: tag.

--

net: state the "XDP excludes HW-GRO" rule in the core

This commit moves the rule that HW-GRO must be off while XDP is attached
into __netdev_update_features(). A new xdp_pending bit makes
dev_xdp_prog_count() report a program while one is being installed. The
attach paths now try to clear HW-GRO first and refuse the attach if they
can't, the detach paths refresh features, and dev_disable_gro_hw() is
removed.

> The device also lost the bit from wanted_features for good, so HW-GRO
> never came back after detach - on mlx5 that took header-data split
> with it, and with it devmem and io_uring zero-copy Rx.

[Severity: Low]
This isn't a bug, but the commit message describes user-visible problems
that this patch fixes, and there is no Fixes: tag. The problems are:

  - the WARN from generic_xdp_install()->dev_disable_gro_hw() on mlx5 with
    tcp-data-split
  - HW-GRO staying off after a generic XDP detach, because
    dev_disable_gro_hw() cleared it from wanted_features
  - idpf running RSC under XDP

idpf_set_netdev_features() advertises GRO_HW with no XDP interlock:

	if (idpf_is_cap_ena_all(adapter, IDPF_RSC_CAPS, IDPF_CAP_RSC))
		other_offloads |= NETIF_F_GRO_HW;

Should this have a Fixes: tag, or a note saying why it isn't meant for
stable?

> diff --git a/net/core/dev.c b/net/core/dev.c
> index 4ca8a9f5a7a5c..5d38cdb6c3260 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c

[ ... ]

> @@ -10617,6 +10599,32 @@ static void dev_xdp_set_prog(struct net_device *dev, enum bpf_xdp_mode mode,
>  	dev->xdp_state[mode].prog = prog;
>  }
>  
> +/* Try to clear HW-GRO before the driver reconfigures for XDP.
> + * Driver may add features back in via ndo_fix_features(), due to feature
> + * dependencies. In that case we can't run XDP at all.
> + */
> +static int dev_xdp_clear_rx_agg(struct net_device *dev,
> +				struct netlink_ext_ack *extack)
> +{
> +	if (!(dev->features & NETIF_F_GRO_HW))
> +		return 0;
> +	if (!(dev->hw_features & NETIF_F_GRO_HW)) {
> +		NL_SET_ERR_MSG(extack,
> +			       "unable to disable HW-GRO, fixed on");
> +		return -EOPNOTSUPP;
> +	}

[Severity: Medium]
Is it intended that generic XDP attach now fails on devices where GRO_HW
is fixed on? The old code warned and attached anyway. This check refuses
the attach in every mode, generic (SKB) mode included.

virtio_net is one such device. With VIRTIO_NET_F_GUEST_TSO4/6 negotiated
and VIRTIO_NET_F_CTRL_GUEST_OFFLOADS missing, virtnet_probe() puts GRO_HW
in features but never in hw_features:

drivers/net/virtio_net.c:virtnet_probe() {
    ...
	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
		dev->features |= NETIF_F_GRO_HW;
    ...
	if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) &&
	    (vi->guest_offloads_capable & GUEST_OFFLOAD_GRO_HW_MASK))
		dev->hw_features |= NETIF_F_GRO_HW;
    ...
}

virtnet_xdp_set() already refuses native XDP in this configuration, so
xdpgeneric was the fallback. Before this patch,
generic_xdp_install()->dev_disable_gro_hw() warned and the program was
attached. Now dev_xdp_attach()->dev_xdp_clear_rx_agg() returns
-EOPNOTSUPP, so xdpgeneric attach fails on these guests.

The commit message covers the old splat and the "attached anyway" outcome.
It doesn't say that such attaches are now refused, and it doesn't mention
the fixed-on case. The later mlx5 patch in the series covers the -EBUSY
refusal for tcp-data-split, but nothing in the series covers virtio_net or
other fixed-on devices.

Could the commit message describe this behavior change?

> +
> +	netdev_update_features(dev);

[ ... ]

> @@ -10880,19 +10905,36 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
>  			return -EOPNOTSUPP;
>  		}
>  
> +		if (new_prog) {
> +			dev->xdp_pending = 1;
> +			err = dev_xdp_clear_rx_agg(dev, extack);
> +			if (err)
> +				goto err_clear_pending;
> +		}
> +
>  		err = dev_xdp_install(dev, mode, bpf_op, extack, flags, new_prog);
>  		if (err)
> -			return err;
> +			goto err_clear_pending;
>  	}

[ ... ]

> +
> +err_clear_pending:
> +	dev->xdp_pending = 0;
> +	netdev_update_features(dev);
> +	return err;
>  }

[Severity: Medium]
Should dev_xdp_clear_rx_agg() run only after dev_xdp_install() has
validated the program?

dev_xdp_clear_rx_agg() calls netdev_update_features(), which drops
NETIF_F_GRO_HW and reconfigures the device through ndo_set_features().
dev_xdp_install() can still reject the attach after that, for reasons
unrelated to HW-GRO:

net/core/dev.c:dev_xdp_install() {
    ...
		if (prog->expected_attach_type == BPF_XDP_DEVMAP) {
			NL_SET_ERR_MSG(extack, "BPF_XDP_DEVMAP programs can not be attached to a device");
			return -EINVAL;
		}
    ...
		if (dev->cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
		    !prog->aux->xdp_has_frags) {
    ...
		if (dev_get_min_mp_channel_count(dev)) {
    ...
}

The same applies to offloaded progs without HW_MODE, CPUMAP-typed progs,
and dev-bound progs on the wrong device or in SKB mode.

When that happens, err_clear_pending calls netdev_update_features() again
to turn HW-GRO back on. Nothing checks whether that call succeeded.

On bnxt, every TPA on/off transition in bnxt_set_features() sets re_init:

drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_set_features() {
    ...
	if (changes & BNXT_FLAG_TPA) {
		update_tpa = true;
		if ((bp->flags & BNXT_FLAG_TPA) == 0 ||
		    (flags & BNXT_FLAG_TPA) == 0 || ...)
			re_init = true;
	}
    ...
}

So a misconfigured attach on bnxt would close and reopen the NIC twice
before being refused. Examples are a DEVMAP-typed program, or any XDP
program on a port with tcp-data-split or a memory provider bound.

Each such attempt also sends two NETDEV_FEAT_CHANGE notifications. If the
restoring ndo_set_features() fails, HW-GRO stays off with no XDP program
attached.

The extack also changes. On mlx5 with tcp-data-split enabled,
mlx5e_fix_features() adds GRO_HW back:

drivers/net/ethernet/mellanox/mlx5/core/en_main.c:mlx5e_fix_features() {
    ...
	if (cfg && cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
	    !(features & NETIF_F_GRO_HW)) {
		...
		features |= NETIF_F_GRO_HW;
	}
    ...
}

A single-buffer program then gets "unable to disable HW-GRO, required by
another feature" instead of the more specific "unable to install XDP to
device using tcp-data-split".

netif_xdp_propagate() runs its hds_config and memory provider checks
before it sets xdp_pending and calls dev_xdp_clear_rx_agg(). Could
dev_xdp_attach() use the same order, so the checks in dev_xdp_install()
run before any features change?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122010112.1471146-1-kuba%40kernel.org
Technical Details
Message-ID: <179539762712.3135.2625842431945223640@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368938-linux-kernel-netdev=dewy.ru
References: <20261122010112.1471146-5-kuba@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368938-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 4/9] net: state the "XDP excludes HW-GRO" rule
 in the core
Date: Mon, 23 Nov 2026 01:33:47 +0000
Organization: Usenet Network
Message-ID: <179539762712.3135.2625842431945223640@kernel.org>
References: <20261122010112.1471146-5-kuba@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3763767"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:A3+ZY2b5f0s2Q/m/beJGfCU4eFQ= sha256:WDWbbZ7vAQNp0APNQVecX5rmpOgutFXXxOaVcLfNmP4=
	sha1:VEHFzX3v6wQ6eDscEsW0C+GCHUw= sha256:OJ5bYUEsA7dwn+Pm/b5/JzDf8eR+qkGt+qG8HtmjVK4=
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 00020125D8F; Mon, 23 Nov 2026 04:34:11 +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 4_GmLGh3HXzy;
	Mon, 23 Nov 2026 04:34:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368938-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 9177E125D8D; Mon, 23 Nov 2026 04:33:58 +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 DAA9526A82; Mon, 23 Nov 2026 01:33:53 +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=1795397630;
	b=Gd+a1gfdXIDgdT6xTfq6b0kXUhLGHQyWp7HEjO5t3hVOGlYSymoZ/4eRsHVqhfW5Ab91
	 dgZd1yxykeKjpQ+nuO/kJmyXLKMuVqldJkVV7ceOQqeaR9ds0VZwWahkaAWXEI2hHXMsy
	 WI8w/WGbVAUFFXdzYbsceZpGJfOq85S6TggRdp2FXnOwh+1Hz0ntXuIWIEoy1GspKVZZC
	 Bd/aEjNe/Iq225+hhynkmTzJUOADq6VYRuQrviAp3JnzoJvPhZQqOQW9XXOVlm2DSE1iR
	 meyt9KUggyKR2/tGRy7hjmL6zIPRltFlAtyekSbxmCEZ0y8bM4QTW8B6RWAfrZ6aJYQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795397630;
	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=/X/XpNu+XU1r4t66dy+UWenVHX0JRM4YPorfQRX/rS8=;
	b=lMEkvt2wQ62XFy8YyZsy9OwrKMta/KayDF1zM79IWtY7nb8JnvWfUGMFXfl7xS9ljsS2
	 ZiqfApdyCSqfdgFJ93NWxoAREjJAH7DsVq3Bg5NY4A4EZEGpPvCLXtQAOxjIgIyUlmvHB
	 9NkvMhbyj1lkq0zYjnrg7dJuaJ8QAM3RJQi+37b4jUpMfoP9AuckwPIzLgb6XYPZPz1Jh
	 UlEqRf7aB6oWm6gvRbdXLQPzgJ1bC4wc76mpm+BSSPNlrQpthZdpIRZQVhUGLah20vtUH
	 sSAmxL1PZUWVqGwP46VwOiLTOLKnve7g8wMriFIamj/b9xyTlC27Pu1H2eXVB4S4YpQ==
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=cPHfPjvB;
	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 144FD606A332;
	Mon, 23 Nov 2026 01:33:50 +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=cPHfPjvB
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=1795397629;
	b=XVPxtncXRWjdfjrQpzKLKG4kTTsXpS3bNbmHT66Py6HwYsQJOXoBKNG/3Xuq2Kc5WEZQ
	 ZFXNh9uNc+FNFceehcfk/6aJH0a/65BOdkas8keqZVbPGoe2j/ExtfYl4OeL3K88GbXKv
	 7o65rupeNmfJydpePGa3iPKLFUQP99GaXdVEN/COdkZ1Vq264m7q58e6yiIBJ2CH9cY1d
	 d72KyZoJf1boq7j2u6oXdY1eo+aXOgvGbZiyXsB8MP2hJH4huWLzAAEUJwh14JdjT8QEJ
	 fPrlSqu50QoY0H+lTk3coLdCH5rILE0WcC4PLGNooQ9crgxj5nCO5H6/t/EGoSIA05Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795397629;
	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=/X/XpNu+XU1r4t66dy+UWenVHX0JRM4YPorfQRX/rS8=;
	b=iALnoNwIAkXkMaeDEzK0lRAsIXRunobse4X0tf6j10kLOnjnJWnH+k4t3XZUZo95hTDl
	 R/1GCWUKLzunRycCeidN6xZ3YI2+5VAH4XSDX2xJTSN6dVaPcNUlNjw8ZCi1Ag8EuDpWd
	 RVa+EXPGSlAc6NUzsa18V/IHATCfQ3lYJaVpDnyJMEoDwhGWvjwzAqC8IgO9twqSj1d3e
	 zC/D+cgnF6OJt4qOaNNtCmmp75vVx6U0VlQ7mSXeAxAGFj82lU2Km7426Cr0HHIG5mXyE
	 Obdlz7EQANGeh0fkyuMjrd5doyc5NFoHEXQTfaW54Np9m7me+0QlntWZE4FAH3h3YeQ==
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=cPHfPjvB;
	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 301D0606A31A;
	Mon, 23 Nov 2026 01:33:48 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E8961F000CA;
	Mon, 23 Nov 2026 01:33:47 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795397628;
	bh=/X/XpNu+XU1r4t66dy+UWenVHX0JRM4YPorfQRX/rS8=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=cPHfPjvBzRfvqtr0mQTN/wEv7wC+FV9msUfZyPluXpl3IADfXmEot7WrmTJj0R68d
	 c5iu0R/hx7w1cdc0W0ThVQZR5rMgDfIR6YOZOX0CudXKz1i7IwU4FlMQvdSijM1SH2
	 +WUKtranC5D+TT2HXlmL/WEUKAH+mtbSPwyy7A1FYxHk+ws6bUj0mg7taBVEavu4dO
	 u3rcWL1kQN/u/5i0LuDD1dF70UEJ/e5b/sJ0VB5a8Hi2jC001CzqpOCKcp2PGj5mse
	 FPNnEAWd25ldUd7t6K9T3bXTmvuGv5cvmZoWANmRZb3ccAm1NhqW43/0MPKNGSMl4o
	 mI2b+NzjcnXKg==
X-Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
 pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
 michael.chan@broadcom.com, manishc@marvell.com, joshwash@google.com,
 hramamurthy@google.com, tariqt@nvidia.com, saeedm@nvidia.com,
 daniel@iogearbox.net, hawk@kernel.org, sdf@fomichev.me, willemb@google.com,
 przemyslaw.kitszel@intel.com, bpf@vger.kernel.org, nktgrg@google.com
X-In-Reply-To: <20261122010112.1471146-5-kuba@kernel.org>
X-sashiko-severity: Medium
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