diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-10-31 15:18:14 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-10-31 15:18:14 -0700 |
commit | 4c934f4dd3715e3705c089ed3fcb132b7e821de4 (patch) | |
tree | d93ff0e34ca0c00266ef50e58488713dc9637f16 /pcap-linux.c | |
parent | ca24274ab20f398d8d6113178f0c18890371e73b (diff) |
More comments.
Indicate why it's OK to use a tpacket_stats_v3, even for TPACKET_V1 and
TPACKET_V2 (and that we could probably just use a tpacket_stats).
Diffstat (limited to 'pcap-linux.c')
-rw-r--r-- | pcap-linux.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/pcap-linux.c b/pcap-linux.c index 23aeb217..03ff5d30 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -1845,12 +1845,26 @@ pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats) struct pcap_linux *handlep = handle->priv; #ifdef HAVE_TPACKET_STATS #ifdef HAVE_TPACKET3 + /* + * For sockets using TPACKET_V1 or TPACKET_V2, the extra + * stuff at the end of a struct tpacket_stats_v3 will not + * be filled in, and we don't look at it so this is OK even + * for those sockets. In addition, the PF_PACKET socket + * code in the kernel only uses the length parameter to + * compute how much data to copy out and to indicate how + * much data was copied out, so it's OK to base it on the + * size of a struct tpacket_stats. + * + * XXX - it's probably OK, in fact, to just use a + * struct tpacket_stats for V3 sockets, as we don't + * care about the tp_freeze_q_cnt stat. + */ struct tpacket_stats_v3 kstats; -#else +#else /* HAVE_TPACKET3 */ struct tpacket_stats kstats; -#endif +#endif /* HAVE_TPACKET3 */ socklen_t len = sizeof (struct tpacket_stats); -#endif +#endif /* HAVE_TPACKET_STATS */ long if_dropped = 0; |