#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
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;
}
{
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)
/* 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);
}
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);
#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;
#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 = {
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)
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;
void fib6_gc_cleanup(void)
{
unregister_pernet_subsys(&fib6_net_ops);
- kfree(rt6_stats);
kmem_cache_destroy(fib6_node_kmem);
}
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;
}