]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow/bypass: add util func to check if flow is bypassed
authorVictor Julien <victor@inliniac.net>
Mon, 25 Oct 2021 18:25:39 +0000 (20:25 +0200)
committerShivani Bhardwaj <shivanib134@gmail.com>
Thu, 20 Jan 2022 14:45:04 +0000 (20:15 +0530)
To hide the ifdefs for capture offload.

(cherry picked from commit b19d1df69f47b4b85337f1695bc770f4b0703bac)

src/flow-manager.c
src/flow-worker.c
src/flow.h

index 5e8251aa3017e4bb0834fc5d139538193c6402cb..359a39eceef9c0b11fb1f3384c4466c9df45ecb8 100644 (file)
@@ -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);
index b84ec58db0ba668cd15cb5d28cb51a1cee42dc19..677c7f1c3e0614832e43b64861d7b870ac608535 100644 (file)
@@ -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++;
index 12120ede72f3e0704135d657b9b09946561b6c8d..0a319ffaf2dd513a3b85c437ddee3b03835d21fb 100644 (file)
@@ -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);