]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
af-packet: count only CPUs once
authorEric Leblond <eric@regit.org>
Wed, 31 Jan 2018 20:12:59 +0000 (21:12 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 6 Feb 2018 16:48:03 +0000 (17:48 +0100)
src/source-af-packet.c

index 040ab196a5abc20961743898e55c247d1a856b45..874118f8907d0072806ba7cd5945bec866a30636 100644 (file)
@@ -314,6 +314,9 @@ static int AFPGetDevFlags(int fd, const char *ifname);
 static int AFPDerefSocket(AFPPeer* peer);
 static int AFPRefSocket(AFPPeer* peer);
 
+
+static unsigned int nr_cpus;
+
 /**
  * \brief Registration Function for RecieveAFP.
  * \todo Unit tests are needed for this module.
@@ -330,6 +333,8 @@ void TmModuleReceiveAFPRegister (void)
     tmm_modules[TMM_RECEIVEAFP].RegisterTests = NULL;
     tmm_modules[TMM_RECEIVEAFP].cap_flags = SC_CAP_NET_RAW;
     tmm_modules[TMM_RECEIVEAFP].flags = TM_FLAG_RECEIVE_TM;
+
+    nr_cpus = UtilCpuGetNumProcessorsConfigured();
 }
 
 
@@ -2265,7 +2270,6 @@ TmEcode AFPSetBPFFilter(AFPThreadVars *ptv)
  */
 static int AFPInsertHalfFlow(int mapd, void *key, uint64_t inittime)
 {
-    unsigned int nr_cpus = UtilCpuGetNumProcessorsConfigured();
     struct pair value[nr_cpus];
     unsigned int i;