]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Feature 638: Display DAG drop counts on exit; add DAG packet and drop stats to live...
authorJason Ish <jason.ish@endace.com>
Thu, 22 Nov 2012 19:45:05 +0000 (13:45 -0600)
committerVictor Julien <victor@inliniac.net>
Wed, 28 Nov 2012 09:14:14 +0000 (10:14 +0100)
src/source-erf-dag.c

index 5ba67a1ef3cb6b45bc48b2bdcdc3f4e15f27e9d0..2233d84371fa3905fdc9977531298ea0ffd7308e 100644 (file)
@@ -85,8 +85,9 @@ typedef struct ErfDagThreadVars_ {
 
     struct timeval maxwait, poll;   /* Could possibly be made static */
 
-    uint32_t pkts;
     uint64_t bytes;
+    uint16_t packets;
+    uint16_t drops;
 
     /* Current location in the DAG stream input buffer.
      */
@@ -280,6 +281,11 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
         SCReturnInt(TM_ECODE_FAILED);
     }
 
+    ewtn->packets = SCPerfTVRegisterCounter("capture.dag_packets",
+        tv, SC_PERF_TYPE_UINT64, "NULL");
+    ewtn->drops = SCPerfTVRegisterCounter("capture.dag_drops",
+        tv, SC_PERF_TYPE_UINT64, "NULL");
+
     ewtn->tv = tv;
     *data = (void *)ewtn;
 
@@ -352,6 +358,8 @@ TmEcode ReceiveErfDagLoop(ThreadVars *tv, void *data, void *slot)
             SCReturnInt(TM_ECODE_FAILED);
         }
 
+        SCPerfSyncCountersIfSignalled(tv, 0);
+
         SCLogDebug("Read %d records from stream: %d, DAG: %s",
                    pkts_read, dtv->dagstream, dtv->dagname);
     }
@@ -411,10 +419,16 @@ static inline TmEcode ProcessErfDagRecords(ErfDagThreadVars *ewtn, uint8_t *top,
         case TYPE_PAD:
             /* Skip. */
             continue;
-        case TYPE_ETH:
         case TYPE_DSM_COLOR_ETH:
         case TYPE_COLOR_ETH:
         case TYPE_COLOR_HASH_ETH:
+            /* In these types the color value overwrites the lctr
+             * (drop count). */
+            break;
+        case TYPE_ETH:
+            if (dr->lctr) {
+                SCPerfCounterIncr(ewtn->drops, ewtn->tv->sc_perf_pca);
+            }
             break;
         default:
             SCLogError(SC_ERR_UNIMPLEMENTED,
@@ -505,7 +519,7 @@ static inline TmEcode ProcessErfDagRecord(ErfDagThreadVars *ewtn, char *prec)
         p->ts.tv_sec++;
     }
 
-    ewtn->pkts++;
+    SCPerfCounterIncr(ewtn->packets, ewtn->tv->sc_perf_pca);
     ewtn->bytes += wlen;
 
     if (TmThreadsSlotProcessPkt(ewtn->tv, ewtn->slot, p) != TM_ECODE_OK) {
@@ -527,7 +541,12 @@ ReceiveErfDagThreadExitStats(ThreadVars *tv, void *data)
 {
     ErfDagThreadVars *ewtn = (ErfDagThreadVars *)data;
 
-    SCLogInfo("Packets: %"PRIu32"; Bytes: %"PRIu64, ewtn->pkts, ewtn->bytes);
+    SCLogInfo("Stream: %d; Bytes: %"PRIu64"; Packets: %"PRIu64
+        "; Drops: %"PRIu64,
+        ewtn->dagstream,
+        ewtn->bytes,
+        (uint64_t)SCPerfGetLocalCounterValue(ewtn->packets, tv->sc_perf_pca),
+        (uint64_t)SCPerfGetLocalCounterValue(ewtn->drops, tv->sc_perf_pca));
 }
 
 /**
@@ -606,10 +625,6 @@ TmEcode DecodeErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
     SCEnter();
     DecodeThreadVars *dtv = NULL;
 
-   // if ( (dtv = SCMalloc(sizeof(DecodeThreadVars))) == NULL)
-   //     SCReturnInt(TM_ECODE_FAILED);
-   // memset(dtv, 0, sizeof(DecodeThreadVars));
-
     dtv = DecodeThreadVarsAlloc();
 
     if(dtv == NULL)