]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow: change flow id computation method
authorEric Leblond <el@stamus-networks.com>
Thu, 25 Mar 2021 23:13:43 +0000 (00:13 +0100)
committerVictor Julien <vjulien@oisf.net>
Mon, 3 Oct 2022 09:03:08 +0000 (11:03 +0200)
Previous method was truncating the flow hash value when building
the flow_id. It is interesting not to loose the flow hash value
as it can be used in other tools or to interact with a flow that
is still active.

src/flow.h

index a238ff0b99abe52671d4261d3f142b94538f677e..ac9c314dab64d55f406caa9aa53a7400834b97db 100644 (file)
@@ -691,9 +691,8 @@ static inline void FlowDeReference(Flow **d)
  */
 static inline int64_t FlowGetId(const Flow *f)
 {
-    int64_t id = (int64_t)f->flow_hash << 31 |
-        (int64_t)(f->startts.tv_sec & 0x0000FFFF) << 16 |
-        (int64_t)(f->startts.tv_usec & 0x0000FFFF);
+    int64_t id = (uint64_t)(f->startts.tv_sec & 0x0000FFFF) << 48 |
+                 (uint64_t)(f->startts.tv_usec & 0x0000FFFF) << 32 | (int64_t)f->flow_hash;
     /* reduce to 51 bits as Javascript and even JSON often seem to
      * max out there. */
     id &= 0x7ffffffffffffLL;