]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
defrag: use 'struct timeval' for timeout tracking 1088/head
authorVictor Julien <victor@inliniac.net>
Tue, 5 Aug 2014 15:28:17 +0000 (17:28 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 6 Aug 2014 09:15:18 +0000 (11:15 +0200)
Until now the time out handling in defrag was done using a single
uint32_t that tracked seconds. This lead to corner cases, where
defrag trackers could be timed out a little too early.

src/defrag-timeout.c
src/defrag.c
src/defrag.h

index f77cc59cf92403803e30c6af0647912061f5cc1d..663ee3b595f6bd724f6f5fb36014571aa3d9af3d 100644 (file)
@@ -53,7 +53,7 @@ static int DefragTrackerTimedOut(DefragTracker *dt, struct timeval *ts)
     }
 
     /* retain if remove is not set and not timed out */
-    if (!dt->remove && dt->timeout > (uint32_t)ts->tv_sec)
+    if (!dt->remove && timercmp(&dt->timeout, ts, >))
         return 0;
 
     return 1;
index a75978e013c15d7aa73258529932117ff9553104..c0088234df9e575381580d90607fd5b30f830c0a 100644 (file)
@@ -579,7 +579,8 @@ DefragInsertFrag(ThreadVars *tv, DecodeThreadVars *dtv, DefragTracker *tracker,
     }
 
     /* Update timeout. */
-    tracker->timeout = p->ts.tv_sec + tracker->host_timeout;
+    tracker->timeout.tv_sec = p->ts.tv_sec + tracker->host_timeout;
+    tracker->timeout.tv_usec = p->ts.tv_usec;
 
     Frag *prev = NULL, *next;
     int overlap = 0;
index dd4aac09bd98ebb1eb6df84ec46254763babfb72..8bd0325a341f40d2a1f791da8e713f5db5707d03 100644 (file)
@@ -110,7 +110,7 @@ typedef struct DefragTracker_ {
     Address src_addr; /**< Source address for this tracker. */
     Address dst_addr; /**< Destination address for this tracker. */
 
-    uint32_t timeout; /**< When this tracker will timeout. */
+    struct timeval timeout; /**< When this tracker will timeout. */
     uint32_t host_timeout;  /**< Host timeout, statically assigned from the yaml */
 
     /** use cnt, reference counter */