]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow queue handler: use int16_t
authorVictor Julien <victor@inliniac.net>
Wed, 18 Mar 2015 10:24:26 +0000 (11:24 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 10 May 2016 06:46:13 +0000 (08:46 +0200)
Use int16_t instead of int to store the autofp queue id. We should
not easily get to 32k threads so 2 bytes per flow is sufficient.

src/stream-tcp.c
src/tmqh-flow.c
src/tmqh-flow.h

index 875a9d6f3e4cbb68cc5c56f83143432836535feb..b83d45c33644b00c7e329a7298d4778931b188fd 100644 (file)
@@ -4907,7 +4907,7 @@ static void TcpSessionReuseHandle(Packet *p) {
 
     /* get some settings that we move over to the new flow */
     FlowThreadId thread_id = old_f->thread_id;
-    int autofp_tmqh_flow_qid = SC_ATOMIC_GET(old_f->autofp_tmqh_flow_qid);
+    int16_t autofp_tmqh_flow_qid = SC_ATOMIC_GET(old_f->autofp_tmqh_flow_qid);
 
     /* disconnect the packet from the old flow */
     FlowHandlePacketUpdateRemove(p->flow, p);
index 29b8a6ad98d6c8c27f83bd7befb0601ee6377d9a..5a6b40c9f58f512fe466feb7623a647b33c111b8 100644 (file)
@@ -289,13 +289,12 @@ void TmqhOutputFlowActivePackets(ThreadVars *tv, Packet *p)
 
     TmqhFlowCtx *ctx = (TmqhFlowCtx *)tv->outctx;
 
-    /* if no flow we use the first queue,
-     * should be rare */
+    /* if no flow we round robin the packets over the queues */
     if (p->flow != NULL) {
         qid = SC_ATOMIC_GET(p->flow->autofp_tmqh_flow_qid);
         if (qid == -1) {
-            uint16_t i = 0;
-            int lowest_id = 0;
+            int16_t i = 0;
+            int16_t lowest_id = 0;
             TmqhFlowMode *queues = ctx->queues;
             uint32_t lowest = queues[i].q->len;
             for (i = 1; i < ctx->size; i++) {
@@ -350,7 +349,7 @@ void TmqhOutputFlowHash(ThreadVars *tv, Packet *p)
             addr >>= 7;
 
             /* we don't have to worry about possible overflow, since
-             * ctx->size will be lesser than 2 ** 31 for sure */
+             * ctx->size will be less than 2 ** 15 for sure */
             qid = addr % ctx->size;
             (void) SC_ATOMIC_SET(p->flow->autofp_tmqh_flow_qid, qid);
             (void) SC_ATOMIC_ADD(ctx->queues[qid].total_flows, 1);
index 1206a05c13e53d5eb88ca46e4123f6d925f690f5..e710ffeca468f58aa08f8c030a73a8f363beaa8b 100644 (file)
@@ -39,7 +39,7 @@ typedef struct TmqhFlowCtx_ {
 
     TmqhFlowMode *queues;
 
-    SC_ATOMIC_DECLARE(uint16_t, round_robin_idx);
+    SC_ATOMIC_DECLARE(int16_t, round_robin_idx);
 } TmqhFlowCtx;
 
 void TmqhFlowRegister (void);