]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: move detect cleanup into util func
authorVictor Julien <victor@inliniac.net>
Sat, 7 Oct 2017 10:17:39 +0000 (12:17 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 8 Jan 2018 09:01:47 +0000 (10:01 +0100)
src/detect.c

index 2e374896baedf1e18569cc2313a2b831ad61b156..d408a74dfa9ccc863c0a7f0f50b18cbbf27a8241 100644 (file)
@@ -72,6 +72,9 @@
 #include "util-validate.h"
 #include "util-detect.h"
 
+static void SigMatchSignaturesCleanup(DetectEngineThreadCtx *det_ctx,
+    Packet *p, Flow *pflow, const bool use_flow_sgh);
+
 int SigMatchSignaturesRunPostMatch(ThreadVars *tv,
                                    DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p,
                                    const Signature *s)
@@ -935,6 +938,14 @@ end:
     }
     PACKET_PROFILING_DETECT_END(p, PROF_DETECT_ALERT);
 
+    SigMatchSignaturesCleanup(det_ctx, p, pflow, use_flow_sgh);
+    SCReturn;
+}
+
+/* TODO move use_flow_sgh into det_ctx */
+static void SigMatchSignaturesCleanup(DetectEngineThreadCtx *det_ctx,
+    Packet *p, Flow * const pflow, const bool use_flow_sgh)
+{
     PACKET_PROFILING_DETECT_START(p, PROF_DETECT_CLEANUP);
     /* cleanup pkt specific part of the patternmatcher */
     PacketPatternCleanup(det_ctx);
@@ -942,7 +953,7 @@ end:
     /* store the found sgh (or NULL) in the flow to save us from looking it
      * up again for the next packet. Also return any stream chunk we processed
      * to the pool. */
-    if (p->flags & PKT_HAS_FLOW) {
+    if (pflow != NULL) {
         /* HACK: prevent the wrong sgh (or NULL) from being stored in the
          * flow's sgh pointers */
         if (PKT_IS_ICMPV4(p) && ICMPV4_DEST_UNREACH_IS_VALID(p)) {