From: Victor Julien Date: Tue, 21 Nov 2017 17:22:12 +0000 (+0100) Subject: pfring: various build issues X-Git-Tag: suricata-4.1.0-beta1~560 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ce45bcf38b5eb17fc4dd721037408ffb8ff78ef;p=thirdparty%2Fsuricata.git pfring: various build issues pfring.h brings a different version of likely/unlikely that gives warnings. So make sure we include our own before. Make sure pfring.h isn't included globally due to apparent redefinition of pthread_rwlock_t. --- diff --git a/src/decode.h b/src/decode.h index d3d5b21a92..7205ea94dc 100644 --- a/src/decode.h +++ b/src/decode.h @@ -69,7 +69,9 @@ enum PktSrcEnum { #include "source-af-packet.h" #include "source-mpipe.h" #include "source-netmap.h" +#ifdef HAVE_PF_RING_FLOW_OFFLOAD #include "source-pfring.h" +#endif #include "action-globals.h" @@ -462,7 +464,9 @@ typedef struct Packet_ NetmapPacketVars netmap_v; #endif #ifdef HAVE_PFRING +#ifdef HAVE_PF_RING_FLOW_OFFLOAD PfringPacketVars pfring_v; +#endif #endif /** libpcap vars: shared by Pcap Live mode and Pcap File mode */ diff --git a/src/runmode-pfring.c b/src/runmode-pfring.c index 1a1683dc56..ef0b490aba 100644 --- a/src/runmode-pfring.c +++ b/src/runmode-pfring.c @@ -30,6 +30,10 @@ #include "util-runmodes.h" #include "util-device.h" +#ifdef HAVE_PFRING +#include +#endif + static const char *default_mode_autofp = NULL; diff --git a/src/source-pfring.c b/src/source-pfring.c index b423778c73..4eb9f79338 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -28,10 +28,6 @@ * \todo Allow ring options such as snaplen etc, to be user configurable. */ -#ifdef HAVE_PFRING -#include -#endif /* HAVE_PFRING */ - #include "suricata-common.h" #include "suricata.h" #include "conf.h" @@ -119,6 +115,8 @@ TmEcode NoPfringSupportExit(ThreadVars *tv, const void *initdata, void **data) #else /* implied we do have PF_RING support */ +#include + /** protect pfring_set_bpf_filter, as it is not thread safe */ static SCMutex pfring_bpf_set_filter_lock = SCMUTEX_INITIALIZER; @@ -578,7 +576,7 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, const void *initdata, void **dat } else if (strncmp(ptv->interface, "zc", 2) == 0) { SCLogInfo("ZC interface detected, not adding thread to cluster"); } else { - ptv->ctype = pfconf->ctype; + ptv->ctype = (cluster_type)pfconf->ctype; rc = pfring_set_cluster(ptv->pd, ptv->cluster_id, ptv->ctype); if (rc != 0) { diff --git a/src/source-pfring.h b/src/source-pfring.h index dc4535556d..da173cea79 100644 --- a/src/source-pfring.h +++ b/src/source-pfring.h @@ -27,9 +27,6 @@ #define PFRING_IFACE_NAME_LENGTH 48 #include -#ifdef HAVE_PFRING -#include -#endif typedef struct PfringThreadVars_ PfringThreadVars; @@ -43,9 +40,8 @@ typedef struct PfringIfaceConfig_ /* cluster param */ int cluster_id; -#ifdef HAVE_PFRING - cluster_type ctype; -#endif + unsigned int ctype; + char iface[PFRING_IFACE_NAME_LENGTH]; /* number of threads */ int threads; diff --git a/src/suricata-common.h b/src/suricata-common.h index ec34a8c6ce..31c3993652 100644 --- a/src/suricata-common.h +++ b/src/suricata-common.h @@ -419,6 +419,7 @@ typedef enum { LOGGER_SIZE, } LoggerId; +#include "util-optimize.h" #include #include "threads.h" #include "tm-threads-common.h" @@ -426,7 +427,6 @@ typedef enum { #include "util-error.h" #include "util-mem.h" #include "detect-engine-alert.h" -#include "util-optimize.h" #include "util-path.h" #include "util-conf.h"