On 12/18/2015 11:58 AM, Phil Sutter wrote:
This has a slight side-effect of not aborting when /proc/net/dev is
malformed, but OTOH stats are not parsed for uninteresting interfaces.

Signed-off-by: Phil Sutter <p...@nwl.cc>
---
Changes since v1:
- Fix conflict resolution (sscan from 'buf' instead of 'ptr').
[...]

Hmm, did you actually compile that?

The code is still the same as in v1 ... the only thing added is the "Changes since 
v1"
description. ;)

[...]
+void tnl_print_stats(const char *buf)
+{
+       unsigned long rx_bytes, rx_packets, rx_errs, rx_drops,
+                     rx_fifo, rx_frame,
+                     tx_bytes, tx_packets, tx_errs, tx_drops,
+                     tx_fifo, tx_colls, tx_carrier, rx_multi;
+
+       if (sscanf(ptr, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",

  s/ptr/buf/

+                  &rx_bytes, &rx_packets, &rx_errs, &rx_drops,
+                  &rx_fifo, &rx_frame, &rx_multi,
+                  &tx_bytes, &tx_packets, &tx_errs, &tx_drops,
+                  &tx_fifo, &tx_colls, &tx_carrier) != 14)
+               return;
+
+       printf("%s", _SL_);
+       printf("RX: Packets    Bytes        Errors CsumErrs OutOfSeq Mcasts%s", 
_SL_);
+       printf("    %-10ld %-12ld %-6ld %-8ld %-8ld %-8ld%s",
+              rx_packets, rx_bytes, rx_errs, rx_frame, rx_fifo, rx_multi, 
_SL_);
+       printf("TX: Packets    Bytes        Errors DeadLoop NoRoute  NoBufs%s", 
_SL_);
+       printf("    %-10ld %-12ld %-6ld %-8ld %-8ld %-6ld",
+              tx_packets, tx_bytes, tx_errs, tx_colls, tx_carrier, tx_drops);
+}

tunnel.c: In function ‘tnl_print_stats’:
tunnel.c:211:13: error: ‘buff’ undeclared (first use in this function)
  if (sscanf(buff, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
             ^
tunnel.c:211:13: note: each undeclared identifier is reported only once for 
each function it appears in
make[1]: *** [tunnel.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to