]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
defrag: minor cleanups; dead code removal
authorVictor Julien <vjulien@oisf.net>
Thu, 23 May 2024 04:42:20 +0000 (06:42 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 4 Jun 2024 04:28:26 +0000 (06:28 +0200)
src/defrag-hash.c
src/defrag-queue.c
src/defrag-queue.h

index 6f1b59ff7f70091dab3f98cf5b2f7c34ae39c373..693ff4fc5f87e2afcd3e1d7105b29927234e7653 100644 (file)
@@ -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;
 }
-
-
index 0d07d2196eb32ac16c60af205fa60b6848de11a7..76ab25de98c2c4b5c04c55a8c7da31467d0438d3 100644 (file)
@@ -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
  *
index f527b6fce1ec75cdfb27a67b480e71c3d6b2f67a..014c78360422cb53316854f8953d92bfc857d9af 100644 (file)
@@ -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 *);