From: netdev-bot+sashiko@kernel.org
To: gargaditya@linux.microsoft.com
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: Sun, 29 Nov 2026 07:10:52 +0000 [thread overview]
Message-ID: <179593625222.3146.9294740311224290988@kernel.org> (raw)
In-Reply-To: <20261125065620.1604647-1-gargaditya@linux.microsoft.com>
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
prev parent reply other threads:[~2026-11-29 7:10 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-26 6:56 ` sashiko-bot
2026-11-29 7:10 ` netdev-bot+sashiko [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=179593625222.3146.9294740311224290988@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=amir@boussejra.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@kernel.org \
--cc=gargaditya@linux.microsoft.com \
--cc=gargaditya@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-hyperv@vger.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