diff --git a/src/flow.h b/src/flow.h index d5e48c0427..93ca7afc65 100644 --- a/src/flow.h +++ b/src/flow.h @@ -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 ); diff --git a/src/output-json.c b/src/output-json.c index a20b0df6af..071b3f233f 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -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)); } diff --git a/src/util-lua-common.c b/src/util-lua-common.c index 2df0f6f349..f29dc48532 100644 --- a/src/util-lua-common.c +++ b/src/util-lua-common.c @@ -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; }