diff options
Diffstat (limited to 'net/ipv6/ip6_fib.c')
-rw-r--r-- | net/ipv6/ip6_fib.c | 32 |
1 files changed, 15 insertions, 17 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 | ||
51 | struct rt6_statistics *rt6_stats; | ||
52 | |||
53 | static struct kmem_cache * fib6_node_kmem __read_mostly; | 51 | static struct kmem_cache * fib6_node_kmem __read_mostly; |
54 | 52 | ||
55 | enum fib_walk_state_t | 53 | enum 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 |
1525 | out_fib_table_hash: | 1528 | out_fib_table_hash: |
1526 | kfree(net->ipv6.fib_table_hash); | 1529 | kfree(net->ipv6.fib_table_hash); |
1530 | out_rt6_stats: | ||
1531 | kfree(net->ipv6.rt6_stats); | ||
1527 | out_timer: | 1532 | out_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 | ||
1543 | static struct pernet_operations fib6_net_ops = { | 1549 | static 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 | ||
1574 | out_unregister_subsys: | 1575 | out_unregister_subsys: |
1575 | unregister_pernet_subsys(&fib6_net_ops); | 1576 | unregister_pernet_subsys(&fib6_net_ops); |
1576 | out_rt6_stats: | ||
1577 | kfree(rt6_stats); | ||
1578 | out_kmem_cache_create: | 1577 | out_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: | |||
1583 | void fib6_gc_cleanup(void) | 1582 | void 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 | } |