aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-07-05 22:02:59 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-05 22:02:59 -0400
commit9f5e97e53675caeda48e9988122a30470f4d309d (patch)
treebf236781b078866c1b2190784611815738bf3a81 /net/ipv4/route.c
parent39a23e75087ce815abbddbd565b9a2e567ac47da (diff)
netns: make rt_secret_rebuild timer per namespace
Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 6fe799de9b96..f99d9dbb7720 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -132,7 +132,6 @@ static int ip_rt_secret_interval __read_mostly = 10 * 60 * HZ;
132 132
133static void rt_worker_func(struct work_struct *work); 133static void rt_worker_func(struct work_struct *work);
134static DECLARE_DELAYED_WORK(expires_work, rt_worker_func); 134static DECLARE_DELAYED_WORK(expires_work, rt_worker_func);
135static struct timer_list rt_secret_timer;
136 135
137/* 136/*
138 * Interface to generic destination cache. 137 * Interface to generic destination cache.
@@ -801,10 +800,11 @@ void rt_cache_flush(struct net *net, int delay)
801/* 800/*
802 * We change rt_genid and let gc do the cleanup 801 * We change rt_genid and let gc do the cleanup
803 */ 802 */
804static void rt_secret_rebuild(unsigned long dummy) 803static void rt_secret_rebuild(unsigned long __net)
805{ 804{
805 struct net *net = (struct net *)__net;
806 rt_cache_invalidate(); 806 rt_cache_invalidate();
807 mod_timer(&rt_secret_timer, jiffies + ip_rt_secret_interval); 807 mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval);
808} 808}
809 809
810/* 810/*
@@ -3072,6 +3072,31 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
3072}; 3072};
3073#endif 3073#endif
3074 3074
3075
3076static __net_init int rt_secret_timer_init(struct net *net)
3077{
3078 net->ipv4.rt_secret_timer.function = rt_secret_rebuild;
3079 net->ipv4.rt_secret_timer.data = (unsigned long)net;
3080 init_timer_deferrable(&net->ipv4.rt_secret_timer);
3081
3082 net->ipv4.rt_secret_timer.expires =
3083 jiffies + net_random() % ip_rt_secret_interval +
3084 ip_rt_secret_interval;
3085 add_timer(&net->ipv4.rt_secret_timer);
3086 return 0;
3087}
3088
3089static __net_exit void rt_secret_timer_exit(struct net *net)
3090{
3091 del_timer_sync(&net->ipv4.rt_secret_timer);
3092}
3093
3094static __net_initdata struct pernet_operations rt_secret_timer_ops = {
3095 .init = rt_secret_timer_init,
3096 .exit = rt_secret_timer_exit,
3097};
3098
3099
3075#ifdef CONFIG_NET_CLS_ROUTE 3100#ifdef CONFIG_NET_CLS_ROUTE
3076struct ip_rt_acct *ip_rt_acct __read_mostly; 3101struct ip_rt_acct *ip_rt_acct __read_mostly;
3077#endif /* CONFIG_NET_CLS_ROUTE */ 3102#endif /* CONFIG_NET_CLS_ROUTE */
@@ -3124,19 +3149,14 @@ int __init ip_rt_init(void)
3124 devinet_init(); 3149 devinet_init();
3125 ip_fib_init(); 3150 ip_fib_init();
3126 3151
3127 rt_secret_timer.function = rt_secret_rebuild;
3128 rt_secret_timer.data = 0;
3129 init_timer_deferrable(&rt_secret_timer);
3130
3131 /* All the timers, started at system startup tend 3152 /* All the timers, started at system startup tend
3132 to synchronize. Perturb it a bit. 3153 to synchronize. Perturb it a bit.
3133 */ 3154 */
3134 schedule_delayed_work(&expires_work, 3155 schedule_delayed_work(&expires_work,
3135 net_random() % ip_rt_gc_interval + ip_rt_gc_interval); 3156 net_random() % ip_rt_gc_interval + ip_rt_gc_interval);
3136 3157
3137 rt_secret_timer.expires = jiffies + net_random() % ip_rt_secret_interval + 3158 if (register_pernet_subsys(&rt_secret_timer_ops))
3138 ip_rt_secret_interval; 3159 printk(KERN_ERR "Unable to setup rt_secret_timer\n");
3139 add_timer(&rt_secret_timer);
3140 3160
3141 if (ip_rt_proc_init()) 3161 if (ip_rt_proc_init())
3142 printk(KERN_ERR "Unable to create route proc files\n"); 3162 printk(KERN_ERR "Unable to create route proc files\n");