/* tag flow as reused so future lookups won't find it */
old_f->flags |= FLOW_TCP_REUSED;
/* get some settings that we move over to the new flow */
- FlowThreadId thread_id = old_f->thread_id;
+ FlowThreadId thread_id[2] = { old_f->thread_id[0], old_f->thread_id[1] };
/* since fb lock is still held this flow won't be found until we are done */
FLOWLOCK_UNLOCK(old_f);
f->flow_hash = hash;
f->fb = fb;
- f->thread_id = thread_id;
+ f->thread_id[0] = thread_id[0];
+ f->thread_id[1] = thread_id[1];
return f;
}
}
/* inject the packet(s) into the appropriate thread */
- int thread_id = (int)f->thread_id;
+ int thread_id = (int)f->thread_id[0];
Packet *packets[3] = { p1, p2 ? p2 : NULL, NULL }; /**< null terminated array of packets */
if (unlikely(!(TmThreadsInjectPacketsById(packets, thread_id)))) {
FlowDeReference(&p1->flow);
(f)->alproto_orig = 0; \
(f)->alproto_expect = 0; \
(f)->de_ctx_version = 0; \
- (f)->thread_id = 0; \
+ (f)->thread_id[0] = 0; \
+ (f)->thread_id[1] = 0; \
(f)->alparser = NULL; \
(f)->alstate = NULL; \
(f)->sgh_toserver = NULL; \
(f)->alproto_orig = 0; \
(f)->alproto_expect = 0; \
(f)->de_ctx_version = 0; \
- (f)->thread_id = 0; \
+ (f)->thread_id[0] = 0; \
+ (f)->thread_id[1] = 0; \
(f)->sgh_toserver = NULL; \
(f)->sgh_toclient = NULL; \
GenericVarFree((f)->flowvar); \
return 0;
}
-/* flow is and stays locked */
-int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt,
- PacketQueue *pq)
+static inline void HandleThreadId(ThreadVars *tv, Packet *p, StreamTcpThread *stt)
{
- SCEnter();
-
- DEBUG_ASSERT_FLOW_LOCKED(p->flow);
-
- SCLogDebug("p->pcap_cnt %"PRIu64, p->pcap_cnt);
+ const int idx = (!(PKT_IS_TOSERVER(p)));
/* assign the thread id to the flow */
- if (unlikely(p->flow->thread_id == 0)) {
- p->flow->thread_id = (FlowThreadId)tv->id;
- } else if (unlikely((FlowThreadId)tv->id != p->flow->thread_id)) {
- SCLogDebug("wrong thread: flow has %u, we are %d", p->flow->thread_id, tv->id);
+ if (unlikely(p->flow->thread_id[idx] == 0)) {
+ p->flow->thread_id[idx] = (FlowThreadId)tv->id;
+ } else if (unlikely((FlowThreadId)tv->id != p->flow->thread_id[idx])) {
+ SCLogDebug("wrong thread: flow has %u, we are %d", p->flow->thread_id[idx], tv->id);
if (p->pkt_src == PKT_SRC_WIRE) {
StatsIncr(tv, stt->counter_tcp_wrong_thread);
if ((p->flow->flags & FLOW_WRONG_THREAD) == 0) {
}
}
}
+}
+
+/* flow is and stays locked */
+int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt,
+ PacketQueue *pq)
+{
+ SCEnter();
+
+ DEBUG_ASSERT_FLOW_LOCKED(p->flow);
+
+ SCLogDebug("p->pcap_cnt %"PRIu64, p->pcap_cnt);
+
+ HandleThreadId(tv, p, stt);
TcpSession *ssn = (TcpSession *)p->flow->protoctx;