Netdev List
 help / color / mirror / Atom feed
From: Aditya Garg <gargaditya@linux.microsoft.com>
To: netdev-bot+sashiko@kernel.org
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
Subject: Re: [PATCH net] net: hv_netvsc: Preserve RSS indirection table across device recreation
Date: Mon, 30 Nov 2026 14:34:22 +0530	[thread overview]
Message-ID: <9d3f2b02-617f-4ced-8273-dc831568f8ec@linux.microsoft.com> (raw)
In-Reply-To: <179593625222.3146.9294740311224290988@kernel.org>

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

      reply	other threads:[~2026-11-30  9:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  6:56 [PATCH net] net: hv_netvsc: Preserve RSS indirection table across device recreation Aditya Garg
2026-11-29  7:10 ` netdev-bot+sashiko
2026-11-30  9:04   ` Aditya Garg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d3f2b02-617f-4ced-8273-dc831568f8ec@linux.microsoft.com \
    --to=gargaditya@linux.microsoft.com \
    --cc=amir@boussejra.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=edumazet@kernel.org \
    --cc=gargaditya@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shradhagupta@linux.microsoft.com \
    --cc=ssengar@linux.microsoft.com \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox