1
Sync with upstream CVS, complete log:
3
Revision 1.21 - Fri Oct 3 00:05:20 2008 UTC by ecki
4
Enable netstat -s for IPv6 (Debian Bug #453859 from Varun Chandramohan)
6
Revision 1.20 - Sat Dec 1 18:44:56 2007 UTC by ecki
7
Faster pagesize aligned fopen for netstat -s (Eric Dumazet)
9
Revision 1.19 - Sat Dec 1 18:29:05 2007 UTC by ecki
10
Better netstat -s error handling and larger buffers
12
Revision 1.18 - Wed Feb 12 03:30:57 2003 UTC by ak
13
Add text for two new TCP statistics and fix some existing descriptions
15
Revision 1.17 - Sun Apr 28 15:41:01 2002 UTC by ak
16
Fix some counter descriptions. Noted by Jamal Hadi.
18
Revision 1.16 - Wed Oct 24 11:57:05 2001 UTC by ak
19
(Finally) update netstat -s for 2.4 statistics.
21
Revision 1.15 - Fri Oct 19 09:28:01 2001 UTC by ak
22
Only print unknown statistics when their counter is > 0.
24
Index: net-tools/statistics.c
25
===================================================================
26
--- net-tools.orig/statistics.c
27
+++ net-tools/statistics.c
30
* Copyright 1997,1999,2000 Andi Kleen. Subject to the GPL.
31
- * $Id: statistics.c,v 1.14 2001/02/02 18:01:23 pb Exp $
32
+ * $Id: statistics.c,v 1.21 2008/10/03 00:05:20 ecki Exp $
33
* 19980630 - i18n - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
34
* 19981113 - i18n fixes - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
35
* 19990101 - added net/netstat, -t, -u, -w supprt - Bernd Eckenfels
44
@@ -83,6 +84,32 @@ struct entry Iptab[] =
45
{"FragCreates", N_("%u fragments created"), opt_number}
48
+struct entry Ip6tab[] =
50
+ {"Ip6InReceives", N_("%u total packets received"), number},
51
+ {"Ip6InHdrErrors", N_("%u with invalid headers"), opt_number},
52
+ {"Ip6InTooBigErrors", N_("%u with packets too big"), opt_number},
53
+ {"Ip6InNoRoutes", N_("%u incoming packets with no route"), opt_number},
54
+ {"Ip6InAddrErrors", N_("%u with invalid addresses"), opt_number},
55
+ {"Ip6InUnknownProtos", N_("%u with unknown protocol"), opt_number},
56
+ {"Ip6InTruncatedPkts", N_("%u with truncated packets"), opt_number},
57
+ {"Ip6InDiscards", N_("%u incoming packets discarded"), number},
58
+ {"Ip6InDelivers", N_("%u incoming packets delivered"), number},
59
+ {"Ip6OutForwDatagrams", N_("%u forwarded"), number},
60
+ {"Ip6OutRequests", N_("%u requests sent out"), number}, /*? */
61
+ {"Ip6OutDiscards", N_("%u outgoing packets dropped"), opt_number},
62
+ {"Ip6OutNoRoutes", N_("%u dropped because of missing route"), opt_number},
63
+ {"Ip6ReasmTimeout", N_("%u fragments dropped after timeout"), opt_number},
64
+ {"Ip6ReasmReqds", N_("%u reassemblies required"), opt_number}, /* ? */
65
+ {"Ip6ReasmOKs", N_("%u packets reassembled ok"), opt_number},
66
+ {"Ip6ReasmFails", N_("%u packet reassembles failed"), opt_number},
67
+ {"Ip6FragOKs", N_("%u fragments received ok"), opt_number},
68
+ {"Ip6FragFails", N_("%u fragments failed"), opt_number},
69
+ {"Ip6FragCreates", N_("%u fragments created"), opt_number},
70
+ {"Ip6InMcastPkts", N_("%u incoming multicast packets"), opt_number},
71
+ {"Ip6OutMcastPkts", N_("%u outgoing multicast packets"), opt_number}
74
struct entry Icmptab[] =
76
{"InMsgs", N_("%u ICMP messages received"), number},
77
@@ -113,6 +140,41 @@ struct entry Icmptab[] =
78
{"OutAddrMaskReps", N_("address mask replies: %u"), i_outp_icmp | I_TITLE},
81
+struct entry Icmp6tab[] =
83
+ {"Icmp6InMsgs", N_("%u ICMP messages received"), number},
84
+ {"Icmp6InErrors", N_("%u input ICMP message failed."), number},
85
+ {"Icmp6InDestUnreachs", N_("destination unreachable: %u"), i_inp_icmp | I_TITLE},
86
+ {"Icmp6InPktTooBigs", N_("packets too big: %u"), i_inp_icmp | I_TITLE},
87
+ {"Icmp6InTimeExcds", N_("received ICMPv6 time exceeded: %u"), i_inp_icmp | I_TITLE},
88
+ {"Icmp6InParmProblems", N_("parameter problem: %u"), i_inp_icmp | I_TITLE},
89
+ {"Icmp6InEchos", N_("echo requests: %u"), i_inp_icmp | I_TITLE},
90
+ {"Icmp6InEchoReplies", N_("echo replies: %u"), i_inp_icmp | I_TITLE},
91
+ {"Icmp6InGroupMembQueries", N_("group member queries: %u"), i_inp_icmp | I_TITLE},
92
+ {"Icmp6InGroupMembResponses", N_("group member responses: %u"), i_inp_icmp | I_TITLE},
93
+ {"Icmp6InGroupMembReductions", N_("group member reductions: %u"), i_inp_icmp | I_TITLE},
94
+ {"Icmp6InRouterSolicits", N_("router solicits: %u"), i_inp_icmp | I_TITLE},
95
+ {"Icmp6InRouterAdvertisements", N_("router advertisement: %u"), i_inp_icmp | I_TITLE},
96
+ {"Icmp6InNeighborSolicits", N_("neighbour solicits: %u"), i_inp_icmp | I_TITLE},
97
+ {"Icmp6InNeighborAdvertisements", N_("neighbour advertisement: %u"), i_inp_icmp | I_TITLE},
98
+ {"Icmp6InRedirects", N_("redirects: %u"), i_inp_icmp | I_TITLE},
99
+ {"Icmp6OutMsgs", N_("%u ICMP messages sent"), number},
100
+ {"Icmp6OutDestUnreachs", N_("destination unreachable: %u"), i_outp_icmp | I_TITLE},
101
+ {"Icmp6OutPktTooBigs", N_("packets too big: %u"), i_outp_icmp | I_TITLE},
102
+ {"Icmp6OutTimeExcds", N_("sent ICMPv6 time exceeded: %u"), i_outp_icmp | I_TITLE},
103
+ {"Icmp6OutParmProblems", N_("parameter problem: %u"), i_outp_icmp | I_TITLE},
104
+ {"Icmp6OutEchos", N_("echo requests: %u"), i_outp_icmp | I_TITLE},
105
+ {"Icmp6OutEchoReplies", N_("echo replies: %u"), i_outp_icmp | I_TITLE},
106
+ {"Icmp6OutGroupMembQueries", N_("group member queries: %u"), i_outp_icmp | I_TITLE},
107
+ {"Icmp6OutGroupMembResponses", N_("group member responses: %u"), i_outp_icmp | I_TITLE},
108
+ {"Icmp6OutGroupMembReductions", N_("group member reductions: %u"), i_outp_icmp | I_TITLE},
109
+ {"Icmp6OutRouterSolicits", N_("router solicits: %u"), i_outp_icmp | I_TITLE},
110
+ {"Icmp6OutRouterAdvertisements ", N_("router advertisement: %u"), i_outp_icmp | I_TITLE},
111
+ {"Icmp6OutNeighborSolicits", N_("neighbor solicits: %u"), i_outp_icmp | I_TITLE},
112
+ {"Icmp6OutNeighborAdvertisements", N_("neighbor advertisements: %u"), i_outp_icmp | I_TITLE},
113
+ {"Icmp6OutRedirects", N_("redirects: %u"), i_outp_icmp | I_TITLE},
116
struct entry Tcptab[] =
118
{"RtoAlgorithm", N_("RTO algorithm is %s"), i_rto_alg | I_STATIC},
119
@@ -139,6 +201,14 @@ struct entry Udptab[] =
120
{"OutDatagrams", N_("%u packets sent"), number},
123
+struct entry Udp6tab[] =
125
+ {"Udp6InDatagrams", N_("%u packets received"), number},
126
+ {"Udp6NoPorts", N_("%u packets to unknown port received."), number},
127
+ {"Udp6InErrors", N_("%u packet receive errors"), number},
128
+ {"Udp6OutDatagrams", N_("%u packets sent"), number},
131
struct entry Tcpexttab[] =
133
{"SyncookiesSent", N_("%u SYN cookies sent"), opt_number},
134
@@ -172,19 +242,59 @@ struct entry Tcpexttab[] =
135
{ "DelayedACKLost", N_("Quick ack mode was activated %u times"), opt_number },
136
{ "ListenOverflows", N_("%u times the listen queue of a socket overflowed"),
138
- { "ListenDrops", N_("%u SYNs to LISTEN sockets ignored"), opt_number },
139
+ { "ListenDrops", N_("%u SYNs to LISTEN sockets dropped"), opt_number },
140
{ "TCPPrequeued", N_("%u packets directly queued to recvmsg prequeue."),
142
- { "TCPDirectCopyFromBacklog", N_("%u packets directly received"
143
- " from backlog"), opt_number },
144
- { "TCPDirectCopyFromPrequeue", N_("%u packets directly received"
145
- " from prequeue"), opt_number },
146
+ { "TCPDirectCopyFromBacklog", N_("%u bytes directly in process context from backlog"), opt_number },
147
+ { "TCPDirectCopyFromPrequeue", N_("%u bytes directly received in process context from prequeue"),
149
{ "TCPPrequeueDropped", N_("%u packets dropped from prequeue"), opt_number },
150
- { "TCPHPHits", N_("%u packets header predicted"), number },
151
+ { "TCPHPHits", N_("%u packet headers predicted"), number },
152
{ "TCPHPHitsToUser", N_("%u packets header predicted and "
153
"directly queued to user"), opt_number },
154
{ "SockMallocOOM", N_("Ran %u times out of system memory during "
155
"packet sending"), opt_number },
156
+ { "TCPPureAcks", N_("%u acknowledgments not containing data payload received"), opt_number },
157
+ { "TCPHPAcks", N_("%u predicted acknowledgments"), opt_number },
158
+ { "TCPRenoRecovery", N_("%u times recovered from packet loss due to fast retransmit"), opt_number },
159
+ { "TCPSackRecovery", N_("%u times recovered from packet loss by selective acknowledgements"), opt_number },
160
+ { "TCPSACKReneging", N_("%u bad SACK blocks received"), opt_number },
161
+ { "TCPFACKReorder", N_("Detected reordering %u times using FACK"), opt_number },
162
+ { "TCPSACKReorder", N_("Detected reordering %u times using SACK"), opt_number },
163
+ { "TCPTSReorder", N_("Detected reordering %u times using time stamp"), opt_number },
164
+ { "TCPRenoReorder", N_("Detected reordering %u times using reno fast retransmit"), opt_number },
165
+ { "TCPFullUndo", N_("%u congestion windows fully recovered without slow start"), opt_number },
166
+ { "TCPPartialUndo", N_("%u congestion windows partially recovered using Hoe heuristic"), opt_number },
167
+ { "TCPDSackUndo", N_("%u congestion window recovered without slow start using DSACK"), opt_number },
168
+ { "TCPLossUndo", N_("%u congestion windows recovered without slow start after partial ack"), opt_number },
169
+ { "TCPLostRetransmits", N_("%u retransmits lost"), opt_number },
170
+ { "TCPRenoFailures", N_("%u timeouts after reno fast retransmit"), opt_number },
171
+ { "TCPSackFailures", N_("%u timeouts after SACK recovery"), opt_number },
172
+ { "TCPLossFailures", N_("%u timeouts in loss state"), opt_number },
173
+ { "TCPFastRetrans", N_("%u fast retransmits"), opt_number },
174
+ { "TCPForwardRetrans", N_("%u forward retransmits"), opt_number },
175
+ { "TCPSlowStartRetrans", N_("%u retransmits in slow start"), opt_number },
176
+ { "TCPTimeouts", N_("%u other TCP timeouts"), opt_number },
177
+ { "TCPRenoRecoveryFailed", N_("%u reno fast retransmits failed"), opt_number },
178
+ { "TCPSackRecoveryFail", N_("%u SACK retransmits failed"), opt_number },
179
+ { "TCPSchedulerFailed", N_("%u times receiver scheduled too late for direct processing"), opt_number },
180
+ { "TCPRcvCollapsed", N_("%u packets collapsed in receive queue due to low socket buffer"), opt_number },
181
+ { "TCPDSACKOldSent", N_("%u DSACKs sent for old packets"), opt_number },
182
+ { "TCPDSACKOfoSent", N_("%u DSACKs sent for out of order packets"), opt_number },
183
+ { "TCPDSACKRecv", N_("%u DSACKs received"), opt_number },
184
+ { "TCPDSACKOfoRecv", N_("%u DSACKs for out of order packets received"), opt_number },
185
+ { "TCPAbortOnSyn", N_("%u connections reset due to unexpected SYN"), opt_number },
186
+ { "TCPAbortOnData", N_("%u connections reset due to unexpected data"), opt_number },
187
+ { "TCPAbortOnClose", N_("%u connections reset due to early user close"), opt_number },
188
+ { "TCPAbortOnMemory", N_("%u connections aborted due to memory pressure"), opt_number },
189
+ { "TCPAbortOnTimeout", N_("%u connections aborted due to timeout"), opt_number },
190
+ { "TCPAbortOnLinger", N_("%u connections aborted after user close in linger timeout"), opt_number },
191
+ { "TCPAbortFailed", N_("%u times unabled to send RST due to no memory"), opt_number },
192
+ { "TCPMemoryPressures", N_("TCP ran low on memory %u times"), opt_number },
193
+ { "TCPLoss", N_("%u TCP data loss events"), opt_number },
194
+ { "TCPDSACKUndo", N_("%u congestion windows recovered without slow start by DSACK"),
196
+ { "TCPRenoRecoveryFail", N_("%u classic Reno fast retransmits failed"), opt_number },
200
@@ -204,6 +314,15 @@ struct tabtab snmptabs[] =
204
+struct tabtab snmp6tabs[] =
206
+ {"Ip6", Ip6tab, sizeof(Ip6tab), &f_raw},
207
+ {"Icmp6", Icmp6tab, sizeof(Icmp6tab), &f_raw},
208
+ {"Udp6", Udp6tab, sizeof(Udp6tab), &f_udp},
209
+ {"Tcp6", Tcptab, sizeof(Tcptab), &f_tcp},
215
int cmpentries(const void *a, const void *b)
216
@@ -222,7 +341,8 @@ void printval(struct tabtab *tab, char *
217
ent = bsearch(&key, tab->tab, tab->size / sizeof(struct entry),
218
sizeof(struct entry), cmpentries);
219
if (!ent) { /* try our best */
220
- printf("%*s%s: %d\n", states[state].indent, "", title, val);
222
+ printf("%*s%s: %d\n", states[state].indent, "", title, val);
226
@@ -289,14 +409,17 @@ struct tabtab *newtable(struct tabtab *t
230
-void process_fd(FILE *f)
231
+int process_fd(FILE *f, int all, char *filter)
233
- char buf1[1024], buf2[1024];
234
+ char buf1[2048], buf2[2048];
236
while (fgets(buf1, sizeof buf1, f)) {
240
+ if (buf1[0] == '\n') // skip empty first line in 2.6 kernels
243
if (!fgets(buf2, sizeof buf2, f))
245
sp = strchr(buf1, ':');
246
@@ -305,6 +428,10 @@ void process_fd(FILE *f)
251
+ if (strncmp(buf1, filter, strlen(filter)))
254
tab = newtable(snmptabs, buf1);
256
printf("unknown %s\n", buf1);
257
@@ -330,13 +457,47 @@ void process_fd(FILE *f)
265
- perror(_("error parsing /proc/net/snmp"));
270
+void cpytitle(char *original, char *new)
272
+ char *ptr = original;
273
+ while(*ptr != '6' && *ptr != '\0') {
283
+void process6_fd(FILE *f)
285
+ char buf1[1024],buf2[50],buf3[1024];
287
+ struct tabtab *tab = NULL;
290
+ while (fgets(buf1, sizeof buf1, f)) {
291
+ sscanf(buf1, "%s %lu", buf2, &val);
293
+ cpytitle(buf2, buf3);
294
+ tab = newtable(snmp6tabs, buf3);
297
+ if(!strstr(buf2, buf3)) {
298
+ cpytitle(buf2, buf3);
299
+ tab = newtable(snmp6tabs, buf3);
301
+ printval(tab, buf2, val);
306
void parsesnmp(int flag_raw, int flag_tcp, int flag_udp)
308
@@ -344,22 +505,25 @@ void parsesnmp(int flag_raw, int flag_tc
310
f_raw = flag_raw; f_tcp = flag_tcp; f_udp = flag_udp;
312
- f = fopen("/proc/net/snmp", "r");
313
+ f = proc_fopen("/proc/net/snmp");
315
perror(_("cannot open /proc/net/snmp"));
320
+ if (process_fd(f, 1, NULL) < 0)
321
+ fprintf(stderr, _("Problem while parsing /proc/net/snmp\n"));
324
perror("/proc/net/snmp");
328
- f = fopen("/proc/net/netstat", "r");
329
+ f = proc_fopen("/proc/net/netstat");
333
+ if (process_fd(f, 1, NULL) <0)
334
+ fprintf(stderr, _("Problem while parsing /proc/net/netstat\n"));
337
perror("/proc/net/netstat");
338
@@ -369,6 +533,33 @@ void parsesnmp(int flag_raw, int flag_tc
342
+void parsesnmp6(int flag_raw, int flag_tcp, int flag_udp)
346
+ f_raw = flag_raw; f_tcp = flag_tcp; f_udp = flag_udp;
348
+ f = fopen("/proc/net/snmp6", "r");
350
+ perror(_("cannot open /proc/net/snmp6"));
355
+ perror("/proc/net/snmp6");
358
+ f = fopen("/proc/net/snmp", "r");
360
+ perror(_("cannot open /proc/net/snmp"));
363
+ process_fd(f, 0, "Tcp");
365
+ perror("/proc/net/snmp");
372
@@ -379,3 +570,13 @@ void inittab(void)
373
qsort(t->tab, t->size / sizeof(struct entry),
374
sizeof(struct entry), cmpentries);
381
+ for (t = snmp6tabs; t->title; t++)
382
+ qsort(t->tab, t->size / sizeof(struct entry),
383
+ sizeof(struct entry), cmpentries);