Linux-HyperV List
 help / color / mirror / Atom feed
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 v2] net: hv_netvsc: Preserve RSS indirection table across device recreation
Date: Fri, 04 Dec 2026 07:47:49 +0000	[thread overview]
Message-ID: <179637046957.3146.6988724081260927365@kernel.org> (raw)
In-Reply-To: <20261203071129.396360-1-gargaditya@linux.microsoft.com>

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

      parent reply	other threads:[~2026-12-04  7:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  7:11 [PATCH net v2] net: hv_netvsc: Preserve RSS indirection table across device recreation Aditya Garg
2026-12-04  7:11 ` sashiko-bot
2026-12-04  7:47 ` 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=179637046957.3146.6988724081260927365@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