diff --git a/src/util-spm.c b/src/util-spm.c index 6e1192a892..04e7676f5c 100644 --- a/src/util-spm.c +++ b/src/util-spm.c @@ -65,6 +65,9 @@ uint16_t SinglePatternMatchDefaultMatcher(void) char *spm_algo; if ((ConfGet("spm-algo", &spm_algo)) == 1) { if (spm_algo != NULL) { + if (strcmp("auto", spm_algo) == 0) { + goto default_matcher; + } for (uint16_t i = 0; i < SPM_TABLE_SIZE; i++) { if (spm_table[i].name == NULL) { continue; @@ -82,7 +85,15 @@ uint16_t SinglePatternMatchDefaultMatcher(void) exit(EXIT_FAILURE); } - return SPM_BM; /* default to Boyer-Moore */ +default_matcher: + /* When Suricata is built with Hyperscan support, default to using it for + * SPM. */ +#ifdef BUILD_HYPERSCAN + return SPM_HS; +#else + /* Otherwise, default to Boyer-Moore */ + return SPM_BM; +#endif } void SpmTableSetup(void) diff --git a/suricata.yaml.in b/suricata.yaml.in index 12a18faf17..c93bfd613a 100644 --- a/suricata.yaml.in +++ b/suricata.yaml.in @@ -729,8 +729,10 @@ mpm-algo: ac # # Supported algorithms are "bm" (Boyer-Moore) and "hs" (Hyperscan, only # available if Suricata has been built with Hyperscan support). +# +# The default of "auto" will use "hs" if available, otherwise "bm". -spm-algo: bm +spm-algo: auto # Defrag settings: