From: Victor Julien Date: Wed, 14 Mar 2012 12:32:40 +0000 (+0100) Subject: Minor flowq updates. X-Git-Tag: suricata-1.3beta1~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40ed10ab3857f68058bd094f501a20b16e838b9f;p=thirdparty%2Fsuricata.git Minor flowq updates. --- diff --git a/src/flow.h b/src/flow.h index c5a2af8993..a42995d3a2 100644 --- a/src/flow.h +++ b/src/flow.h @@ -253,6 +253,9 @@ typedef struct Flow_ */ SC_ATOMIC_DECLARE(unsigned short, use_cnt); + /** flow queue id, used with autofp */ + SC_ATOMIC_DECLARE(int, autofp_tmqh_flow_qid); + uint32_t probing_parser_toserver_al_proto_masks; uint32_t probing_parser_toclient_al_proto_masks; @@ -311,8 +314,6 @@ typedef struct Flow_ uint32_t tosrcpktcnt; uint64_t bytecnt; #endif - - SC_ATOMIC_DECLARE(int, autofp_tmqh_flow_qid); } Flow; enum { diff --git a/src/tmqh-flow.c b/src/tmqh-flow.c index 7f25861adc..91022e1d99 100644 --- a/src/tmqh-flow.c +++ b/src/tmqh-flow.c @@ -59,14 +59,14 @@ void TmqhFlowRegister(void) char *scheduler = NULL; if (ConfGet("autofp-scheduler", &scheduler) == 1) { - if (strcasecmp(scheduler, "round_robin") == 0) { - SCLogInfo("AutoFP mode using \"Round Robin\" Q Handler"); + if (strcasecmp(scheduler, "round-robin") == 0) { + SCLogInfo("AutoFP mode using \"Round Robin\" flow load balancer"); tmqh_table[TMQH_FLOW].OutHandler = TmqhOutputFlowRoundRobin; - } else if (strcasecmp(scheduler, "active_packets") == 0) { - SCLogInfo("AutoFP mode using \"Active Packets\" Q Handler"); + } else if (strcasecmp(scheduler, "active-packets") == 0) { + SCLogInfo("AutoFP mode using \"Active Packets\" flow load balancer"); tmqh_table[TMQH_FLOW].OutHandler = TmqhOutputFlowActivePackets; } else if (strcasecmp(scheduler, "hash") == 0) { - SCLogInfo("AutoFP mode using \"Hash\" Q Handler"); + SCLogInfo("AutoFP mode using \"Hash\" flow load balancer"); tmqh_table[TMQH_FLOW].OutHandler = TmqhOutputFlowHash; } else { SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid entry \"%s\" " @@ -75,7 +75,7 @@ void TmqhFlowRegister(void) exit(EXIT_FAILURE); } } else { - SCLogInfo("AutoFP mode using default \"Active Packets\" Q Handler"); + SCLogInfo("AutoFP mode using default \"Active Packets\" flow load balancer"); tmqh_table[TMQH_FLOW].OutHandler = TmqhOutputFlowActivePackets; } @@ -87,14 +87,14 @@ Packet *TmqhInputFlow(ThreadVars *tv) { PacketQueue *q = &trans_q[tv->inq->id]; + SCPerfSyncCountersIfSignalled(tv, 0); + SCMutexLock(&q->mutex_q); if (q->len == 0) { /* if we have no packets in queue, wait... */ SCCondWait(&q->cond_q, &q->mutex_q); } - SCPerfSyncCountersIfSignalled(tv, 0); - if (q->len > 0) { Packet *p = PacketDequeue(q); SCMutexUnlock(&q->mutex_q); @@ -206,10 +206,9 @@ void TmqhOutputFlowFreeCtx(void *ctx) SCLogInfo("AutoFP - Total flow handler queues - %" PRIu16, tmqh_flow_outctx->size); for (i = 0; i < fctx->size; i++) { - SCLogInfo("AutoFP - Total Packets - Queue %"PRIu32 " - %"PRIu64 , i, - SC_ATOMIC_GET(fctx->queues[i].total_packets)); - SCLogInfo("AutoFP - Total Flows - Queue %"PRIu32 " - %"PRIu64 , i, - SC_ATOMIC_GET(fctx->queues[i].total_flows)); + SCLogInfo("AutoFP - Queue %-2"PRIu32 " - pkts: %-12"PRIu64" flows: %-12"PRIu64, i, + SC_ATOMIC_GET(fctx->queues[i].total_packets), + SC_ATOMIC_GET(fctx->queues[i].total_flows)); SC_ATOMIC_DESTROY(fctx->queues[i].total_packets); SC_ATOMIC_DESTROY(fctx->queues[i].total_flows); } diff --git a/src/tmqh-simple.c b/src/tmqh-simple.c index 53277dbc67..3a1feafbaa 100644 --- a/src/tmqh-simple.c +++ b/src/tmqh-simple.c @@ -46,6 +46,8 @@ Packet *TmqhInputSimple(ThreadVars *t) { PacketQueue *q = &trans_q[t->inq->id]; + SCPerfSyncCountersIfSignalled(t, 0); + SCMutexLock(&q->mutex_q); if (q->len == 0) { @@ -53,8 +55,6 @@ Packet *TmqhInputSimple(ThreadVars *t) SCCondWait(&q->cond_q, &q->mutex_q); } - SCPerfSyncCountersIfSignalled(t, 0); - if (q->len > 0) { Packet *p = PacketDequeue(q); SCMutexUnlock(&q->mutex_q); diff --git a/suricata.yaml.in b/suricata.yaml.in index 7b0f71f695..e73dae3541 100644 --- a/suricata.yaml.in +++ b/suricata.yaml.in @@ -20,12 +20,16 @@ #runmode: auto # Specifies the kind of q scheduler used by flow pinned autofp mode. -# Supported scheduler are : -# round_robin - Flow alloted to queue in a round robin fashion. -# active-packets - Flow alloted to queue that has the least no of +# +# Supported schedulers are: +# +# round-robin - Flows assigned to threads in a round robin fashion. +# active-packets - Flows assigned to threads that have the lowest number of # unprocessed packets. -# hash - Flow alloted usihng the address hash. More of a random technique. -#autofp-scheduler: active_packets +# hash - Flow alloted usihng the address hash. More of a random technique. Was +# the default in 1.2.1 and older. +# +autofp-scheduler: active-packets # Default pid file. # Will use this file if no --pidfile in command options.