From: Daniel Lezcano <dlezcano@fr.ibm.com>
To: davem@davemloft.net
Cc: benjamin.thery@bull.net, netdev@vger.kernel.org, den@openvz.org
Subject: [patch 11/11][NETNS][IPV6] rt6_stats - make rt6_stats per namespace
Date: Fri, 25 Jan 2008 17:50:19 +0100 [thread overview]
Message-ID: <20080125170825.725269338@localhost.localdomain> (raw)
In-Reply-To: 20080125165008.317745745@localhost.localdomain
[-- Attachment #1: rt6-stats-per-namespace.patch --]
[-- Type: text/plain, Size: 5759 bytes --]
The rt6_stats is now per namespace with this patch. It is
allocated when a network namespace is created and freed
when the network namespace exits and references are relative
to the network namespace.
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
include/net/ipv6.h | 1 -
include/net/netns/ipv6.h | 1 +
net/ipv6/ip6_fib.c | 32 +++++++++++++++-----------------
net/ipv6/route.c | 12 +++++++-----
4 files changed, 23 insertions(+), 23 deletions(-)
Index: net-2.6.25/include/net/ipv6.h
===================================================================
--- net-2.6.25.orig/include/net/ipv6.h
+++ net-2.6.25/include/net/ipv6.h
@@ -604,7 +604,6 @@ extern void ipv6_misc_proc_exit(void);
extern int snmp6_register_dev(struct inet6_dev *idev);
extern int snmp6_unregister_dev(struct inet6_dev *idev);
-extern struct rt6_statistics *rt6_stats;
#else
static inline int snmp6_register_dev(struct inet6_dev *idev)
{
Index: net-2.6.25/net/ipv6/ip6_fib.c
===================================================================
--- net-2.6.25.orig/net/ipv6/ip6_fib.c
+++ net-2.6.25/net/ipv6/ip6_fib.c
@@ -48,8 +48,6 @@
#define RT6_TRACE(x...) do { ; } while (0)
#endif
-struct rt6_statistics *rt6_stats;
-
static struct kmem_cache * fib6_node_kmem __read_mostly;
enum fib_walk_state_t
@@ -653,10 +651,10 @@ static int fib6_add_rt2node(struct fib6_
rt->rt6i_node = fn;
atomic_inc(&rt->rt6i_ref);
inet6_rt_notify(RTM_NEWROUTE, rt, info);
- rt6_stats->fib_rt_entries++;
+ info->nl_net->ipv6.rt6_stats->fib_rt_entries++;
if ((fn->fn_flags & RTN_RTINFO) == 0) {
- rt6_stats->fib_route_nodes++;
+ info->nl_net->ipv6.rt6_stats->fib_route_nodes++;
fn->fn_flags |= RTN_RTINFO;
}
@@ -1087,14 +1085,15 @@ static void fib6_del_route(struct fib6_n
{
struct fib6_walker_t *w;
struct rt6_info *rt = *rtp;
+ struct net *net = info->nl_net;
RT6_TRACE("fib6_del_route\n");
/* Unlink it */
*rtp = rt->u.dst.rt6_next;
rt->rt6i_node = NULL;
- rt6_stats->fib_rt_entries--;
- rt6_stats->fib_discarded_routes++;
+ net->ipv6.rt6_stats->fib_rt_entries--;
+ net->ipv6.rt6_stats->fib_discarded_routes++;
/* Reset round-robin state, if necessary */
if (fn->rr_ptr == rt)
@@ -1117,7 +1116,7 @@ static void fib6_del_route(struct fib6_n
/* If it was last route, expunge its radix tree node */
if (fn->leaf == NULL) {
fn->fn_flags &= ~RTN_RTINFO;
- rt6_stats->fib_route_nodes--;
+ net->ipv6.rt6_stats->fib_route_nodes--;
fn = fib6_repair_tree(fn);
}
@@ -1486,11 +1485,15 @@ static int fib6_net_init(struct net *net
setup_timer(timer, fib6_gc_timer_cb, (unsigned long)net);
net->ipv6.ip6_fib_timer = timer;
+ net->ipv6.rt6_stats = kzalloc(sizeof(*net->ipv6.rt6_stats), GFP_KERNEL);
+ if (!net->ipv6.rt6_stats)
+ goto out_timer;
+
net->ipv6.fib_table_hash =
kzalloc(sizeof(*net->ipv6.fib_table_hash)*FIB_TABLE_HASHSZ,
GFP_KERNEL);
if (!net->ipv6.fib_table_hash)
- goto out_timer;
+ goto out_rt6_stats;
net->ipv6.fib6_main_tbl = kzalloc(sizeof(*net->ipv6.fib6_main_tbl),
GFP_KERNEL);
@@ -1524,6 +1527,8 @@ out_fib6_main_tbl:
#endif
out_fib_table_hash:
kfree(net->ipv6.fib_table_hash);
+out_rt6_stats:
+ kfree(net->ipv6.rt6_stats);
out_timer:
kfree(timer);
goto out;
@@ -1538,6 +1543,7 @@ static void fib6_net_exit(struct net *ne
#endif
kfree(net->ipv6.fib6_main_tbl);
kfree(net->ipv6.fib_table_hash);
+ kfree(net->ipv6.rt6_stats);
}
static struct pernet_operations fib6_net_ops = {
@@ -1556,14 +1562,9 @@ int __init fib6_init(void)
if (!fib6_node_kmem)
goto out;
- ret = -ENOMEM;
- rt6_stats = kzalloc(sizeof(*rt6_stats), GFP_KERNEL);
- if (!rt6_stats)
- goto out_kmem_cache_create;
-
ret = register_pernet_subsys(&fib6_net_ops);
if (ret)
- goto out_rt6_stats;
+ goto out_kmem_cache_create;
ret = __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib);
if (ret)
@@ -1573,8 +1574,6 @@ out:
out_unregister_subsys:
unregister_pernet_subsys(&fib6_net_ops);
-out_rt6_stats:
- kfree(rt6_stats);
out_kmem_cache_create:
kmem_cache_destroy(fib6_node_kmem);
goto out;
@@ -1583,6 +1582,5 @@ out_kmem_cache_create:
void fib6_gc_cleanup(void)
{
unregister_pernet_subsys(&fib6_net_ops);
- kfree(rt6_stats);
kmem_cache_destroy(fib6_node_kmem);
}
Index: net-2.6.25/net/ipv6/route.c
===================================================================
--- net-2.6.25.orig/net/ipv6/route.c
+++ net-2.6.25/net/ipv6/route.c
@@ -2349,11 +2349,13 @@ static const struct file_operations ipv6
static int rt6_stats_seq_show(struct seq_file *seq, void *v)
{
seq_printf(seq, "%04x %04x %04x %04x %04x %04x %04x\n",
- rt6_stats->fib_nodes, rt6_stats->fib_route_nodes,
- rt6_stats->fib_rt_alloc, rt6_stats->fib_rt_entries,
- rt6_stats->fib_rt_cache,
- atomic_read(&ip6_dst_ops.entries),
- rt6_stats->fib_discarded_routes);
+ init_net.ipv6.rt6_stats->fib_nodes,
+ init_net.ipv6.rt6_stats->fib_route_nodes,
+ init_net.ipv6.rt6_stats->fib_rt_alloc,
+ init_net.ipv6.rt6_stats->fib_rt_entries,
+ init_net.ipv6.rt6_stats->fib_rt_cache,
+ atomic_read(&ip6_dst_ops.entries),
+ init_net.ipv6.rt6_stats->fib_discarded_routes);
return 0;
}
Index: net-2.6.25/include/net/netns/ipv6.h
===================================================================
--- net-2.6.25.orig/include/net/netns/ipv6.h
+++ net-2.6.25/include/net/netns/ipv6.h
@@ -32,6 +32,7 @@ struct netns_ipv6 {
struct ipv6_devconf *devconf_dflt;
struct netns_frags frags;
+ struct rt6_statistics *rt6_stats;
struct timer_list *ip6_fib_timer;
struct hlist_head *fib_table_hash;
struct fib6_table *fib6_main_tbl;
--
prev parent reply other threads:[~2008-01-25 17:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-25 16:50 [patch 00/11][NETNS][IPV6] make a subset of the routing per namespace Daniel Lezcano
2008-01-25 16:50 ` [patch 01/11][NETNS][IPV6] ip6_fib - dynamically allocate the tables Daniel Lezcano
2008-01-25 16:50 ` [patch 02/11][NETNS][IPV6] ip6_fib - make the tables per namespace Daniel Lezcano
2008-01-25 16:50 ` [patch 03/11][NETNS][IPV6] ip6_fib - make fib6_clean_all " Daniel Lezcano
2008-01-25 16:50 ` [patch 04/11][NETNS][IPV6] ip6_fib - pass the network namespace parameter to timer callback Daniel Lezcano
2008-01-25 16:50 ` [patch 05/11][NETNS][IPV6] ip6_fib - dynamically allocate the gc_timer Daniel Lezcano
2008-01-25 16:50 ` [patch 06/11][NETNS][IPV6] ip6_fib - make the ip6 fib gc timer per network namespace Daniel Lezcano
2008-01-25 16:50 ` [patch 07/11][NETNS][IPV6] make fib6_clean_node to use the " Daniel Lezcano
2008-01-25 16:50 ` [patch 08/11][NETNS][IPV6] fib6_rules - dynamically allocate the fib rules ops Daniel Lezcano
2008-01-25 16:50 ` [patch 09/11][NETNS][IPV6] fib6_rules: make per network namespace Daniel Lezcano
2008-01-25 16:50 ` [patch 10/11][NETNS][IPV6] rt6_stats - dynamically allocate the rt6_stats Daniel Lezcano
2008-01-25 16:50 ` Daniel Lezcano [this message]
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=20080125170825.725269338@localhost.localdomain \
--to=dlezcano@fr.ibm.com \
--cc=benjamin.thery@bull.net \
--cc=davem@davemloft.net \
--cc=den@openvz.org \
--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).