diff options
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/route.c | 70 |
1 files changed, 27 insertions, 43 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 3afc3f41f2d5..5d9d293156cd 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -2377,40 +2377,6 @@ static const struct file_operations rt6_stats_seq_fops = { | |||
2377 | .llseek = seq_lseek, | 2377 | .llseek = seq_lseek, |
2378 | .release = single_release, | 2378 | .release = single_release, |
2379 | }; | 2379 | }; |
2380 | |||
2381 | static int ipv6_route_proc_init(struct net *net) | ||
2382 | { | ||
2383 | int ret = -ENOMEM; | ||
2384 | if (!proc_net_fops_create(net, "ipv6_route", | ||
2385 | 0, &ipv6_route_proc_fops)) | ||
2386 | goto out; | ||
2387 | |||
2388 | if (!proc_net_fops_create(net, "rt6_stats", | ||
2389 | S_IRUGO, &rt6_stats_seq_fops)) | ||
2390 | goto out_ipv6_route; | ||
2391 | |||
2392 | ret = 0; | ||
2393 | out: | ||
2394 | return ret; | ||
2395 | out_ipv6_route: | ||
2396 | proc_net_remove(net, "ipv6_route"); | ||
2397 | goto out; | ||
2398 | } | ||
2399 | |||
2400 | static void ipv6_route_proc_fini(struct net *net) | ||
2401 | { | ||
2402 | proc_net_remove(net, "ipv6_route"); | ||
2403 | proc_net_remove(net, "rt6_stats"); | ||
2404 | } | ||
2405 | #else | ||
2406 | static inline int ipv6_route_proc_init(struct net *net) | ||
2407 | { | ||
2408 | return 0; | ||
2409 | } | ||
2410 | static inline void ipv6_route_proc_fini(struct net *net) | ||
2411 | { | ||
2412 | return ; | ||
2413 | } | ||
2414 | #endif /* CONFIG_PROC_FS */ | 2380 | #endif /* CONFIG_PROC_FS */ |
2415 | 2381 | ||
2416 | #ifdef CONFIG_SYSCTL | 2382 | #ifdef CONFIG_SYSCTL |
@@ -2544,6 +2510,28 @@ struct ctl_table *ipv6_route_sysctl_init(struct net *net) | |||
2544 | } | 2510 | } |
2545 | #endif | 2511 | #endif |
2546 | 2512 | ||
2513 | static int ip6_route_net_init(struct net *net) | ||
2514 | { | ||
2515 | #ifdef CONFIG_PROC_FS | ||
2516 | proc_net_fops_create(net, "ipv6_route", 0, &ipv6_route_proc_fops); | ||
2517 | proc_net_fops_create(net, "rt6_stats", S_IRUGO, &rt6_stats_seq_fops); | ||
2518 | #endif | ||
2519 | return 0; | ||
2520 | } | ||
2521 | |||
2522 | static void ip6_route_net_exit(struct net *net) | ||
2523 | { | ||
2524 | #ifdef CONFIG_PROC_FS | ||
2525 | proc_net_remove(net, "ipv6_route"); | ||
2526 | proc_net_remove(net, "rt6_stats"); | ||
2527 | #endif | ||
2528 | } | ||
2529 | |||
2530 | static struct pernet_operations ip6_route_net_ops = { | ||
2531 | .init = ip6_route_net_init, | ||
2532 | .exit = ip6_route_net_exit, | ||
2533 | }; | ||
2534 | |||
2547 | int __init ip6_route_init(void) | 2535 | int __init ip6_route_init(void) |
2548 | { | 2536 | { |
2549 | int ret; | 2537 | int ret; |
@@ -2560,13 +2548,9 @@ int __init ip6_route_init(void) | |||
2560 | if (ret) | 2548 | if (ret) |
2561 | goto out_kmem_cache; | 2549 | goto out_kmem_cache; |
2562 | 2550 | ||
2563 | ret = ipv6_route_proc_init(&init_net); | ||
2564 | if (ret) | ||
2565 | goto out_fib6_init; | ||
2566 | |||
2567 | ret = xfrm6_init(); | 2551 | ret = xfrm6_init(); |
2568 | if (ret) | 2552 | if (ret) |
2569 | goto out_proc_init; | 2553 | goto out_fib6_init; |
2570 | 2554 | ||
2571 | ret = fib6_rules_init(); | 2555 | ret = fib6_rules_init(); |
2572 | if (ret) | 2556 | if (ret) |
@@ -2578,7 +2562,9 @@ int __init ip6_route_init(void) | |||
2578 | __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL)) | 2562 | __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL)) |
2579 | goto fib6_rules_init; | 2563 | goto fib6_rules_init; |
2580 | 2564 | ||
2581 | ret = 0; | 2565 | ret = register_pernet_subsys(&ip6_route_net_ops); |
2566 | if (ret) | ||
2567 | goto fib6_rules_init; | ||
2582 | out: | 2568 | out: |
2583 | return ret; | 2569 | return ret; |
2584 | 2570 | ||
@@ -2586,8 +2572,6 @@ fib6_rules_init: | |||
2586 | fib6_rules_cleanup(); | 2572 | fib6_rules_cleanup(); |
2587 | xfrm6_init: | 2573 | xfrm6_init: |
2588 | xfrm6_fini(); | 2574 | xfrm6_fini(); |
2589 | out_proc_init: | ||
2590 | ipv6_route_proc_fini(&init_net); | ||
2591 | out_fib6_init: | 2575 | out_fib6_init: |
2592 | rt6_ifdown(&init_net, NULL); | 2576 | rt6_ifdown(&init_net, NULL); |
2593 | fib6_gc_cleanup(); | 2577 | fib6_gc_cleanup(); |
@@ -2598,8 +2582,8 @@ out_kmem_cache: | |||
2598 | 2582 | ||
2599 | void ip6_route_cleanup(void) | 2583 | void ip6_route_cleanup(void) |
2600 | { | 2584 | { |
2585 | unregister_pernet_subsys(&ip6_route_net_ops); | ||
2601 | fib6_rules_cleanup(); | 2586 | fib6_rules_cleanup(); |
2602 | ipv6_route_proc_fini(&init_net); | ||
2603 | xfrm6_fini(); | 2587 | xfrm6_fini(); |
2604 | rt6_ifdown(&init_net, NULL); | 2588 | rt6_ifdown(&init_net, NULL); |
2605 | fib6_gc_cleanup(); | 2589 | fib6_gc_cleanup(); |