From 6c55af847b5018fed759f2d885c62b430ca852e7 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Wed, 7 Dec 2011 19:17:13 +0100 Subject: [PATCH] 'auto' running mode does not support 'threads' var. This patch modifies the RunModeSetLiveCaptureAuto() prototype to be able to detect that a 'threads' variable (telling how much threads must listen to one socket in IDS mode) has been used in the configuration file. It then print a warning message if this is the case. --- src/runmode-af-packet.c | 4 +++- src/runmode-pcap.c | 4 +++- src/runmode-pfring.c | 3 ++- src/util-runmodes.c | 18 +++++++++++++++++- src/util-runmodes.h | 4 +++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/runmode-af-packet.c b/src/runmode-af-packet.c index 6ef9fa722b..165d478e39 100644 --- a/src/runmode-af-packet.c +++ b/src/runmode-af-packet.c @@ -246,7 +246,9 @@ int RunModeIdsAFPAuto(DetectEngineCtx *de_ctx) ConfGet("af-packet.live-interface", &live_dev); ret = RunModeSetLiveCaptureAuto(de_ctx, - ParseAFPConfig, "ReceiveAFP", + ParseAFPConfig, + AFPConfigGeThreadsCount, + "ReceiveAFP", "DecodeAFP", "RecvAFP", live_dev); if (ret != 0) { diff --git a/src/runmode-pcap.c b/src/runmode-pcap.c index 1460a70f79..0d0475bbe3 100644 --- a/src/runmode-pcap.c +++ b/src/runmode-pcap.c @@ -215,7 +215,9 @@ int RunModeIdsPcapAuto(DetectEngineCtx *de_ctx) ConfGet("pcap.single_pcap_dev", &live_dev); ret = RunModeSetLiveCaptureAuto(de_ctx, - ParsePcapConfig, "ReceivePcap", + ParsePcapConfig, + PcapConfigGeThreadsCount, + "ReceivePcap", "DecodePcap", "RecvPcap", live_dev); if (ret != 0) { diff --git a/src/runmode-pfring.c b/src/runmode-pfring.c index eec9e94418..21f5e9333e 100644 --- a/src/runmode-pfring.c +++ b/src/runmode-pfring.c @@ -403,7 +403,8 @@ int RunModeIdsPfringAuto(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } - ret = RunModeSetLiveCaptureAuto(de_ctx, tparser, "ReceivePfring", "DecodePfring", + ret = RunModeSetLiveCaptureAuto(de_ctx, tparser, PfringConfigGeThreadsCount, + "ReceivePfring", "DecodePfring", "RxPFR", live_dev); if (ret != 0) { SCLogError(SC_ERR_RUNMODE, "Runmode start failed"); diff --git a/src/util-runmodes.c b/src/util-runmodes.c index 0036fecca7..3bbace8494 100644 --- a/src/util-runmodes.c +++ b/src/util-runmodes.c @@ -50,7 +50,9 @@ #include "util-runmodes.h" int RunModeSetLiveCaptureAuto(DetectEngineCtx *de_ctx, - ConfigIfaceParserFunc ConfigParser, char *recv_mod_name, + ConfigIfaceParserFunc ConfigParser, + ConfigIfaceThreadsCountFunc ModThreadsCount, + char *recv_mod_name, char *decode_mod_name, char *thread_name, const char *live_dev) { @@ -71,6 +73,13 @@ int RunModeSetLiveCaptureAuto(DetectEngineCtx *de_ctx, exit(EXIT_FAILURE); } + if (ModThreadsCount(aconf) > 1) { + SCLogWarning(SC_ERR_UNIMPLEMENTED, "'Auto' running mode does not honor 'threads'" + " variable (set on '%s'). Please use an other mode as" + " 'autofp' or 'worker'", + live_dev); + } + /* create the threads */ ThreadVars *tv_receive = TmThreadCreatePacketHandler(recv_mod_name, @@ -115,6 +124,13 @@ int RunModeSetLiveCaptureAuto(DetectEngineCtx *de_ctx, exit(EXIT_FAILURE); } + if (ModThreadsCount(aconf) > 1) { + SCLogWarning(SC_ERR_UNIMPLEMENTED, "'Auto' running mode does not honor 'threads'" + " variable (set on '%s'). Please use an other mode as" + " 'autofp' or 'worker'", + live_dev); + } + snprintf(tname, sizeof(tname),"%s-%s", thread_name, live_dev); tnamec = SCStrdup(tname); if (tnamec == NULL) { diff --git a/src/util-runmodes.h b/src/util-runmodes.h index 29a70400ac..a5bd5066a2 100644 --- a/src/util-runmodes.h +++ b/src/util-runmodes.h @@ -28,7 +28,9 @@ typedef void *(*ConfigIfaceParserFunc) (const char *); typedef int (*ConfigIfaceThreadsCountFunc) (void *); int RunModeSetLiveCaptureAuto(DetectEngineCtx *de_ctx, - ConfigIfaceParserFunc configparser, char *recv_mod_name, + ConfigIfaceParserFunc configparser, + ConfigIfaceThreadsCountFunc ModThreadsCount, + char *recv_mod_name, char *decode_mod_name, char *thread_name, const char *live_dev);