]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
af-packet: fix IPS mode
authorEric Leblond <eric@regit.org>
Wed, 19 Sep 2012 07:55:50 +0000 (09:55 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 19 Sep 2012 09:33:58 +0000 (11:33 +0200)
There was an inversion in code resulting as all sockets being seen
as non IPS mode when doing the peering. This resulted in a crash at
first packet because it has no peer.

src/source-af-packet.c

index 904d571f5d93628efa28349bcb3095f8bd1568e2..d924c86eebc41bd40c1b6ca7fcb92f52c964570a 100644 (file)
@@ -1512,18 +1512,18 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, void *initdata, void **data) {
         SCLogInfo("Enabling zero copy mode by using data release call");
     }
 
-    if (AFPPeersListAdd(ptv) == TM_ECODE_FAILED) {
-        SCFree(ptv);
-        afpconfig->DerefFunc(afpconfig);
-        SCReturnInt(TM_ECODE_FAILED);
-    }
-
     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);
         ptv->out_iface[AFP_IFACE_NAME_LENGTH - 1]= '\0';
     }
 
+    if (AFPPeersListAdd(ptv) == TM_ECODE_FAILED) {
+        SCFree(ptv);
+        afpconfig->DerefFunc(afpconfig);
+        SCReturnInt(TM_ECODE_FAILED);
+    }
+
 #define T_DATA_SIZE 70000
     ptv->data = SCMalloc(T_DATA_SIZE);
     if (ptv->data == NULL) {