From: Eric Leblond Date: Sun, 9 Jun 2019 21:32:36 +0000 (+0200) Subject: bypass: restore interface counter X-Git-Tag: suricata-5.0.0-rc1~302 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f78e5ba1e122cc736d6599351413d8e30bd31ee8;p=thirdparty%2Fsuricata.git bypass: restore interface counter --- diff --git a/src/flow-manager.c b/src/flow-manager.c index 449163d4d5..408a9fd004 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -255,6 +255,10 @@ static int FlowManagerFlowTimeout(Flow *f, enum FlowState state, struct timeval if (fc) { if (fc->BypassUpdate) { /* flow will be possibly updated */ + uint64_t pkts_tosrc = fc->tosrcpktcnt; + uint64_t bytes_tosrc = fc->tosrcbytecnt; + uint64_t pkts_todst = fc->todstpktcnt; + uint64_t bytes_todst = fc->todstbytecnt; bool update = fc->BypassUpdate(f, fc->bypass_data, ts->tv_sec); /* FIXME do global accounting: store pkts and bytes before and add difference here to counter */ if (update) { @@ -262,6 +266,14 @@ static int FlowManagerFlowTimeout(Flow *f, enum FlowState state, struct timeval flow_times_out_at = (int32_t)(f->lastts.tv_sec + timeout); if (*next_ts == 0 || flow_times_out_at < *next_ts) *next_ts = flow_times_out_at; + pkts_tosrc = fc->tosrcpktcnt - pkts_tosrc; + bytes_tosrc = fc->tosrcbytecnt - bytes_tosrc; + pkts_todst = fc->todstpktcnt - pkts_todst; + bytes_todst = fc->todstbytecnt - bytes_todst; + if (f->livedev) { + SC_ATOMIC_ADD(f->livedev->bypassed, + pkts_tosrc + pkts_todst); + } return 0; } else { SCLogDebug("No new packet, dead flow %ld", FlowGetId(f)); diff --git a/src/flow.h b/src/flow.h index 3744a61805..6727816135 100644 --- a/src/flow.h +++ b/src/flow.h @@ -347,7 +347,7 @@ typedef struct Flow_ uint8_t vlan_idx; /** Incoming interface */ - const struct LiveDevice_ *livedev; + struct LiveDevice_ *livedev; /** flow hash - the flow hash before hash table size mod. */ uint32_t flow_hash;