diff options
author | Daniel Lezcano <dlezcano@fr.ibm.com> | 2007-12-08 03:13:32 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:56:58 -0500 |
commit | 75314fb38364c81a573cd222f74d792409a7afba (patch) | |
tree | c9f65215a6c0be4a61acd4c54c39a43c76af33c6 /net/ipv6 | |
parent | b8e1f9b5c37e77cc8f978a58859b35fe5edd5542 (diff) |
[IPV6]: create route6 proc init-fini functions
Make the proc creation/destruction to be a separate function. That
allows to remove the #ifdef CONFIG_PROC_FS in the init/fini function
and make them more readable.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/route.c | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 6f833cacfcfb..dbdae143ef5f 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -2358,6 +2358,40 @@ static const struct file_operations rt6_stats_seq_fops = { | |||
2358 | .llseek = seq_lseek, | 2358 | .llseek = seq_lseek, |
2359 | .release = single_release, | 2359 | .release = single_release, |
2360 | }; | 2360 | }; |
2361 | |||
2362 | static int ipv6_route_proc_init(struct net *net) | ||
2363 | { | ||
2364 | int ret = -ENOMEM; | ||
2365 | if (!proc_net_fops_create(net, "ipv6_route", | ||
2366 | 0, &ipv6_route_proc_fops)) | ||
2367 | goto out; | ||
2368 | |||
2369 | if (!proc_net_fops_create(net, "rt6_stats", | ||
2370 | S_IRUGO, &rt6_stats_seq_fops)) | ||
2371 | goto out_ipv6_route; | ||
2372 | |||
2373 | ret = 0; | ||
2374 | out: | ||
2375 | return ret; | ||
2376 | out_ipv6_route: | ||
2377 | proc_net_remove(net, "ipv6_route"); | ||
2378 | goto out; | ||
2379 | } | ||
2380 | |||
2381 | static void ipv6_route_proc_fini(struct net *net) | ||
2382 | { | ||
2383 | proc_net_remove(net, "ipv6_route"); | ||
2384 | proc_net_remove(net, "rt6_stats"); | ||
2385 | } | ||
2386 | #else | ||
2387 | static inline int ipv6_route_proc_init(struct net *net) | ||
2388 | { | ||
2389 | return 0; | ||
2390 | } | ||
2391 | static inline void ipv6_route_proc_fini(struct net *net) | ||
2392 | { | ||
2393 | return ; | ||
2394 | } | ||
2361 | #endif /* CONFIG_PROC_FS */ | 2395 | #endif /* CONFIG_PROC_FS */ |
2362 | 2396 | ||
2363 | #ifdef CONFIG_SYSCTL | 2397 | #ifdef CONFIG_SYSCTL |
@@ -2484,21 +2518,14 @@ int __init ip6_route_init(void) | |||
2484 | if (ret) | 2518 | if (ret) |
2485 | goto out_kmem_cache; | 2519 | goto out_kmem_cache; |
2486 | 2520 | ||
2487 | #ifdef CONFIG_PROC_FS | 2521 | ret = ipv6_route_proc_init(&init_net); |
2488 | ret = -ENOMEM; | 2522 | if (ret) |
2489 | if (!proc_net_fops_create(&init_net, "ipv6_route", | ||
2490 | 0, &ipv6_route_proc_fops)) | ||
2491 | goto out_fib6_init; | 2523 | goto out_fib6_init; |
2492 | 2524 | ||
2493 | if (!proc_net_fops_create(&init_net, "rt6_stats", | ||
2494 | S_IRUGO, &rt6_stats_seq_fops)) | ||
2495 | goto out_proc_ipv6_route; | ||
2496 | #endif | ||
2497 | |||
2498 | #ifdef CONFIG_XFRM | 2525 | #ifdef CONFIG_XFRM |
2499 | ret = xfrm6_init(); | 2526 | ret = xfrm6_init(); |
2500 | if (ret) | 2527 | if (ret) |
2501 | goto out_proc_rt6_stats; | 2528 | goto out_proc_init; |
2502 | #endif | 2529 | #endif |
2503 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 2530 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
2504 | ret = fib6_rules_init(); | 2531 | ret = fib6_rules_init(); |
@@ -2522,14 +2549,10 @@ xfrm6_init: | |||
2522 | #endif | 2549 | #endif |
2523 | #ifdef CONFIG_XFRM | 2550 | #ifdef CONFIG_XFRM |
2524 | xfrm6_fini(); | 2551 | xfrm6_fini(); |
2525 | out_proc_rt6_stats: | ||
2526 | #endif | 2552 | #endif |
2527 | #ifdef CONFIG_PROC_FS | 2553 | out_proc_init: |
2528 | proc_net_remove(&init_net, "rt6_stats"); | 2554 | ipv6_route_proc_fini(&init_net); |
2529 | out_proc_ipv6_route: | ||
2530 | proc_net_remove(&init_net, "ipv6_route"); | ||
2531 | out_fib6_init: | 2555 | out_fib6_init: |
2532 | #endif | ||
2533 | rt6_ifdown(NULL); | 2556 | rt6_ifdown(NULL); |
2534 | fib6_gc_cleanup(); | 2557 | fib6_gc_cleanup(); |
2535 | out_kmem_cache: | 2558 | out_kmem_cache: |
@@ -2542,8 +2565,7 @@ void ip6_route_cleanup(void) | |||
2542 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 2565 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
2543 | fib6_rules_cleanup(); | 2566 | fib6_rules_cleanup(); |
2544 | #endif | 2567 | #endif |
2545 | proc_net_remove(&init_net, "ipv6_route"); | 2568 | ipv6_route_proc_fini(&init_net); |
2546 | proc_net_remove(&init_net, "rt6_stats"); | ||
2547 | #ifdef CONFIG_XFRM | 2569 | #ifdef CONFIG_XFRM |
2548 | xfrm6_fini(); | 2570 | xfrm6_fini(); |
2549 | #endif | 2571 | #endif |