]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream: optimize session pruning
authorVictor Julien <victor@inliniac.net>
Wed, 1 Mar 2017 13:50:20 +0000 (14:50 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 20 Apr 2017 15:41:11 +0000 (17:41 +0200)
src/stream-tcp-list.c

index 2546c5d3d2036518bc9d851078bd0d8d37a30184..a532c3cb1037fd282540d7f0a628ec8e3bfc6076 100644 (file)
@@ -744,16 +744,27 @@ void StreamTcpPruneSession(Flow *f, uint8_t flags)
         SCReturn;
     }
 
+    if (stream->flags & STREAMTCP_STREAM_FLAG_NOREASSEMBLY) {
+        return;
+    }
+
     if (stream->flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED) {
         stream->flags |= STREAMTCP_STREAM_FLAG_NOREASSEMBLY;
         SCLogDebug("ssn %p: reassembly depth reached, "
                  "STREAMTCP_STREAM_FLAG_NOREASSEMBLY set", ssn);
+        StreamTcpReturnStreamSegments(stream);
+        StreamingBufferClear(&stream->sb);
+        return;
+
     } else if ((ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED) &&
         (stream->flags & STREAMTCP_STREAM_FLAG_DISABLE_RAW))
     {
         SCLogDebug("ssn %p: both app and raw are done, "
                  "STREAMTCP_STREAM_FLAG_NOREASSEMBLY set", ssn);
         stream->flags |= STREAMTCP_STREAM_FLAG_NOREASSEMBLY;
+        StreamTcpReturnStreamSegments(stream);
+        StreamingBufferClear(&stream->sb);
+        return;
     }
 
     uint64_t left_edge = GetLeftEdge(ssn, stream);