diff options
author | Daniel Lezcano <dlezcano@fr.ibm.com> | 2008-03-04 02:33:43 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-04 02:33:43 -0500 |
commit | 6cc118bd506ae8c6436f507b838a0e1f6185fec2 (patch) | |
tree | 64c06a8f0c6c5fded8aa4298f5ddb2bfd15cccc0 | |
parent | dcabb819a6eced95ef531b001e663d0d592c8d9f (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>
-rw-r--r-- | include/net/ipv6.h | 2 | ||||
-rw-r--r-- | net/ipv6/ip6_fib.c | 22 | ||||
-rw-r--r-- | net/ipv6/route.c | 8 |
3 files changed, 20 insertions, 12 deletions
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 5dc8164e5d3b..9a00f35ae773 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -611,7 +611,7 @@ extern void ipv6_misc_proc_exit(void); | |||
611 | extern int snmp6_register_dev(struct inet6_dev *idev); | 611 | extern int snmp6_register_dev(struct inet6_dev *idev); |
612 | extern int snmp6_unregister_dev(struct inet6_dev *idev); | 612 | extern int snmp6_unregister_dev(struct inet6_dev *idev); |
613 | 613 | ||
614 | extern struct rt6_statistics rt6_stats; | 614 | extern struct rt6_statistics *rt6_stats; |
615 | #else | 615 | #else |
616 | static inline int snmp6_register_dev(struct inet6_dev *idev) | 616 | static inline int snmp6_register_dev(struct inet6_dev *idev) |
617 | { | 617 | { |
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 | ||
51 | struct rt6_statistics rt6_stats; | 51 | struct rt6_statistics *rt6_stats; |
52 | 52 | ||
53 | static struct kmem_cache * fib6_node_kmem __read_mostly; | 53 | static 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 | ||
1569 | out_unregister_subsys: | 1574 | out_unregister_subsys: |
1570 | unregister_pernet_subsys(&fib6_net_ops); | 1575 | unregister_pernet_subsys(&fib6_net_ops); |
1576 | out_rt6_stats: | ||
1577 | kfree(rt6_stats); | ||
1571 | out_kmem_cache_create: | 1578 | out_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: | |||
1576 | void fib6_gc_cleanup(void) | 1583 | void 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 | } |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index b13eb0111270..370f2aef6909 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -2354,11 +2354,11 @@ static const struct file_operations ipv6_route_proc_fops = { | |||
2354 | static int rt6_stats_seq_show(struct seq_file *seq, void *v) | 2354 | static 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 | rt6_stats->fib_nodes, rt6_stats->fib_route_nodes, |
2358 | rt6_stats.fib_rt_alloc, rt6_stats.fib_rt_entries, | 2358 | rt6_stats->fib_rt_alloc, rt6_stats->fib_rt_entries, |
2359 | rt6_stats.fib_rt_cache, | 2359 | rt6_stats->fib_rt_cache, |
2360 | atomic_read(&ip6_dst_ops.entries), | 2360 | atomic_read(&ip6_dst_ops.entries), |
2361 | rt6_stats.fib_discarded_routes); | 2361 | rt6_stats->fib_discarded_routes); |
2362 | 2362 | ||
2363 | return 0; | 2363 | return 0; |
2364 | } | 2364 | } |