~ubuntu-branches/ubuntu/saucy/net-tools/saucy-proposed

« back to all changes in this revision

Viewing changes to debian/patches/CVS-20081003-statistics.c_sync.patch

  • Committer: Bazaar Package Importer
  • Author(s): Muharem Hrnjadovic
  • Date: 2009-05-04 12:29:43 UTC
  • mfrom: (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090504122943-6zyafjosb8a1u21q
Tags: 1.60-23ubuntu1
* Merge from debian unstable, remaining changes:
  Ubuntu_unit_conversion.patch:
    - the diff-style patch was converted into quilt format
    - Ubuntu Policy: output using standard SI unit multiples:
      KB (10^3), MB (10^6), GB (10^9), TB (10^12) and PB (10^15).
      Includes manpage update to remove comment about IEC units.
      LP: #240073.
  Dropped patches, already in debian:
    - lib/ec_hw.c: #include <stddef.h to get definition of NULL.
    - lib/fddi.c: #include <linux/types.h> to get types.  LP: #66209.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Sync with upstream CVS, complete log:
 
2
 
 
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)
 
5
 
 
6
Revision 1.20 - Sat Dec 1 18:44:56 2007 UTC by ecki
 
7
Faster pagesize aligned fopen for netstat -s (Eric Dumazet)
 
8
 
 
9
Revision 1.19 - Sat Dec 1 18:29:05 2007 UTC by ecki
 
10
Better netstat -s error handling and larger buffers
 
11
 
 
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
 
14
 
 
15
Revision 1.17 - Sun Apr 28 15:41:01 2002 UTC by ak
 
16
Fix some counter descriptions.  Noted by Jamal Hadi.
 
17
 
 
18
Revision 1.16 - Wed Oct 24 11:57:05 2001 UTC by ak
 
19
(Finally) update netstat -s for 2.4 statistics.
 
20
 
 
21
Revision 1.15 - Fri Oct 19 09:28:01 2001 UTC by ak
 
22
Only print unknown statistics when their counter is > 0.
 
23
 
 
24
Index: net-tools/statistics.c
 
25
===================================================================
 
26
--- net-tools.orig/statistics.c
 
27
+++ net-tools/statistics.c
 
28
@@ -1,6 +1,6 @@
 
29
 /*
 
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 
 
36
@@ -11,6 +11,7 @@
 
37
 #include <string.h>
 
38
 #include "config.h"
 
39
 #include "intl.h"
 
40
+#include "proc.h"
 
41
 
 
42
 /* #define WARN 1 */
 
43
 
 
44
@@ -83,6 +84,32 @@ struct entry Iptab[] =
 
45
     {"FragCreates", N_("%u fragments created"), opt_number}
 
46
 };
 
47
 
 
48
+struct entry Ip6tab[] =
 
49
+{
 
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}
 
72
+};
 
73
+
 
74
 struct entry Icmptab[] =
 
75
 {
 
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},
 
79
 };
 
80
 
 
81
+struct entry Icmp6tab[] =
 
82
+{
 
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},
 
114
+};
 
115
+
 
116
 struct entry Tcptab[] =
 
117
 {
 
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},
 
121
 };
 
122
 
 
123
+struct entry Udp6tab[] =
 
124
+{
 
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},
 
129
+};
 
130
+
 
131
 struct entry Tcpexttab[] =
 
132
 {
 
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"),
 
137
       opt_number },
 
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."), 
 
141
       opt_number },
 
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"),
 
148
+                                     opt_number },
 
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"), 
 
195
+       opt_number },
 
196
+    { "TCPRenoRecoveryFail", N_("%u classic Reno fast retransmits failed"), opt_number },
 
197
 };
 
198
 
 
199
 struct tabtab {
 
200
@@ -204,6 +314,15 @@ struct tabtab snmptabs[] =
 
201
     {NULL}
 
202
 };
 
203
 
 
204
+struct tabtab snmp6tabs[] =
 
205
+{
 
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},
 
210
+    {NULL}
 
211
+};
 
212
+
 
213
 /* XXX IGMP */
 
214
 
 
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);
 
221
+       if (val) 
 
222
+               printf("%*s%s: %d\n", states[state].indent, "", title, val);
 
223
        return;
 
224
     }
 
225
     type = ent->type;
 
226
@@ -289,14 +409,17 @@ struct tabtab *newtable(struct tabtab *t
 
227
        return &dummytab;
 
228
 }
 
229
 
 
230
-void process_fd(FILE *f)
 
231
+int process_fd(FILE *f, int all, char *filter)
 
232
 {
 
233
-    char buf1[1024], buf2[1024];
 
234
+    char buf1[2048], buf2[2048];
 
235
     char *sp, *np, *p;
 
236
     while (fgets(buf1, sizeof buf1, f)) {
 
237
        int endflag;
 
238
        struct tabtab *tab;
 
239
 
 
240
+        if (buf1[0] == '\n') // skip empty first line in 2.6 kernels
 
241
+            continue;
 
242
+            
 
243
        if (!fgets(buf2, sizeof buf2, f))
 
244
            break;
 
245
        sp = strchr(buf1, ':');
 
246
@@ -305,6 +428,10 @@ void process_fd(FILE *f)
 
247
            goto formaterr;
 
248
        *sp = '\0';
 
249
 
 
250
+        if (!all)
 
251
+           if (strncmp(buf1, filter, strlen(filter)))
 
252
+               continue;
 
253
+
 
254
        tab = newtable(snmptabs, buf1);
 
255
        if (tab == NULL) {
 
256
                printf("unknown %s\n", buf1);
 
257
@@ -330,13 +457,47 @@ void process_fd(FILE *f)
 
258
            sp = p + 1;
 
259
        }
 
260
     }
 
261
-  return;
 
262
+  return 0;
 
263
   
 
264
 formaterr:
 
265
-  perror(_("error parsing /proc/net/snmp"));
 
266
-  return;
 
267
+  return -1;
 
268
+}
 
269
+
 
270
+void cpytitle(char *original, char *new)
 
271
+{
 
272
+     char *ptr = original;
 
273
+     while(*ptr != '6' && *ptr != '\0') {
 
274
+           *new = *ptr;
 
275
+            new++;
 
276
+            ptr++;
 
277
+     }
 
278
+    *new = *ptr;
 
279
+    new++;
 
280
+    *new = '\0';
 
281
 }
 
282
 
 
283
+void process6_fd(FILE *f)
 
284
+{
 
285
+   char buf1[1024],buf2[50],buf3[1024];
 
286
+   unsigned long val;
 
287
+   struct tabtab *tab = NULL;
 
288
+   int cpflg = 0;
 
289
+
 
290
+   while (fgets(buf1, sizeof buf1, f)) {
 
291
+          sscanf(buf1, "%s %lu", buf2, &val);
 
292
+          if(!cpflg) {
 
293
+             cpytitle(buf2, buf3);
 
294
+             tab = newtable(snmp6tabs, buf3);
 
295
+             cpflg = 1;
 
296
+          }
 
297
+          if(!strstr(buf2, buf3)) {
 
298
+             cpytitle(buf2, buf3);
 
299
+             tab = newtable(snmp6tabs, buf3);
 
300
+          }
 
301
+          printval(tab, buf2, val);
 
302
+   }
 
303
+
 
304
+}
 
305
 
 
306
 void parsesnmp(int flag_raw, int flag_tcp, int flag_udp)
 
307
 {
 
308
@@ -344,22 +505,25 @@ void parsesnmp(int flag_raw, int flag_tc
 
309
 
 
310
     f_raw = flag_raw; f_tcp = flag_tcp; f_udp = flag_udp;
 
311
     
 
312
-    f = fopen("/proc/net/snmp", "r");
 
313
+    f = proc_fopen("/proc/net/snmp");
 
314
     if (!f) {
 
315
        perror(_("cannot open /proc/net/snmp"));
 
316
        return;
 
317
     }
 
318
-    process_fd(f);
 
319
+
 
320
+    if (process_fd(f, 1, NULL) < 0)
 
321
+      fprintf(stderr, _("Problem while parsing /proc/net/snmp\n"));
 
322
 
 
323
     if (ferror(f))
 
324
        perror("/proc/net/snmp");
 
325
 
 
326
     fclose(f);
 
327
 
 
328
-    f = fopen("/proc/net/netstat", "r");
 
329
+    f = proc_fopen("/proc/net/netstat");
 
330
 
 
331
     if (f) {
 
332
-       process_fd(f);
 
333
+       if (process_fd(f, 1, NULL) <0)
 
334
+          fprintf(stderr, _("Problem while parsing /proc/net/netstat\n"));
 
335
 
 
336
         if (ferror(f))
 
337
            perror("/proc/net/netstat");
 
338
@@ -369,6 +533,33 @@ void parsesnmp(int flag_raw, int flag_tc
 
339
     return;
 
340
 }
 
341
     
 
342
+void parsesnmp6(int flag_raw, int flag_tcp, int flag_udp)
 
343
+{
 
344
+    FILE *f;
 
345
+
 
346
+    f_raw = flag_raw; f_tcp = flag_tcp; f_udp = flag_udp;
 
347
+
 
348
+    f = fopen("/proc/net/snmp6", "r");
 
349
+    if (!f) {
 
350
+        perror(_("cannot open /proc/net/snmp6"));
 
351
+        return;
 
352
+    }
 
353
+    process6_fd(f);
 
354
+    if (ferror(f))
 
355
+        perror("/proc/net/snmp6");
 
356
+
 
357
+    fclose(f);
 
358
+    f = fopen("/proc/net/snmp", "r");
 
359
+    if (!f) {
 
360
+        perror(_("cannot open /proc/net/snmp"));
 
361
+        return;
 
362
+    }
 
363
+    process_fd(f, 0, "Tcp");
 
364
+    if (ferror(f))
 
365
+        perror("/proc/net/snmp");
 
366
+
 
367
+    fclose(f);
 
368
+}
 
369
 
 
370
 void inittab(void)
 
371
 {
 
372
@@ -379,3 +570,13 @@ void inittab(void)
 
373
        qsort(t->tab, t->size / sizeof(struct entry),
 
374
              sizeof(struct entry), cmpentries);
 
375
 }
 
376
+
 
377
+void inittab6(void)
 
378
+{
 
379
+    struct tabtab *t;
 
380
+
 
381
+    for (t = snmp6tabs; t->title; t++)
 
382
+        qsort(t->tab, t->size / sizeof(struct entry),
 
383
+              sizeof(struct entry), cmpentries);
 
384
+}
 
385
+