]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
defrag: tracker initialization cleanup
authorJason Ish <ish@unx.ca>
Mon, 15 Jun 2015 17:14:16 +0000 (11:14 -0600)
committerVictor Julien <victor@inliniac.net>
Thu, 8 Oct 2015 08:35:45 +0000 (10:35 +0200)
Remove the old tracker reset macro which is no longer being used.
Clear last_seen and remove flags on initialization.
Remove extra call to DefragTrackerInit as it was being called 2x
for each new tracker.

Now that DefragTrackerNew is just a wrapper for DefragTrackerAlloc,
remove it and just call DefragTrackerAlloc directly.

src/defrag-hash.c
src/defrag.h

index be2fd456ac84a629ff7cc059648984e3f002535d..e37a08738d85bb433d58f46e93dd3b2f671b5419 100644 (file)
@@ -96,24 +96,13 @@ static void DefragTrackerInit(DefragTracker *dt, Packet *p)
     dt->vlan_id[1] = p->vlan_id[1];
     dt->policy = DefragGetOsPolicy(p);
     dt->host_timeout = DefragPolicyGetHostTimeout(p);
+    dt->remove = 0;
+    dt->seen_last = 0;
 
     TAILQ_INIT(&dt->frags);
     (void) DefragTrackerIncrUsecnt(dt);
 }
 
-static DefragTracker *DefragTrackerNew(Packet *p)
-{
-    DefragTracker *dt = DefragTrackerAlloc();
-    if (dt == NULL)
-        goto error;
-
-    DefragTrackerInit(dt, p);
-    return dt;
-
-error:
-    return NULL;
-}
-
 void DefragTrackerRelease(DefragTracker *t)
 {
     (void) DefragTrackerDecrUsecnt(t);
@@ -467,7 +456,7 @@ static DefragTracker *DefragTrackerGetNew(Packet *p)
             /* freed a tracker, but it's unlocked */
         } else {
             /* now see if we can alloc a new tracker */
-            dt = DefragTrackerNew(p);
+            dt = DefragTrackerAlloc();
             if (dt == NULL) {
                 return NULL;
             }
index 8bd0325a341f40d2a1f791da8e713f5db5707d03..2dfaec60cf302ad42cc1a08ef7b559cafdcc2f02 100644 (file)
@@ -71,20 +71,6 @@ typedef struct Frag_ {
     TAILQ_ENTRY(Frag_) next;    /**< Pointer to next fragment for tailq. */
 } Frag;
 
-/** \brief Reset tracker fields except "lock" */
-#define DEFRAG_TRACKER_RESET(t) { \
-    (t)->timeout = 0; \
-    (t)->id = 0; \
-    (t)->policy = 0; \
-    (t)->af = 0; \
-    (t)->seen_last = 0; \
-    (t)->remove = 0; \
-    CLEAR_ADDR(&(t)->src_addr); \
-    CLEAR_ADDR(&(t)->dst_addr); \
-    (t)->frags.tqh_first = NULL; \
-    (t)->frags.tqh_last = NULL; \
-}
-
 /**
  * A defragmentation tracker.  Used to track fragments that make up a
  * single packet.