From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795936254; b=cItinUEu62WDz2i+v9Ie2qsod5Zi/WXvW7932cTjdtjDHKjtnt74B/CcgUWgQ5Y/NMvL SQhv3iG7K6XGnUihDC2P0QGkkL13HlWhYUBT3THJtlGVt6gWX+3C4MovVjBpcuxCalseM SNwy2iVXqJMHT8yQ+IbXgi6pM4yY0cJS85vAYkvdK3MP0b8zQINWFfB2uOso3Y1bziE+l jQp6mbF/vZx8L+mtcd0rwV4yT2aOH6tQzn4ELuG01WgDiGq9Ve60JVmye1n8s1H0dhNcs fhjUV6HqMSRiG2l4CN4fSy/HhkpbVqeC54xn1tIKLAY377y79Ikhm7ha5YnNWB5ypAg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795936254; 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=s4UkENEZ94gMYiu4Syeai05/WE3vUK5d1DXoqagCSJE=; b=x6/6W9PiBy85Y5ycf0r43YWO7ra8BuYRAtqp8LkAgtSEqoLdALo/RRS/2EWC1adatLLT p+mlTt8laMQZCJ2LXLH9s47+xt0FpzfMYP8G5lnyAIRtbtz9seQIX4+q9u3UV1iDfooNo QC7x8e2B918AFcapQyrk7pu4x5uEZ7DFNomKOXDflQDp1qzGUNA+5vrQYyOnCueKBLrki b1xY8aD5eqCh3shIf3cXvCIlmmO4l/dqRIJSo0DhIx7CueZZDeBdqi+Uk/lN7JGsXVzGz HafGqmRIT51N3Z4F7F6ZaezBQOsRUZLM/iKa303NOq4jDUYyF8//tskUH7PbdrfQr/A== 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=PCMAQIMu; arc=none smtp.remote-ip=100.103.45.18 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 7FB9A606A31C; Sun, 29 Nov 2026 07:10:54 +0000 (UTC) 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=PCMAQIMu Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA3A81F00899; Sun, 29 Nov 2026 07:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795936253; bh=s4UkENEZ94gMYiu4Syeai05/WE3vUK5d1DXoqagCSJE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=PCMAQIMu0cPBzIhBmWwEm6lVNNzr1ymgAroX6SsBqxDKJjSTwnnai9BeuPkV7LVfU 7u59yo7Nu+QrHWVS23aT6bAawnGu/KobGfnnV8VAHEAdsTpgqCKdp8Z98H9+QaUgJ3 9INwdbzXwkZbmXSM2eEPACUBKaAgJyLplMYYKOXx6p6qqXpwSLzAltQPZPMlHVpyGV YU3qzr8bJCWr+VUydgcf90PLPzhVf7YPHFlArYmj1kSLMbtu1Uk1PeyzDaI7Ny6wF9 uLBIXxqWGo4XCCICJ2IEOOGq/+XRNHdEtsQFOjKi5jEypm6cqwOS/jKLXBOjpWZPUd ztsyzj9SFaduA== Subject: Re: [PATCH net] net: hv_netvsc: Preserve RSS indirection table across device recreation 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 Date: Sun, 29 Nov 2026 07:10:52 +0000 Message-ID: <179593625222.3146.9294740311224290988@kernel.org> In-Reply-To: <20261125065620.1604647-1-gargaditya@linux.microsoft.com> References: <20261125065620.1604647-1-gargaditya@linux.microsoft.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-hyperv@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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