Commit 107f1634 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

[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: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 78c686e9
...@@ -520,6 +520,44 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset, ...@@ -520,6 +520,44 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset,
return length; return length;
} }
#endif #endif
static __init int ip_rt_proc_init(struct net *net)
{
struct proc_dir_entry *pde;
pde = proc_net_fops_create(net, "rt_cache", S_IRUGO,
&rt_cache_seq_fops);
if (!pde)
goto err1;
pde = create_proc_entry("rt_cache", S_IRUGO, net->proc_net_stat);
if (!pde)
goto err2;
pde->proc_fops = &rt_cpu_seq_fops;
#ifdef CONFIG_NET_CLS_ROUTE
pde = create_proc_read_entry("rt_acct", 0, net->proc_net,
ip_rt_acct_read, NULL);
if (!pde)
goto err3;
#endif
return 0;
#ifdef CONFIG_NET_CLS_ROUTE
err3:
remove_proc_entry("rt_cache", net->proc_net_stat);
#endif
err2:
remove_proc_entry("rt_cache", net->proc_net);
err1:
return -ENOMEM;
}
#else
static inline int ip_rt_proc_init(struct net *net)
{
return 0;
}
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
static __inline__ void rt_free(struct rtable *rt) static __inline__ void rt_free(struct rtable *rt)
...@@ -3000,20 +3038,8 @@ int __init ip_rt_init(void) ...@@ -3000,20 +3038,8 @@ int __init ip_rt_init(void)
ip_rt_secret_interval; ip_rt_secret_interval;
add_timer(&rt_secret_timer); add_timer(&rt_secret_timer);
#ifdef CONFIG_PROC_FS if (ip_rt_proc_init(&init_net))
{ printk(KERN_ERR "Unable to create route proc files\n");
struct proc_dir_entry *rtstat_pde = NULL; /* keep gcc happy */
if (!proc_net_fops_create(&init_net, "rt_cache", S_IRUGO, &rt_cache_seq_fops) ||
!(rtstat_pde = create_proc_entry("rt_cache", S_IRUGO,
init_net.proc_net_stat))) {
return -ENOMEM;
}
rtstat_pde->proc_fops = &rt_cpu_seq_fops;
}
#ifdef CONFIG_NET_CLS_ROUTE
create_proc_read_entry("rt_acct", 0, init_net.proc_net, ip_rt_acct_read, NULL);
#endif
#endif
#ifdef CONFIG_XFRM #ifdef CONFIG_XFRM
xfrm_init(); xfrm_init();
xfrm4_init(); xfrm4_init();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment