Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flow: Use proper thread id for injection #10650

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/flow-timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

/**
Expand All @@ -355,7 +362,7 @@ void FlowForceReassemblyForFlow(Flow *f)
* - silence complaining profilers
* - allow us to aggressively check using debug validation assertions
* - be robust in case of future changes
* - locking overhead if neglectable when no other thread fights us
* - locking overhead is negligible when no other thread fights us
*
* \param q The queue to process flows from.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ void FlowSwap(Flow *f)
FlowSwapFlags(f);
FlowSwapFileFlags(f);

SWAP_VARS(FlowThreadId, f->thread_id[0], f->thread_id[1]);

if (f->proto == IPPROTO_TCP) {
TcpStreamFlowSwap(f);
}
Expand Down
Loading