From: Jeff Lucovsky Date: Mon, 11 Mar 2024 18:57:16 +0000 (-0400) Subject: flow/inject: Ensure initialized thread value used X-Git-Tag: suricata-8.0.0-beta1~1626 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ad73faa0a52428e47412474514b125fda6aa03d;p=thirdparty%2Fsuricata.git flow/inject: Ensure initialized thread value used Issue: 6835 When injecting a flow, ensure that the selected thread_id has been initialized. When a flow is picked up midstream, the initialized thread can be the second thread element. --- diff --git a/src/flow-timeout.c b/src/flow-timeout.c index 546fc35fe9..92632e68f6 100644 --- a/src/flow-timeout.c +++ b/src/flow-timeout.c @@ -334,14 +334,21 @@ 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. + * * \param f Pointer to the flow. * * \retval 0 This flow doesn't need any reassembly processing; 1 otherwise. */ void FlowForceReassemblyForFlow(Flow *f) { - const int thread_id = (int)f->thread_id[0]; - TmThreadsInjectFlowById(f, thread_id); + // Have packets traveled to the server? If not, + // use the reverse direction + int idx = f->todstpktcnt > 0 ? 0 : 1; + TmThreadsInjectFlowById(f, (const int)f->thread_id[idx]); } /**