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=1796176533; b=ypDc1ukaH6WqboTQ01v4LvrWThejTNaGEf3qzSUClGGAOI1mnJY59KXvKbPx7wfKRa6X xXZWeKtC+n8QMusny/gfe21ptbNA9tQrOOqaIxVYeFs8xRPjp7xTpUhqAkrSWH24vN4Mo FDHr6lqepcXYeEALncgdtGEVkqKzmebbU7Yr49HB2mcDFKDTWK1WAytBiPCpWr0KeFwDs eyIE9CEX4ocZGYOynDPXV/6puspFWIPNtGZIL4zbEj0qBXvk7Bzb2X4FRRte+MtomEDHC kB5u/oMWIXQx02biqHLKptvCMLi46o3Fmf0q/t1MWjKh2o+8Xo1ylzV5BuMa6Zv0T/g== 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== 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 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 ; Wed, 2 Dec 2026 01:55:33 +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=c6/V7nm4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EC3F1F00897; Wed, 2 Dec 2026 01:55:32 +0000 (UTC) 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== From: David Ahern To: netdev@vger.kernel.org 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 Subject: [PATCH net-next 1/2] ipv6: remove dst_ops gc handler Date: Tue, 1 Dec 2026 18:55:22 -0700 Message-ID: <20261202015529.7846-2-dsahern@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261202015529.7846-1-dsahern@kernel.org> References: <20261202015529.7846-1-dsahern@kernel.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: David Ahern 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 --- 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)