]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow/inject: Select thread_id by flow flag 10852/head
authorJeff Lucovsky <jeff.lucovsky@corelight.com>
Mon, 15 Apr 2024 14:17:17 +0000 (10:17 -0400)
committerVictor Julien <victor@inliniac.net>
Mon, 15 Apr 2024 18:34:39 +0000 (20:34 +0200)
Issue: 6957

Rather than selecting the thread_id index by packets traveling to the
server, use the flow flags. If the flow has been reversed, the second
slot is represents the thread id to be used.

src/flow-timeout.c

index 0b75228ca3753ac94d38b8c914119e1b2d4bc38c..63aec2f0e64a2fdc6e819b3334987070153109dc 100644 (file)
@@ -335,9 +335,8 @@ int FlowForceReassemblyNeedReassembly(Flow *f)
  *        The function requires flow to be locked beforehand.
  *
  * Normally, the first thread_id value should be used. This is when the flow is
- * created on seeing the first packet to the server; sometimes, if the first
- * packet is determined to be to the client, the second thread_id value should
- * be used.
+ * created on seeing the first packet to the server; when the flow's reversed
+ * flag is set, choose the second thread_id (to client/source).
  *
  * \param f Pointer to the flow.
  *
@@ -345,9 +344,9 @@ int FlowForceReassemblyNeedReassembly(Flow *f)
  */
 void FlowForceReassemblyForFlow(Flow *f)
 {
-    // Have packets traveled to the server? If not,
-    // use the reverse direction
-    int idx = f->todstpktcnt > 0 ? 0 : 1;
+    // Choose the thread_id based on whether the flow has been
+    // reversed.
+    int idx = f->flags & FLOW_DIR_REVERSED ? 1 : 0;
     TmThreadsInjectFlowById(f, (const int)f->thread_id[idx]);
 }