From: Victor Julien Date: Mon, 25 Oct 2021 18:25:39 +0000 (+0200) Subject: flow/bypass: add util func to check if flow is bypassed X-Git-Tag: suricata-6.0.5~134 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16bf8a6ee42903807bd7f28ca3bda6146abdb708;p=thirdparty%2Fsuricata.git flow/bypass: add util func to check if flow is bypassed To hide the ifdefs for capture offload. (cherry picked from commit b19d1df69f47b4b85337f1695bc770f4b0703bac) --- diff --git a/src/flow-manager.c b/src/flow-manager.c index 5e8251aa30..359a39ecee 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -275,11 +275,7 @@ static uint32_t ProcessAsideQueue(FlowManagerTimeoutThread *td, FlowTimeoutCount /* flow is still locked */ if (f->proto == IPPROTO_TCP && !(f->flags & FLOW_TIMEOUT_REASSEMBLY_DONE) && -#ifdef CAPTURE_OFFLOAD - f->flow_state != FLOW_STATE_CAPTURE_BYPASSED && -#endif - f->flow_state != FLOW_STATE_LOCAL_BYPASSED && - FlowForceReassemblyNeedReassembly(f) == 1) { + !FlowIsBypassed(f) && FlowForceReassemblyNeedReassembly(f) == 1) { /* Send the flow to its thread */ FlowForceReassemblyForFlow(f); FLOWLOCK_UNLOCK(f); diff --git a/src/flow-worker.c b/src/flow-worker.c index b84ec58db0..677c7f1c3e 100644 --- a/src/flow-worker.c +++ b/src/flow-worker.c @@ -171,16 +171,9 @@ static void CheckWorkQueue(ThreadVars *tv, FlowWorkerThreadData *fw, FLOWLOCK_WRLOCK(f); f->flow_end_flags |= FLOW_END_FLAG_TIMEOUT; //TODO emerg - const FlowStateType state = f->flow_state; if (f->proto == IPPROTO_TCP) { - if (!(f->flags & FLOW_TIMEOUT_REASSEMBLY_DONE) && -#ifdef CAPTURE_OFFLOAD - state != FLOW_STATE_CAPTURE_BYPASSED && -#endif - state != FLOW_STATE_LOCAL_BYPASSED && - FlowForceReassemblyNeedReassembly(f) == 1 && - f->ffr != 0) - { + if (!(f->flags & FLOW_TIMEOUT_REASSEMBLY_DONE) && !FlowIsBypassed(f) && + FlowForceReassemblyNeedReassembly(f) == 1 && f->ffr != 0) { int cnt = FlowFinish(tv, f, fw, detect_thread); counters->flows_aside_pkt_inject += cnt; counters->flows_aside_needs_work++; diff --git a/src/flow.h b/src/flow.h index 12120ede72..0a319ffaf2 100644 --- a/src/flow.h +++ b/src/flow.h @@ -697,6 +697,18 @@ static inline void FlowSetEndFlags(Flow *f) #endif } +static inline bool FlowIsBypassed(const Flow *f) +{ + if ( +#ifdef CAPTURE_OFFLOAD + f->flow_state == FLOW_STATE_CAPTURE_BYPASSED || +#endif + f->flow_state == FLOW_STATE_LOCAL_BYPASSED) { + return true; + } + return false; +} + int FlowClearMemory(Flow *,uint8_t ); AppProto FlowGetAppProtocol(const Flow *f);