aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-12-06 00:14:28 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:56:36 -0500
commit107f163428b846d7cef68cb6f436788bb2f6c2e1 (patch)
treed5cc806a1f71471b8dbe67a4a107ed840f757ad2 /net
parent78c686e9faff05f1194e892d5b1273ce24021ff6 (diff)
[IPV4] ROUTE: Clean up proc files creation.
The rt_cache, stats/rt_cache and rt_acct(optional) files creation looks a bit messy. Clean this out and join them to other proc-related functions under the proper ifdef. The struct net * argument in a new function will help net namespaces patches look nicer. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/route.c54
1 files changed, 40 insertions, 14 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 9736f6895628..193788381a59 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -520,6 +520,44 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset,
520 return length; 520 return length;
521} 521}
522#endif 522#endif
523
524static __init int ip_rt_proc_init(struct net *net)
525{
526 struct proc_dir_entry *pde;
527
528 pde = proc_net_fops_create(net, "rt_cache", S_IRUGO,
529 &rt_cache_seq_fops);
530 if (!pde)
531 goto err1;
532
533 pde = create_proc_entry("rt_cache", S_IRUGO, net->proc_net_stat);
534 if (!pde)
535 goto err2;
536
537 pde->proc_fops = &rt_cpu_seq_fops;
538
539#ifdef CONFIG_NET_CLS_ROUTE
540 pde = create_proc_read_entry("rt_acct", 0, net->proc_net,
541 ip_rt_acct_read, NULL);
542 if (!pde)
543 goto err3;
544#endif
545 return 0;
546
547#ifdef CONFIG_NET_CLS_ROUTE
548err3:
549 remove_proc_entry("rt_cache", net->proc_net_stat);
550#endif
551err2:
552 remove_proc_entry("rt_cache", net->proc_net);
553err1:
554 return -ENOMEM;
555}
556#else
557static inline int ip_rt_proc_init(struct net *net)
558{
559 return 0;
560}
523#endif /* CONFIG_PROC_FS */ 561#endif /* CONFIG_PROC_FS */
524 562
525static __inline__ void rt_free(struct rtable *rt) 563static __inline__ void rt_free(struct rtable *rt)
@@ -3000,20 +3038,8 @@ int __init ip_rt_init(void)
3000 ip_rt_secret_interval; 3038 ip_rt_secret_interval;
3001 add_timer(&rt_secret_timer); 3039 add_timer(&rt_secret_timer);
3002 3040
3003#ifdef CONFIG_PROC_FS 3041 if (ip_rt_proc_init(&init_net))
3004 { 3042 printk(KERN_ERR "Unable to create route proc files\n");
3005 struct proc_dir_entry *rtstat_pde = NULL; /* keep gcc happy */
3006 if (!proc_net_fops_create(&init_net, "rt_cache", S_IRUGO, &rt_cache_seq_fops) ||
3007 !(rtstat_pde = create_proc_entry("rt_cache", S_IRUGO,
3008 init_net.proc_net_stat))) {
3009 return -ENOMEM;
3010 }
3011 rtstat_pde->proc_fops = &rt_cpu_seq_fops;
3012 }
3013#ifdef CONFIG_NET_CLS_ROUTE
3014 create_proc_read_entry("rt_acct", 0, init_net.proc_net, ip_rt_acct_read, NULL);
3015#endif
3016#endif
3017#ifdef CONFIG_XFRM 3043#ifdef CONFIG_XFRM
3018 xfrm_init(); 3044 xfrm_init();
3019 xfrm4_init(); 3045 xfrm4_init();