From: "Denis V. Lunev" <den@openvz.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, containers@lists.osdl.org,
"Denis V. Lunev" <den@openvz.org>
Subject: [PATCH net-next 5/9] netns: make rt_secret_rebuild timer per namespace
Date: Fri, 4 Jul 2008 17:17:08 +0400 [thread overview]
Message-ID: <1215177432-25934-5-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1215177360.27873.50.camel@iris.sw.ru>
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
include/net/netns/ipv4.h | 2 ++
net/ipv4/route.c | 40 ++++++++++++++++++++++++++++++----------
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index a29adf1..356617f 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -46,5 +46,7 @@ struct netns_ipv4 {
int sysctl_icmp_ratelimit;
int sysctl_icmp_ratemask;
int sysctl_icmp_errors_use_inbound_ifaddr;
+
+ struct timer_list rt_secret_timer;
};
#endif
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 6fe799d..f99d9db 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;
static void rt_worker_func(struct work_struct *work);
static DECLARE_DELAYED_WORK(expires_work, rt_worker_func);
-static struct timer_list rt_secret_timer;
/*
* Interface to generic destination cache.
@@ -801,10 +800,11 @@ void rt_cache_flush(struct net *net, int delay)
/*
* We change rt_genid and let gc do the cleanup
*/
-static void rt_secret_rebuild(unsigned long dummy)
+static void rt_secret_rebuild(unsigned long __net)
{
+ struct net *net = (struct net *)__net;
rt_cache_invalidate();
- mod_timer(&rt_secret_timer, jiffies + ip_rt_secret_interval);
+ mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval);
}
/*
@@ -3072,6 +3072,31 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
};
#endif
+
+static __net_init int rt_secret_timer_init(struct net *net)
+{
+ net->ipv4.rt_secret_timer.function = rt_secret_rebuild;
+ net->ipv4.rt_secret_timer.data = (unsigned long)net;
+ init_timer_deferrable(&net->ipv4.rt_secret_timer);
+
+ net->ipv4.rt_secret_timer.expires =
+ jiffies + net_random() % ip_rt_secret_interval +
+ ip_rt_secret_interval;
+ add_timer(&net->ipv4.rt_secret_timer);
+ return 0;
+}
+
+static __net_exit void rt_secret_timer_exit(struct net *net)
+{
+ del_timer_sync(&net->ipv4.rt_secret_timer);
+}
+
+static __net_initdata struct pernet_operations rt_secret_timer_ops = {
+ .init = rt_secret_timer_init,
+ .exit = rt_secret_timer_exit,
+};
+
+
#ifdef CONFIG_NET_CLS_ROUTE
struct ip_rt_acct *ip_rt_acct __read_mostly;
#endif /* CONFIG_NET_CLS_ROUTE */
@@ -3124,19 +3149,14 @@ int __init ip_rt_init(void)
devinet_init();
ip_fib_init();
- rt_secret_timer.function = rt_secret_rebuild;
- rt_secret_timer.data = 0;
- init_timer_deferrable(&rt_secret_timer);
-
/* All the timers, started at system startup tend
to synchronize. Perturb it a bit.
*/
schedule_delayed_work(&expires_work,
net_random() % ip_rt_gc_interval + ip_rt_gc_interval);
- rt_secret_timer.expires = jiffies + net_random() % ip_rt_secret_interval +
- ip_rt_secret_interval;
- add_timer(&rt_secret_timer);
+ if (register_pernet_subsys(&rt_secret_timer_ops))
+ printk(KERN_ERR "Unable to setup rt_secret_timer\n");
if (ip_rt_proc_init())
printk(KERN_ERR "Unable to create route proc files\n");
--
1.5.3.rc5
next prev parent reply other threads:[~2008-07-04 13:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-04 13:16 [PATCH net-next 0/9] selective (per/namespace) flush of rt_cache Denis V. Lunev
2008-07-04 13:17 ` [PATCH net-next 1/9] netns: add namespace parameter to rt_cache_flush Denis V. Lunev
2008-07-04 13:17 ` [PATCH net-next 2/9] net: add fib_rules_ops to flush_cache method Denis V. Lunev
2008-07-04 13:17 ` [PATCH net-next 3/9] ipv4: remove static flush_delay variable Denis V. Lunev
2008-07-07 8:43 ` Eric W. Biederman
2008-07-07 11:26 ` Denis V. Lunev
2008-07-08 10:05 ` David Miller
2008-07-04 13:17 ` [PATCH net-next 4/9] netns: register net.ipv4.route.flush in each namespace Denis V. Lunev
2008-07-04 13:17 ` Denis V. Lunev [this message]
2008-07-04 13:17 ` [PATCH net-next 6/9] netns: add struct net parameter to rt_cache_invalidate Denis V. Lunev
2008-07-04 13:17 ` [PATCH net-next 7/9] ipv4: pass current value of rt_genid into rt_hash Denis V. Lunev
2008-07-04 13:17 ` [PATCH net-next 8/9] netns: place rt_genid into struct net Denis V. Lunev
2008-07-04 13:17 ` [PATCH net-next 9/9] netns: selective flush of rt_cache Denis V. Lunev
[not found] ` <1215177360.27873.50.camel-aPCOdVxUTlgvJsYlp49lxw@public.gmane.org>
2008-07-06 3:55 ` [PATCH net-next 0/9] selective (per/namespace) " David Miller
2008-07-07 10:29 ` Eric W. Biederman
2008-07-07 10:39 ` Denis V. Lunev
2008-07-07 10:51 ` Denis V. Lunev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1215177432-25934-5-git-send-email-den@openvz.org \
--to=den@openvz.org \
--cc=containers@lists.osdl.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).