]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
autofp: print packet scheduler info only on autofp
authorVictor Julien <victor@inliniac.net>
Sat, 26 Mar 2016 09:59:52 +0000 (10:59 +0100)
committerVictor Julien <victor@inliniac.net>
Sat, 26 Mar 2016 10:05:43 +0000 (11:05 +0100)
To avoid confusion about what runmode is active, only print autofp
related scheduler information if autofp is the actual runmode.

src/runmodes.c
src/tmqh-flow.c
src/tmqh-flow.h

index 601d356b91731f78bc9b0f81f8723df8221b4914..d4eda057af2b2927346f69881b68a59e0bd47050 100644 (file)
@@ -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)
index 49679b8fb203d7da9eed79a9ec963f191294a162..615546bf5999b390485b5aa6425390d4215e37e8 100644 (file)
@@ -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)
 {
index ccf926333710622c29bc79dd51039d593d3be94d..1206a05c13e53d5eb88ca46e4123f6d925f690f5 100644 (file)
@@ -45,4 +45,6 @@ typedef struct TmqhFlowCtx_ {
 void TmqhFlowRegister (void);
 void TmqhFlowRegisterTests(void);
 
+void TmqhFlowPrintAutofpHandler(void);
+
 #endif /* __TMQH_FLOW_H__ */