aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorNeil Horman <nhorman@tuxdriver.com>2010-05-08 04:57:52 -0400
committerDavid S. Miller <davem@davemloft.net>2010-05-08 04:57:52 -0400
commit3ee943728fff536edaf8f59faa58aaa1aa7366e3 (patch)
tree98ab529c1be1e4cb4b291c9d4c9fc9dba678967e /net/ipv4/route.c
parente0e33280fedcfa9dd70a54085c4d44d9d53b788f (diff)
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>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c108
1 files changed, 8 insertions, 100 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a947428ef0ae..dea3f9264250 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -129,7 +129,6 @@ static int ip_rt_gc_elasticity __read_mostly = 8;
129static int ip_rt_mtu_expires __read_mostly = 10 * 60 * HZ; 129static int ip_rt_mtu_expires __read_mostly = 10 * 60 * HZ;
130static int ip_rt_min_pmtu __read_mostly = 512 + 20 + 20; 130static int ip_rt_min_pmtu __read_mostly = 512 + 20 + 20;
131static int ip_rt_min_advmss __read_mostly = 256; 131static int ip_rt_min_advmss __read_mostly = 256;
132static int ip_rt_secret_interval __read_mostly = 10 * 60 * HZ;
133static int rt_chain_length_max __read_mostly = 20; 132static int rt_chain_length_max __read_mostly = 20;
134 133
135static struct delayed_work expires_work; 134static struct delayed_work expires_work;
@@ -918,32 +917,11 @@ void rt_cache_flush_batch(void)
918 rt_do_flush(!in_softirq()); 917 rt_do_flush(!in_softirq());
919} 918}
920 919
921/*
922 * We change rt_genid and let gc do the cleanup
923 */
924static 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
931static 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
939static void rt_emergency_hash_rebuild(struct net *net) 920static void rt_emergency_hash_rebuild(struct net *net)
940{ 921{
941 if (net_ratelimit()) { 922 if (net_ratelimit())
942 printk(KERN_WARNING "Route hash chain too long!\n"); 923 printk(KERN_WARNING "Route hash chain too long!\n");
943 printk(KERN_WARNING "Adjust your secret_interval!\n"); 924 rt_cache_invalidate(net);
944 }
945
946 rt_secret_rebuild_oneshot(net);
947} 925}
948 926
949/* 927/*
@@ -3101,48 +3079,6 @@ static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write,
3101 return -EINVAL; 3079 return -EINVAL;
3102} 3080}
3103 3081
3104static 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
3134static 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
3146static ctl_table ipv4_route_table[] = { 3082static ctl_table ipv4_route_table[] = {
3147 { 3083 {
3148 .procname = "gc_thresh", 3084 .procname = "gc_thresh",
@@ -3251,13 +3187,6 @@ static ctl_table ipv4_route_table[] = {
3251 .mode = 0644, 3187 .mode = 0644,
3252 .proc_handler = proc_dointvec, 3188 .proc_handler = proc_dointvec,
3253 }, 3189 },
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 },
3261 { } 3190 { }
3262}; 3191};
3263 3192
@@ -3336,34 +3265,15 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
3336}; 3265};
3337#endif 3266#endif
3338 3267
3339 3268static __net_init int rt_genid_init(struct net *net)
3340static __net_init int rt_secret_timer_init(struct net *net)
3341{ 3269{
3342 atomic_set(&net->ipv4.rt_genid, 3270 get_random_bytes(&net->ipv4.rt_genid,
3343 (int) ((num_physpages ^ (num_physpages>>8)) ^ 3271 sizeof(net->ipv4.rt_genid));
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 }
3356 return 0; 3272 return 0;
3357} 3273}
3358 3274
3359static __net_exit void rt_secret_timer_exit(struct net *net) 3275static __net_initdata struct pernet_operations rt_genid_ops = {
3360{ 3276 .init = rt_genid_init,
3361 del_timer_sync(&net->ipv4.rt_secret_timer);
3362}
3363
3364static __net_initdata struct pernet_operations rt_secret_timer_ops = {
3365 .init = rt_secret_timer_init,
3366 .exit = rt_secret_timer_exit,
3367}; 3277};
3368 3278
3369 3279
@@ -3424,9 +3334,6 @@ int __init ip_rt_init(void)
3424 schedule_delayed_work(&expires_work, 3334 schedule_delayed_work(&expires_work,
3425 net_random() % ip_rt_gc_interval + ip_rt_gc_interval); 3335 net_random() % ip_rt_gc_interval + ip_rt_gc_interval);
3426 3336
3427 if (register_pernet_subsys(&rt_secret_timer_ops))
3428 printk(KERN_ERR "Unable to setup rt_secret_timer\n");
3429
3430 if (ip_rt_proc_init()) 3337 if (ip_rt_proc_init())
3431 printk(KERN_ERR "Unable to create route proc files\n"); 3338 printk(KERN_ERR "Unable to create route proc files\n");
3432#ifdef CONFIG_XFRM 3339#ifdef CONFIG_XFRM
@@ -3438,6 +3345,7 @@ int __init ip_rt_init(void)
3438#ifdef CONFIG_SYSCTL 3345#ifdef CONFIG_SYSCTL
3439 register_pernet_subsys(&sysctl_route_ops); 3346 register_pernet_subsys(&sysctl_route_ops);
3440#endif 3347#endif
3348 register_pernet_subsys(&rt_genid_ops);
3441 return rc; 3349 return rc;
3442} 3350}
3443 3351