From: David Ahern <dahe…@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 <dahe…@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)