fb->head = f;
/* initialize and return */
- FlowInit(f, p);
+ FlowInit(tv, f, p);
f->flow_hash = hash;
f->fb = fb;
FlowUpdateState(f, FLOW_STATE_NEW);
fb->head = f;
/* got one, now lock, initialize and return */
- FlowInit(f, p);
+ FlowInit(tv, f, p);
f->flow_hash = hash;
f->fb = fb;
FlowUpdateState(f, FLOW_STATE_NEW);
fb->head = f;
/* initialize and return */
- FlowInit(f, p);
+ FlowInit(tv, f, p);
f->flow_hash = hash;
f->fb = fb;
FlowUpdateState(f, FLOW_STATE_NEW);
/* initialize the flow from the first packet
* we see from it. */
-void FlowInit(Flow *f, const Packet *p)
+void FlowInit(ThreadVars *tv, Flow *f, const Packet *p)
{
SCEnter();
SCLogDebug("flow %p", f);
f->recursion_level = p->recursion_level;
memcpy(&f->vlan_id[0], &p->vlan_id[0], sizeof(f->vlan_id));
f->vlan_idx = p->vlan_idx;
+
+ f->thread_id[0] = (FlowThreadId)tv->id;
+
f->livedev = p->livedev;
if (PKT_IS_IPV4(p)) {
Flow *FlowAlloc(void);
void FlowFree(Flow *);
uint8_t FlowGetProtoMapping(uint8_t);
-void FlowInit(Flow *, const Packet *);
+void FlowInit(ThreadVars *, Flow *, const Packet *);
uint8_t FlowGetReverseProtoMapping(uint8_t rproto);
/* flow end counter logic */
FlowUpdateTtlTC(f, p, IPV6_GET_HLIM(p));
}
}
+ if (f->thread_id[pkt_dir] == 0) {
+ f->thread_id[pkt_dir] = (FlowThreadId)tv->id;
+ }
if (f->flow_state == FLOW_STATE_ESTABLISHED) {
SCLogDebug("pkt %p FLOW_PKT_ESTABLISHED", p);
return 0;
}
-static inline void HandleThreadId(ThreadVars *tv, Packet *p, StreamTcpThread *stt)
+static inline void CheckThreadId(ThreadVars *tv, Packet *p, StreamTcpThread *stt)
{
const int idx = (!(PKT_IS_TOSERVER(p)));
/* assign the thread id to the flow */
- 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) {
- p->flow->flags |= FLOW_WRONG_THREAD;
- StreamTcpSetEvent(p, STREAM_WRONG_THREAD);
+ if (likely(p->flow->thread_id[idx] != 0)) {
+ 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) {
+ p->flow->flags |= FLOW_WRONG_THREAD;
+ StreamTcpSetEvent(p, STREAM_WRONG_THREAD);
+ }
}
}
}
return TM_ECODE_OK;
}
- HandleThreadId(tv, p, stt);
+ CheckThreadId(tv, p, stt);
/* only TCP packets with a flow from here */