From c587e90ebccfe8883ea951e723be461dc58dcc06 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sun, 15 Sep 2024 19:15:56 +0200 Subject: [PATCH] time: thread time update after flow update The flow worker needs to get the opportunity to run the flow update before globally making it's current timestamp available. This is to avoid another thread using the time to evict the flow that is about to get a legitimate update. Ticket: #7455. --- src/flow-worker.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/flow-worker.c b/src/flow-worker.c index 63de42a266..3c95fe8789 100644 --- a/src/flow-worker.c +++ b/src/flow-worker.c @@ -554,11 +554,6 @@ static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data) SCLogDebug("packet %"PRIu64, p->pcap_cnt); - /* update time */ - if (!(PKT_IS_PSEUDOPKT(p))) { - TimeSetByThread(tv->id, p->ts); - } - /* handle Flow */ if (p->flags & PKT_WANTS_FLOW) { FLOWWORKER_PROFILING_START(p, PROFILE_FLOWWORKER_FLOW); @@ -567,6 +562,10 @@ static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data) if (likely(p->flow != NULL)) { DEBUG_ASSERT_FLOW_LOCKED(p->flow); if (FlowUpdate(tv, fw, p) == TM_ECODE_DONE) { + /* update time */ + if (!(PKT_IS_PSEUDOPKT(p))) { + TimeSetByThread(tv->id, p->ts); + } goto housekeeping; } } @@ -581,6 +580,11 @@ static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data) DEBUG_VALIDATE_BUG_ON(p->pkt_src != PKT_SRC_FFR); } + /* update time */ + if (!(PKT_IS_PSEUDOPKT(p))) { + TimeSetByThread(tv->id, p->ts); + } + SCLogDebug("packet %"PRIu64" has flow? %s", p->pcap_cnt, p->flow ? "yes" : "no"); /* handle TCP and app layer */