aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/ip6_fib.c
diff options
context:
space:
mode:
authorDaniel Lezcano <dlezcano@fr.ibm.com>2008-03-04 02:33:43 -0500
committerDavid S. Miller <davem@davemloft.net>2008-03-04 02:33:43 -0500
commit6cc118bd506ae8c6436f507b838a0e1f6185fec2 (patch)
tree64c06a8f0c6c5fded8aa4298f5ddb2bfd15cccc0 /net/ipv6/ip6_fib.c
parentdcabb819a6eced95ef531b001e663d0d592c8d9f (diff)
[NETNS][IPV6] rt6_stats - dynamically allocate the routes statistics
This patch allocates the rt6_stats struct dynamically when the fib6 is initialized. That provides the ability to create several instances of this structure for the network namespaces. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: Benjamin Thery <benjamin.thery@bull.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ip6_fib.c')
-rw-r--r--net/ipv6/ip6_fib.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 350a970ca1e3..7d82ad540140 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -48,7 +48,7 @@
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; 51struct rt6_statistics *rt6_stats;
52 52
53static struct kmem_cache * fib6_node_kmem __read_mostly; 53static struct kmem_cache * fib6_node_kmem __read_mostly;
54 54
@@ -653,10 +653,10 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
653 rt->rt6i_node = fn; 653 rt->rt6i_node = fn;
654 atomic_inc(&rt->rt6i_ref); 654 atomic_inc(&rt->rt6i_ref);
655 inet6_rt_notify(RTM_NEWROUTE, rt, info); 655 inet6_rt_notify(RTM_NEWROUTE, rt, info);
656 rt6_stats.fib_rt_entries++; 656 rt6_stats->fib_rt_entries++;
657 657
658 if ((fn->fn_flags & RTN_RTINFO) == 0) { 658 if ((fn->fn_flags & RTN_RTINFO) == 0) {
659 rt6_stats.fib_route_nodes++; 659 rt6_stats->fib_route_nodes++;
660 fn->fn_flags |= RTN_RTINFO; 660 fn->fn_flags |= RTN_RTINFO;
661 } 661 }
662 662
@@ -1093,8 +1093,8 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
1093 /* Unlink it */ 1093 /* Unlink it */
1094 *rtp = rt->u.dst.rt6_next; 1094 *rtp = rt->u.dst.rt6_next;
1095 rt->rt6i_node = NULL; 1095 rt->rt6i_node = NULL;
1096 rt6_stats.fib_rt_entries--; 1096 rt6_stats->fib_rt_entries--;
1097 rt6_stats.fib_discarded_routes++; 1097 rt6_stats->fib_discarded_routes++;
1098 1098
1099 /* Reset round-robin state, if necessary */ 1099 /* Reset round-robin state, if necessary */
1100 if (fn->rr_ptr == rt) 1100 if (fn->rr_ptr == rt)
@@ -1117,7 +1117,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 */ 1117 /* If it was last route, expunge its radix tree node */
1118 if (fn->leaf == NULL) { 1118 if (fn->leaf == NULL) {
1119 fn->fn_flags &= ~RTN_RTINFO; 1119 fn->fn_flags &= ~RTN_RTINFO;
1120 rt6_stats.fib_route_nodes--; 1120 rt6_stats->fib_route_nodes--;
1121 fn = fib6_repair_tree(fn); 1121 fn = fib6_repair_tree(fn);
1122 } 1122 }
1123 1123
@@ -1556,9 +1556,14 @@ int __init fib6_init(void)
1556 if (!fib6_node_kmem) 1556 if (!fib6_node_kmem)
1557 goto out; 1557 goto out;
1558 1558
1559 ret = -ENOMEM;
1560 rt6_stats = kzalloc(sizeof(*rt6_stats), GFP_KERNEL);
1561 if (!rt6_stats)
1562 goto out_kmem_cache_create;
1563
1559 ret = register_pernet_subsys(&fib6_net_ops); 1564 ret = register_pernet_subsys(&fib6_net_ops);
1560 if (ret) 1565 if (ret)
1561 goto out_kmem_cache_create; 1566 goto out_rt6_stats;
1562 1567
1563 ret = __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib); 1568 ret = __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib);
1564 if (ret) 1569 if (ret)
@@ -1568,6 +1573,8 @@ out:
1568 1573
1569out_unregister_subsys: 1574out_unregister_subsys:
1570 unregister_pernet_subsys(&fib6_net_ops); 1575 unregister_pernet_subsys(&fib6_net_ops);
1576out_rt6_stats:
1577 kfree(rt6_stats);
1571out_kmem_cache_create: 1578out_kmem_cache_create:
1572 kmem_cache_destroy(fib6_node_kmem); 1579 kmem_cache_destroy(fib6_node_kmem);
1573 goto out; 1580 goto out;
@@ -1576,5 +1583,6 @@ out_kmem_cache_create:
1576void fib6_gc_cleanup(void) 1583void fib6_gc_cleanup(void)
1577{ 1584{
1578 unregister_pernet_subsys(&fib6_net_ops); 1585 unregister_pernet_subsys(&fib6_net_ops);
1586 kfree(rt6_stats);
1579 kmem_cache_destroy(fib6_node_kmem); 1587 kmem_cache_destroy(fib6_node_kmem);
1580} 1588}