From: Victor Julien Date: Sun, 8 Nov 2015 08:06:03 +0000 (+0100) Subject: afpacket: move zero copy setup to config parsing X-Git-Tag: suricata-3.0RC2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bed18678308c18be47797cd1beeb3743eaeb5cc7;p=thirdparty%2Fsuricata.git afpacket: move zero copy setup to config parsing This way it's run and logged per device, instead of per thread. --- diff --git a/src/runmode-af-packet.c b/src/runmode-af-packet.c index 16d9113cb8..e151806b8e 100644 --- a/src/runmode-af-packet.c +++ b/src/runmode-af-packet.c @@ -372,6 +372,22 @@ void *ParseAFPConfig(const char *iface) "Using AF_PACKET with GRO or LRO activated can lead to capture problems"); } + char *active_runmode = RunmodeGetActive(); + if (active_runmode && !strcmp("workers", active_runmode)) { + aconf->flags |= AFP_ZERO_COPY; + SCLogInfo("%s: enabling zero copy mode", iface); + } else { + /* If we are using copy mode we need a lock */ + aconf->flags |= AFP_SOCK_PROTECT; + } + + /* If we are in RING mode, then we can use ZERO copy + * by using the data release mechanism */ + if (aconf->flags & AFP_RING_MODE) { + aconf->flags |= AFP_ZERO_COPY; + SCLogInfo("%s: enabling zero copy mode by using data release call", iface); + } + return aconf; } diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 66fe18db6a..12c9324ee9 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -1720,23 +1720,6 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, void *initdata, void **data) ptv->tv); #endif - char *active_runmode = RunmodeGetActive(); - - if (active_runmode && !strcmp("workers", active_runmode)) { - ptv->flags |= AFP_ZERO_COPY; - SCLogInfo("Enabling zero copy mode"); - } else { - /* If we are using copy mode we need a lock */ - ptv->flags |= AFP_SOCK_PROTECT; - } - - /* If we are in RING mode, then we can use ZERO copy - * by using the data release mechanism */ - if (ptv->flags & AFP_RING_MODE) { - ptv->flags |= AFP_ZERO_COPY; - SCLogInfo("Enabling zero copy mode by using data release call"); - } - ptv->copy_mode = afpconfig->copy_mode; if (ptv->copy_mode != AFP_COPY_MODE_NONE) { strlcpy(ptv->out_iface, afpconfig->out_iface, AFP_IFACE_NAME_LENGTH);