From: Victor Julien Date: Thu, 2 Jun 2016 04:53:32 +0000 (+0200) Subject: netmap: handle missing config with better defaults X-Git-Tag: suricata-3.1RC1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d58d02fed5e674011cca50d3e3ab203d9b93e335;p=thirdparty%2Fsuricata.git netmap: handle missing config with better defaults Default to 'threads: auto' which uses RSS RX count when no config has been created for a interface. --- diff --git a/src/runmode-netmap.c b/src/runmode-netmap.c index f154e7cf15..ccc25719c6 100644 --- a/src/runmode-netmap.c +++ b/src/runmode-netmap.c @@ -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; } diff --git a/suricata.yaml.in b/suricata.yaml.in index 582592cb00..f830a12421 100644 --- a/suricata.yaml.in +++ b/suricata.yaml.in @@ -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