🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #1148

[PATCH] neighbour: Move the netdev_put() out of RCU callback

#1148
From: Zqiang
Date: Fri, 09 Oct 2026 09:19
57 lines
6930 bytes
For builts with CONFIG_NET_DEV_REFCNT_TRACKER=y kernels, netdev_put()
records the caller's stack trace via ref_tracker_free() for debugging
reference leaks. however, the netdev_put() is within pneigh_destroy()
RCU callback, this recorded stack is uninformative, it does not reveal
which code path initiated the deletion.

This commit therefore move netdev_put() from the RCU callback into the
caller's process context, and replace call_rcu() with kfree_rcu().

Fixes: d539d8fbd8fc ("neighbour: Free pneigh_entry after RCU grace period.")
Signed-off-by: Zqiang <qiang.zhang@linux.dev>
---
 net/core/neighbour.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 6ed8eb075146..4263689fc415 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -818,14 +818,6 @@ int pneigh_create(struct neigh_table *tbl,
 	return err;
 }
 
-static void pneigh_destroy(struct rcu_head *rcu)
-{
-	struct pneigh_entry *n = container_of(rcu, struct pneigh_entry, rcu);
-
-	netdev_put(n->dev, &n->dev_tracker);
-	kfree(n);
-}
-
 int pneigh_delete(struct neigh_table *tbl, const void *pkey,
 		  struct net_device *dev)
 {
@@ -849,7 +841,8 @@ int pneigh_delete(struct neigh_table *tbl, const void *pkey,
 			if (tbl->pdestructor)
 				tbl->pdestructor(n);
 
-			call_rcu(&n->rcu, pneigh_destroy);
+			netdev_put(n->dev, &n->dev_tracker);
+			kfree_rcu(n, rcu);
 			return 0;
 		}
 	}
@@ -891,7 +884,8 @@ static void pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev,
 		if (tbl->pdestructor)
 			tbl->pdestructor(n);
 
-		call_rcu(&n->rcu, pneigh_destroy);
+		netdev_put(n->dev, &n->dev_tracker);
+		kfree_rcu(n, rcu);
 	}
 }
 
-- 
2.17.1
Technical Details
Message-ID: <20261009091941.5837-1-qiang.zhang@linux.dev>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343549-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343549-linux-kernel-netdev=dewy.ru
From: qiang.zhang@linux.dev (Zqiang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH] neighbour: Move the netdev_put() out of RCU callback
Date: Fri,  9 Oct 2026 17:19:41 +0800
Organization: Usenet Network
Message-ID: <20261009091941.5837-1-qiang.zhang@linux.dev>
Injection-Info: usenet.network;
	logging-data="1073049"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rCTCULBsrAMmlIKF8PxMxi91Qu0= sha256:l+ssTkrOzJvRszK/fUqmjlHrZP0iZPwwEg5wE8X3xQM=
	sha1:WQsWBB9/umIwUe3C48KnpxSTgow= sha256:0jIbM/2DObLzapB7BecdcVsHnn/+5zvcpskJyG9Jtvg=
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 20FE810F634; Fri,  9 Oct 2026 12:25:20 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.751
X-Spam-Status: No, score=-0.751 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
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 FoLhyl1RFc2c;
	Fri,  9 Oct 2026 12:25:17 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-343549-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id A69CB10F61C; Fri,  9 Oct 2026 12:25:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 696FA2E9AC; Fri,  9 Oct 2026 09:19:59 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 98C203DDB00;
	Fri,  9 Oct 2026 09:19:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="EBkeodVV"
X-Received: from mta1.migadu.com (out-50.mta1.migadu.com [95.215.58.50])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AD0D3E2ADD
	for <netdev@vger.kernel.org>; Fri,  9 Oct 2026 09:19:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.50
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791537598; cv=none; b=koLuH4xlS3sW2JUuPZKwNQtiChTx+2LXkmPxexMluuf6NlV+k7T1EEaeg3GpXpioR5W84XoXYnc8oDcgZg60oiwuJsOV+pPjJjJl0nZRDFhAakhgaZKLX4Qe9Qpf0D4HES9p7KScd5/RlPj92AfoHSE1rpsPbQu4ABKacA62qek=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791537598; c=relaxed/simple;
	bh=ksBroh4OF2plcmIbcovrByuMBHM7UNbgzBZb/2QTmvE=;
	h=From:To:Cc:Subject:Date:Message-Id; b=tW5mdys5Qr7p5DxpQ3REGMZw6Zi63gh1z6LH6aKGbRz7COrqrbqTYOYM3pv4XnOePq0hIvi3SmgmwDnSAFmGWpNfvOYD/WLrpZTqf8slAMn5RaUdBUvU/TOP3QbgvKFNTX8GOy/xbrMCH46gKR3X8VBB4+4a/+urPT3DwXK+YRg=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=EBkeodVV; arc=none smtp.client-ip=95.215.58.50
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=ksBroh4OF2plcmIbcovrByuMBHM7UNbgzBZb/2QTmvE=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1791537585; v=1; x=1792142385;
 b=EBkeodVVszkZHqmSIuCNd/bn2uVilfdiSSa30Cyfq+EF9mrC74AQRjD4+fXx+sahDHJBCCIe
 ciwWDqscJKsVSOI0x3ht9k5F3y2QP/1onsYti1RyswpBOw722jjrov0g4y2Oew6wmI5Y/VFlENq
 B0VWJ2zar1cJpQHhjUQ1pTdE=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 38152ee524beeb58;
	Fri, 09 Oct 2026 09:19:45 +0000
X-Mizu-Trace-ID: 38152ee524beeb58
X-Migadu-Flow: FLOW_OUT
X-Cc: qiang.zhang@linux.dev,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.17.1
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>