]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
netmap: handle missing config with better defaults
authorVictor Julien <victor@inliniac.net>
Thu, 2 Jun 2016 04:53:32 +0000 (06:53 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 2 Jun 2016 04:58:15 +0000 (06:58 +0200)
Default to 'threads: auto' which uses RSS RX count when no config
has been created for a interface.

src/runmode-netmap.c
suricata.yaml.in

index f154e7cf15787669fb34540f77991980ba7f6a28..ccc25719c6cfaf1d15929f93660b1c908ce69de8 100644 (file)
@@ -127,7 +127,7 @@ static void *ParseNetmapConfig(const char *iface_name)
 
     memset(aconf, 0, sizeof(*aconf));
     aconf->DerefFunc = NetmapDerefConfig;
-    aconf->threads = 1;
+    aconf->threads = 0;
     aconf->promisc = 1;
     aconf->checksum_mode = CHECKSUM_VALIDATION_AUTO;
     aconf->copy_mode = NETMAP_COPY_MODE_NONE;
@@ -156,7 +156,7 @@ static void *ParseNetmapConfig(const char *iface_name)
     netmap_node = ConfGetNode("netmap");
     if (netmap_node == NULL) {
         SCLogInfo("Unable to find netmap config using default value");
-        return aconf;
+        goto finalize;
     }
 
     if_root = ConfFindDeviceConfig(netmap_node, aconf->iface_name);
@@ -167,7 +167,7 @@ static void *ParseNetmapConfig(const char *iface_name)
         SCLogInfo("Unable to find netmap config for "
                 "interface \"%s\" or \"default\", using default value",
                 aconf->iface_name);
-        return aconf;
+        goto finalize;
     }
 
     /* If there is no setting for current interface use default one as main iface */
@@ -177,23 +177,15 @@ static void *ParseNetmapConfig(const char *iface_name)
     }
 
     if (ConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
-        aconf->threads = 1;
+        aconf->threads = 0;
     } else {
         if (strcmp(threadsstr, "auto") == 0) {
-            aconf->threads = NetmapGetRSSCount(aconf->iface);
+            aconf->threads = 0;
         } else {
             aconf->threads = (uint8_t)atoi(threadsstr);
         }
     }
 
-    if (aconf->threads <= 0) {
-        aconf->threads = 1;
-    }
-    if (aconf->threads) {
-        SCLogInfo("Using %d threads for interface %s", aconf->threads,
-                  aconf->iface_name);
-    }
-
     if (ConfGetChildValueWithDefault(if_root, if_default, "copy-iface", &out_iface) == 1) {
         if (strlen(out_iface) > 0) {
             aconf->out_iface_name = out_iface;
@@ -231,9 +223,6 @@ static void *ParseNetmapConfig(const char *iface_name)
         }
     }
 
-    SC_ATOMIC_RESET(aconf->ref);
-    (void) SC_ATOMIC_ADD(aconf->ref, aconf->threads);
-
     /* load netmap bpf filter */
     /* command line value has precedence */
     if (ConfGet("bpf-filter", &bpf_filter) != 1) {
@@ -263,6 +252,19 @@ static void *ParseNetmapConfig(const char *iface_name)
         }
     }
 
+finalize:
+
+    if (aconf->threads == 0) {
+        aconf->threads = NetmapGetRSSCount(aconf->iface);
+    }
+    if (aconf->threads <= 0) {
+        aconf->threads = 1;
+    }
+    SC_ATOMIC_RESET(aconf->ref);
+    (void) SC_ATOMIC_ADD(aconf->ref, aconf->threads);
+    SCLogInfo("Using %d threads for interface %s", aconf->threads,
+            aconf->iface_name);
+
     return aconf;
 }
 
index 582592cb00ce21e8736aeb13d4cea844bc1daedb..f830a1242176eb0c122d88fdd1c3aaaacb6866e1 100644 (file)
@@ -1445,7 +1445,7 @@ netmap:
    # To specify OS endpoint add plus sign at the end (e.g. "eth0+")
  - interface: eth2
    # Number of receive threads. "auto" uses number of RSS queues on interface.
-   threads: auto
+   #threads: auto
    # You can use the following variables to activate netmap tap or IPS mode.
    # If copy-mode is set to ips or tap, the traffic coming to the current
    # interface will be copied to the copy-iface interface. If 'tap' is set, the