diff --git a/src/detect-engine-prefilter.c b/src/detect-engine-prefilter.c index a7cc85f8db..dee4c316dc 100644 --- a/src/detect-engine-prefilter.c +++ b/src/detect-engine-prefilter.c @@ -48,6 +48,7 @@ #include "suricata.h" #include "detect-engine-prefilter.h" +#include "detect-engine-mpm.h" #include "app-layer-parser.h" #include "app-layer-htp.h" @@ -323,6 +324,41 @@ void PrefilterFreeEngines(PrefilterEngine *list) } } +void PrefilterSetupRuleGroup(DetectEngineCtx *de_ctx, SigGroupHead *sgh) +{ + BUG_ON(PatternMatchPrepareGroup(de_ctx, sgh) != 0); + + if (de_ctx->prefilter_setting == DETECT_PREFILTER_AUTO) { + int i = 0; + for (i = 0; i < DETECT_TBLSIZE; i++) + { + if (sigmatch_table[i].SetupPrefilter != NULL) { + sigmatch_table[i].SetupPrefilter(sgh); + } + } + } + +#ifdef PROFILING + PrefilterEngine *e; + uint32_t engines = 0; + uint32_t tx_engines = 0; + + for (e = sgh->pkt_engines ; e != NULL; e = e->next) { + engines++; + de_ctx->profile_prefilter_maxid = MAX(de_ctx->profile_prefilter_maxid, e->profile_id); + } + for (e = sgh->payload_engines ; e != NULL; e = e->next) { + engines++; + de_ctx->profile_prefilter_maxid = MAX(de_ctx->profile_prefilter_maxid, e->profile_id); + } + for (e = sgh->tx_engines ; e != NULL; e = e->next) { + tx_engines++; + de_ctx->profile_prefilter_maxid = MAX(de_ctx->profile_prefilter_maxid, e->profile_id); + } + SCLogDebug("SGH %p: engines %u tx_engines %u", sgh, engines, tx_engines); +#endif +} + #ifdef PROFILING /* hash table for assigning a unique id to each engine type. */ diff --git a/src/detect-engine-prefilter.h b/src/detect-engine-prefilter.h index 5ce32fea0a..7836bab39a 100644 --- a/src/detect-engine-prefilter.h +++ b/src/detect-engine-prefilter.h @@ -45,6 +45,8 @@ int PrefilterAppendTxEngine(SigGroupHead *sgh, void PrefilterFreeEngines(PrefilterEngine *list); +void PrefilterSetupRuleGroup(DetectEngineCtx *de_ctx, SigGroupHead *sgh); + #ifdef PROFILING const char *PrefilterStoreGetName(const uint32_t id); #endif diff --git a/src/detect.c b/src/detect.c index a955b5fe2a..900f824386 100644 --- a/src/detect.c +++ b/src/detect.c @@ -3787,37 +3787,7 @@ int SigAddressPrepareStage4(DetectEngineCtx *de_ctx) SigGroupHeadSetFilestoreCount(de_ctx, sgh); SCLogDebug("filestore count %u", sgh->filestore_cnt); - BUG_ON(PatternMatchPrepareGroup(de_ctx, sgh) != 0); - - if (de_ctx->prefilter_setting == DETECT_PREFILTER_AUTO) { - int i = 0; - for (i = 0; i < DETECT_TBLSIZE; i++) - { - if (sigmatch_table[i].SetupPrefilter != NULL) { - sigmatch_table[i].SetupPrefilter(sgh); - } - } - } - -#ifdef PROFILING - PrefilterEngine *e; - uint32_t engines = 0; - uint32_t tx_engines = 0; - - for (e = sgh->pkt_engines ; e != NULL; e = e->next) { - engines++; - de_ctx->profile_prefilter_maxid = MAX(de_ctx->profile_prefilter_maxid, e->profile_id); - } - for (e = sgh->payload_engines ; e != NULL; e = e->next) { - engines++; - de_ctx->profile_prefilter_maxid = MAX(de_ctx->profile_prefilter_maxid, e->profile_id); - } - for (e = sgh->tx_engines ; e != NULL; e = e->next) { - tx_engines++; - de_ctx->profile_prefilter_maxid = MAX(de_ctx->profile_prefilter_maxid, e->profile_id); - } - SCLogDebug("SGH %p: engines %u tx_engines %u", sgh, engines, tx_engines); -#endif + PrefilterSetupRuleGroup(de_ctx, sgh); SigGroupHeadBuildNonPrefilterArray(de_ctx, sgh);