🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26818

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

#26818
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 07:47
164 lines
14007 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · 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).

- [Medium] When netvsc_attach() hits its multi-queue error fallback, it
  zeroes the only cached copy of the RSS Toeplitz key.
- [Medium] If rndis_set_subchannel() succeeds and only the new
  rndis_filter_set_rss_param() call fails, netvsc_attach() zeroes…

--

net: hv_netvsc: Preserve RSS indirection table across device recreation

This patch saves a user-configured RSS indirection table in
netvsc_device_info before the RNDIS device is recreated. The table is
restored after subchannel negotiation if it is still valid. Otherwise
defaults are used and the loss is reported with ethtool_rxfh_indir_lost().
On subchannel or RSS programming failure in netvsc_attach(), the patch
also clears the cached table and key.

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..4df17d7baa30c 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c

[ ... ]

> @@ -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]

Suppose rndis_set_subchannel() succeeds and only the new
rndis_filter_set_rss_param() call fails. This memset then zeroes rx_table,
but nvdev->num_chn is still greater than 1, and rndis_set_subchannel() has
already set the real rx queue count to num_chn. Is an all-zero table the
intended state for a multi-queue device here?

If the table was user-configured, the check further down calls
ethtool_rxfh_indir_lost(). That clears rss_indir_user_size, so the ethtool
core treats the device as using the default table. The driver, however,
holds all zeros, not ethtool_rxfh_indir_default(i, num_chn). The same
all-zero table is left behind when no custom table was configured.

A later key-only update such as "ethtool -X ethX hkey ..." reaches
netvsc_set_rxfh() with rxfh->indir == NULL. It leaves rx_table untouched
and programs it to the host:

drivers/net/hyperv/netvsc_drv.c:netvsc_set_rxfh() {
    ...
	rndis_dev = ndev->extension;
	if (rxfh->indir) {
	    ...
	}
    ...
	return rndis_filter_set_rss_param(rndis_dev, key);
}

rndis_set_rss_param_msg() then copies ndc->rx_table straight into the
request:

	for (i = 0; i < ndc->rx_table_sz; i++)
		itab[i] = ndc->rx_table[i];

Wouldn't that enable RSS with every entry pointing at queue 0? ethtool -x
would also show an all-zero table on a multi-queue device that the core
reports as unconfigured.

Before this patch, rndis_set_subchannel() ignored set_rss_param failures
here and rx_table kept valid entries. An all-zero table matches the
num_chn == 1 case on the out: path of rndis_filter_device_add(), but this
branch keeps the subchannels.

When only RSS programming failed, should rx_table be filled with defaults
for num_chn instead?

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

[Severity: Medium]

This memset runs on both the subchannel failure path and the RSS
programming failure path, whether or not netif_is_rxfh_configured() is
true. Is it safe to clear rdev->rss_key here, when the same cache is the
source for later host programming?

On the next recreation (MTU change, ethtool -L, ringparam change or
suspend/resume), netvsc_devinfo_get() copies the zeroed key into dev_info:

	memcpy(dev_info->rss_key, nvdev->extension->rss_key,
	       NETVSC_HASH_KEYLEN);

The new memcpy in rndis_filter_device_add() carries that key into the new
rndis_device:

	memcpy(rndis_device->rss_key, device_info->rss_key,
	       NETVSC_HASH_KEYLEN);

netvsc_attach() then calls rndis_filter_set_rss_param(nvdev->extension,
dev_info->rss_key). rndis_set_rss_param_msg() copies the 40 zero bytes into
the Toeplitz OID_GEN_RECEIVE_SCALE_PARAMETERS request:

	memcpy(keyp, rss_key, NETVSC_HASH_KEYLEN);

A table-only retry such as "ethtool -X ethX equal N" without hkey takes
this fallback in netvsc_set_rxfh(), so it also programs the zero key:

	if (!key) {
		if (!rxfh->indir)
			return 0;

		key = rndis_dev->rss_key;
	}

A Toeplitz hash with an all-zero key is 0 for every input. If the host
accepts the key, wouldn't every flow land on rx_table[0]? That is the
all-RX-on-queue-0 symptom this patch is meant to fix. If the host rejects
the key, RSS programming would fail on every recreation and the device
would stay single-queue.

rndis_set_rss_param_msg() refreshes rdev->rss_key only when the host
reports success. netvsc_hash_key is used only on the probe path, where
dev_info is NULL. So nothing seems to restore a valid key unless the user
supplies an explicit hkey.

The commit message says:

    Preserve the cached RSS key and zero table entries on single-queue error
    fallbacks.

The out: single-queue fallback in rndis_filter_device_add() keeps the key.
The single-queue fallback here, after a subchannel failure, clears it.
Should these two paths behave the same way?

> +			rss_failed = true;
>  		}
>  	}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203071129.396360-1-gargaditya%40linux.microsoft.com
Technical Details
Message-ID: <179637046957.3146.6988724081260927365@kernel.org>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377168-linux-kernel-netdev=dewy.ru
References: <20261203071129.396360-1-gargaditya@linux.microsoft.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377168-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] net: hv_netvsc: Preserve RSS indirection table
 across device recreation
Date: Fri, 04 Dec 2026 07:47:49 +0000
Organization: Usenet Network
Message-ID: <179637046957.3146.6988724081260927365@kernel.org>
References: <20261203071129.396360-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="2707880"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dUBpJUIAeFX47+4G96GxiqavqCA= sha256:AKKEPiNyhL1HJeDQdBMIn0DgOyzkC9w/rAf5jzHrWvE=
	sha1:qA0eMwjSa/0Gx6SKkIUZBIQ0fJE= sha256:FW+OHJavWDiLLlXkQwUh+ZQ4AolqBaq5iCdX2MFW0xY=
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 57763117B58; Fri,  4 Dec 2026 10:48:15 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.739
X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.24, 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 sQZNMxc26WtH;
	Fri,  4 Dec 2026 10:48:12 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377168-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 E4F79117B46; Fri,  4 Dec 2026 10:48: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 B4CF0261A0; Fri,  4 Dec 2026 07:47:59 +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=1796370477;
	b=bdbR3wlJ5vXO52hj9T5GYV2Md3BL7KwUmu94T6FryHilAhplBLaRb7jc6Yv5vKZ0kPJd
	 gG5n77jSbrXpqkamMOzHu1yiMDGUSi+1Kn45JmE7y1hO+LGL379yXhg7gB/UtMPf+7wYH
	 fHjEIhXpe7hxeLtby+5QSw165SJxmAkavwyR4EoTwtZvAZ504o4LMfugLbmICVoK82HR+
	 Fjmf2Jt8cLEM1q9vpobh38bvNMaiVWyjPyEc9o5bqJnFjgT5UqqCTvTOfun6CDi7NVqm5
	 NtSBJtGjJqsqW5td8gJ4tbVCm7HcDyNtjJg7axjmh8Dj3iJKUKekZODT/uPmLMLC7Ng==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796370477;
	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=WXnaABr5M93Sa05PoWrmeWBNhbUw6fYT8XnDOSRmuVg=;
	b=Uk5bTydy/zyFgE+5QiMu4f/Vre/S8I8wyq/BTEx+D+7AJwQFDVKsmEJY3j2q2fvrbnOj
	 f3rqg5zOqpY/ss2GclQWrdClclbYpBjzPX5Z7v9inHZEwZVc65qFU6lMkGFQnFqu0dD1x
	 SGVLAv/6ExcdMVxreQHPF93kIWetiL243PkGWVAtNQWIvMGE0DsXH2y/CVqNWuMLDQil6
	 u20Qb9roQ2zoHA+OuKW5WJVxj8cqTRfFZ8Pt+I65GZuoU33BghBHGgqdpugVTSIYLunB9
	 K5PHWWLjCB0W9C9LBvvUeteiqGlg7Y6PDjgH+INPsfLgFsg6cdXjSHIYZtaZj4y0oUg==
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=cENzc9l+;
	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 9A821606A335;
	Fri,  4 Dec 2026 07:47:57 +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=cENzc9l+
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=1796370471;
	b=UFSD/tduNFY01p4JDJWGGI4A4xK3Hx0zQbQoxd9fz7vUmYGyCaKeR33ImHS5MIMINRNz
	 IXpG0a/594lEUB6wK15lvqgH+GJ+E7KPvYKNEaRmll2MYpJODEHoWRlfMlYQDCX9MW7B+
	 tdg+EB3Q1XtoczM0BpiI9o6/INYMKtuEKassIY5BwxPuiPdRwTOOv5jsRc9QywDrmG3J4
	 J4jOdi3ivxE+03ZOVbJ+3w+DAM+4Id5vqxFHsfu+npEDJGkaQSmszNVjYKaNEftpxz3Al
	 /rSqFxgOw0jE+lyOnIQc8m40ew3tfvCe9DRbsZAEfU5ySaAMIEeXGHgXFrkQEt1hapA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796370471;
	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=WXnaABr5M93Sa05PoWrmeWBNhbUw6fYT8XnDOSRmuVg=;
	b=D3F0ILWgjtm5fVkADSHOTI6uj/Jg+4p/fDNmmF9i0cYsiMbftdXJIEVPDIa/WFY7MIUi
	 pcCD4KR9vQJdRbtCBDJm04aJ9FsGBKjE6gQm7ciB4foFrS5SgQGp1Jh8+REi7DIJRmctD
	 4k0d/cFQECVXMFcZfszsx/FjZE5RkLT/hvm7Bzr51nP/PL5l1tdf9ausJZJwxP6GofcWD
	 rjgUb20eC4z1yWPoGZEahdxH+6w0CGIDUksnGyZLu7dDbBr3WtBarW72yBR4IHMBnyJaX
	 yGfhr6WnuQH/o1CQ6U0b8ESPlpgIsJnKIgUmWTplQ44QBHh6P4LRstM7OoYhA+5wzKw==
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=cENzc9l+;
	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 B9F1D606A322;
	Fri,  4 Dec 2026 07:47:51 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11C0E1F00897;
	Fri,  4 Dec 2026 07:47:50 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796370470;
	bh=WXnaABr5M93Sa05PoWrmeWBNhbUw6fYT8XnDOSRmuVg=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=cENzc9l+EIC+ezeDCi7ugczqy/+NW8Jy+qeBhpxh8QrBiBRnnntF8H1PPmV4nYfHK
	 SO0e9wSSEAk0F3XA/OAClb5FtMhxD62+Ela5qRuZ1nPOg3YwEW6b0C1pLezkeu3tl0
	 qSybBKvA7Huk2CDL8u5bnS4+u4HFaMjf8X0uxO0yOKyXYYBKeksKx7iprtRUmtPnuQ
	 Srv7Pqo4wgHhevzkJTj8cijgahADyNYnd7YOQ4r0mV//TZU2qqM9/kZTtu0UQ//tit
	 5wxvVgvK2Z8gV1hdk+0ZdAOXGtQsDJ+GAknGFSKRp4kkL1K81ofg6oG5/G14LxMM0M
	 PKg/0ab3+RbSQ==
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: <20261203071129.396360-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