🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #22474

Re: [PATCH net v2] netdevsim: fix rate node leak during reload and removal

#22474
From: netdev-bot+sashiko
Date: Wed, 25 Nov 2026 11:22
108 lines
12001 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · 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] The fix is incomplete: rate nodes still leak, and the same
  WARNs still fire, when the device has been left in the devlink…

--

netdevsim: fix rate node leak during reload and removal

nsim_dev_reload_destroy() now checks the eswitch mode unconditionally.
Rate nodes created on a zero-VF switchdev device are then destroyed via
nsim_esw_legacy_enable() -> devl_rate_nodes_destroy() on both reload and
removal, which avoids the devlink_free() and
devlink_reload_reinit_sanity_check() WARNs.

Link: https://lore.kernel.org/all/17cc4251-04ae-41a7-a872-fc5cf525b58f@linux.dev/

> diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
> index c6b17b3873271..b483c25dfecdd 100644
> --- a/drivers/net/netdevsim/dev.c
> +++ b/drivers/net/netdevsim/dev.c
> @@ -1700,11 +1700,10 @@ static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev)
>  		return;
>  	debugfs_remove(nsim_dev->take_snapshot);
>  
> -	if (nsim_dev_get_vfs(nsim_dev)) {
> +	if (nsim_dev_get_vfs(nsim_dev))
>  		nsim_bus_dev_set_vfs(nsim_dev->nsim_bus_dev, 0);
> -		if (nsim_esw_mode_is_switchdev(nsim_dev))
> -			nsim_esw_legacy_enable(nsim_dev, NULL);
> -	}
> +	if (nsim_esw_mode_is_switchdev(nsim_dev))
> +		nsim_esw_legacy_enable(nsim_dev, NULL);

[Severity: Medium]
Can rate nodes still leak when the device is in the reload_failed state?

The new unconditional check sits after the early return at the top of
nsim_dev_reload_destroy():

drivers/net/netdevsim/dev.c:nsim_dev_reload_destroy() {
    ...
	if (devlink_is_reload_failed(devlink))
		return;
    ...
}

When reload_failed is set, devl_rate_nodes_destroy() is never reached.

Nothing seems to stop rate nodes from being created while reload_failed
is set. One possible sequence:

1) devlink dev reload runs nsim_dev_reload_down(), which resets
   esw_mode to legacy. nsim_dev_reload_up() then fails, either through
   the fail_reload debugfs knob (returns -EINVAL) or through an error in
   nsim_dev_reload_create(). devlink_reload() then calls:

	devlink_reload_failed_set(devlink, !!err);

2) devlink dev eswitch set ... mode switchdev still succeeds. With zero
   VFs, nsim_esw_switchdev_enable() only does:

	nsim_dev->esw_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV;

   No devlink command in net/devlink/ checks reload_failed.

3) devlink port function rate add .../n1 also succeeds.
   devlink_nl_rate_new_doit() has no reload_failed check, and
   nsim_rate_node_new() only checks nsim_esw_mode_is_switchdev(). The
   node is added to devlink->rate_list.

4) del_device leads to nsim_drv_remove() -> nsim_dev_reload_destroy(),
   which returns early. nsim_drv_remove() has no other rate cleanup, so
   devlink_free() hits:

	WARN_ON(devlink_rates_check(devlink, NULL, NULL));

   The devlink_rate and nsim_rate_node allocations and their debugfs
   directories are leaked.

If step 4 is a second devlink dev reload instead,
nsim_dev_reload_down() -> nsim_dev_reload_destroy() returns early again,
and the WARN in devlink_reload_reinit_sanity_check() fires.

These are the same two WARNs the commit message describes. The early
return is older than this patch. However, the subject promises to fix the
rate node leak during reload and removal, and this case is still
reachable.

Would it make sense to also destroy the rate nodes before the
reload_failed early return, or in nsim_drv_remove()?

>  
>  	nsim_dev_port_del_all(nsim_dev);
>  	nsim_dev_hwstats_exit(nsim_dev);

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121110858.1337003-1-xietangxin%40h-partners.com
Technical Details
Message-ID: <179560577028.3135.18386607599971206035@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371259-linux-kernel-netdev=dewy.ru
References: <20261121110858.1337003-1-xietangxin@h-partners.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371259-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] netdevsim: fix rate node leak during reload and removal
Date: Wed, 25 Nov 2026 11:22:50 +0000
Organization: Usenet Network
Message-ID: <179560577028.3135.18386607599971206035@kernel.org>
References: <20261121110858.1337003-1-xietangxin@h-partners.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="192275"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dGKCnQ/ZPV7Pyz1utHHkDKZHTe8= sha256:VODhndolRFgCAqjWEJx0Ngw66gd2hXssNzpDM26pWQQ=
	sha1:vkPPzrhzcpb1BtkCwHNjp4NoWQY= sha256:8W/WTg3trbIDwMkWioOXMGg5Hthu2vId8Hz00UU4pVc=
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 912DF125E55; Wed, 25 Nov 2026 14:24:05 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
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 tdci3Sd6RwXY;
	Wed, 25 Nov 2026 14:24:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-371259-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 89EDC125E57; Wed, 25 Nov 2026 14:23:50 +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 AE83F2F675; Wed, 25 Nov 2026 11:23:01 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795605772;
	b=rS0j+nlPbaKSkz1bFY6uiawtckvLzXB5td2kNIXDkwMY1sJtcvbIu5Wk2wmJbBSLUTqX
	 mVK7PIcYpC097uhbpuCgnBoRTpp9KhW/GesQZcsv00HUBPb3Isa/WaHBZZ56Ou8MI/E3y
	 j/jAhY9dr9dE8YrnhnmWAiUYZyYf56pwjuUW4M4e0weQD/Q0z7nDaAwkcxisfGnUpOlK1
	 +d8nLSgx9yeyibW/I6RhQ7PkDV8IWhJ5lSJLRJyWzoEkodhLrTcMNUqq4VCF7UQCFbxsx
	 AGIpKKoMYbuyaNTzrzh+qsnmTtdZF7jcxIZ1/NLa68FJxTWxQK8r2pshdrDYAwrllpA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795605772;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=Ykzuj/zaY6gslsjzhbJvcRZzYsnVjN0GyJsjC47/W18=;
	b=UyJ3cJKLgqiprqSdxQyQElX4vMYc1kuTVpU5J+SfAZTVggdXwaBz8e8mXItVCejEAL//
	 LjGPdkjLW2mfjvcwTvFPEjYmdCZEF/psYZ1hUQIajax+ZtTgY9MK5b1euGgjI211lieDG
	 +0ipWP82Y13+rgkBhHfoM4qyCGAeXTckYVWuppRJxCfzL3Yg92boQ1YXyA70T9ek3S4Zk
	 cO9/6gT2Zv4+WeCevp/d+IsDTXYW3DHGV9u9MD3mVGNJ44+dzIGSatdcMQYqtX3kxdV1q
	 K/W81OTcS64xISaSbIdQrVFlK5iV/SID2XXgyqlrcdQpYStjv+ZA25UhRpG99Ae/0yg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aqUl1elz;
	arc=pass header.oldest-pass=0 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 9DF8C606A338;
	Wed, 25 Nov 2026 11:22:52 +0000 (UTC)
X-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=aqUl1elz
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795605771;
	b=gdXmn/qt8xjnk+GdAg9TvpAAHgOcDX5U1YAp9J3KYHHION9PI5YYT/OauimMXxvk1u7C
	 rMlZWuRgwNqCIe58u9M8Qi8mGmM9ocmjhRLF1gOwcSbZfxT18RA0spft5H/QusQRopr91
	 7bjkjVEaGc1WF3zfqsVBn3Sm4+KhKbgDt5z8Oznbfz/eVfurLiZpb7/5gemX/mrZS1igJ
	 rffHYVMcY9aveXVfA4CNMX2wrGXAyMGStmyHhdDruyCHntHOAVFGvJslSJcFApuFNYdsa
	 /OpBAvvlBgC6m43TvjMrBdge96LdUbwr7bb6bmQcphKk/MZ8fOXMKEe9vnY/YNOgwxA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795605771;
	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=Ykzuj/zaY6gslsjzhbJvcRZzYsnVjN0GyJsjC47/W18=;
	b=NUgRQn1OOC1mQeaf61AGAfIGFysAtCnQyLnmToqOObGk0apEdClXVMYvKWozqse0p0Po
	 V0x7BJd+PdOz8ubgQLY/Urw9RX0HHADkI2yj6zAiY7kXIBgpASoAy3EewUtudNruZOw7I
	 caBgwz70kL6VGN2Dka1Nc6g2x8/3qwHFPU/xu6xZPUXLdD4Hp202q20KcrDuqgntROLid
	 bA9Zav/3yuzqV/kI5PjIaaJXKXXhOiq2YXLr+X2fBPlQRSb17Pm9GQRUUAUE6E44GJM0l
	 gSJKtZzQNShcsujZGfL3VJJ0CUN47czfbkrLZvwnYTBXsRhEF3PWt9nopyHpFhZIVaA==
X-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=aqUl1elz;
	arc=none smtp.remote-ip=100.103.45.18
X-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 C0BDE606A31E;
	Wed, 25 Nov 2026 11:22:51 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC92B1F000CF;
	Wed, 25 Nov 2026 11:22:50 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795605771;
	bh=Ykzuj/zaY6gslsjzhbJvcRZzYsnVjN0GyJsjC47/W18=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=aqUl1elz3yTedvagE4ap1hYKrnCKuXMvv2B2OTA9F6VtfGiKNq52APuaqULyb2L9d
	 DT+JIWg2RE4X3/El8P+TEtWW4FlEb9hpoEDNZ2uDdTt9g9SEyDx9wZuP85epKfxiE8
	 xSlGLRLfoGRkazc1SvAc23csHe6kkA96Rcv+gBue4LcHF3XmgJqgc3nGLCvGQzOMeQ
	 ci0Ihaa5zUWgggMPuq1yYv3VApjic7gNVgm3GWtIqmByxRLLlRzWDGwnHwkenYvma3
	 JPQh9MJv7i7SWveyk14fef2oLss5xwpP14pLSQ7SqJ8AT5SRsyJiltFJocOcxDCutw
	 +QdtOIqHxiH5Q==
X-Cc: kuba@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, pabeni@redhat.com, dlinkin@nvidia.com, vladbu@nvidia.com,
 jiri@resnulli.us, netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
 stable@vger.kernel.org, syzbot+bbd81e1e2276c534dea1@syzkaller.appspotmail.com,
 gaoxingwang1@huawei.com, huyizhen2@huawei.com, xuanqiang.luo@linux.dev
X-In-Reply-To: <20261121110858.1337003-1-xietangxin@h-partners.com>
X-sashiko-severity: Medium
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