aboutsummaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorMario J. Rugiero <mrugiero@gmail.com>2019-10-04 23:56:19 -0300
committerMario J. Rugiero <mrugiero@gmail.com>2019-10-05 17:17:24 -0300
commite2c3935228b6c17127aed88627567bdf6dfa171a (patch)
tree8024b9abdfc8e39e2a0bf1faeac1588a6a7f0f58 /pcap-linux.c
parentc55ba0d5b0f83ba9b23c54609eaf2a2a146eb4e5 (diff)
Linux: fix mentions to stats coming from procfs.
Also fixes a swap in the original /sys/class/net comment
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index 7531acb0..59b1cc44 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -303,7 +303,7 @@ typedef int socklen_t;
*/
struct pcap_linux {
u_int packets_read; /* count of packets read with recvfrom() */
- long proc_dropped; /* packets reported dropped by /proc/net/dev */
+ long sysfs_dropped; /* packets reported dropped by /sys/class/net/{if_name}/statistics/rx_{missed,fifo}_errors */
struct pcap_stat stat;
char *device; /* device name */
@@ -1167,7 +1167,7 @@ pcap_can_set_rfmon_linux(pcap_t *handle)
/*
* Grabs the number of missed packets by the interface from
- * /sys/class/net/statistics/{if_name}/rx_{missed,fifo}_errors.
+ * /sys/class/net/{if_name}/statistics/rx_{missed,fifo}_errors.
*
* Compared to /proc/net/dev this avoids counting software drops,
* but may be unimplemented and just return 0.
@@ -1633,10 +1633,10 @@ pcap_activate_linux(pcap_t *handle)
/*
* If we're in promiscuous mode, then we probably want
* to see when the interface drops packets too, so get an
- * initial count from /proc/net/dev
+ * initial count from /sys/class/net/{if_name}/statistics/rx_{missed,fifo}_errors
*/
if (handle->opt.promisc)
- handlep->proc_dropped = linux_if_drops(handlep->device);
+ handlep->sysfs_dropped = linux_if_drops(handlep->device);
#ifdef HAVE_PF_PACKET_SOCKETS
/*
@@ -2331,13 +2331,15 @@ pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats)
long if_dropped = 0;
/*
- * To fill in ps_ifdrop, we parse /proc/net/dev for the number
+ * To fill in ps_ifdrop, we parse
+ * /sys/class/net/{if_name}/statistics/rx_{missed,fifo}_errors
+ * for the numbers
*/
if (handle->opt.promisc)
{
- if_dropped = handlep->proc_dropped;
- handlep->proc_dropped = linux_if_drops(handlep->device);
- handlep->stat.ps_ifdrop += (handlep->proc_dropped - if_dropped);
+ if_dropped = handlep->sysfs_dropped;
+ handlep->sysfs_dropped = linux_if_drops(handlep->device);
+ handlep->stat.ps_ifdrop += (handlep->sysfs_dropped - if_dropped);
}
#ifdef HAVE_STRUCT_TPACKET_STATS
@@ -2426,7 +2428,8 @@ pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats)
* "ps_drop" is not supported.
*
* "ps_ifdrop" is supported. It will return the number
- * of drops the interface reports in /proc/net/dev,
+ * of drops the interface reports in
+ * /sys/class/net/{if_name}/statistics/rx_{missed,fifo}_errors,
* if that is available.
*
* "ps_recv" doesn't include packets not yet read from