]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
bypass: restore interface counter
authorEric Leblond <eric@regit.org>
Sun, 9 Jun 2019 21:32:36 +0000 (23:32 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 18 Jun 2019 05:07:02 +0000 (07:07 +0200)
src/flow-manager.c
src/flow.h

index 449163d4d538c3314dc8cde7e337c0a4435c0de4..408a9fd0043193ad600ccba4c80ba330906486b9 100644 (file)
@@ -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));
index 3744a6180599914b02f54b0691d2b9c608e67599..6727816135031aad27bc32bdcb464fe7ecd15311 100644 (file)
@@ -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;