]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow/bypass: clear memory on bypass
authorVictor Julien <victor@inliniac.net>
Mon, 25 Oct 2021 17:15:23 +0000 (19:15 +0200)
committerVictor Julien <victor@inliniac.net>
Sat, 30 Oct 2021 12:19:56 +0000 (14:19 +0200)
Previously the flow would hold on to the app-layer and segment data
until the end of the flow, even though it would never be accessed again.

This patch clears app-layer and stream data, but not stream ssn as its
used in flow logging.

Bug: #4778.

src/flow-worker.c

index 677c7f1c3e0614832e43b64861d7b870ac608535..984b81a875c6ca3bae31c0dea28f3925e4322c97 100644 (file)
@@ -562,7 +562,12 @@ static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data)
     if (p->flow != NULL) {
         DEBUG_ASSERT_FLOW_LOCKED(p->flow);
 
-        if (p->proto == IPPROTO_TCP) {
+        if (FlowIsBypassed(p->flow)) {
+            FlowCleanupAppLayer(p->flow);
+            if (p->proto == IPPROTO_TCP) {
+                StreamTcpSessionCleanup(p->flow->protoctx);
+            }
+        } else if (p->proto == IPPROTO_TCP && p->flow->protoctx) {
             FLOWWORKER_PROFILING_START(p, PROFILE_FLOWWORKER_TCPPRUNE);
             StreamTcpPruneSession(p->flow, p->flowflags & FLOW_PKT_TOSERVER ?
                     STREAM_TOSERVER : STREAM_TOCLIENT);