]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
netmap: strict check for zero copy mode
authorAleksey Katargin <gureedo@gmail.com>
Thu, 16 Jul 2015 13:51:03 +0000 (18:51 +0500)
committerVictor Julien <victor@inliniac.net>
Tue, 21 Jul 2015 21:26:13 +0000 (23:26 +0200)
Netmap does not guarantees that mmap'ed regions for different interfaces would be the same.

src/source-netmap.c

index 7d56e623b97dddb17ab8a3734d67da61579fe458..b00dd43b7546a739b79600b567ee6af24330e563 100644 (file)
@@ -578,8 +578,15 @@ static TmEcode ReceiveNetmapThreadInit(ThreadVars *tv, void *initdata, void **da
 
     char const *active_runmode = RunmodeGetActive();
     if (active_runmode && !strcmp("workers", active_runmode)) {
-        ntv->flags |= NETMAP_FLAG_ZERO_COPY;
-        SCLogInfo("Enabling zero copy mode");
+        if (likely(ntv->ifsrc->mem == ntv->ifdst->mem)) {
+            ntv->flags |= NETMAP_FLAG_ZERO_COPY;
+            SCLogInfo("Enabling zero copy mode for %s->%s",
+                      aconf->iface, aconf->out_iface);
+        } else {
+            SCLogInfo("Unable to set zero copy mode for %s->%s",
+                      aconf->iface, aconf->out_iface);
+        }
+
     }
 
     if (aconf->bpf_filter) {