]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pfring: removes old API and #ifdef chunks
authorGiuseppe Longo <giuseppelng@gmail.com>
Thu, 16 Oct 2014 08:23:19 +0000 (10:23 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 22 Oct 2014 09:20:50 +0000 (11:20 +0200)
src/runmode-pfring.c
src/source-pfring.c
src/source-pfring.h

index fc9271d5762581a9a90319186519b840098b3aa7..28759464287617c5bbee4d4f17deff851ae394c6 100644 (file)
@@ -79,11 +79,9 @@ void PfringDerefConfig(void *conf)
 {
     PfringIfaceConfig *pfp = (PfringIfaceConfig *)conf;
     if (SC_ATOMIC_SUB(pfp->ref, 1) == 0) {
-#ifdef HAVE_PFRING_SET_BPF_FILTER
         if (pfp->bpf_filter) {
             SCFree(pfp->bpf_filter);
         }
-#endif
         SCFree(pfp);
     }
 }
@@ -106,7 +104,7 @@ void *OldParsePfringConfig(const char *iface)
     char *threadsstr = NULL;
     PfringIfaceConfig *pfconf = SCMalloc(sizeof(*pfconf));
     char *tmpclusterid;
-#ifdef HAVE_PFRING_CLUSTER_TYPE
+#ifdef HAVE_PFRING
     char *tmpctype = NULL;
     cluster_type default_ctype = CLUSTER_ROUND_ROBIN;
 #endif
@@ -123,7 +121,7 @@ void *OldParsePfringConfig(const char *iface)
     strlcpy(pfconf->iface, iface, sizeof(pfconf->iface));
     pfconf->threads = 1;
     pfconf->cluster_id = 1;
-#ifdef HAVE_PFRING_CLUSTER_TYPE
+#ifdef HAVE_PFRING
     pfconf->ctype = default_ctype;
 #endif
     pfconf->DerefFunc = PfringDerefConfig;
@@ -158,7 +156,7 @@ void *OldParsePfringConfig(const char *iface)
         SCLogDebug("Going to use cluster-id %" PRId32, pfconf->cluster_id);
     }
 
-#ifdef HAVE_PFRING_CLUSTER_TYPE
+#ifdef HAVE_PFRING
     if (strncmp(pfconf->iface, "zc", 2) == 0) {
         SCLogInfo("ZC interface detected, not setting cluster type for PF_RING (iface %s)",
                 pfconf->iface);
@@ -180,7 +178,7 @@ void *OldParsePfringConfig(const char *iface)
         SCFree(pfconf);
         return NULL;
     }
-#endif
+#endif /* HAVE_PFRING */
 
     return pfconf;
 }
@@ -207,13 +205,11 @@ void *ParsePfringConfig(const char *iface)
     PfringIfaceConfig *pfconf = SCMalloc(sizeof(*pfconf));
     char *tmpclusterid;
     char *tmpctype = NULL;
-#ifdef HAVE_PFRING_CLUSTER_TYPE
+#ifdef HAVE_PFRING
     cluster_type default_ctype = CLUSTER_ROUND_ROBIN;
     int getctype = 0;
 #endif
-#ifdef HAVE_PFRING_SET_BPF_FILTER
     char *bpf_filter = NULL;
-#endif /* HAVE_PFRING_SET_BPF_FILTER */
 
     if (unlikely(pfconf == NULL)) {
         return NULL;
@@ -228,7 +224,7 @@ void *ParsePfringConfig(const char *iface)
     strlcpy(pfconf->iface, iface, sizeof(pfconf->iface));
     pfconf->threads = 1;
     pfconf->cluster_id = 1;
-#ifdef HAVE_PFRING_CLUSTER_TYPE
+#ifdef HAVE_PFRING
     pfconf->ctype = (cluster_type)default_ctype;
 #endif
     pfconf->DerefFunc = PfringDerefConfig;
@@ -297,7 +293,7 @@ void *ParsePfringConfig(const char *iface)
             SCLogDebug("Going to use cluster-id %" PRId32, pfconf->cluster_id);
         }
     }
-#ifdef HAVE_PFRING_SET_BPF_FILTER
+
     /*load pfring bpf filter*/
     /* command line value has precedence */
     if (ConfGet("bpf-filter", &bpf_filter) == 1) {
@@ -325,9 +321,8 @@ void *ParsePfringConfig(const char *iface)
             }
         }
     }
-#endif /* HAVE_PFRING_SET_BPF_FILTER */
 
-#ifdef HAVE_PFRING_CLUSTER_TYPE
+#ifdef HAVE_PFRING
     if (ConfGet("pfring.cluster-type", &tmpctype) == 1) {
         SCLogDebug("Going to use command-line provided cluster-type");
         getctype = 1;
@@ -363,9 +358,7 @@ void *ParsePfringConfig(const char *iface)
             return NULL;
         }
     }
-
-#endif /* HAVE_PFRING_CLUSTER_TYPE */
-
+#endif /* HAVE_PFRING */
     if (ConfGetChildValueWithDefault(if_root, if_default, "checksum-checks", &tmpctype) == 1) {
         if (strcmp(tmpctype, "auto") == 0) {
             pfconf->checksum_mode = CHECKSUM_VALIDATION_AUTO;
index bbf3275ed3440b98ce3fcbdbeec1328e9a237cc9..45527fd99b30aab45492f231a6ac31cc0b40d459 100644 (file)
@@ -149,15 +149,13 @@ typedef struct PfringThreadVars_
     /* threads count */
     int threads;
 
-#ifdef HAVE_PFRING_CLUSTER_TYPE
     cluster_type ctype;
-#endif /* HAVE_PFRING_CLUSTER_TYPE */
+
     uint8_t cluster_id;
     char *interface;
     LiveDevice *livedev;
-#ifdef HAVE_PFRING_SET_BPF_FILTER
+
     char *bpf_filter;
-#endif /* HAVE_PFRING_SET_BPF_FILTER */
 
      ChecksumValidationMode checksum_mode;
 } PfringThreadVars;
@@ -306,13 +304,11 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot)
 
     /* we have to enable the ring here as we need to do it after all
      * the threads have called pfring_set_cluster(). */
-#ifdef HAVE_PFRING_ENABLE
     int rc = pfring_enable_ring(ptv->pd);
     if (rc != 0) {
         SCLogError(SC_ERR_PF_RING_OPEN, "pfring_enable_ring failed returned %d ", rc);
         SCReturnInt(TM_ECODE_FAILED);
     }
-#endif /* HAVE_PFRING_ENABLE */
 
     while(1) {
         if (suricata_ctl_flags & (SURICATA_STOP | SURICATA_KILL)) {
@@ -333,7 +329,6 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot)
         hdr.ts.tv_sec = hdr.ts.tv_usec = 0;
 
         /* Depending on what compile time options are used for pfring we either return 0 or -1 on error and always 1 for success */
-#ifdef HAVE_PFRING_RECV_UCHAR
         u_char *pkt_buffer = GET_PKT_DIRECT_DATA(p);
         u_int buffer_size = GET_PKT_DIRECT_MAX_SIZE(p);
         int r = pfring_recv(ptv->pd, &pkt_buffer,
@@ -345,12 +340,6 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot)
         if (buffer_size == 0) {
             PacketSetData(p, pkt_buffer, hdr.caplen);
         }
-#else
-        int r = pfring_recv(ptv->pd, (char *)GET_PKT_DIRECT_DATA(p),
-                (u_int)GET_PKT_DIRECT_MAX_SIZE(p),
-                &hdr,
-                LIBPFRING_WAIT_FOR_INCOMING);
-#endif /* HAVE_PFRING_RECV_UCHAR */
 
         if (r == 1) {
             //printf("RecievePfring src %" PRIu32 " sport %" PRIu32 " dst %" PRIu32 " dstport %" PRIu32 "\n",
@@ -448,11 +437,7 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data)
         }
     }
 
-#ifdef HAVE_PFRING_OPEN_NEW
     ptv->pd = pfring_open(ptv->interface, (uint32_t)default_packet_size, opflag);
-#else
-    ptv->pd = pfring_open(ptv->interface, LIBPFRING_PROMISC, (uint32_t)default_packet_size, LIBPFRING_REENTRANT);
-#endif
     if (ptv->pd == NULL) {
         SCLogError(SC_ERR_PF_RING_OPEN,"Failed to open %s: pfring_open error."
                 " Check if %s exists and pf_ring module is loaded.",
@@ -475,12 +460,8 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data)
     } else if (strncmp(ptv->interface, "zc", 2) == 0) {
         SCLogInfo("ZC interface detected, not adding thread to cluster");
     } else {
-#ifdef HAVE_PFRING_CLUSTER_TYPE
         ptv->ctype = pfconf->ctype;
         rc = pfring_set_cluster(ptv->pd, ptv->cluster_id, ptv->ctype);
-#else
-        rc = pfring_set_cluster(ptv->pd, ptv->cluster_id);
-#endif /* HAVE_PFRING_CLUSTER_TYPE */
 
         if (rc != 0) {
             SCLogError(SC_ERR_PF_RING_SET_CLUSTER_FAILED, "pfring_set_cluster "
@@ -500,7 +481,6 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data)
                 version & 0x000000FF, ptv->interface, ptv->cluster_id);
     }
 
-#ifdef HAVE_PFRING_SET_BPF_FILTER
     if (pfconf->bpf_filter) {
         ptv->bpf_filter = SCStrdup(pfconf->bpf_filter);
         if (unlikely(ptv->bpf_filter == NULL)) {
@@ -516,7 +496,6 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data)
             }
         }
     }
-#endif /* HAVE_PFRING_SET_BPF_FILTER */
 
     ptv->capture_kernel_packets = SCPerfTVRegisterCounter("capture.kernel_packets",
             ptv->tv,
@@ -577,12 +556,12 @@ TmEcode ReceivePfringThreadDeinit(ThreadVars *tv, void *data)
     if (ptv->interface)
         SCFree(ptv->interface);
     pfring_remove_from_cluster(ptv->pd);
-#ifdef HAVE_PFRING_SET_BPF_FILTER
+
     if (ptv->bpf_filter) {
         pfring_remove_bpf_filter(ptv->pd);
         SCFree(ptv->bpf_filter);
     }
-#endif /* HAVE_PFRING_SET_BPF_FILTER */
+
     pfring_close(ptv->pd);
     return TM_ECODE_OK;
 }
index 5e499bb59a0ca49f84788aff385aaf3ac946c32d..7439828fb5d327fb29f26b914f9b7ceb1d687754 100644 (file)
@@ -35,15 +35,15 @@ typedef struct PfringIfaceConfig_
 {
     /* cluster param */
     int cluster_id;
-#ifdef HAVE_PFRING_CLUSTER_TYPE
+#ifdef HAVE_PFRING
     cluster_type ctype;
-#endif /* HAVE_PFRING_CLUSTER_TYPE */
+#endif
     char iface[PFRING_IFACE_NAME_LENGTH];
     /* number of threads */
     int threads;
-#ifdef HAVE_PFRING_SET_BPF_FILTER
+
     char *bpf_filter;
-#endif /* HAVE_PFRING_SET_BPF_FILTER */
+
     ChecksumValidationMode checksum_mode;
     SC_ATOMIC_DECLARE(unsigned int, ref);
     void (*DerefFunc)(void *);