diff --git a/src/detect-engine-mpm.c b/src/detect-engine-mpm.c index c923b59361..dd454ce5a4 100644 --- a/src/detect-engine-mpm.c +++ b/src/detect-engine-mpm.c @@ -116,7 +116,11 @@ void DetectMpmInitializeAppMpms(DetectEngineCtx *de_ctx) for (i = 0; i < APP_MPMS_MAX; i++) { AppLayerMpms *am = &app_mpms[i]; - am->sgh_mpm_context = MpmFactoryRegisterMpmCtxProfile(de_ctx, am->name); + if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { + am->sgh_mpm_context = MpmFactoryRegisterMpmCtxProfile(de_ctx, am->name); + } else { + am->sgh_mpm_context = MPM_CTX_FACTORY_UNIQUE_CONTEXT; + } SCLogDebug("AppLayer MPM %s: %u", am->name, am->sgh_mpm_context); } @@ -782,11 +786,7 @@ void MpmStoreSetup(const DetectEngineCtx *de_ctx, MpmStore *ms) dir = 0; } - if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { - ms->mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, ms->sgh_mpm_context, dir); - } else { - ms->mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, dir); - } + ms->mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, ms->sgh_mpm_context, dir); MpmInitCtx(ms->mpm_ctx, de_ctx->mpm_matcher); /* add the patterns */ diff --git a/src/detect.c b/src/detect.c index 40ba84bbb6..734117cf07 100644 --- a/src/detect.c +++ b/src/detect.c @@ -2730,14 +2730,21 @@ static int SignatureCreateMask(Signature *s) static void SigInitStandardMpmFactoryContexts(DetectEngineCtx *de_ctx) { - de_ctx->sgh_mpm_context_proto_tcp_packet = - MpmFactoryRegisterMpmCtxProfile(de_ctx, "packet_proto_tcp"); - de_ctx->sgh_mpm_context_proto_udp_packet = - MpmFactoryRegisterMpmCtxProfile(de_ctx, "packet_proto_udp"); - de_ctx->sgh_mpm_context_proto_other_packet = - MpmFactoryRegisterMpmCtxProfile(de_ctx, "packet_proto_other"); - de_ctx->sgh_mpm_context_stream = - MpmFactoryRegisterMpmCtxProfile(de_ctx, "stream"); + if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { + de_ctx->sgh_mpm_context_proto_tcp_packet = + MpmFactoryRegisterMpmCtxProfile(de_ctx, "packet_proto_tcp"); + de_ctx->sgh_mpm_context_proto_udp_packet = + MpmFactoryRegisterMpmCtxProfile(de_ctx, "packet_proto_udp"); + de_ctx->sgh_mpm_context_proto_other_packet = + MpmFactoryRegisterMpmCtxProfile(de_ctx, "packet_proto_other"); + de_ctx->sgh_mpm_context_stream = + MpmFactoryRegisterMpmCtxProfile(de_ctx, "stream"); + } else { + de_ctx->sgh_mpm_context_proto_tcp_packet = MPM_CTX_FACTORY_UNIQUE_CONTEXT; + de_ctx->sgh_mpm_context_proto_udp_packet = MPM_CTX_FACTORY_UNIQUE_CONTEXT; + de_ctx->sgh_mpm_context_proto_other_packet = MPM_CTX_FACTORY_UNIQUE_CONTEXT; + de_ctx->sgh_mpm_context_stream = MPM_CTX_FACTORY_UNIQUE_CONTEXT; + } DetectMpmInitializeAppMpms(de_ctx); @@ -4112,11 +4119,7 @@ int SigGroupBuild(DetectEngineCtx *de_ctx) if (DetectSetFastPatternAndItsId(de_ctx) < 0) return -1; - /* if we are using single sgh_mpm_context then let us init the standard mpm - * contexts using the mpm_ctx factory */ - if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { - SigInitStandardMpmFactoryContexts(de_ctx); - } + SigInitStandardMpmFactoryContexts(de_ctx); if (SigAddressPrepareStage1(de_ctx) != 0) { SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");