Hi David,
Please pull from:
master.kernel.org:/home/acme/BK/net-2.5
- Arnaldo
You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.
===================================================================
[email protected], 2002-11-12 22:55:20-02:00, [email protected]
o ipv4: convert /proc/net/snmp to seq_file
proc.c | 121 +++++++++++++++++++++++++++++++++++++++--------------------------
1 files changed, 74 insertions(+), 47 deletions(-)
diff -Nru a/net/ipv4/proc.c b/net/ipv4/proc.c
--- a/net/ipv4/proc.c Wed Nov 13 00:18:37 2002
+++ b/net/ipv4/proc.c Wed Nov 13 00:18:37 2002
@@ -26,6 +26,7 @@
* Andi Kleen : Add support for open_requests and
* split functions for more readibility.
* 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
* modify it under the terms of the GNU General Public License
@@ -115,52 +116,73 @@
/*
* Called from the PROCfs module. This outputs /proc/net/snmp.
*/
-
-int snmp_get_info(char *buffer, char **start, off_t offset, int length)
+static int snmp_seq_show(struct seq_file *seq, void *v)
{
extern int sysctl_ip_default_ttl;
- int len, i;
+ int i;
- len = sprintf (buffer,
- "Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates\n"
- "Ip: %d %d", ipv4_devconf.forwarding ? 1 : 2, sysctl_ip_default_ttl);
- for (i=0; i<offsetof(struct ip_mib, __pad)/sizeof(unsigned long); i++)
- len += sprintf(buffer+len, " %lu", fold_field((unsigned long*)ip_statistics, sizeof(struct ip_mib), i));
-
- 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"
- "Icmp:");
- for (i=0; i<offsetof(struct icmp_mib, dummy)/sizeof(unsigned long); i++)
- len += sprintf(buffer+len, " %lu", fold_field((unsigned long*)icmp_statistics, sizeof(struct icmp_mib), i));
-
- len += sprintf (buffer + len,
- "\nTcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts\n"
- "Tcp:");
- for (i=0; i<offsetof(struct tcp_mib, __pad)/sizeof(unsigned long); i++)
- len += sprintf(buffer+len, " %lu", fold_field((unsigned long*)tcp_statistics, sizeof(struct tcp_mib), i));
-
- len += sprintf (buffer + len,
- "\nUdp: InDatagrams NoPorts InErrors OutDatagrams\n"
- "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));
+ seq_printf(seq, "Ip: Forwarding DefaultTTL InReceives InHdrErrors "
+ "InAddrErrors ForwDatagrams InUnknownProtos "
+ "InDiscards InDelivers OutRequests OutDiscards "
+ "OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs "
+ "ReasmFails FragOKs FragFails FragCreates\nIp: %d %d",
+ ipv4_devconf.forwarding ? 1 : 2, sysctl_ip_default_ttl);
- len += sprintf (buffer + len, "\n");
+ for (i = 0;
+ i < offsetof(struct ip_mib, __pad) / sizeof(unsigned long); i++)
+ seq_printf(seq, " %lu",
+ fold_field((unsigned long *)ip_statistics,
+ sizeof(struct ip_mib), i));
- if (offset >= len)
- {
- *start = buffer;
- return 0;
- }
- *start = buffer + offset;
- len -= offset;
- if (len > length)
- len = length;
- if (len < 0)
- len = 0;
- return len;
+ seq_printf(seq, "\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\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:");
+
+ 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));
+
+ seq_putc(seq, '\n');
+ return 0;
}
+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
*/
@@ -181,7 +203,8 @@
" TCPPureAcks TCPHPAcks"
" TCPRenoRecovery TCPSackRecovery"
" TCPSACKReneging"
- " TCPFACKReorder TCPSACKReorder TCPRenoReorder TCPTSReorder"
+ " TCPFACKReorder TCPSACKReorder TCPRenoReorder"
+ " TCPTSReorder"
" TCPFullUndo TCPPartialUndo TCPDSACKUndo TCPLossUndo"
" TCPLoss TCPLostRetransmit"
" TCPRenoFailures TCPSackFailures TCPLossFailures"
@@ -189,14 +212,14 @@
" TCPTimeouts"
" TCPRenoRecoveryFail TCPSackRecoveryFail"
" TCPSchedulerFailed TCPRcvCollapsed"
- " TCPDSACKOldSent TCPDSACKOfoSent TCPDSACKRecv TCPDSACKOfoRecv"
+ " TCPDSACKOldSent TCPDSACKOfoSent TCPDSACKRecv"
+ " TCPDSACKOfoRecv"
" TCPAbortOnSyn TCPAbortOnData TCPAbortOnClose"
" TCPAbortOnMemory TCPAbortOnTimeout TCPAbortOnLinger"
" TCPAbortFailed TCPMemoryPressures\n"
"TcpExt:");
for (i = 0;
- i < offsetof(struct linux_mib, __pad) / sizeof(unsigned long);
- i++)
+ i < offsetof(struct linux_mib, __pad) / sizeof(unsigned long); i++)
seq_printf(seq, " %lu",
fold_field((unsigned long *)net_statistics,
sizeof(struct linux_mib), i));
@@ -219,20 +242,24 @@
int __init ip_misc_proc_init(void)
{
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)
goto out_netstat;
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;
+ p->proc_fops = &snmp_seq_fops;
+
if (!proc_net_create("sockstat", 0, afinet_get_info))
goto out_sockstat;
out:
return rc;
out_sockstat:
- proc_net_remove("snmp");
+ remove_proc_entry("snmp", proc_net);
out_snmp:
remove_proc_entry("netstat", proc_net);
out_netstat:
===================================================================
This BitKeeper patch contains the following changesets:
1.825
## Wrapped with gzip_uu ##
begin 664 bkpatch4864
M'XL(`'VVT3T``\U7;7/:1A#^+/V*+9DTQL&@%\1;ZC0..`EC.Z:R_<TSC"P=
MH+&D(W<'CEORW[M[`@$N3IQ,FRG&OMN]V]WG=I][\3.XDDQTC"!,F?D,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