Go to the documentation of this file.
59 const char *scheduler = NULL;
60 if (
ConfGet(
"autofp-scheduler", &scheduler) == 1) {
61 if (strcasecmp(scheduler,
"round-robin") == 0) {
62 SCLogNotice(
"using flow hash instead of round robin");
64 }
else if (strcasecmp(scheduler,
"active-packets") == 0) {
65 SCLogNotice(
"using flow hash instead of active packets");
67 }
else if (strcasecmp(scheduler,
"hash") == 0) {
69 }
else if (strcasecmp(scheduler,
"ippair") == 0) {
71 }
else if (strcasecmp(scheduler,
"ftp-hash") == 0) {
75 "for autofp-scheduler in conf. Killing engine.",
86 #define PRINT_IF_FUNC(f, msg) \
87 if (tmqh_table[TMQH_FLOW].OutHandler == (f)) \
88 SCLogConfig("AutoFP mode using \"%s\" flow load balancer", (msg))
132 if (
ctx->queues == NULL) {
135 if (
ctx->queues == NULL) {
150 ctx->queues[
ctx->size - 1].q = tmq->
pq;
167 if (queue_str == NULL || strlen(queue_str) == 0)
184 char *comma = strchr(tstr,
',');
188 int r = StoreQueueId(
ctx,qname);
193 int r = StoreQueueId(
ctx,qname);
197 tstr = comma ? (comma + 1) : comma;
198 }
while (tstr != NULL);
214 SCLogPerf(
"AutoFP - Total flow handler queues - %" PRIu16,
227 qid = hash %
ctx->size;
231 if (
ctx->last ==
ctx->size)
250 uint32_t addr_hash = 0;
255 for (
int i = 0; i < 4; i++) {
256 addr_hash += p->
src.addr_data32[i] + p->
dst.addr_data32[i];
259 addr_hash = p->
src.addr_data32[0] + p->
dst.addr_data32[0];
262 uint32_t qid = addr_hash %
ctx->size;
277 if (PacketIsTCP(p) && ((p->
sp >= 1024 && p->
dp >= 1024) || p->
dp == 21 || p->
sp == 21 ||
278 p->
dp == 20 || p->
sp == 20)) {
281 qid = hash %
ctx->size;
285 if (
ctx->last ==
ctx->size)
298 static int TmqhOutputFlowSetupCtxTest01(
void)
311 const char *
str =
"queue1,queue2,another,yetanother";
331 static int TmqhOutputFlowSetupCtxTest02(
void)
344 const char *
str =
"queue1";
361 static int TmqhOutputFlowSetupCtxTest03(
void)
365 const char *
str =
"queue1,queue2,another,yetanother";
400 TmqhOutputFlowSetupCtxTest01);
402 TmqhOutputFlowSetupCtxTest02);
404 TmqhOutputFlowSetupCtxTest03);
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
void TmqhOutputFlowIPPair(ThreadVars *t, Packet *p)
select the queue to output based on IP address pair.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
void TmqhFlowPrintAutofpHandler(void)
void PacketEnqueue(PacketQueue *q, Packet *p)
simple fifo queue for packets with mutex and cond Calling the mutex or triggering the cond is respons...
void TmqhFlowRegisterTests(void)
void(* OutHandler)(ThreadVars *, Packet *)
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
void TmqhFlowRegister(void)
Packet *(* InHandler)(ThreadVars *)
void TmqhOutputFlowFreeCtx(void *ctx)
int ConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
#define PASS
Pass the test.
#define SCMutexUnlock(mut)
Per thread variable structure.
Tmq * TmqGetQueueByName(const char *name)
void(* RegisterTests)(void)
void * TmqhOutputFlowSetupCtx(const char *queue_str)
setup the queue handlers ctx
void(* OutHandlerCtxFree)(void *)
void TmqhOutputFlowHash(ThreadVars *t, Packet *p)
#define SCRealloc(ptr, sz)
uint32_t FlowGetIpPairProtoHash(const Packet *p)
#define PRINT_IF_FUNC(f, msg)
Tmqh tmqh_table[TMQH_SIZE]
Packet * PacketDequeue(PacketQueue *q)
void *(* OutHandlerCtxSetup)(const char *)
#define SCLogError(...)
Macro used to log ERROR messages.
Tmq * TmqCreateQueue(const char *name)
Packet * TmqhInputFlow(ThreadVars *t)
void StatsSyncCountersIfSignalled(ThreadVars *tv)
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Ctx for the flow queue handler.
void TmqResetQueues(void)