detstats() and ifstats() could not account bad IPv4 packets (packets with invalid header checksum) because since version iptraf-3.0.0 we were dropping them. This caused the BadIP column to be always zero.
Fix this by allowing pkt_result value CHECKSUM_ERROR to continue down the code.
Signed-off-by: Vitezslav Samel vitezslav@samel.cz --- src/detstats.c | 18 ++++++++++-------- src/ifstats.c | 17 ++++++++++------- 2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/src/detstats.c b/src/detstats.c index 5783fd6..646893f 100644 --- a/src/detstats.c +++ b/src/detstats.c @@ -253,8 +253,6 @@ void detstats(char *iface, time_t facilitytime) WINDOW *statwin; PANEL *statpanel;
- int pkt_result = 0; - FILE *logfile = NULL;
unsigned int iplen = 0; @@ -518,14 +516,18 @@ void detstats(char *iface, time_t facilitytime)
int outgoing;
- pkt_result = - packet_process(&pkt, NULL, NULL, NULL, - MATCH_OPPOSITE_USECONFIG, - options.v6inv4asv6); + int pkt_result = packet_process(&pkt, NULL, NULL, NULL, + MATCH_OPPOSITE_USECONFIG, + options.v6inv4asv6);
- if (pkt_result != PACKET_OK - && pkt_result != MORE_FRAGMENTS) + switch (pkt_result) { + case PACKET_OK: /* we only handle these */ + case MORE_FRAGMENTS: + case CHECKSUM_ERROR: + break; + default: /* drop others */ continue; + }
outgoing = (pkt.pkt_pkttype == PACKET_OUTGOING); update_proto_counter(&ifcounts.total, outgoing, pkt.pkt_len); diff --git a/src/ifstats.c b/src/ifstats.c index 2b009e5..2eb51b6 100644 --- a/src/ifstats.c +++ b/src/ifstats.c @@ -411,8 +411,6 @@ void ifstats(time_t facilitytime) int logging = options.logging; struct iftab table;
- int pkt_result = 0; - struct iflist *ptmp = NULL;
FILE *logfile = NULL; @@ -570,13 +568,18 @@ void ifstats(time_t facilitytime) if (pkt.pkt_len <= 0) continue;
- pkt_result = packet_process(&pkt, NULL, NULL, NULL, - MATCH_OPPOSITE_USECONFIG, - options.v6inv4asv6); + int pkt_result = packet_process(&pkt, NULL, NULL, NULL, + MATCH_OPPOSITE_USECONFIG, + options.v6inv4asv6);
- if (pkt_result != PACKET_OK - && pkt_result != MORE_FRAGMENTS) + switch (pkt_result) { + case PACKET_OK: /* we only handle these */ + case MORE_FRAGMENTS: + case CHECKSUM_ERROR: + break; + default: /* drop others */ continue; + }
ptmp = positionptr(table.head, pkt.pkt_ifindex); if (!ptmp)