ipv4: move proc stuff from net/ipv4/af_inet.c to net/ipv4/proc.c

Also make compilation of this misc proc stuff not compile/link if
CONFIG_PROC_FS is not set. Now to seq_file this routines.
parent 29cdd1db
......@@ -277,5 +277,6 @@ static inline void fib_res_put(struct fib_result *res)
}
extern int fib_proc_init(void);
extern void fib_proc_exit(void);
#endif /* _NET_FIB_H */
......@@ -2,13 +2,14 @@
# Makefile for the Linux TCP/IP (INET) layer.
#
obj-y := utils.o route.o inetpeer.o proc.o protocol.o \
obj-y := utils.o route.o inetpeer.o protocol.o \
ip_input.o ip_fragment.o ip_forward.o ip_options.o \
ip_output.o ip_sockglue.o \
tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o tcp_minisocks.o \
tcp_diag.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \
sysctl_net_ipv4.o fib_frontend.o fib_semantics.o fib_hash.o
obj-$(CONFIG_PROC_FS) += proc.o
obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o
obj-$(CONFIG_IP_ROUTE_NAT) += ip_nat_dumb.o
obj-$(CONFIG_IP_MROUTE) += ipmr.o
......
......@@ -1155,12 +1155,9 @@ module_init(inet_init);
#ifdef CONFIG_PROC_FS
extern int ip_misc_proc_init(void);
extern int raw_get_info(char *, char **, off_t, int);
extern int snmp_get_info(char *, char **, off_t, int);
extern int netstat_get_info(char *, char **, off_t, int);
extern int afinet_get_info(char *, char **, off_t, int);
extern int tcp_get_info(char *, char **, off_t, int);
extern int udp_get_info(char *, char **, off_t, int);
int __init ipv4_proc_init(void)
{
......@@ -1168,45 +1165,29 @@ int __init ipv4_proc_init(void)
if (!proc_net_create("raw", 0, raw_get_info))
goto out_raw;
if (!proc_net_create("netstat", 0, netstat_get_info))
goto out_netstat;
if (!proc_net_create("snmp", 0, snmp_get_info))
goto out_snmp;
if (!proc_net_create("sockstat", 0, afinet_get_info))
goto out_sockstat;
if (!proc_net_create("tcp", 0, tcp_get_info))
goto out_tcp;
if (udp_proc_init())
goto out_udp;
if (fib_proc_init())
goto out_fib;
if (ip_misc_proc_init())
goto out_misc;
out:
return rc;
out_misc:
fib_proc_exit();
out_fib:
udp_proc_exit();
out_udp:
proc_net_remove("tcp");
out_tcp:
proc_net_remove("sockstat");
out_sockstat:
proc_net_remove("snmp");
out_snmp:
proc_net_remove("netstat");
out_netstat:
proc_net_remove("raw");
out_raw:
rc = -ENOMEM;
goto out;
}
int ip_seq_release(struct inode *inode, struct file *file)
{
struct seq_file *seq = (struct seq_file *)file->private_data;
kfree(seq->private);
seq->private = NULL;
return seq_release(inode, file);
}
#else /* CONFIG_PROC_FS */
int __init ipv4_proc_init(void)
{
......
......@@ -1086,9 +1086,21 @@ int __init fib_proc_init(void)
rc = -ENOMEM;
return rc;
}
void __init fib_proc_exit(void)
{
remove_proc_entry("route", proc_net);
}
#else /* CONFIG_PROC_FS */
int __init fib_proc_init(void)
{
return 0;
}
void __init fib_proc_exit(void)
{
return 0;
}
#endif /* CONFIG_PROC_FS */
......@@ -47,6 +47,8 @@
#include <net/tcp.h>
#include <net/udp.h>
#include <linux/skbuff.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <net/sock.h>
#include <net/raw.h>
......@@ -212,3 +214,33 @@ int netstat_get_info(char *buffer, char **start, off_t offset, int length)
len = 0;
return len;
}
int __init ip_misc_proc_init(void)
{
int rc = 0;
if (!proc_net_create("netstat", 0, netstat_get_info))
goto out_netstat;
if (!proc_net_create("snmp", 0, snmp_get_info))
goto out_snmp;
if (!proc_net_create("sockstat", 0, afinet_get_info))
goto out_sockstat;
out:
return rc;
out_sockstat:
proc_net_remove("snmp");
out_snmp:
proc_net_remove("netstat");
out_netstat:
rc = -ENOMEM;
goto out;
}
int ip_seq_release(struct inode *inode, struct file *file)
{
struct seq_file *seq = (struct seq_file *)file->private_data;
kfree(seq->private);
seq->private = NULL;
return seq_release(inode, file);
}
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