mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 19:18:19 +00:00
Fix PktSrc::Statistics returning bogus stats.
When reading from trace files, 'dropped' and 'link' fields are now just zeroed. When reading from an interface, the values filled in by pcap_stats() are now only used when that function indicates success. Closes #500.
This commit is contained in:
parent
c0c8b515f9
commit
d6d34f3a1f
3 changed files with 23 additions and 8 deletions
|
@ -393,21 +393,27 @@ void PktSrc::AddSecondaryTablePrograms()
|
|||
|
||||
void PktSrc::Statistics(Stats* s)
|
||||
{
|
||||
struct pcap_stat pstat;
|
||||
|
||||
if ( reading_traces )
|
||||
s->received = s->dropped = s->link = 0;
|
||||
|
||||
else if ( pcap_stats(pd, &pstat) < 0 )
|
||||
else
|
||||
{
|
||||
reporter->Error("problem getting packet filter statistics: %s",
|
||||
ErrorMsg());
|
||||
s->received = s->dropped = s->link = 0;
|
||||
struct pcap_stat pstat;
|
||||
if ( pcap_stats(pd, &pstat) < 0 )
|
||||
{
|
||||
reporter->Error("problem getting packet filter statistics: %s",
|
||||
ErrorMsg());
|
||||
s->received = s->dropped = s->link = 0;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
s->dropped = pstat.ps_drop;
|
||||
s->link = pstat.ps_recv;
|
||||
}
|
||||
}
|
||||
|
||||
s->received = stats.received;
|
||||
s->dropped = pstat.ps_drop;
|
||||
s->link = pstat.ps_recv;
|
||||
|
||||
if ( pseudo_realtime )
|
||||
s->dropped = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue