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.
pull/2132/head
Victor Julien 9 years ago
parent f446577412
commit d58d02fed5

@ -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;
}

@ -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

Loading…
Cancel
Save