]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow: enforce 51 bits id globally
authorVictor Julien <victor@inliniac.net>
Wed, 31 May 2017 08:19:49 +0000 (10:19 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 31 May 2017 08:19:49 +0000 (10:19 +0200)
src/flow.h
src/output-json.c
src/util-lua-common.c

index d5e48c04278b395fd96669b1a690f4ebafb151a6..93ca7afc659768466188712e1fc47ad0545541cb 100644 (file)
@@ -579,9 +579,13 @@ static inline void FlowDeReference(Flow **d)
  */
 static inline int64_t FlowGetId(const Flow *f)
 {
-    return (int64_t)f->flow_hash << 31 |
+    int64_t id = (int64_t)f->flow_hash << 31 |
         (int64_t)(f->startts.tv_sec & 0x0000FFFF) << 16 |
         (int64_t)(f->startts.tv_usec & 0x0000FFFF);
+    /* reduce to 51 bits as Javascript and even JSON often seem to
+     * max out there. */
+    id &= 0x7ffffffffffffLL;
+    return id;
 }
 
 int FlowClearMemory(Flow *,uint8_t );
index a20b0df6af8a1e789915c3b15c342b98b73bbf9d..071b3f233fab7011d6fcd0fb8f65fc8363dca406 100644 (file)
@@ -381,9 +381,6 @@ void CreateJSONFlowId(json_t *js, const Flow *f)
     if (f == NULL)
         return;
     int64_t flow_id = FlowGetId(f);
-    /* reduce to 51 bits as Javascript and even JSON often seem to
-     * max out there. */
-    flow_id &= 0x7ffffffffffffLL;
     json_object_set_new(js, "flow_id", json_integer(flow_id));
 }
 
index 2df0f6f349a71e4f3c4d85d685c6dd741962080c..f29dc48532e450ab519f430b474753912f1f9ed4 100644 (file)
@@ -524,10 +524,7 @@ static int LuaCallbackStatsFlow(lua_State *luastate)
  */
 static int LuaCallbackPushFlowIdToStackFromFlow(lua_State *luastate, const Flow *f)
 {
-    uint64_t id = FlowGetId(f);
-    /* reduce to 51 bits as Javascript and even JSON often seem to
-     * max out there. */
-    id &= 0x7ffffffffffffLL;
+    int64_t id = FlowGetId(f);
     lua_pushinteger(luastate, id);
     return 1;
 }