From: Victor Julien Date: Thu, 23 May 2024 04:42:20 +0000 (+0200) Subject: defrag: minor cleanups; dead code removal X-Git-Tag: suricata-8.0.0-beta1~1226 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=475c40f9c20419d5f87e69b6353d3d1fbafb5d22;p=thirdparty%2Fsuricata.git defrag: minor cleanups; dead code removal --- diff --git a/src/defrag-hash.c b/src/defrag-hash.c index 6f1b59ff7f..693ff4fc5f 100644 --- a/src/defrag-hash.c +++ b/src/defrag-hash.c @@ -168,8 +168,7 @@ void DefragInitConfig(bool quiet) { SCLogDebug("initializing defrag engine..."); - memset(&defrag_config, 0, sizeof(defrag_config)); - //SC_ATOMIC_INIT(flow_flags); + memset(&defrag_config, 0, sizeof(defrag_config)); SC_ATOMIC_INIT(defragtracker_counter); SC_ATOMIC_INIT(defrag_memuse); SC_ATOMIC_INIT(defragtracker_prune_idx); @@ -290,20 +289,11 @@ void DefragInitConfig(bool quiet) } } -/** \brief print some defrag stats - * \warning Not thread safe */ -static void DefragTrackerPrintStats (void) -{ -} - /** \brief shutdown the flow engine * \warning Not thread safe */ void DefragHashShutdown(void) { DefragTracker *dt; - uint32_t u; - - DefragTrackerPrintStats(); /* free spare queue */ while((dt = DefragTrackerDequeue(&defragtracker_spare_q))) { @@ -313,7 +303,7 @@ void DefragHashShutdown(void) /* clear and free the hash */ if (defragtracker_hash != NULL) { - for (u = 0; u < defrag_config.hash_size; u++) { + for (uint32_t u = 0; u < defrag_config.hash_size; u++) { dt = defragtracker_hash[u].head; while (dt) { DefragTracker *n = dt->hnext; @@ -433,9 +423,9 @@ static inline uint32_t DefragHashGetKey(Packet *p) uint32_t hash = hashword(dhk.u32, sizeof(dhk.u32) / sizeof(uint32_t), defrag_config.hash_rand); key = hash % defrag_config.hash_size; - } else + } else { key = 0; - + } return key; } @@ -496,16 +486,6 @@ static DefragTracker *DefragTrackerGetNew(ThreadVars *tv, DecodeThreadVars *dtv, if (dt == NULL) { /* If we reached the max memcap, we get a used tracker */ if (!(DEFRAG_CHECK_MEMCAP(sizeof(DefragTracker)))) { - /* declare state of emergency */ - //if (!(SC_ATOMIC_GET(defragtracker_flags) & DEFRAG_EMERGENCY)) { - // SC_ATOMIC_OR(defragtracker_flags, DEFRAG_EMERGENCY); - - /* under high load, waking up the flow mgr each time leads - * to high cpu usage. Flows are not timed out much faster if - * we check a 1000 times a second. */ - // FlowWakeupFlowManagerThread(); - //} - dt = DefragTrackerGetUsedDefragTracker(); if (dt == NULL) { ExceptionPolicyApply(p, defrag_config.memcap_policy, PKT_DROP_REASON_DEFRAG_MEMCAP); @@ -715,5 +695,3 @@ static DefragTracker *DefragTrackerGetUsedDefragTracker(void) return NULL; } - - diff --git a/src/defrag-queue.c b/src/defrag-queue.c index 0d07d2196e..76ab25de98 100644 --- a/src/defrag-queue.c +++ b/src/defrag-queue.c @@ -38,17 +38,6 @@ DefragTrackerQueue *DefragTrackerQueueInit (DefragTrackerQueue *q) return q; } -DefragTrackerQueue *DefragTrackerQueueNew(void) -{ - DefragTrackerQueue *q = (DefragTrackerQueue *)SCMalloc(sizeof(DefragTrackerQueue)); - if (q == NULL) { - SCLogError("Fatal error encountered in DefragTrackerQueueNew. Exiting..."); - exit(EXIT_SUCCESS); - } - q = DefragTrackerQueueInit(q); - return q; -} - /** * \brief Destroy a tracker queue * diff --git a/src/defrag-queue.h b/src/defrag-queue.h index f527b6fce1..014c783604 100644 --- a/src/defrag-queue.h +++ b/src/defrag-queue.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2012 Open Information Security Foundation +/* Copyright (C) 2007-2024 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -72,7 +72,6 @@ typedef struct DefragTrackerQueue_ #endif /* prototypes */ -DefragTrackerQueue *DefragTrackerQueueNew(void); DefragTrackerQueue *DefragTrackerQueueInit(DefragTrackerQueue *); void DefragTrackerQueueDestroy (DefragTrackerQueue *);