🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24520

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

#24520
From: Aditya Garg
Date: Mon, 30 Nov 2026 09:04
249 lines
18058 bytes
On 29-11-2026 12:40, netdev-bot+sashiko@kernel.org wrote:
> 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.
> 

I used GFP_ATOMIC to match the existing dev_info allocation in this
function. However, the callers reaching this branch can sleep, so the
new allocation does not need GFP_ATOMIC. I will use GFP_KERNEL for the
RSS table copy in v2.

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

The caches are cleared deliberately. Once RSS restoration fails, 
retaining the saved values would misleadingly report them as restored.

Substituting defaults would be no more accurate and could suppress 
matching netlink retries before they reach the driver.

The failure is logged. Recovery under this policy requires explicitly
configuring both the key and table again. A partial update retains the
zeroed value of the omitted parameter.

>> +			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;
>>   		}
>>   	}
> 
> [ ... ]
> 

The same reasoning applies to the key as explained above: the failed 
request does not tell us whether the host accepted either parameter. 
Yes, a table-only update or a later recreation can reuse the zero key; 
recovery under this policy requires explicitly reconfiguring both 
parameters, as noted above.

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

will update commit message with this in v2

>> +
>>   	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?
> 

will update commit message in v2

pw-bot: cr
Technical Details
Message-ID: <9d3f2b02-617f-4ced-8273-dc831568f8ec@linux.microsoft.com>
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-374054-linux-kernel-netdev=dewy.ru
References: <20261125065620.1604647-1-gargaditya@linux.microsoft.com> <179593625222.3146.9294740311224290988@kernel.org>

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-374054-linux-kernel-netdev=dewy.ru
From: gargaditya@linux.microsoft.com (Aditya Garg)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: hv_netvsc: Preserve RSS indirection table across
 device recreation
Date: Mon, 30 Nov 2026 14:34:22 +0530
Organization: Usenet Network
Message-ID: <9d3f2b02-617f-4ced-8273-dc831568f8ec@linux.microsoft.com>
References: <20261125065620.1604647-1-gargaditya@linux.microsoft.com>
 <179593625222.3146.9294740311224290988@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1388051"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:4aMkmLFOj/Bj11p7H5xZvC1gHo0= sha256:HMB37j9VZmpMBTLWvOj6S2eqHzAb/ly12YpFZiI+HUg=
	sha1:2xYSaeTPwTnyDWsG462pTicZg40= sha256:GQ/xLoQQ+bzlgp47LZbK3Xs7JbKV7vfMo2gINxTw2Sk=
Content-Language: en-US
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 61182125FCC; Mon, 30 Nov 2026 12:04:54 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.microsoft.com
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 PVLb6RwGvDYZ;
	Mon, 30 Nov 2026 12:04:46 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374054-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 60B67125FC8; Mon, 30 Nov 2026 12:04:33 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id C64C425641; Mon, 30 Nov 2026 09:04:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1796029471;
	b=PKr+BnTYKA4K+0bQBhWviP+KwkPby323mg41RAYBP0fcmNkv9pAGYbOPGEnVn+99T6by
	 tP5718wnu0WYly6pjXaP0W2B2xpweNPouZiSoboNI0eD3inN+RW/WVEVs29oli3C1fPVM
	 XwPison3Gg8BDv1qhDZEOQ6j0wJi9oAdO7tZwS07ppFU1TAlLZhS88weMJFfag8WESLEz
	 y2UMWC+i3SPOcuX2GNgBKfbbbrnyfEY1D67KCLTPmModwrF/+DJZZv4qHMTwhZZUN+taP
	 aJo2zNbXvtM5shMZOqe1G7YI1Skq8QKRhPWPDDV8vN5Pksw6jm+e+AcSoE+xR5p8rKA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796029471;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Filter:
	 DKIM-Signature:Message-ID:Date:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language:
	 From:In-Reply-To:Content-Type:Content-Transfer-Encoding;
	bh=mk2+II/8RA3RFstuwk6Fx/kJ8tN1Mq+/hnaAdvOp29s=;
	b=M/zLHiH6lPg5snsxWB86ecXzNrxlg3uwPh+IcTcCCvCh23m3kZokKktqZ3f4n6W4Ix4m
	 LICxF1ACyqz0mOctaksZzjuLXmmS20N2WC6raftaL/kNMf0hwNuXEyqBsgbp+lDz7uX/1
	 yL4j+XfAtsqOHEKHdmTov63jDsVQaV6LFFpo77xmm5hUdp6FobQg/MHgwOeDRh2pPjcmR
	 tAeVLKVQbaXGf+XIg5UnI1/z6CdGNXPDgfF5xchcuLzS8zwe9xcAxa7gFM3m7QS1iVHqC
	 6fG5E/l1SjaBoAGCgBDXW+5tbgyt1XMez+xxx0YLbO1ngpbJJI5bFo0lh70Hk14qnUA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=Oxcj745V;
	dmarc=pass header.from=linux.microsoft.com;
	spf=pass smtp.mailfrom=linux.microsoft.com;
	arc=fail 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 9F003606A338;
	Mon, 30 Nov 2026 09:04:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=Oxcj745V
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=13.77.154.182
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796029470;
	b=e23H6lKGItOoAhtw7z/Iw/Gutk2rXT5auMFpC9PQdw+noqzBulWr+3zYXrMFqlr5Yqrz
	 oWetxCe5Lh0kK5EuvrWO+gFZjt1uiA/RYx66i201+RwJHzJii2HHg+YeWwrRqVX+TnCDY
	 vXw2Vp4eeXZ93fSGtT2TvhHuPVfnEDcyPyWe9++pPIfsG+UXIXesUSfV1WIWCdiCpS7Ej
	 J6iRrkT9dQMSARQ/gObj9Ao7TLtHRQXPXxC/2BIXx9E9cpPVUDwAKZE6W9/Px3wKrOwoQ
	 6TMySXNMsy5WC4hZ2tzjcVPqMEDc3bXNOkQUP7TPDWv5zsVnkoCCwl/kwpw6CvGMcaQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796029470;
	h=DMARC-Filter:Received:DKIM-Filter:DKIM-Signature:Message-ID:Date:
	 MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language:
	 From:In-Reply-To:Content-Type:Content-Transfer-Encoding:X-Spam-Status:
	 X-Spam-Checker-Version;
	bh=mk2+II/8RA3RFstuwk6Fx/kJ8tN1Mq+/hnaAdvOp29s=;
	b=rAF2hgBwcvIzuFS9aJRunWA/ODT1Rydb2HVuSvL9sHiAkqwFKui+5kguE/3JPI669DmX
	 qg+KX71Y7Gzfq7OTo2g2k444xA5qW9RV2BTE3aIIIbjMqdLMJOpaqhdZMrVsO1xx9+cEa
	 Fwl6ZJbx+vBk1Hkf97Dl3WCU7b5ZJFvbKFZPLWGXzKdCGSBtzmJ8CaJ2M+RYBuJ4Wbucv
	 8Nd25rqwetfmaVC1glMNeNJ3G+wm682do/v1Vkq3bfipfpZova7Y1LVIUXnV2ZM9RNRmW
	 atY6fwmKNn55pte4XBPXdecKOawRcfuHR8luvQC0fiGQLBSIDWWsSg0GmwS9bzItzYQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.microsoft.com;
	spf=pass smtp.mailfrom=linux.microsoft.com;
	dkim=pass header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=Oxcj745V;
	arc=none smtp.remote-ip=13.77.154.182
X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B89D606A32A;
	Mon, 30 Nov 2026 09:04:30 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6B89D606A32A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com
X-Received: from [10.18.180.76] (unknown [167.220.238.76])
	by linux.microsoft.com (Postfix) with ESMTPSA id A8C9320B7166;
	Mon, 30 Nov 2026 01:04:18 -0800 (PST)
X-DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A8C9320B7166
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;
	s=default; t=1796029462;
	bh=mk2+II/8RA3RFstuwk6Fx/kJ8tN1Mq+/hnaAdvOp29s=;
	h=Date:Subject:To:Cc:References:From:In-Reply-To:From;
	b=Oxcj745VqpzBIyF00AKNIfHz7NGYV/PhWTC0AuD5uOr+ByZL1VJg0hFevWzNZ8hUn
	 /KkJqKuQPl1Ql2wkSjlUA0IUzX8eP4SqRzvCxuyolmo3ZR1GyMkCleEs18bG/wODVj
	 HYUxnH8bW0OROrDMTavpbzmbhkhirNpN0k+WE+Pg=
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
X-User-Agent: Mozilla Thunderbird
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: <179593625222.3146.9294740311224290988@kernel.org>