Commit fc3437fa authored by Randy Dunlap's avatar Randy Dunlap Committed by David S. Miller

[IPV6]: Convert /proc/net/{sockstat6,snmp6} to seq_file.

parent a802e299
...@@ -703,6 +703,8 @@ static void cleanup_ipv6_mibs(void) ...@@ -703,6 +703,8 @@ static void cleanup_ipv6_mibs(void)
kfree_percpu(udp_stats_in6[1]); kfree_percpu(udp_stats_in6[1]);
} }
extern int ipv6_misc_proc_init(void);
static int __init inet6_init(void) static int __init inet6_init(void)
{ {
struct sk_buff *dummy_skb; struct sk_buff *dummy_skb;
...@@ -786,10 +788,9 @@ static int __init inet6_init(void) ...@@ -786,10 +788,9 @@ static int __init inet6_init(void)
goto proc_tcp6_fail; goto proc_tcp6_fail;
if (!proc_net_create("udp6", 0, udp6_get_info)) if (!proc_net_create("udp6", 0, udp6_get_info))
goto proc_udp6_fail; goto proc_udp6_fail;
if (!proc_net_create("sockstat6", 0, afinet6_get_info)) if (ipv6_misc_proc_init())
goto proc_sockstat6_fail; goto proc_misc6_fail;
if (!proc_net_create("snmp6", 0, afinet6_get_snmp))
goto proc_snmp6_fail;
if (!proc_net_create("anycast6", 0, anycast6_get_info)) if (!proc_net_create("anycast6", 0, anycast6_get_info))
goto proc_anycast6_fail; goto proc_anycast6_fail;
#endif #endif
...@@ -800,7 +801,7 @@ static int __init inet6_init(void) ...@@ -800,7 +801,7 @@ static int __init inet6_init(void)
addrconf_init(); addrconf_init();
sit_init(); sit_init();
/* Init v6 extention headers. */ /* Init v6 extension headers. */
ipv6_hopopts_init(); ipv6_hopopts_init();
ipv6_rthdr_init(); ipv6_rthdr_init();
ipv6_frag_init(); ipv6_frag_init();
...@@ -815,10 +816,9 @@ static int __init inet6_init(void) ...@@ -815,10 +816,9 @@ static int __init inet6_init(void)
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
proc_anycast6_fail: proc_anycast6_fail:
proc_net_remove("anycast6"); proc_net_remove("snmp6");
proc_snmp6_fail:
proc_net_remove("sockstat6"); proc_net_remove("sockstat6");
proc_sockstat6_fail: proc_misc6_fail:
proc_net_remove("udp6"); proc_net_remove("udp6");
proc_udp6_fail: proc_udp6_fail:
proc_net_remove("tcp6"); proc_net_remove("tcp6");
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <linux/socket.h> #include <linux/socket.h>
#include <linux/net.h> #include <linux/net.h>
#include <linux/ipv6.h> #include <linux/ipv6.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/tcp.h> #include <net/tcp.h>
...@@ -37,22 +39,17 @@ static int fold_prot_inuse(struct proto *proto) ...@@ -37,22 +39,17 @@ static int fold_prot_inuse(struct proto *proto)
return res; return res;
} }
int afinet6_get_info(char *buffer, char **start, off_t offset, int length) static int sockstat6_seq_show(struct seq_file *seq, void *v)
{ {
int len = 0; seq_printf(seq, "TCP6: inuse %d\n",
len += sprintf(buffer+len, "TCP6: inuse %d\n",
fold_prot_inuse(&tcpv6_prot)); fold_prot_inuse(&tcpv6_prot));
len += sprintf(buffer+len, "UDP6: inuse %d\n", seq_printf(seq, "UDP6: inuse %d\n",
fold_prot_inuse(&udpv6_prot)); fold_prot_inuse(&udpv6_prot));
len += sprintf(buffer+len, "RAW6: inuse %d\n", seq_printf(seq, "RAW6: inuse %d\n",
fold_prot_inuse(&rawv6_prot)); fold_prot_inuse(&rawv6_prot));
len += sprintf(buffer+len, "FRAG6: inuse %d memory %d\n", seq_printf(seq, "FRAG6: inuse %d memory %d\n",
ip6_frag_nqueues, atomic_read(&ip6_frag_mem)); ip6_frag_nqueues, atomic_read(&ip6_frag_mem));
*start = buffer + offset; return 0;
len -= offset;
if(len > length)
len = length;
return len;
} }
...@@ -154,23 +151,63 @@ fold_field(void *mib[], int offt) ...@@ -154,23 +151,63 @@ fold_field(void *mib[], int offt)
return res; return res;
} }
int afinet6_get_snmp(char *buffer, char **start, off_t offset, int length) static int snmp6_seq_show(struct seq_file *seq, void *v)
{ {
int len = 0;
int i; int i;
for (i=0; i<sizeof(snmp6_list)/sizeof(snmp6_list[0]); i++) for (i=0; i<sizeof(snmp6_list)/sizeof(snmp6_list[0]); i++)
len += sprintf(buffer+len, "%-32s\t%ld\n", snmp6_list[i].name, seq_printf(seq, "%-32s\t%ld\n", snmp6_list[i].name,
fold_field(snmp6_list[i].mib, snmp6_list[i].offset)); fold_field(snmp6_list[i].mib, snmp6_list[i].offset));
len -= offset; return 0;
}
static int sockstat6_seq_open(struct inode *inode, struct file *file)
{
return single_open(file, sockstat6_seq_show, NULL);
}
static struct file_operations sockstat6_seq_fops = {
.open = sockstat6_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
if (len > length) static int snmp6_seq_open(struct inode *inode, struct file *file)
len = length; {
if(len < 0) return single_open(file, snmp6_seq_show, NULL);
len = 0; }
static struct file_operations snmp6_seq_fops = {
.open = snmp6_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
int __init ipv6_misc_proc_init(void)
{
int rc = 0;
struct proc_dir_entry *p;
*start = buffer + offset; p = create_proc_entry("snmp6", S_IRUGO, proc_net);
if (!p)
goto proc_snmp6_fail;
else
p->proc_fops = &snmp6_seq_fops;
p = create_proc_entry("sockstat6", S_IRUGO, proc_net);
if (!p)
goto proc_sockstat6_fail;
else
p->proc_fops = &sockstat6_seq_fops;
out:
return rc;
return len; proc_sockstat6_fail:
remove_proc_entry("snmp6", proc_net);
proc_snmp6_fail:
rc = -ENOMEM;
goto out;
} }
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