From: Eric Leblond Date: Mon, 18 Apr 2016 12:24:08 +0000 (+0200) Subject: af-packet: make mmap options parsing conditional X-Git-Tag: suricata-3.1RC1~98 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8035d834678cfe82de597b9b0bc72a7f87b23df3;p=thirdparty%2Fsuricata.git af-packet: make mmap options parsing conditional Only parse them if mmap is activated. --- diff --git a/src/runmode-af-packet.c b/src/runmode-af-packet.c index 3deae4e3f6..5b48f7d562 100644 --- a/src/runmode-af-packet.c +++ b/src/runmode-af-packet.c @@ -227,35 +227,40 @@ void *ParseAFPConfig(const char *iface) aconf->flags |= AFP_RING_MODE; } - (void)ConfGetChildValueBoolWithDefault(if_root, if_default, "mmap-locked", (int *)&boolval); - if (boolval) { - SCLogInfo("Enabling locked memory for mmap on iface %s", - aconf->iface); - aconf->flags |= AFP_MMAP_LOCKED; - } - (void)ConfGetChildValueBoolWithDefault(if_root, if_default, "tpacket-v3", (int *)&boolval); - if (boolval) { - if (strcasecmp(RunmodeGetActive(), "workers") == 0) { -#ifdef HAVE_TPACKET_V3 - SCLogInfo("Enabling tpacket v3 capture on iface %s", + if (aconf->flags & AFP_RING_MODE) { + (void)ConfGetChildValueBoolWithDefault(if_root, if_default, + "mmap-locked", (int *)&boolval); + if (boolval) { + SCLogInfo("Enabling locked memory for mmap on iface %s", aconf->iface); - aconf->flags |= AFP_TPACKET_V3|AFP_RING_MODE; + aconf->flags |= AFP_MMAP_LOCKED; + } + (void)ConfGetChildValueBoolWithDefault(if_root, if_default, + "tpacket-v3", (int *)&boolval); + if (boolval) { + if (strcasecmp(RunmodeGetActive(), "workers") == 0) { +#ifdef HAVE_TPACKET_V3 + SCLogInfo("Enabling tpacket v3 capture on iface %s", + aconf->iface); + aconf->flags |= AFP_TPACKET_V3|AFP_RING_MODE; #else - SCLogNotice("System too old for tpacket v3 switching to v2"); - aconf->flags |= AFP_RING_MODE; + SCLogNotice("System too old for tpacket v3 switching to v2"); + aconf->flags |= AFP_RING_MODE; #endif - } else { - SCLogError(SC_ERR_RUNMODE, - "tpacket v3 is only implemented for 'workers' running mode." - " Switching to tpacket v2."); - aconf->flags |= AFP_RING_MODE; + } else { + SCLogError(SC_ERR_RUNMODE, + "tpacket v3 is only implemented for 'workers' running mode." + " Switching to tpacket v2."); + aconf->flags |= AFP_RING_MODE; + } + } + (void)ConfGetChildValueBoolWithDefault(if_root, if_default, + "use-emergency-flush", (int *)&boolval); + if (boolval) { + SCLogInfo("Enabling ring emergency flush on iface %s", + aconf->iface); + aconf->flags |= AFP_EMERGENCY_MODE; } - } - (void)ConfGetChildValueBoolWithDefault(if_root, if_default, "use-emergency-flush", (int *)&boolval); - if (boolval) { - SCLogInfo("Enabling ring emergency flush on iface %s", - aconf->iface); - aconf->flags |= AFP_EMERGENCY_MODE; }