🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25556

[PATCH net-next 1/2] ipv6: remove dst_ops gc handler

#25556
From: David Ahern
Date: Wed, 02 Dec 2026 01:55
204 lines
15221 bytes
From: David Ahern <dahern@nvidia.com>

Remove ip6_dst_gc(), the dst_ops->gc callback that dst_alloc() invoked
synchronously whenever the dst entry count exceeded gc_thresh, together
with its per-netns state (ip6_rt_gc_expire and ip6_rt_last_gc).

Growth of the IPv6 dst cache is instead bounded the same way IPv4
bounds it: cached exceptions live in a hash whose buckets are limited
to a randomized depth, with the oldest entry evicted on insert (see
rt6_insert_exception() and FIB6_MAX_DEPTH, cf. fnhe_remove_oldest() and
FNHE_RECLAIM_DEPTH in net/ipv4/route.c), and per-cpu routes are bounded
by the number of nexthops. Expiry is still handled by the FIB6 gc timer
(gc_interval) and the fib6_run_gc() calls on device events and route
flush. Like IPv4, set the dst_ops gc_thresh default to ~0 since no
threshold is enforced any more.

Mark the gc_thresh, gc_min_interval, gc_min_interval_ms, gc_timeout and
gc_elasticity sysctls as deprecated: they are retained so existing
scripts keep working, but a write now logs a one-time warning that the
setting has no effect. gc_interval is unchanged and still sets the
period of the FIB6 gc timer.

Signed-off-by: David Ahern <dahern@nvidia.com>
---
 include/net/netns/ipv6.h |  2 --
 net/ipv6/ip6_fib.c       |  1 -
 net/ipv6/route.c         | 74 +++++++++++++++++++++++-----------------
 3 files changed, 42 insertions(+), 35 deletions(-)

diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
index aefce37c04a4..ca4462353328 100644
--- a/include/net/netns/ipv6.h
+++ b/include/net/netns/ipv6.h
@@ -82,8 +82,6 @@ struct netns_ipv6 {
 	struct list_head	fib6_walkers;
 	rwlock_t		fib6_walker_lock;
 	spinlock_t		fib6_gc_lock;
-	atomic_t		ip6_rt_gc_expire;
-	unsigned long		ip6_rt_last_gc;
 	unsigned char		flowlabel_has_excl;
 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
 	bool			fib6_has_custom_rules;
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index e1d49897d6ab..2095f023c137 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -2464,7 +2464,6 @@ void fib6_run_gc(unsigned long expires, struct net *net, bool force)
 
 	fib6_gc_all(net, &gc_args);
 	now = jiffies;
-	net->ipv6.ip6_rt_last_gc = now;
 
 	if (gc_args.more)
 		mod_timer(&net->ipv6.ip6_fib_timer,
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index df843178e5ec..14c95d132e1f 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -92,7 +92,6 @@ static void		ip6_negative_advice(struct sock *sk,
 static void		ip6_dst_destroy(struct dst_entry *);
 static void		ip6_dst_ifdown(struct dst_entry *,
 				       struct net_device *dev);
-static void		 ip6_dst_gc(struct dst_ops *ops);
 
 static int		ip6_pkt_discard(struct sk_buff *skb);
 static int		ip6_pkt_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb);
@@ -271,8 +270,7 @@ static void ip6_confirm_neigh(const struct dst_entry *dst, const void *daddr)
 
 static struct dst_ops ip6_dst_ops_template = {
 	.family			=	AF_INET6,
-	.gc			=	ip6_dst_gc,
-	.gc_thresh		=	1024,
+	.gc_thresh		=	~0,
 	.check			=	ip6_dst_check,
 	.default_advmss		=	ip6_default_advmss,
 	.mtu			=	ip6_mtu,
@@ -3367,28 +3365,6 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
 	return dst;
 }
 
-static void ip6_dst_gc(struct dst_ops *ops)
-{
-	struct net *net = container_of(ops, struct net, ipv6.ip6_dst_ops);
-	int rt_min_interval = READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_min_interval);
-	int rt_elasticity = READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_elasticity);
-	int rt_gc_timeout = READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_timeout);
-	unsigned long rt_last_gc = READ_ONCE(net->ipv6.ip6_rt_last_gc);
-	unsigned int val;
-	int entries;
-
-	if (time_after(rt_last_gc + rt_min_interval, jiffies))
-		goto out;
-
-	fib6_run_gc(atomic_inc_return(&net->ipv6.ip6_rt_gc_expire), net, true);
-	entries = dst_entries_get_slow(ops);
-	if (entries < ops->gc_thresh)
-		atomic_set(&net->ipv6.ip6_rt_gc_expire, rt_gc_timeout >> 1);
-out:
-	val = atomic_read(&net->ipv6.ip6_rt_gc_expire);
-	atomic_set(&net->ipv6.ip6_rt_gc_expire, val - (val >> rt_elasticity));
-}
-
 static int ip6_nh_lookup_table(struct net *net, struct fib6_config *cfg,
 			       const struct in6_addr *gw_addr, u32 tbid,
 			       int flags, struct fib6_result *res)
@@ -6615,6 +6591,42 @@ static int ipv6_sysctl_rtcache_flush(const struct ctl_table *ctl, int write,
 
 static unsigned int ip6_rt_gc_elasticity_max = 31;
 
+static void ip6_rt_gc_sysctl_warn(const struct ctl_table *ctl, int write)
+{
+	if (write)
+		pr_warn_once("%s: net.ipv6.route.%s is deprecated and has no effect\n",
+			     current->comm, ctl->procname);
+}
+
+static int ip6_rt_gc_dointvec(const struct ctl_table *ctl, int write,
+			      void *buffer, size_t *lenp, loff_t *ppos)
+{
+	ip6_rt_gc_sysctl_warn(ctl, write);
+	return proc_dointvec(ctl, write, buffer, lenp, ppos);
+}
+
+static int ip6_rt_gc_dointvec_jiffies(const struct ctl_table *ctl, int write,
+				      void *buffer, size_t *lenp, loff_t *ppos)
+{
+	ip6_rt_gc_sysctl_warn(ctl, write);
+	return proc_dointvec_jiffies(ctl, write, buffer, lenp, ppos);
+}
+
+static int ip6_rt_gc_dointvec_ms_jiffies(const struct ctl_table *ctl, int write,
+					 void *buffer, size_t *lenp,
+					 loff_t *ppos)
+{
+	ip6_rt_gc_sysctl_warn(ctl, write);
+	return proc_dointvec_ms_jiffies(ctl, write, buffer, lenp, ppos);
+}
+
+static int ip6_rt_gc_dou8vec_minmax(const struct ctl_table *ctl, int write,
+				    void *buffer, size_t *lenp, loff_t *ppos)
+{
+	ip6_rt_gc_sysctl_warn(ctl, write);
+	return proc_dou8vec_minmax(ctl, write, buffer, lenp, ppos);
+}
+
 static const struct ctl_table ipv6_route_table_template[] = {
 	{
 		.procname	=	"max_size",
@@ -6628,7 +6640,7 @@ static const struct ctl_table ipv6_route_table_template[] = {
 		.data		=	&ip6_dst_ops_template.gc_thresh,
 		.maxlen		=	sizeof(int),
 		.mode		=	0644,
-		.proc_handler	=	proc_dointvec,
+		.proc_handler	=	ip6_rt_gc_dointvec,
 	},
 	{
 		.procname	=	"flush",
@@ -6642,14 +6654,14 @@ static const struct ctl_table ipv6_route_table_template[] = {
 		.data		=	&init_net.ipv6.sysctl.ip6_rt_gc_min_interval,
 		.maxlen		=	sizeof(int),
 		.mode		=	0644,
-		.proc_handler	=	proc_dointvec_jiffies,
+		.proc_handler	=	ip6_rt_gc_dointvec_jiffies,
 	},
 	{
 		.procname	=	"gc_timeout",
 		.data		=	&init_net.ipv6.sysctl.ip6_rt_gc_timeout,
 		.maxlen		=	sizeof(int),
 		.mode		=	0644,
-		.proc_handler	=	proc_dointvec_jiffies,
+		.proc_handler	=	ip6_rt_gc_dointvec_jiffies,
 	},
 	{
 		.procname	=	"gc_interval",
@@ -6663,7 +6675,7 @@ static const struct ctl_table ipv6_route_table_template[] = {
 		.data		=	&init_net.ipv6.sysctl.ip6_rt_gc_elasticity,
 		.maxlen		=	sizeof(u8),
 		.mode		=	0644,
-		.proc_handler	=	proc_dou8vec_minmax,
+		.proc_handler	=	ip6_rt_gc_dou8vec_minmax,
 		.extra2		=	&ip6_rt_gc_elasticity_max,
 	},
 	{
@@ -6685,7 +6697,7 @@ static const struct ctl_table ipv6_route_table_template[] = {
 		.data		=	&init_net.ipv6.sysctl.ip6_rt_gc_min_interval,
 		.maxlen		=	sizeof(int),
 		.mode		=	0644,
-		.proc_handler	=	proc_dointvec_ms_jiffies,
+		.proc_handler	=	ip6_rt_gc_dointvec_ms_jiffies,
 	},
 	{
 		.procname	=	"skip_notify_on_dev_down",
@@ -6796,8 +6808,6 @@ static int __net_init ip6_route_net_init(struct net *net)
 	net->ipv6.sysctl.ip6_rt_min_advmss = IPV6_MIN_MTU - 20 - 40;
 	net->ipv6.sysctl.skip_notify_on_dev_down = 0;
 
-	atomic_set(&net->ipv6.ip6_rt_gc_expire, 30*HZ);
-
 	ret = 0;
 out:
 	return ret;
-- 
2.54.0 (Apple Git-157)
Technical Details
Message-ID: <20261202015529.7846-2-dsahern@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!feed-us-ny.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375480-linux-kernel-netdev=dewy.ru
References: <20261202015529.7846-1-dsahern@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!feed-us-ny.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375480-linux-kernel-netdev=dewy.ru
From: dsahern@kernel.org (David Ahern)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next 1/2] ipv6: remove dst_ops gc handler
Date: Tue,  1 Dec 2026 18:55:22 -0700
Organization: Usenet Network
Message-ID: <20261202015529.7846-2-dsahern@kernel.org>
References: <20261202015529.7846-1-dsahern@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1864138"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:L2Y6zte/ZZl2lvxcPCAi5TlIUOk= sha256:lnLSTQF9GNraEUjkuu3wKABH4I5OWPmPExWRMJ5p3BY=
	sha1:hFOIeyfDzl6DMMjThAYpef0UPww= sha256:Xvrb2rDxlzHZAx0oE4il+3Nkwa4ZsnHN5A+oEhQ+NKo=
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 45523117508; Wed,  2 Dec 2026 04:55:49 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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] 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 KsiY0BRfaFrZ;
	Wed,  2 Dec 2026 04:55:46 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375480-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 1FC88117518; Wed,  2 Dec 2026 04:55:37 +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 60BE02ACE4; Wed,  2 Dec 2026 01:55:34 +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=1796176534;
	b=fIMwBD4M4NAhqliOcKtYbkZqkQTfqIqE1LVETY8YEqsKa1IOX7dEegt2qPWxQ/7GEDL7
	 fyHYTS6gTR9k9fmeFLXzdD8zyPqcIxJMMeEgCaTd5yq0s55pAEVrmHNbM9b7bLyXTNOPY
	 Fq5EdPHSIuVCs65srwN+fgMIhx4aW6ODI8Yrdwla+4NUMTT3fYMv/TXFW7FynKez8I/qq
	 WWo7Kbs8xxwo/zEbs4vgOmxidJEWlVpOhZHeymjufGBZZv+258z0HFOHc+Hwxyu7GpOeb
	 QpqgS0XCbPgqj2lmqnBw1atUaKPDRHguj0ZWHhmReOmE4xyd1OdEYSPgLpiqGnqkjHw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796176534;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=WgnZiwYeK/A4vyUDWAUDiWQtjavL2eMTFVAYlVQa8MA=;
	b=5tg5pPG1Cjt9d3wkWpXymR4F3kHkTHZqzbX+Zetra3029viddmMy7REV09hNq9nOe07Z
	 j2ITdoWkynub0UwB5NKKFfwt/YVFY1IrVUwLMVxCxQrEg/HP0GNR3HtdwUmeUOXj4RVGF
	 kSaf0BGyvcRZJ+Nl9VumqPwdcsRiU7jf/Aw1S759WR14P1Di0dSfOE2YXg96MsNdiT2te
	 AFgW+FeLa9SjnPu3YlpJ9ESTWSKctLtSIMAl9933mOLgiy1OkrWIyMUCawqigwHIuxq/n
	 e/0b3S666oyXGS6GdPLYTH8v3ElKbp4rHllr1FV7U0U27SEpI0VcmpxHQ4cAr1yTC0Q==
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="c6/V7nm4";
	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 37194606A32F;
	Wed,  2 Dec 2026 01:55:34 +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=c6/V7nm4
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=1796176533;
	b=ypDc1ukaH6WqboTQ01v4LvrWThejTNaGEf3qzSUClGGAOI1mnJY59KXvKbPx7wfKRa6X
	 xXZWeKtC+n8QMusny/gfe21ptbNA9tQrOOqaIxVYeFs8xRPjp7xTpUhqAkrSWH24vN4Mo
	 FDHr6lqepcXYeEALncgdtGEVkqKzmebbU7Yr49HB2mcDFKDTWK1WAytBiPCpWr0KeFwDs
	 eyIE9CEX4ocZGYOynDPXV/6puspFWIPNtGZIL4zbEj0qBXvk7Bzb2X4FRRte+MtomEDHC
	 kB5u/oMWIXQx02biqHLKptvCMLi46o3Fmf0q/t1MWjKh2o+8Xo1ylzV5BuMa6Zv0T/g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796176533;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=WgnZiwYeK/A4vyUDWAUDiWQtjavL2eMTFVAYlVQa8MA=;
	b=eedfhAZVweYl5gj01qfn8SClqK+Hyh46B5T30t7/+L3spI+Cptc6opLHsTB2OyUP9Ry9
	 bmpmAZ8rTd0wCreArldONtW4Bpg+SaCWy05agcwF0NZAaELluS1C8SJ61X+NKpoWXdl0O
	 C4CEgF/g2oileD/O0t62K4EsPNjMWFSlJLUCJRoHSGu/w2MRh8JsAVkRXeU2zikIBga5Y
	 2ZCJ8hFdO84wLN4uryJVTWU9j2NVygqO+VEbsbZb1suQhAeduLm1s1f9U4fMz+ju3dvo9
	 vF10Gc/ACMA0IjcqA+qSiaXdNpar9ZsF35meVAJ6BRuiD1ruLAgZ5ziXRyl8fJTME5g==
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="c6/V7nm4";
	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 59A15606A327
	for <netdev@vger.kernel.org>; Wed,  2 Dec 2026 01:55:33 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EC3F1F00897;
	Wed,  2 Dec 2026 01:55:32 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796176533;
	bh=WgnZiwYeK/A4vyUDWAUDiWQtjavL2eMTFVAYlVQa8MA=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=c6/V7nm4OV/42gUlwn5P4GTYuaGuwc6YPl8AwjT8u4K7xpQfpgMgSux5wz/kemV6U
	 XKj1ZQtyhq5ImQvyOGrdw0zAie5QOZvZHncC4vMAGmnrMxUd9W5lppcSA6AEFBHEkb
	 BnVH0OUE/J3+PPFJf2lqvM/kJVdsKzUuGkC7uk8iuJzVkXeg+fPCqcF7maygyOBnfz
	 YG51GXKSckGgfGCDzk1Id291Nv0Ci1V8zr2TQ9GWDddlWR3ts0MQMQbi3yyOdT4Af0
	 4j8u1FOzESQ0qxWHQXSGRPFHfesH5aAMvHNfF03RoAjtVnDLHuaDvFw3EJPYVBve6G
	 DSLvzT14J216A==
X-Cc: dsahern@kernel.org,
	idosch@nvidia.com,
	davem@davemloft.net,
	edumazet@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	willemb@google.com,
	horms@kernel.org,
	David Ahern <dahern@nvidia.com>
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261202015529.7846-1-dsahern@kernel.org>
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