Skip to content

Commit

Permalink
mpm/spm: check for SSSE3 and enable/disable HS
Browse files Browse the repository at this point in the history
The new Hyperscan 4.4 API provides a function to check for SSSE3
presence at runtime. This allows us to fall back to non-Hyperscan
matchers on systems without SSSE3 even when the suricata executable
is built with Hyperscan support. Addresses Redmine issue #2010.

Signed-off-by: Sascha Steinbiss <sascha@steinbiss.name>
Tested-by: Arturo Borrero Gonzalez <arturo@debian.org>
  • Loading branch information
satta authored and victorjulien committed Jan 30, 2017
1 parent a0580d8 commit e6044aa
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 67 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@
fi

AC_CHECK_LIB(hs,hs_compile,,HYPERSCAN="no")
AC_CHECK_FUNCS(hs_valid_platform)
enable_hyperscan="yes"
if test "$HYPERSCAN" = "no"; then
echo
Expand Down
2 changes: 1 addition & 1 deletion src/app-layer-detect-proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ int AppLayerProtoDetectSetup(void)
#ifdef __SC_CUDA_SUPPORT__
/* CUDA won't work here, so fall back to AC */
if (mpm_matcher == MPM_AC_CUDA)
mpm_matcher = DEFAULT_MPM;
mpm_matcher = mpm_default_matcher;
#endif

alpd_ctx.spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
Expand Down
2 changes: 1 addition & 1 deletion src/app-layer-smtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ typedef struct SMTPThreadCtx_ {
PrefilterRuleStore *pmq;
} SMTPThreadCtx;

#define SMTP_MPM DEFAULT_MPM
#define SMTP_MPM mpm_default_matcher

static MpmCtx *smtp_mpm_ctx = NULL;

Expand Down
2 changes: 1 addition & 1 deletion src/detect-csum.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ int DetectCsumICMPV6Test01(void)
printf("DetectEngineCtxInit failure\n");
goto end;
}
de_ctx->mpm_matcher = DEFAULT_MPM;
de_ctx->mpm_matcher = mpm_default_matcher;
de_ctx->flags |= DE_QUIET;

s = de_ctx->sig_list = SigInit(de_ctx, "alert ip any any -> any any "
Expand Down
14 changes: 7 additions & 7 deletions src/detect-dns-query.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static int DetectDnsQueryTest01(void)
if (de_ctx == NULL) {
goto end;
}
de_ctx->mpm_matcher = DEFAULT_MPM;
de_ctx->mpm_matcher = mpm_default_matcher;
de_ctx->flags |= DE_QUIET;

s = DetectEngineAppendSig(de_ctx, "alert dns any any -> any any "
Expand Down Expand Up @@ -286,7 +286,7 @@ static int DetectDnsQueryTest02(void)
if (de_ctx == NULL) {
goto end;
}
de_ctx->mpm_matcher = DEFAULT_MPM;
de_ctx->mpm_matcher = mpm_default_matcher;
de_ctx->flags |= DE_QUIET;

s = DetectEngineAppendSig(de_ctx, "alert dns any any -> any any "
Expand Down Expand Up @@ -441,7 +441,7 @@ static int DetectDnsQueryTest03(void)
if (de_ctx == NULL) {
goto end;
}
de_ctx->mpm_matcher = DEFAULT_MPM;
de_ctx->mpm_matcher = mpm_default_matcher;
de_ctx->flags |= DE_QUIET;

s = DetectEngineAppendSig(de_ctx, "alert dns any any -> any any "
Expand Down Expand Up @@ -548,7 +548,7 @@ static int DetectDnsQueryTest04(void)
if (de_ctx == NULL) {
goto end;
}
de_ctx->mpm_matcher = DEFAULT_MPM;
de_ctx->mpm_matcher = mpm_default_matcher;
de_ctx->flags |= DE_QUIET;

s = DetectEngineAppendSig(de_ctx, "alert dns any any -> any any "
Expand Down Expand Up @@ -714,7 +714,7 @@ static int DetectDnsQueryTest05(void)
if (de_ctx == NULL) {
goto end;
}
de_ctx->mpm_matcher = DEFAULT_MPM;
de_ctx->mpm_matcher = mpm_default_matcher;
de_ctx->flags |= DE_QUIET;

s = DetectEngineAppendSig(de_ctx, "alert dns any any -> any any "
Expand Down Expand Up @@ -887,7 +887,7 @@ static int DetectDnsQueryTest06(void)
if (de_ctx == NULL) {
goto end;
}
de_ctx->mpm_matcher = DEFAULT_MPM;
de_ctx->mpm_matcher = mpm_default_matcher;
de_ctx->flags |= DE_QUIET;

s = DetectEngineAppendSig(de_ctx, "alert dns any any -> any any "
Expand Down Expand Up @@ -1034,7 +1034,7 @@ static int DetectDnsQueryTest07(void)
if (de_ctx == NULL) {
goto end;
}
de_ctx->mpm_matcher = DEFAULT_MPM;
de_ctx->mpm_matcher = mpm_default_matcher;
de_ctx->flags |= DE_QUIET;

s = DetectEngineAppendSig(de_ctx, "alert dns any any -> any any "
Expand Down
2 changes: 1 addition & 1 deletion src/detect-engine-mpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ int SignatureHasStreamContent(const Signature *s)
uint16_t PatternMatchDefaultMatcher(void)
{
char *mpm_algo;
uint16_t mpm_algo_val = DEFAULT_MPM;
uint16_t mpm_algo_val = mpm_default_matcher;

/* Get the mpm algo defined in config file by the user */
if ((ConfGet("mpm-algo", &mpm_algo)) == 1) {
Expand Down

0 comments on commit e6044aa

Please sign in to comment.