Commit 1c7b149b authored by David S. Miller's avatar David S. Miller

Merge master.kernel.org:/home/acme/BK/net-2.5

into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents 81b4c8d1 88de51ee
...@@ -57,7 +57,4 @@ struct udp_sock { ...@@ -57,7 +57,4 @@ struct udp_sock {
#define udp_sk(__sk) (&((struct udp_sock *)__sk)->udp) #define udp_sk(__sk) (&((struct udp_sock *)__sk)->udp)
extern int udp_proc_init(void);
extern void udp_proc_exit(void);
#endif /* _LINUX_UDP_H */ #endif /* _LINUX_UDP_H */
...@@ -276,7 +276,4 @@ static inline void fib_res_put(struct fib_result *res) ...@@ -276,7 +276,4 @@ static inline void fib_res_put(struct fib_result *res)
#endif #endif
} }
extern int fib_proc_init(void);
extern void fib_proc_exit(void);
#endif /* _NET_FIB_H */ #endif /* _NET_FIB_H */
...@@ -76,6 +76,4 @@ extern struct udp_mib udp_statistics[NR_CPUS*2]; ...@@ -76,6 +76,4 @@ extern struct udp_mib udp_statistics[NR_CPUS*2];
#define UDP_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_statistics, field) #define UDP_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_statistics, field)
#define UDP_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_statistics, field) #define UDP_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_statistics, field)
extern int udp_proc_init(void);
#endif /* _UDP_H */ #endif /* _UDP_H */
...@@ -1160,16 +1160,20 @@ module_init(inet_init); ...@@ -1160,16 +1160,20 @@ module_init(inet_init);
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
extern int fib_proc_init(void);
extern void fib_proc_exit(void);
extern int ip_misc_proc_init(void); extern int ip_misc_proc_init(void);
extern int raw_get_info(char *, char **, off_t, int); extern int raw_proc_init(void);
extern int tcp_get_info(char *, char **, off_t, int); extern void raw_proc_exit(void);
extern int tcp_get_info(char *buffer, char **start, off_t offset, int length);
extern int udp_proc_init(void);
extern void udp_proc_exit(void);
int __init ipv4_proc_init(void) int __init ipv4_proc_init(void)
{ {
int rc = 0; int rc = 0;
if (!proc_net_create("raw", 0, raw_get_info)) if (raw_proc_init())
goto out_raw; goto out_raw;
if (!proc_net_create("tcp", 0, tcp_get_info)) if (!proc_net_create("tcp", 0, tcp_get_info))
goto out_tcp; goto out_tcp;
...@@ -1188,7 +1192,7 @@ int __init ipv4_proc_init(void) ...@@ -1188,7 +1192,7 @@ int __init ipv4_proc_init(void)
out_udp: out_udp:
proc_net_remove("tcp"); proc_net_remove("tcp");
out_tcp: out_tcp:
proc_net_remove("raw"); raw_proc_exit();
out_raw: out_raw:
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
......
...@@ -1092,16 +1092,4 @@ void __init fib_proc_exit(void) ...@@ -1092,16 +1092,4 @@ void __init fib_proc_exit(void)
{ {
remove_proc_entry("route", proc_net); 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 */ #endif /* CONFIG_PROC_FS */
...@@ -26,27 +26,18 @@ ...@@ -26,27 +26,18 @@
* Andi Kleen : Add support for open_requests and * Andi Kleen : Add support for open_requests and
* split functions for more readibility. * split functions for more readibility.
* Andi Kleen : Add support for /proc/net/netstat * Andi Kleen : Add support for /proc/net/netstat
* Arnaldo C. Melo : Convert to seq_file
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version * as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#include <asm/system.h> #include <linux/types.h>
#include <linux/sched.h>
#include <linux/socket.h>
#include <linux/net.h>
#include <linux/un.h>
#include <linux/in.h>
#include <linux/param.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <net/ip.h>
#include <net/icmp.h> #include <net/icmp.h>
#include <net/protocol.h> #include <net/protocol.h>
#include <net/tcp.h> #include <net/tcp.h>
#include <net/udp.h> #include <net/udp.h>
#include <linux/skbuff.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <net/sock.h> #include <net/sock.h>
...@@ -57,7 +48,7 @@ static int fold_prot_inuse(struct proto *proto) ...@@ -57,7 +48,7 @@ static int fold_prot_inuse(struct proto *proto)
int res = 0; int res = 0;
int cpu; int cpu;
for (cpu=0; cpu<NR_CPUS; cpu++) for (cpu = 0; cpu < NR_CPUS; cpu++)
res += proto->stats[cpu].inuse; res += proto->stats[cpu].inuse;
return res; return res;
...@@ -66,38 +57,35 @@ static int fold_prot_inuse(struct proto *proto) ...@@ -66,38 +57,35 @@ static int fold_prot_inuse(struct proto *proto)
/* /*
* Report socket allocation statistics [mea@utu.fi] * Report socket allocation statistics [mea@utu.fi]
*/ */
int afinet_get_info(char *buffer, char **start, off_t offset, int length) static int sockstat_seq_show(struct seq_file *seq, void *v)
{ {
/* From net/socket.c */ /* From net/socket.c */
extern int socket_get_info(char *, char **, off_t, int); extern void socket_seq_show(struct seq_file *seq);
int len = socket_get_info(buffer,start,offset,length); socket_seq_show(seq);
seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %d\n",
len += sprintf(buffer+len,"TCP: inuse %d orphan %d tw %d alloc %d mem %d\n", fold_prot_inuse(&tcp_prot), atomic_read(&tcp_orphan_count),
fold_prot_inuse(&tcp_prot), tcp_tw_count, atomic_read(&tcp_sockets_allocated),
atomic_read(&tcp_orphan_count), tcp_tw_count,
atomic_read(&tcp_sockets_allocated),
atomic_read(&tcp_memory_allocated)); atomic_read(&tcp_memory_allocated));
len += sprintf(buffer+len,"UDP: inuse %d\n", seq_printf(seq, "UDP: inuse %d\n", fold_prot_inuse(&udp_prot));
fold_prot_inuse(&udp_prot)); seq_printf(seq, "RAW: inuse %d\n", fold_prot_inuse(&raw_prot));
len += sprintf(buffer+len,"RAW: inuse %d\n", seq_printf(seq, "FRAG: inuse %d memory %d\n", ip_frag_nqueues,
fold_prot_inuse(&raw_prot)); atomic_read(&ip_frag_mem));
len += sprintf(buffer+len, "FRAG: inuse %d memory %d\n",
ip_frag_nqueues, atomic_read(&ip_frag_mem));
if (offset >= len)
{
*start = buffer;
return 0; return 0;
}
*start = buffer + offset;
len -= offset;
if (len > length)
len = length;
if (len < 0)
len = 0;
return len;
} }
static int sockstat_seq_open(struct inode *inode, struct file *file)
{
return single_open(file, sockstat_seq_show, NULL);
}
static struct file_operations sockstat_seq_fops = {
.open = sockstat_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static unsigned long fold_field(unsigned long *begin, int sz, int nr) static unsigned long fold_field(unsigned long *begin, int sz, int nr)
{ {
unsigned long res = 0; unsigned long res = 0;
...@@ -105,9 +93,9 @@ static unsigned long fold_field(unsigned long *begin, int sz, int nr) ...@@ -105,9 +93,9 @@ static unsigned long fold_field(unsigned long *begin, int sz, int nr)
sz /= sizeof(unsigned long); sz /= sizeof(unsigned long);
for (i=0; i<NR_CPUS; i++) { for (i = 0; i < NR_CPUS; i++) {
res += begin[2*i*sz + nr]; res += begin[2 * i * sz + nr];
res += begin[(2*i+1)*sz + nr]; res += begin[(2 * i + 1) * sz + nr];
} }
return res; return res;
} }
...@@ -115,52 +103,73 @@ static unsigned long fold_field(unsigned long *begin, int sz, int nr) ...@@ -115,52 +103,73 @@ static unsigned long fold_field(unsigned long *begin, int sz, int nr)
/* /*
* Called from the PROCfs module. This outputs /proc/net/snmp. * Called from the PROCfs module. This outputs /proc/net/snmp.
*/ */
static int snmp_seq_show(struct seq_file *seq, void *v)
int snmp_get_info(char *buffer, char **start, off_t offset, int length)
{ {
extern int sysctl_ip_default_ttl; extern int sysctl_ip_default_ttl;
int len, i; int i;
len = sprintf (buffer, seq_printf(seq, "Ip: Forwarding DefaultTTL InReceives InHdrErrors "
"Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates\n" "InAddrErrors ForwDatagrams InUnknownProtos "
"Ip: %d %d", ipv4_devconf.forwarding ? 1 : 2, sysctl_ip_default_ttl); "InDiscards InDelivers OutRequests OutDiscards "
for (i=0; i<offsetof(struct ip_mib, __pad)/sizeof(unsigned long); i++) "OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs "
len += sprintf(buffer+len, " %lu", fold_field((unsigned long*)ip_statistics, sizeof(struct ip_mib), i)); "ReasmFails FragOKs FragFails FragCreates\nIp: %d %d",
ipv4_devconf.forwarding ? 1 : 2, sysctl_ip_default_ttl);
len += sprintf (buffer + len,
"\nIcmp: InMsgs InErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps\n" for (i = 0;
"Icmp:"); i < offsetof(struct ip_mib, __pad) / sizeof(unsigned long); i++)
for (i=0; i<offsetof(struct icmp_mib, dummy)/sizeof(unsigned long); i++) seq_printf(seq, " %lu",
len += sprintf(buffer+len, " %lu", fold_field((unsigned long*)icmp_statistics, sizeof(struct icmp_mib), i)); fold_field((unsigned long *)ip_statistics,
sizeof(struct ip_mib), i));
len += sprintf (buffer + len,
"\nTcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts\n" seq_printf(seq, "\nIcmp: InMsgs InErrors InDestUnreachs InTimeExcds "
"Tcp:"); "InParmProbs InSrcQuenchs InRedirects InEchos "
for (i=0; i<offsetof(struct tcp_mib, __pad)/sizeof(unsigned long); i++) "InEchoReps InTimestamps InTimestampReps InAddrMasks "
len += sprintf(buffer+len, " %lu", fold_field((unsigned long*)tcp_statistics, sizeof(struct tcp_mib), i)); "InAddrMaskReps OutMsgs OutErrors OutDestUnreachs "
"OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects "
len += sprintf (buffer + len, "OutEchos OutEchoReps OutTimestamps OutTimestampReps "
"\nUdp: InDatagrams NoPorts InErrors OutDatagrams\n" "OutAddrMasks OutAddrMaskReps\nIcmp:");
for (i = 0;
i < offsetof(struct icmp_mib, dummy) / sizeof(unsigned long); i++)
seq_printf(seq, " %lu",
fold_field((unsigned long *)icmp_statistics,
sizeof(struct icmp_mib), i));
seq_printf(seq, "\nTcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens "
"PassiveOpens AttemptFails EstabResets CurrEstab "
"InSegs OutSegs RetransSegs InErrs OutRsts\nTcp:");
for (i = 0;
i < offsetof(struct tcp_mib, __pad) / sizeof(unsigned long); i++)
seq_printf(seq, " %lu",
fold_field((unsigned long *)tcp_statistics,
sizeof(struct tcp_mib), i));
seq_printf(seq, "\nUdp: InDatagrams NoPorts InErrors OutDatagrams\n"
"Udp:"); "Udp:");
for (i=0; i<offsetof(struct udp_mib, __pad)/sizeof(unsigned long); i++)
len += sprintf(buffer+len, " %lu", fold_field((unsigned long*)udp_statistics, sizeof(struct udp_mib), i));
len += sprintf (buffer + len, "\n"); for (i = 0;
i < offsetof(struct udp_mib, __pad) / sizeof(unsigned long); i++)
seq_printf(seq, " %lu",
fold_field((unsigned long *)udp_statistics,
sizeof(struct udp_mib), i));
if (offset >= len) seq_putc(seq, '\n');
{
*start = buffer;
return 0; return 0;
}
*start = buffer + offset;
len -= offset;
if (len > length)
len = length;
if (len < 0)
len = 0;
return len;
} }
static int snmp_seq_open(struct inode *inode, struct file *file)
{
return single_open(file, snmp_seq_show, NULL);
}
static struct file_operations snmp_seq_fops = {
.open = snmp_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/* /*
* Output /proc/net/netstat * Output /proc/net/netstat
*/ */
...@@ -181,7 +190,8 @@ static int netstat_seq_show(struct seq_file *seq, void *v) ...@@ -181,7 +190,8 @@ static int netstat_seq_show(struct seq_file *seq, void *v)
" TCPPureAcks TCPHPAcks" " TCPPureAcks TCPHPAcks"
" TCPRenoRecovery TCPSackRecovery" " TCPRenoRecovery TCPSackRecovery"
" TCPSACKReneging" " TCPSACKReneging"
" TCPFACKReorder TCPSACKReorder TCPRenoReorder TCPTSReorder" " TCPFACKReorder TCPSACKReorder TCPRenoReorder"
" TCPTSReorder"
" TCPFullUndo TCPPartialUndo TCPDSACKUndo TCPLossUndo" " TCPFullUndo TCPPartialUndo TCPDSACKUndo TCPLossUndo"
" TCPLoss TCPLostRetransmit" " TCPLoss TCPLostRetransmit"
" TCPRenoFailures TCPSackFailures TCPLossFailures" " TCPRenoFailures TCPSackFailures TCPLossFailures"
...@@ -189,14 +199,14 @@ static int netstat_seq_show(struct seq_file *seq, void *v) ...@@ -189,14 +199,14 @@ static int netstat_seq_show(struct seq_file *seq, void *v)
" TCPTimeouts" " TCPTimeouts"
" TCPRenoRecoveryFail TCPSackRecoveryFail" " TCPRenoRecoveryFail TCPSackRecoveryFail"
" TCPSchedulerFailed TCPRcvCollapsed" " TCPSchedulerFailed TCPRcvCollapsed"
" TCPDSACKOldSent TCPDSACKOfoSent TCPDSACKRecv TCPDSACKOfoRecv" " TCPDSACKOldSent TCPDSACKOfoSent TCPDSACKRecv"
" TCPDSACKOfoRecv"
" TCPAbortOnSyn TCPAbortOnData TCPAbortOnClose" " TCPAbortOnSyn TCPAbortOnData TCPAbortOnClose"
" TCPAbortOnMemory TCPAbortOnTimeout TCPAbortOnLinger" " TCPAbortOnMemory TCPAbortOnTimeout TCPAbortOnLinger"
" TCPAbortFailed TCPMemoryPressures\n" " TCPAbortFailed TCPMemoryPressures\n"
"TcpExt:"); "TcpExt:");
for (i = 0; for (i = 0;
i < offsetof(struct linux_mib, __pad) / sizeof(unsigned long); i < offsetof(struct linux_mib, __pad) / sizeof(unsigned long); i++)
i++)
seq_printf(seq, " %lu", seq_printf(seq, " %lu",
fold_field((unsigned long *)net_statistics, fold_field((unsigned long *)net_statistics,
sizeof(struct linux_mib), i)); sizeof(struct linux_mib), i));
...@@ -219,20 +229,26 @@ static struct file_operations netstat_seq_fops = { ...@@ -219,20 +229,26 @@ static struct file_operations netstat_seq_fops = {
int __init ip_misc_proc_init(void) int __init ip_misc_proc_init(void)
{ {
int rc = 0; int rc = 0;
struct proc_dir_entry *p = create_proc_entry("netstat", S_IRUGO, proc_net); struct proc_dir_entry *p;
p = create_proc_entry("netstat", S_IRUGO, proc_net);
if (!p) if (!p)
goto out_netstat; goto out_netstat;
p->proc_fops = &netstat_seq_fops; p->proc_fops = &netstat_seq_fops;
if (!proc_net_create("snmp", 0, snmp_get_info)) p = create_proc_entry("snmp", S_IRUGO, proc_net);
if (!p)
goto out_snmp; goto out_snmp;
if (!proc_net_create("sockstat", 0, afinet_get_info)) p->proc_fops = &snmp_seq_fops;
p = create_proc_entry("sockstat", S_IRUGO, proc_net);
if (!p)
goto out_sockstat; goto out_sockstat;
p->proc_fops = &sockstat_seq_fops;
out: out:
return rc; return rc;
out_sockstat: out_sockstat:
proc_net_remove("snmp"); remove_proc_entry("snmp", proc_net);
out_snmp: out_snmp:
remove_proc_entry("netstat", proc_net); remove_proc_entry("netstat", proc_net);
out_netstat: out_netstat:
......
...@@ -40,31 +40,42 @@ ...@@ -40,31 +40,42 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <asm/system.h> #include <asm/atomic.h>
#include <asm/byteorder.h>
#include <asm/current.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/ioctls.h> #include <asm/ioctls.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/sched.h> #include <linux/stddef.h>
#include <linux/slab.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/timer.h> #include <linux/aio.h>
#include <linux/mm.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/fcntl.h> #include <linux/spinlock.h>
#include <linux/sockios.h>
#include <linux/socket.h> #include <linux/socket.h>
#include <linux/in.h> #include <linux/in.h>
#include <linux/inet.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/mroute.h> #include <linux/in_route.h>
#include <net/tcp.h> #include <linux/route.h>
#include <net/protocol.h> #include <linux/tcp.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <net/dst.h>
#include <net/sock.h> #include <net/sock.h>
#include <linux/gfp.h>
#include <linux/ip.h>
#include <net/ip.h>
#include <net/icmp.h> #include <net/icmp.h>
#include <net/udp.h> #include <net/udp.h>
#include <net/raw.h> #include <net/raw.h>
#include <net/snmp.h>
#include <net/inet_common.h> #include <net/inet_common.h>
#include <net/checksum.h> #include <net/checksum.h>
#include <net/xfrm.h> #include <net/xfrm.h>
#include <linux/rtnetlink.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv4.h>
struct sock *raw_v4_htable[RAWV4_HTABLE_SIZE]; struct sock *raw_v4_htable[RAWV4_HTABLE_SIZE];
...@@ -656,7 +667,95 @@ static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg) ...@@ -656,7 +667,95 @@ static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg)
} }
} }
static void get_raw_sock(struct sock *sp, char *tmpbuf, int i) struct proto raw_prot = {
.name = "RAW",
.close = raw_close,
.connect = udp_connect,
.disconnect = udp_disconnect,
.ioctl = raw_ioctl,
.init = raw_init,
.setsockopt = raw_setsockopt,
.getsockopt = raw_getsockopt,
.sendmsg = raw_sendmsg,
.recvmsg = raw_recvmsg,
.bind = raw_bind,
.backlog_rcv = raw_rcv_skb,
.hash = raw_v4_hash,
.unhash = raw_v4_unhash,
};
#ifdef CONFIG_PROC_FS
struct raw_iter_state {
int bucket;
};
#define raw_seq_private(seq) ((struct raw_iter_state *)&seq->private)
static struct sock *raw_get_first(struct seq_file *seq)
{
struct sock *sk = NULL;
struct raw_iter_state* state = raw_seq_private(seq);
for (state->bucket = 0; state->bucket < RAWV4_HTABLE_SIZE; ++state->bucket) {
sk = raw_v4_htable[state->bucket];
while (sk && sk->family != PF_INET)
sk = sk->next;
if (sk)
break;
}
return sk;
}
static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk)
{
struct raw_iter_state* state = raw_seq_private(seq);
do {
sk = sk->next;
try_again:
} while (sk && sk->family != PF_INET);
if (!sk && ++state->bucket < RAWV4_HTABLE_SIZE) {
sk = raw_v4_htable[state->bucket];
goto try_again;
}
return sk;
}
static struct sock *raw_get_idx(struct seq_file *seq, loff_t pos)
{
struct sock *sk = raw_get_first(seq);
if (sk)
while (pos && (sk = raw_get_next(seq, sk)) != NULL)
--pos;
return pos ? NULL : sk;
}
static void *raw_seq_start(struct seq_file *seq, loff_t *pos)
{
read_lock(&raw_v4_lock);
return *pos ? raw_get_idx(seq, *pos) : (void *)1;
}
static void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct sock *sk;
if (v == (void *)1)
sk = raw_get_first(seq);
else
sk = raw_get_next(seq, v);
++*pos;
return sk;
}
static void raw_seq_stop(struct seq_file *seq, void *v)
{
read_unlock(&raw_v4_lock);
}
static __inline__ char *get_raw_sock(struct sock *sp, char *tmpbuf, int i)
{ {
struct inet_opt *inet = inet_sk(sp); struct inet_opt *inet = inet_sk(sp);
unsigned int dest = inet->daddr, unsigned int dest = inet->daddr,
...@@ -668,65 +767,63 @@ static void get_raw_sock(struct sock *sp, char *tmpbuf, int i) ...@@ -668,65 +767,63 @@ static void get_raw_sock(struct sock *sp, char *tmpbuf, int i)
" %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p", " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
i, src, srcp, dest, destp, sp->state, i, src, srcp, dest, destp, sp->state,
atomic_read(&sp->wmem_alloc), atomic_read(&sp->rmem_alloc), atomic_read(&sp->wmem_alloc), atomic_read(&sp->rmem_alloc),
0, 0L, 0, 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
sock_i_uid(sp), 0,
sock_i_ino(sp),
atomic_read(&sp->refcnt), sp); atomic_read(&sp->refcnt), sp);
return tmpbuf;
} }
int raw_get_info(char *buffer, char **start, off_t offset, int length) static int raw_seq_show(struct seq_file *seq, void *v)
{ {
int len = 0, num = 0, i;
off_t pos = 128;
off_t begin;
char tmpbuf[129]; char tmpbuf[129];
if (offset < 128) if (v == (void *)1)
len += sprintf(buffer, "%-127s\n", seq_printf(seq, "%-127s\n",
" sl local_address rem_address st tx_queue " " sl local_address rem_address st tx_queue "
"rx_queue tr tm->when retrnsmt uid timeout " "rx_queue tr tm->when retrnsmt uid timeout "
"inode"); "inode");
read_lock(&raw_v4_lock); else {
for (i = 0; i < RAWV4_HTABLE_SIZE; i++) { struct raw_iter_state *state = raw_seq_private(seq);
struct sock *sk;
for (sk = raw_v4_htable[i]; sk; sk = sk->next, num++) { seq_printf(seq, "%-127s\n",
if (sk->family != PF_INET) get_raw_sock(v, tmpbuf, state->bucket));
continue;
pos += 128;
if (pos <= offset)
continue;
get_raw_sock(sk, tmpbuf, i);
len += sprintf(buffer + len, "%-127s\n", tmpbuf);
if (len >= length)
goto out;
}
} }
out: return 0;
read_unlock(&raw_v4_lock);
begin = len - (pos - offset);
*start = buffer + begin;
len -= begin;
if (len > length)
len = length;
if (len < 0)
len = 0;
return len;
} }
struct proto raw_prot = { static struct seq_operations raw_seq_ops = {
.name = "RAW", .start = raw_seq_start,
.close = raw_close, .next = raw_seq_next,
.connect = udp_connect, .stop = raw_seq_stop,
.disconnect = udp_disconnect, .show = raw_seq_show,
.ioctl = raw_ioctl,
.init = raw_init,
.setsockopt = raw_setsockopt,
.getsockopt = raw_getsockopt,
.sendmsg = raw_sendmsg,
.recvmsg = raw_recvmsg,
.bind = raw_bind,
.backlog_rcv = raw_rcv_skb,
.hash = raw_v4_hash,
.unhash = raw_v4_unhash,
}; };
static int raw_seq_open(struct inode *inode, struct file *file)
{
return seq_open(file, &raw_seq_ops);
}
static struct file_operations raw_seq_fops = {
.open = raw_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
int __init raw_proc_init(void)
{
struct proc_dir_entry *p;
int rc = 0;
p = create_proc_entry("raw", S_IRUGO, proc_net);
if (p)
p->proc_fops = &raw_seq_fops;
else
rc = -ENOMEM;
return rc;
}
void __init raw_proc_exit(void)
{
remove_proc_entry("raw", proc_net);
}
#endif /* CONFIG_PROC_FS */
...@@ -1377,16 +1377,4 @@ void __init udp_proc_exit(void) ...@@ -1377,16 +1377,4 @@ void __init udp_proc_exit(void)
{ {
remove_proc_entry("udp", proc_net); remove_proc_entry("udp", proc_net);
} }
#else /* CONFIG_PROC_FS */
int __init udp_proc_init(void)
{
return 0;
}
void __init udp_proc_exit(void)
{
return 0;
}
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/wanrouter.h> #include <linux/wanrouter.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
...@@ -1839,29 +1840,19 @@ void __init sock_init(void) ...@@ -1839,29 +1840,19 @@ void __init sock_init(void)
#endif #endif
} }
int socket_get_info(char *buffer, char **start, off_t offset, int length) #ifdef CONFIG_PROC_FS
void socket_seq_show(struct seq_file *seq)
{ {
int len, cpu; int cpu;
int counter = 0; int counter = 0;
for (cpu=0; cpu<NR_CPUS; cpu++) for (cpu = 0; cpu < NR_CPUS; cpu++)
counter += sockets_in_use[cpu].counter; counter += sockets_in_use[cpu].counter;
/* It can be negative, by the way. 8) */ /* It can be negative, by the way. 8) */
if (counter < 0) if (counter < 0)
counter = 0; counter = 0;
len = sprintf(buffer, "sockets: used %d\n", counter); seq_printf(seq, "sockets: used %d\n", counter);
if (offset >= len)
{
*start = buffer;
return 0;
}
*start = buffer + offset;
len -= offset;
if (len > length)
len = length;
if (len < 0)
len = 0;
return len;
} }
#endif /* CONFIG_PROC_FS */
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