]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
afpacket: move zero copy setup to config parsing
authorVictor Julien <victor@inliniac.net>
Sun, 8 Nov 2015 08:06:03 +0000 (09:06 +0100)
committerVictor Julien <victor@inliniac.net>
Sun, 6 Dec 2015 09:49:29 +0000 (10:49 +0100)
This way it's run and logged per device, instead of per thread.

src/runmode-af-packet.c
src/source-af-packet.c

index 16d9113cb8d8660d187a9a14a9e69f80f2bffa37..e151806b8e181b90d66d8622bb32616d580e9544 100644 (file)
@@ -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;
 }
 
index 66fe18db6a83ab7077fb76a7bfa4ac10529ced04..12c9324ee93f8eeb9d5f1526364532d76daef560 100644 (file)
@@ -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);