aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorBenjamin Thery <benjamin.thery@bull.net>2008-03-04 02:34:17 -0500
committerDavid S. Miller <davem@davemloft.net>2008-03-04 02:34:17 -0500
commitc572872f89e46e38cdb35a43b81122bfb7ff43fc (patch)
tree2392f9991dc73bff96966fabe9e25bd4ebfa2dda /net
parent6cc118bd506ae8c6436f507b838a0e1f6185fec2 (diff)
[NETNS][IPV6] rt6_stats - make the stats per network namespace
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv6/ip6_fib.c32
-rw-r--r--net/ipv6/route.c12
2 files changed, 22 insertions, 22 deletions
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 7d82ad540140..1c2566e3d392 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -48,8 +48,6 @@
48#define RT6_TRACE(x...) do { ; } while (0) 48#define RT6_TRACE(x...) do { ; } while (0)
49#endif 49#endif
50 50
51struct rt6_statistics *rt6_stats;
52
53static struct kmem_cache * fib6_node_kmem __read_mostly; 51static struct kmem_cache * fib6_node_kmem __read_mostly;
54 52
55enum fib_walk_state_t 53enum fib_walk_state_t
@@ -653,10 +651,10 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
653 rt->rt6i_node = fn; 651 rt->rt6i_node = fn;
654 atomic_inc(&rt->rt6i_ref); 652 atomic_inc(&rt->rt6i_ref);
655 inet6_rt_notify(RTM_NEWROUTE, rt, info); 653 inet6_rt_notify(RTM_NEWROUTE, rt, info);
656 rt6_stats->fib_rt_entries++; 654 info->nl_net->ipv6.rt6_stats->fib_rt_entries++;
657 655
658 if ((fn->fn_flags & RTN_RTINFO) == 0) { 656 if ((fn->fn_flags & RTN_RTINFO) == 0) {
659 rt6_stats->fib_route_nodes++; 657 info->nl_net->ipv6.rt6_stats->fib_route_nodes++;
660 fn->fn_flags |= RTN_RTINFO; 658 fn->fn_flags |= RTN_RTINFO;
661 } 659 }
662 660
@@ -1087,14 +1085,15 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
1087{ 1085{
1088 struct fib6_walker_t *w; 1086 struct fib6_walker_t *w;
1089 struct rt6_info *rt = *rtp; 1087 struct rt6_info *rt = *rtp;
1088 struct net *net = info->nl_net;
1090 1089
1091 RT6_TRACE("fib6_del_route\n"); 1090 RT6_TRACE("fib6_del_route\n");
1092 1091
1093 /* Unlink it */ 1092 /* Unlink it */
1094 *rtp = rt->u.dst.rt6_next; 1093 *rtp = rt->u.dst.rt6_next;
1095 rt->rt6i_node = NULL; 1094 rt->rt6i_node = NULL;
1096 rt6_stats->fib_rt_entries--; 1095 net->ipv6.rt6_stats->fib_rt_entries--;
1097 rt6_stats->fib_discarded_routes++; 1096 net->ipv6.rt6_stats->fib_discarded_routes++;
1098 1097
1099 /* Reset round-robin state, if necessary */ 1098 /* Reset round-robin state, if necessary */
1100 if (fn->rr_ptr == rt) 1099 if (fn->rr_ptr == rt)
@@ -1117,7 +1116,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
1117 /* If it was last route, expunge its radix tree node */ 1116 /* If it was last route, expunge its radix tree node */
1118 if (fn->leaf == NULL) { 1117 if (fn->leaf == NULL) {
1119 fn->fn_flags &= ~RTN_RTINFO; 1118 fn->fn_flags &= ~RTN_RTINFO;
1120 rt6_stats->fib_route_nodes--; 1119 net->ipv6.rt6_stats->fib_route_nodes--;
1121 fn = fib6_repair_tree(fn); 1120 fn = fib6_repair_tree(fn);
1122 } 1121 }
1123 1122
@@ -1486,11 +1485,15 @@ static int fib6_net_init(struct net *net)
1486 setup_timer(timer, fib6_gc_timer_cb, (unsigned long)net); 1485 setup_timer(timer, fib6_gc_timer_cb, (unsigned long)net);
1487 net->ipv6.ip6_fib_timer = timer; 1486 net->ipv6.ip6_fib_timer = timer;
1488 1487
1488 net->ipv6.rt6_stats = kzalloc(sizeof(*net->ipv6.rt6_stats), GFP_KERNEL);
1489 if (!net->ipv6.rt6_stats)
1490 goto out_timer;
1491
1489 net->ipv6.fib_table_hash = 1492 net->ipv6.fib_table_hash =
1490 kzalloc(sizeof(*net->ipv6.fib_table_hash)*FIB_TABLE_HASHSZ, 1493 kzalloc(sizeof(*net->ipv6.fib_table_hash)*FIB_TABLE_HASHSZ,
1491 GFP_KERNEL); 1494 GFP_KERNEL);
1492 if (!net->ipv6.fib_table_hash) 1495 if (!net->ipv6.fib_table_hash)
1493 goto out_timer; 1496 goto out_rt6_stats;
1494 1497
1495 net->ipv6.fib6_main_tbl = kzalloc(sizeof(*net->ipv6.fib6_main_tbl), 1498 net->ipv6.fib6_main_tbl = kzalloc(sizeof(*net->ipv6.fib6_main_tbl),
1496 GFP_KERNEL); 1499 GFP_KERNEL);
@@ -1524,6 +1527,8 @@ out_fib6_main_tbl:
1524#endif 1527#endif
1525out_fib_table_hash: 1528out_fib_table_hash:
1526 kfree(net->ipv6.fib_table_hash); 1529 kfree(net->ipv6.fib_table_hash);
1530out_rt6_stats:
1531 kfree(net->ipv6.rt6_stats);
1527out_timer: 1532out_timer:
1528 kfree(timer); 1533 kfree(timer);
1529 goto out; 1534 goto out;
@@ -1538,6 +1543,7 @@ static void fib6_net_exit(struct net *net)
1538#endif 1543#endif
1539 kfree(net->ipv6.fib6_main_tbl); 1544 kfree(net->ipv6.fib6_main_tbl);
1540 kfree(net->ipv6.fib_table_hash); 1545 kfree(net->ipv6.fib_table_hash);
1546 kfree(net->ipv6.rt6_stats);
1541} 1547}
1542 1548
1543static struct pernet_operations fib6_net_ops = { 1549static struct pernet_operations fib6_net_ops = {
@@ -1556,14 +1562,9 @@ int __init fib6_init(void)
1556 if (!fib6_node_kmem) 1562 if (!fib6_node_kmem)
1557 goto out; 1563 goto out;
1558 1564
1559 ret = -ENOMEM;
1560 rt6_stats = kzalloc(sizeof(*rt6_stats), GFP_KERNEL);
1561 if (!rt6_stats)
1562 goto out_kmem_cache_create;
1563
1564 ret = register_pernet_subsys(&fib6_net_ops); 1565 ret = register_pernet_subsys(&fib6_net_ops);
1565 if (ret) 1566 if (ret)
1566 goto out_rt6_stats; 1567 goto out_kmem_cache_create;
1567 1568
1568 ret = __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib); 1569 ret = __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib);
1569 if (ret) 1570 if (ret)
@@ -1573,8 +1574,6 @@ out:
1573 1574
1574out_unregister_subsys: 1575out_unregister_subsys:
1575 unregister_pernet_subsys(&fib6_net_ops); 1576 unregister_pernet_subsys(&fib6_net_ops);
1576out_rt6_stats:
1577 kfree(rt6_stats);
1578out_kmem_cache_create: 1577out_kmem_cache_create:
1579 kmem_cache_destroy(fib6_node_kmem); 1578 kmem_cache_destroy(fib6_node_kmem);
1580 goto out; 1579 goto out;
@@ -1583,6 +1582,5 @@ out_kmem_cache_create:
1583void fib6_gc_cleanup(void) 1582void fib6_gc_cleanup(void)
1584{ 1583{
1585 unregister_pernet_subsys(&fib6_net_ops); 1584 unregister_pernet_subsys(&fib6_net_ops);
1586 kfree(rt6_stats);
1587 kmem_cache_destroy(fib6_node_kmem); 1585 kmem_cache_destroy(fib6_node_kmem);
1588} 1586}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 370f2aef6909..3afc3f41f2d5 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2354,11 +2354,13 @@ static const struct file_operations ipv6_route_proc_fops = {
2354static int rt6_stats_seq_show(struct seq_file *seq, void *v) 2354static int rt6_stats_seq_show(struct seq_file *seq, void *v)
2355{ 2355{
2356 seq_printf(seq, "%04x %04x %04x %04x %04x %04x %04x\n", 2356 seq_printf(seq, "%04x %04x %04x %04x %04x %04x %04x\n",
2357 rt6_stats->fib_nodes, rt6_stats->fib_route_nodes, 2357 init_net.ipv6.rt6_stats->fib_nodes,
2358 rt6_stats->fib_rt_alloc, rt6_stats->fib_rt_entries, 2358 init_net.ipv6.rt6_stats->fib_route_nodes,
2359 rt6_stats->fib_rt_cache, 2359 init_net.ipv6.rt6_stats->fib_rt_alloc,
2360 atomic_read(&ip6_dst_ops.entries), 2360 init_net.ipv6.rt6_stats->fib_rt_entries,
2361 rt6_stats->fib_discarded_routes); 2361 init_net.ipv6.rt6_stats->fib_rt_cache,
2362 atomic_read(&ip6_dst_ops.entries),
2363 init_net.ipv6.rt6_stats->fib_discarded_routes);
2362 2364
2363 return 0; 2365 return 0;
2364} 2366}