]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
host/iprep: run all timeout logic
authorVictor Julien <vjulien@oisf.net>
Mon, 11 Sep 2023 05:05:48 +0000 (07:05 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 1 Nov 2023 05:50:27 +0000 (06:50 +0100)
Run all timeout logic if iprep is in use as well.

Minor code cleanups.

Bug: #6436.

src/host-timeout.c

index 75918f3ebadd707a931d9dc693c3303f24dd36e5..8542d5f78abb01188f2c5618fa452be9a92f9c0d 100644 (file)
@@ -53,9 +53,7 @@ uint32_t HostGetActiveCount(void)
  */
 static int HostHostTimedOut(Host *h, SCTime_t ts)
 {
-    int tags = 0;
-    int thresholds = 0;
-    int vars = 0;
+    int busy = 0;
 
     /** never prune a host that is used by a packet
      *  we are currently processing in one of the threads */
@@ -63,28 +61,12 @@ static int HostHostTimedOut(Host *h, SCTime_t ts)
         return 0;
     }
 
-    if (h->iprep) {
-        if (SRepHostTimedOut(h) == 0)
-            return 0;
-
-        SCLogDebug("host %p reputation timed out", h);
-    }
-
-    if (TagHostHasTag(h) && TagTimeoutCheck(h, ts) == 0) {
-        tags = 1;
-    }
-    if (ThresholdHostHasThreshold(h) && ThresholdHostTimeoutCheck(h, ts) == 0) {
-        thresholds = 1;
-    }
-    if (HostHasHostBits(h) && HostBitsTimedoutCheck(h, ts) == 0) {
-        vars = 1;
-    }
-
-    if (tags || thresholds || vars)
-        return 0;
-
-    SCLogDebug("host %p timed out", h);
-    return 1;
+    busy |= (h->iprep && SRepHostTimedOut(h) == 0);
+    busy |= (TagHostHasTag(h) && TagTimeoutCheck(h, ts) == 0);
+    busy |= (ThresholdHostHasThreshold(h) && ThresholdHostTimeoutCheck(h, ts) == 0);
+    busy |= (HostHasHostBits(h) && HostBitsTimedoutCheck(h, ts) == 0);
+    SCLogDebug("host %p %s", h, busy ? "still active" : "timed out");
+    return !busy;
 }
 
 /**