Skip to content

Commit 3ee9437

Browse files
nhormandavem330
authored andcommitted
ipv4: remove ip_rt_secret timer (v4)
A while back there was a discussion regarding the rt_secret_interval timer. Given that we've had the ability to do emergency route cache rebuilds for awhile now, based on a statistical analysis of the various hash chain lengths in the cache, the use of the flush timer is somewhat redundant. This patch removes the rt_secret_interval sysctl, allowing us to rely solely on the statistical analysis mechanism to determine the need for route cache flushes. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e0e3328 commit 3ee9437

3 files changed

Lines changed: 8 additions & 102 deletions

File tree

‎include/net/netns/ipv4.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ struct netns_ipv4 {
5555
int sysctl_rt_cache_rebuild_count;
5656
int current_rt_cache_rebuild_count;
5757

58-
struct timer_list rt_secret_timer;
5958
atomic_t rt_genid;
6059

6160
#ifdef CONFIG_IP_MROUTE

‎kernel/sysctl_binary.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ static const struct bin_table bin_net_ipv4_route_table[] = {
224224
{ CTL_INT, NET_IPV4_ROUTE_MTU_EXPIRES, "mtu_expires" },
225225
{ CTL_INT, NET_IPV4_ROUTE_MIN_PMTU, "min_pmtu" },
226226
{ CTL_INT, NET_IPV4_ROUTE_MIN_ADVMSS, "min_adv_mss" },
227-
{ CTL_INT, NET_IPV4_ROUTE_SECRET_INTERVAL, "secret_interval" },
228227
{}
229228
};
230229

‎net/ipv4/route.c‎

Lines changed: 8 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ static int ip_rt_gc_elasticity __read_mostly = 8;
129129
static int ip_rt_mtu_expires __read_mostly = 10 * 60 * HZ;
130130
static int ip_rt_min_pmtu __read_mostly = 512 + 20 + 20;
131131
static int ip_rt_min_advmss __read_mostly = 256;
132-
static int ip_rt_secret_interval __read_mostly = 10 * 60 * HZ;
133132
static int rt_chain_length_max __read_mostly = 20;
134133

135134
static struct delayed_work expires_work;
@@ -918,32 +917,11 @@ void rt_cache_flush_batch(void)
918917
rt_do_flush(!in_softirq());
919918
}
920919

921-
/*
922-
* We change rt_genid and let gc do the cleanup
923-
*/
924-
static void rt_secret_rebuild(unsigned long __net)
925-
{
926-
struct net *net = (struct net *)__net;
927-
rt_cache_invalidate(net);
928-
mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval);
929-
}
930-
931-
static void rt_secret_rebuild_oneshot(struct net *net)
932-
{
933-
del_timer_sync(&net->ipv4.rt_secret_timer);
934-
rt_cache_invalidate(net);
935-
if (ip_rt_secret_interval)
936-
mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval);
937-
}
938-
939920
static void rt_emergency_hash_rebuild(struct net *net)
940921
{
941-
if (net_ratelimit()) {
922+
if (net_ratelimit())
942923
printk(KERN_WARNING "Route hash chain too long!\n");
943-
printk(KERN_WARNING "Adjust your secret_interval!\n");
944-
}
945-
946-
rt_secret_rebuild_oneshot(net);
924+
rt_cache_invalidate(net);
947925
}
948926

949927
/*
@@ -3101,48 +3079,6 @@ static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write,
31013079
return -EINVAL;
31023080
}
31033081

3104-
static void rt_secret_reschedule(int old)
3105-
{
3106-
struct net *net;
3107-
int new = ip_rt_secret_interval;
3108-
int diff = new - old;
3109-
3110-
if (!diff)
3111-
return;
3112-
3113-
rtnl_lock();
3114-
for_each_net(net) {
3115-
int deleted = del_timer_sync(&net->ipv4.rt_secret_timer);
3116-
long time;
3117-
3118-
if (!new)
3119-
continue;
3120-
3121-
if (deleted) {
3122-
time = net->ipv4.rt_secret_timer.expires - jiffies;
3123-
3124-
if (time <= 0 || (time += diff) <= 0)
3125-
time = 0;
3126-
} else
3127-
time = new;
3128-
3129-
mod_timer(&net->ipv4.rt_secret_timer, jiffies + time);
3130-
}
3131-
rtnl_unlock();
3132-
}
3133-
3134-
static int ipv4_sysctl_rt_secret_interval(ctl_table *ctl, int write,
3135-
void __user *buffer, size_t *lenp,
3136-
loff_t *ppos)
3137-
{
3138-
int old = ip_rt_secret_interval;
3139-
int ret = proc_dointvec_jiffies(ctl, write, buffer, lenp, ppos);
3140-
3141-
rt_secret_reschedule(old);
3142-
3143-
return ret;
3144-
}
3145-
31463082
static ctl_table ipv4_route_table[] = {
31473083
{
31483084
.procname = "gc_thresh",
@@ -3251,13 +3187,6 @@ static ctl_table ipv4_route_table[] = {
32513187
.mode = 0644,
32523188
.proc_handler = proc_dointvec,
32533189
},
3254-
{
3255-
.procname = "secret_interval",
3256-
.data = &ip_rt_secret_interval,
3257-
.maxlen = sizeof(int),
3258-
.mode = 0644,
3259-
.proc_handler = ipv4_sysctl_rt_secret_interval,
3260-
},
32613190
{ }
32623191
};
32633192

@@ -3336,34 +3265,15 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
33363265
};
33373266
#endif
33383267

3339-
3340-
static __net_init int rt_secret_timer_init(struct net *net)
3268+
static __net_init int rt_genid_init(struct net *net)
33413269
{
3342-
atomic_set(&net->ipv4.rt_genid,
3343-
(int) ((num_physpages ^ (num_physpages>>8)) ^
3344-
(jiffies ^ (jiffies >> 7))));
3345-
3346-
net->ipv4.rt_secret_timer.function = rt_secret_rebuild;
3347-
net->ipv4.rt_secret_timer.data = (unsigned long)net;
3348-
init_timer_deferrable(&net->ipv4.rt_secret_timer);
3349-
3350-
if (ip_rt_secret_interval) {
3351-
net->ipv4.rt_secret_timer.expires =
3352-
jiffies + net_random() % ip_rt_secret_interval +
3353-
ip_rt_secret_interval;
3354-
add_timer(&net->ipv4.rt_secret_timer);
3355-
}
3270+
get_random_bytes(&net->ipv4.rt_genid,
3271+
sizeof(net->ipv4.rt_genid));
33563272
return 0;
33573273
}
33583274

3359-
static __net_exit void rt_secret_timer_exit(struct net *net)
3360-
{
3361-
del_timer_sync(&net->ipv4.rt_secret_timer);
3362-
}
3363-
3364-
static __net_initdata struct pernet_operations rt_secret_timer_ops = {
3365-
.init = rt_secret_timer_init,
3366-
.exit = rt_secret_timer_exit,
3275+
static __net_initdata struct pernet_operations rt_genid_ops = {
3276+
.init = rt_genid_init,
33673277
};
33683278

33693279

@@ -3424,9 +3334,6 @@ int __init ip_rt_init(void)
34243334
schedule_delayed_work(&expires_work,
34253335
net_random() % ip_rt_gc_interval + ip_rt_gc_interval);
34263336

3427-
if (register_pernet_subsys(&rt_secret_timer_ops))
3428-
printk(KERN_ERR "Unable to setup rt_secret_timer\n");
3429-
34303337
if (ip_rt_proc_init())
34313338
printk(KERN_ERR "Unable to create route proc files\n");
34323339
#ifdef CONFIG_XFRM
@@ -3438,6 +3345,7 @@ int __init ip_rt_init(void)
34383345
#ifdef CONFIG_SYSCTL
34393346
register_pernet_subsys(&sysctl_route_ops);
34403347
#endif
3348+
register_pernet_subsys(&rt_genid_ops);
34413349
return rc;
34423350
}
34433351

0 commit comments

Comments
 (0)