From 9ab8fa19d28e3c3472605a83f356d1e113908bd6 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Wed, 22 Jul 2026 11:48:20 +0200 Subject: [PATCH] flow: update bypassed flows on shutdown/recycle --- src/flow-manager.c | 13 +++++++++++++ src/flow-timeout.c | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/flow-manager.c b/src/flow-manager.c index c29fd10482..1c04b6dbd6 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -1094,6 +1094,19 @@ static void Recycler(ThreadVars *tv, FlowRecyclerThreadData *ftd, Flow *f) { FLOWLOCK_WRLOCK(f); +#ifdef CAPTURE_OFFLOAD + // If the flow was timed out already, we already updated the stats + if ((f->flow_end_flags & FLOW_END_FLAG_TIMEOUT) == 0) { + FlowTimeoutCounters counters = { 0 }; + FlowBypassedTimeout(f, TimeGet(), &counters); + // TODO use the counters to update + // like StatsCounterAddI64(&tv->stats, ftd->cnt.flow_bypassed_cnt_clo, + // (int64_t)counters.bypassed_count); same for bypassed_pkts and bypassed_bytes needs to + // check if the flow recycler thread can update these stats and give it access to the + // StatsCounterId flow_bypassed_cnt_clo and such + } +#endif + (void)OutputFlowLog(tv, ftd->output_thread_data, f); FlowEndCountersUpdate(tv, &ftd->fec, f); diff --git a/src/flow-timeout.c b/src/flow-timeout.c index 04e5a0a2fc..1f8e1634bd 100644 --- a/src/flow-timeout.c +++ b/src/flow-timeout.c @@ -407,8 +407,9 @@ static inline void FlowRemoveHash(void) } /* in case of additional work, we pull the flow out of the - * hash and xfer ownership to the injected packet(s) */ - if (FlowNeedsReassembly(f)) { + * hash and xfer ownership to the injected packet(s) + * Bypassed flows will be handled by Recycler */ + if (FlowNeedsReassembly(f) && !FlowIsBypassed(f)) { RemoveFromHash(f, prev_f); f->flow_end_flags |= FLOW_END_FLAG_SHUTDOWN; FlowSendToLocalThread(f);