From 286c510ece27c8fd408434c1786df26aba0c5581 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 26 Oct 2021 11:09:51 +0200 Subject: [PATCH] flow: immediately evict tcp reused flows Since we already know we're going to no longer use it, might as well evict it right away. --- src/flow-hash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/flow-hash.c b/src/flow-hash.c index 9e8ea3d309..f43e9a8440 100644 --- a/src/flow-hash.c +++ b/src/flow-hash.c @@ -809,11 +809,17 @@ Flow *FlowGetFlowFromHash(ThreadVars *tv, FlowLookupStruct *fls, FromHashLockCMP(f);//FLOWLOCK_WRLOCK(f); /* found a matching flow that is not timed out */ if (unlikely(TcpSessionPacketSsnReuse(p, f, f->protoctx) == 1)) { - f = TcpReuseReplace(tv, fls, fb, f, hash, p); - if (f == NULL) { + Flow *new_f = TcpReuseReplace(tv, fls, fb, f, hash, p); + if (f->use_cnt == 0) { + if (prev_f == NULL) /* if we have no prev it means new_f is now our prev */ + prev_f = new_f; + MoveToWorkQueue(tv, fls, fb, f, prev_f); /* evict old flow */ + } + if (new_f == NULL) { FBLOCK_UNLOCK(fb); return NULL; } + f = new_f; } FlowReference(dest, f); FBLOCK_UNLOCK(fb); -- 2.47.2