]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
spm: add "spm-algo: auto" setting
authorJustin Viiret <justin.viiret@intel.com>
Mon, 16 May 2016 04:15:45 +0000 (14:15 +1000)
committerVictor Julien <victor@inliniac.net>
Wed, 18 May 2016 07:58:33 +0000 (09:58 +0200)
This will default to Hyperscan when Suricata is built with Hyperscan
support. Otherwise, Boyer-Moore is used by default.

src/util-spm.c
suricata.yaml.in

index 6e1192a892db8b3d6b9ed78816d3ef51f4876c39..04e7676f5cde788800cbff9193ec564dfd6d0ef8 100644 (file)
@@ -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)
index 12a18faf17e4adea4f6e2f29f769ed3b4d3df816..c93bfd613aba93f3cf210016fea1581ba057d5d0 100644 (file)
@@ -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: