🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24068

Re: [PATCH net] net: hv_netvsc: Preserve RSS indirection table across device recreation

#24068
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 07:10
219 lines
16125 bytes
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.

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

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] When subchannel setup or RSS programming fails,
  netvsc_attach() runs memset(nvdev->extension->rss_key, 0,…
- [Medium] When rndis_set_subchannel() succeeds, so num_chn > 1 and the
  real RX queue count is already raised, but…
- [Low] The commit message understates what the patch changes.
- [Low] The Fixes: tag points to 4cab498f33f7 (June 2023, v6.5 era).
- [Low] netvsc_devinfo_get() adds a kmemdup() of the RSS indirection
  table (rx_table_sz u16 entries, at most ITAB_NUM_MAX = 256, so up to…

--

net: hv_netvsc: Preserve RSS indirection table across device recreation

This patch saves the user-configured RSS indirection table before the
RNDIS device is torn down. It restores the table after subchannel
negotiation if the table is still valid, and also carries the cached RSS
key across recreation. If RSS restore fails, it clears the cached table
and key and reports the table lost via ethtool_rxfh_indir_lost().

Closes: https://lore.kernel.org/all/40fb2352-4859-4334-849b-f6a4229605a1@boussejra.com/

> diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
> index 1d43c73fd73f1..f51e7b349d7f7 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c

[ ... ]

> @@ -939,6 +940,21 @@ struct netvsc_device_info *netvsc_devinfo_get(struct netvsc_device *nvdev)
>  	if (nvdev) {
>  		ASSERT_RTNL();
>  
> +		ndc = netdev_priv(nvdev->extension->ndev);
> +		if (netif_is_rxfh_configured(nvdev->extension->ndev) &&
> +		    ndc->rx_table_sz) {
> +			dev_info->rss_indir_table =
> +				kmemdup(ndc->rx_table,
> +					ndc->rx_table_sz * sizeof(*ndc->rx_table),
> +					GFP_ATOMIC);

[Severity: Low]
Does this kmemdup() need GFP_ATOMIC? Only four callers reach this
branch: netvsc_set_channels(), netvsc_change_mtu(),
netvsc_set_ringparam() and netvsc_suspend(). All of them run in process
context with RTNL held, as the ASSERT_RTNL() above shows.

If this allocation fails, the MTU, channel or ring change now returns
-ENOMEM, or suspend is aborted. GFP_KERNEL would be less likely to fail
here.

> +			if (!dev_info->rss_indir_table) {
> +				kfree(dev_info);
> +				return NULL;
> +			}

[ ... ]

> @@ -1036,6 +1054,19 @@ static int netvsc_attach(struct net_device *ndev,
>  		if (ret) {
>  			nvdev->max_chn = 1;
>  			nvdev->num_chn = 1;
> +		} else {
> +			ret = rndis_filter_set_rss_param(nvdev->extension, dev_info->rss_key);
> +		}
> +
> +		if (ret) {
> +			netdev_err(ndev,
> +				   "unable to restore RSS parameters (ret %d).\n",
> +				   ret);
> +			/* Do not report the saved parameters as restored. */
> +			memset(ndev_ctx->rx_table, 0,
> +			       ndev_ctx->rx_table_sz * sizeof(*ndev_ctx->rx_table));

[Severity: Medium]
What happens to RX steering when rndis_set_subchannel() succeeds but
rndis_filter_set_rss_param() fails?

In that case num_chn is still greater than one and the real RX queue
count has already been raised. Every entry in ndev_ctx->rx_table now
points to queue 0.

If a user table was configured, ethtool_rxfh_indir_lost() is called
later. That tells the core the table is unconfigured, so the core
assumes the default spread. netvsc_get_rxfh() reports the all-zero
table instead.

If no user table was configured, nothing is reported. Before this patch,
that case kept the ethtool_rxfh_indir_default() table.

A later key-only change such as "ethtool -X ethX hkey ..." reaches
netvsc_set_rxfh() with rxfh->indir == NULL. rndis_set_rss_param_msg()
then sends the table unchanged:

rndis_set_rss_param_msg() {
    ...
    itab[i] = ndc->rx_table[i];
    ...
}

Would that program an all-zero indirection table while several channels
are open? All RX would go to queue 0 while ethtool reports the default
table.

> +			memset(nvdev->extension->rss_key, 0, NETVSC_HASH_KEYLEN);

[Severity: Medium]
Can this zeroed key later be programmed into the host as the real
Toeplitz key? Nothing in the driver treats an all-zero rss_key as
invalid.

The next recreation can be an MTU change, ethtool -L, ethtool -G, or a
resume. In each case netvsc_devinfo_get() copies the zero key into
dev_info->rss_key. The new memcpy() in rndis_filter_device_add() then
copies it into the new rndis_device, and netvsc_attach() programs it:

netvsc_attach()
    rndis_set_subchannel()   /* succeeds this time */
    rndis_filter_set_rss_param(nvdev->extension, dev_info->rss_key)

A table-only "ethtool -X" retry also uses the zero key. When no hkey is
given, netvsc_set_rxfh() gets rxfh->key == NULL and falls back to the
cached key:

netvsc_set_rxfh() {
    ...
    key = rndis_dev->rss_key;
    ...
}

rndis_set_rss_param_msg() copies the key into an NDIS_HASH_FUNC_TOEPLITZ
request. A Toeplitz hash with an all-zero key is 0 for every packet, so
every flow would select indirection entry 0. Isn't that the same
all-RX-on-one-queue symptom this patch is fixing?

On success, rndis_set_rss_param_msg() also writes the key back into
rdev->rss_key. The zero key would then persist across later recreations
until the user sets a key explicitly.

The commit message says the caches are cleared so that netlink retries
are not skipped as matching. Could the driver keep the last valid key
(or netvsc_hash_key) for programming, and track the "not applied" state
separately?

> +			rss_failed = true;
>  		}
>  	}

[ ... ]

> @@ -1066,6 +1097,14 @@ static int netvsc_attach(struct net_device *ndev,
>  			netif_carrier_on(ndev);
>  	}
>  
> +	/* Check whether the custom RSS table was lost and notify ethtool. */
> +	if (netif_is_rxfh_configured(ndev) &&
> +	    (rss_failed || !ndev_ctx->rx_table_sz ||
> +	     ndev_ctx->rx_table_sz != dev_info->rss_indir_size ||
> +	     memcmp(ndev_ctx->rx_table, dev_info->rss_indir_table,
> +		    dev_info->rss_indir_size * sizeof(*ndev_ctx->rx_table))))
> +		ethtool_rxfh_indir_lost(ndev);

[Severity: Low]
The Fixes: tag points to 4cab498f33f7 ("hv_netvsc: Allocate rx
indirection table size dynamically"), which is from the v6.5 era. This
fix depends on two things added much later, in commit 0475f9e779b456
(2026): ethtool_rxfh_indir_lost(), and the netif_is_rxfh_configured()
that reads dev->ethtool->rss_indir_user_size.

Stable trees that have 4cab498f33f7 but not 0475f9e779b456 can't take
this patch as written. A backport would need another way to clear the
user-configured state, such as the older IFF_RXFH_CONFIGURED flag.
Should the commit message mention this dependency?

> +
>  	return 0;

[ ... ]

> @@ -2719,6 +2758,11 @@ static int netvsc_suspend(struct hv_device *dev)
>  		goto out;
>  	}
>  	ret = netvsc_detach(net, nvdev);
> +	if (ret) {
> +		netvsc_devinfo_put(ndev_ctx->saved_netvsc_dev_info);
> +		ndev_ctx->saved_netvsc_dev_info = NULL;
> +	}

[Severity: Low]
This isn't a bug, but this hunk is a separate fix that the commit
message doesn't mention. Before this patch, a failed netvsc_detach()
leaked the saved devinfo and its bpf_prog reference.
saved_netvsc_dev_info is otherwise only freed in netvsc_resume(). Could
the commit message describe this change?

The commit message also says:

  "Changing the MTU recreates the RNDIS device and frees the RSS
  indirection table."

MTU changes are not the only trigger. netvsc_set_channels(),
netvsc_set_ringparam() and netvsc_resume() use the same
netvsc_devinfo_get()/netvsc_detach()/netvsc_attach() sequence. They had
the same zeroed-table problem and are fixed here too. Could the commit
message list these triggers as well?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125065620.1604647-1-gargaditya%40linux.microsoft.com
Technical Details
Message-ID: <179593625222.3146.9294740311224290988@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-373392-linux-kernel-netdev=dewy.ru
References: <20261125065620.1604647-1-gargaditya@linux.microsoft.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-373392-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: hv_netvsc: Preserve RSS indirection table across
 device recreation
Date: Sun, 29 Nov 2026 07:10:52 +0000
Organization: Usenet Network
Message-ID: <179593625222.3146.9294740311224290988@kernel.org>
References: <20261125065620.1604647-1-gargaditya@linux.microsoft.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1123546"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:WeTX6dLU70YUiGaeC9A0ccLbyrI= sha256:LY1PgK1F9zPWKl7jbHkUIMw+mpitYTd5FSXuEJbrCZQ=
	sha1:MEU/SCxre8oV6l/7bTkqOQibbTU= sha256:WaPeMKn3AwjXfXZiQaOL1w/bIkUvPnhQWIwFA3QFvbQ=
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 01969125F95; Sun, 29 Nov 2026 10:11:19 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31
	tests=[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 Ero3yDyzJdg4;
	Sun, 29 Nov 2026 10:11:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-373392-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 47C57125F93; Sun, 29 Nov 2026 10:10:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 3358F601A61; Sun, 29 Nov 2026 07:10:58 +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=1795936255;
	b=GpiMVF8HBexViFnolePNZCQzwiRw1jumnoCPUNczf8N8SAdyJKtBDLAugDCxYLYUbbDw
	 jA0mil8RUwtbadG8AuoKhuwvs5Qszb+DnV0H/ahjqSOX0RBTqDCEpC0lj2WqLTCmqAus2
	 Dw2RiHpOEM0livHNceikRWZGLD+bGejezuvSbdkIDmWEnKVZqssWENenbchjb8BSdSNgA
	 IhTAN0+dBXkbTilPpNtCijilPYloGwLjc1QoGQFqX1sreJ3Xu6vrJitPde67PVR7Zej1/
	 s83dqx3Pwp5z/097jlV1UKw4MZfAyA8ZpXNVc2RwANe+vI/mgKB0vs5j41vKHT4BKQA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795936255;
	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=s4UkENEZ94gMYiu4Syeai05/WE3vUK5d1DXoqagCSJE=;
	b=5LlJO1aCFp09m1tWqPGKl5+GwarfHDfGL1IwRiBMdghUeDCAHp6t6jsAXnfmv/W0epDW
	 X5UPWCmJPUXu8J/iFKkdomArNYXAwoMY9fKWlW5O7UXb8IkuCWgE9s0KdLVtvYAmlWtWm
	 wMdbxiBB3mDW25F4LUW/Du8GRNowSkWQ/Evpk+E6NNM8R++0LfEP96a4wzs9EcpcVyMeN
	 AwjmjTryVZ4eqJGaRQUMpuJFVdagTHgCCelkPhmLxWtZOpfLy9SP8HgceE8+C3i7B5LZ5
	 YdS7fXzdEtjix3k0O/LwGWakPjasfXyascbQd+vBmbV7+j/VyL5aSbWI9Hy2rviVs/g==
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=PCMAQIMu;
	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 643FF606A32C;
	Sun, 29 Nov 2026 07:10: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=PCMAQIMu
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=1795936254;
	b=cItinUEu62WDz2i+v9Ie2qsod5Zi/WXvW7932cTjdtjDHKjtnt74B/CcgUWgQ5Y/NMvL
	 SQhv3iG7K6XGnUihDC2P0QGkkL13HlWhYUBT3THJtlGVt6gWX+3C4MovVjBpcuxCalseM
	 SNwy2iVXqJMHT8yQ+IbXgi6pM4yY0cJS85vAYkvdK3MP0b8zQINWFfB2uOso3Y1bziE+l
	 jQp6mbF/vZx8L+mtcd0rwV4yT2aOH6tQzn4ELuG01WgDiGq9Ve60JVmye1n8s1H0dhNcs
	 fhjUV6HqMSRiG2l4CN4fSy/HhkpbVqeC54xn1tIKLAY377y79Ikhm7ha5YnNWB5ypAg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795936254;
	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=s4UkENEZ94gMYiu4Syeai05/WE3vUK5d1DXoqagCSJE=;
	b=x6/6W9PiBy85Y5ycf0r43YWO7ra8BuYRAtqp8LkAgtSEqoLdALo/RRS/2EWC1adatLLT
	 p+mlTt8laMQZCJ2LXLH9s47+xt0FpzfMYP8G5lnyAIRtbtz9seQIX4+q9u3UV1iDfooNo
	 QC7x8e2B918AFcapQyrk7pu4x5uEZ7DFNomKOXDflQDp1qzGUNA+5vrQYyOnCueKBLrki
	 b1xY8aD5eqCh3shIf3cXvCIlmmO4l/dqRIJSo0DhIx7CueZZDeBdqi+Uk/lN7JGsXVzGz
	 HafGqmRIT51N3Z4F7F6ZaezBQOsRUZLM/iKa303NOq4jDUYyF8//tskUH7PbdrfQr/A==
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=PCMAQIMu;
	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 7FB9A606A31C;
	Sun, 29 Nov 2026 07:10:54 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA3A81F00899;
	Sun, 29 Nov 2026 07:10:52 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795936253;
	bh=s4UkENEZ94gMYiu4Syeai05/WE3vUK5d1DXoqagCSJE=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=PCMAQIMu0cPBzIhBmWwEm6lVNNzr1ymgAroX6SsBqxDKJjSTwnnai9BeuPkV7LVfU
	 7u59yo7Nu+QrHWVS23aT6bAawnGu/KobGfnnV8VAHEAdsTpgqCKdp8Z98H9+QaUgJ3
	 9INwdbzXwkZbmXSM2eEPACUBKaAgJyLplMYYKOXx6p6qqXpwSLzAltQPZPMlHVpyGV
	 YU3qzr8bJCWr+VUydgcf90PLPzhVf7YPHFlArYmj1kSLMbtu1Uk1PeyzDaI7Ny6wF9
	 uLBIXxqWGo4XCCICJ2IEOOGq/+XRNHdEtsQFOjKi5jEypm6cqwOS/jKLXBOjpWZPUd
	 ztsyzj9SFaduA==
X-Cc: haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
 andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, shradhagupta@linux.microsoft.com,
 horms@kernel.org, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org,
 gargaditya@microsoft.com, ssengar@linux.microsoft.com, amir@boussejra.com
X-In-Reply-To: <20261125065620.1604647-1-gargaditya@linux.microsoft.com>
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