From: Victor Julien Date: Sat, 26 Mar 2016 09:59:52 +0000 (+0100) Subject: autofp: print packet scheduler info only on autofp X-Git-Tag: suricata-3.0.1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e0b5eb529bda9a2d978a1242016e222f5e6f5c3;p=thirdparty%2Fsuricata.git autofp: print packet scheduler info only on autofp To avoid confusion about what runmode is active, only print autofp related scheduler information if autofp is the actual runmode. --- diff --git a/src/runmodes.c b/src/runmodes.c index 601d356b91..d4eda057af 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -49,6 +49,8 @@ #include "source-pfring.h" +#include "tmqh-flow.h" + int debuglog_enabled = 0; /** @@ -369,6 +371,10 @@ void RunModeDispatch(int runmode, const char *custom_mode) exit(EXIT_FAILURE); } + if (strcasecmp(active_runmode, "autofp") == 0) { + TmqhFlowPrintAutofpHandler(); + } + mode->RunModeFunc(); if (local_custom_mode != NULL) diff --git a/src/tmqh-flow.c b/src/tmqh-flow.c index 49679b8fb2..615546bf59 100644 --- a/src/tmqh-flow.c +++ b/src/tmqh-flow.c @@ -59,16 +59,12 @@ void TmqhFlowRegister(void) char *scheduler = NULL; if (ConfGet("autofp-scheduler", &scheduler) == 1) { 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\" flow load balancer"); tmqh_table[TMQH_FLOW].OutHandler = TmqhOutputFlowActivePackets; } else if (strcasecmp(scheduler, "hash") == 0) { - SCLogInfo("AutoFP mode using \"Hash\" flow load balancer"); tmqh_table[TMQH_FLOW].OutHandler = TmqhOutputFlowHash; } else if (strcasecmp(scheduler, "ippair") == 0) { - SCLogInfo("AutoFP mode using \"ippair\" flow load balancer"); tmqh_table[TMQH_FLOW].OutHandler = TmqhOutputFlowIPPair; } else { SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid entry \"%s\" " @@ -77,13 +73,26 @@ void TmqhFlowRegister(void) exit(EXIT_FAILURE); } } else { - SCLogInfo("AutoFP mode using default \"Active Packets\" flow load balancer"); tmqh_table[TMQH_FLOW].OutHandler = TmqhOutputFlowActivePackets; } return; } +void TmqhFlowPrintAutofpHandler(void) +{ +#define PRINT_IF_FUNC(f, msg) \ + if (tmqh_table[TMQH_FLOW].OutHandler == (f)) \ + SCLogInfo("AutoFP mode using \"%s\" flow load balancer", (msg)) + + PRINT_IF_FUNC(TmqhOutputFlowRoundRobin, "Round Robin"); + PRINT_IF_FUNC(TmqhOutputFlowActivePackets, "Active Packets"); + PRINT_IF_FUNC(TmqhOutputFlowHash, "Hash"); + PRINT_IF_FUNC(TmqhOutputFlowIPPair, "IPPair"); + +#undef PRINT_IF_FUNC +} + /* same as 'simple' */ Packet *TmqhInputFlow(ThreadVars *tv) { diff --git a/src/tmqh-flow.h b/src/tmqh-flow.h index ccf9263337..1206a05c13 100644 --- a/src/tmqh-flow.h +++ b/src/tmqh-flow.h @@ -45,4 +45,6 @@ typedef struct TmqhFlowCtx_ { void TmqhFlowRegister (void); void TmqhFlowRegisterTests(void); +void TmqhFlowPrintAutofpHandler(void); + #endif /* __TMQH_FLOW_H__ */