aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/sflow
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/sflow')
-rw-r--r--src/plugins/sflow/CMakeLists.txt19
-rw-r--r--src/plugins/sflow/sflow.c2
-rw-r--r--src/plugins/sflow/sflow.h5
-rw-r--r--src/plugins/sflow/sflow_common.h2
-rw-r--r--src/plugins/sflow/sflow_vapi.c5
-rw-r--r--src/plugins/sflow/sflow_vapi.h3
6 files changed, 32 insertions, 4 deletions
diff --git a/src/plugins/sflow/CMakeLists.txt b/src/plugins/sflow/CMakeLists.txt
index fc20f0f78e8..35433bd24df 100644
--- a/src/plugins/sflow/CMakeLists.txt
+++ b/src/plugins/sflow/CMakeLists.txt
@@ -12,6 +12,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+vpp_find_path(NETLINK_INCLUDE_DIR NAMES linux/netlink.h)
+if (NOT NETLINK_INCLUDE_DIR)
+ message(WARNING "netlink headers not found - sflow plugin disabled")
+ return()
+endif()
+
+if ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
+ message(WARNING "sflow is not supported on FreeBSD - sflow plugin disabled")
+ return()
+endif()
+
+LIST(FIND excluded_plugins linux-cp exc_index)
+if(${exc_index} EQUAL "-1")
+ message(WARNING "sflow plugin - linux-cp plugin included: compiling VAPI calls")
+ add_compile_definitions(SFLOW_USE_VAPI)
+else()
+ message(WARNING "sflow plugin - linux-cp plugin excluded: not compiling VAPI calls")
+endif()
+
include_directories(${CMAKE_SOURCE_DIR}/vpp-api ${CMAKE_CURRENT_BINARY_DIR}/../../vpp-api)
add_vpp_plugin(sflow
SOURCES
diff --git a/src/plugins/sflow/sflow.c b/src/plugins/sflow/sflow.c
index ad8cf7c1b19..5aa65062330 100644
--- a/src/plugins/sflow/sflow.c
+++ b/src/plugins/sflow/sflow.c
@@ -539,8 +539,10 @@ sflow_sampling_start (sflow_main_t *smp)
smp->psample_seq_egress = 0;
smp->psample_send_drops = 0;
+#ifdef SFLOW_USE_VAPI
// reset vapi request count so that we make a request the first time
smp->vapi_requests = 0;
+#endif
/* open PSAMPLE netlink channel for writing packet samples */
SFLOWPS_open (&smp->sflow_psample);
diff --git a/src/plugins/sflow/sflow.h b/src/plugins/sflow/sflow.h
index 18e2dab9ee0..609ff723816 100644
--- a/src/plugins/sflow/sflow.h
+++ b/src/plugins/sflow/sflow.h
@@ -33,7 +33,6 @@
#define SFLOW_MIN_HEADER_BYTES 64
#define SFLOW_HEADER_BYTES_STEP 32
-#define SFLOW_USE_VAPI
#define SFLOW_FIFO_DEPTH 2048 // must be power of 2
#define SFLOW_POLL_WAIT_S 0.001
#define SFLOW_READ_BATCH 100
@@ -165,12 +164,12 @@ typedef struct
u32 csample_send;
u32 csample_send_drops;
u32 unixsock_seq;
-
+#ifdef SFLOW_USE_VAPI
/* vapi query helper thread (transient) */
CLIB_CACHE_LINE_ALIGN_MARK (_vapi);
sflow_vapi_client_t vac;
int vapi_requests;
-
+#endif
} sflow_main_t;
extern sflow_main_t sflow_main;
diff --git a/src/plugins/sflow/sflow_common.h b/src/plugins/sflow/sflow_common.h
index 1d5b908ded8..29784638bb9 100644
--- a/src/plugins/sflow/sflow_common.h
+++ b/src/plugins/sflow/sflow_common.h
@@ -15,7 +15,7 @@
#ifndef __included_sflow_common_h__
#define __included_sflow_common_h__
-#define SFLOW_USE_VAPI
+// #define SFLOW_USE_VAPI (set by CMakeLists.txt)
extern vlib_log_class_t sflow_logger;
#define SFLOW_DBG(...) vlib_log_debug (sflow_logger, __VA_ARGS__);
diff --git a/src/plugins/sflow/sflow_vapi.c b/src/plugins/sflow/sflow_vapi.c
index 66e9ebaf1db..cdc89a54c80 100644
--- a/src/plugins/sflow/sflow_vapi.c
+++ b/src/plugins/sflow/sflow_vapi.c
@@ -15,6 +15,8 @@
#include <sflow/sflow_vapi.h>
+#ifdef SFLOW_USE_VAPI
+
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vpp/app/version.h>
@@ -212,6 +214,9 @@ sflow_vapi_check_for_linux_if_index_results (sflow_vapi_client_t *vac,
}
return false;
}
+
+#endif /* SFLOW_USE_VAPI */
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/sflow/sflow_vapi.h b/src/plugins/sflow/sflow_vapi.h
index baf43041716..640fe997684 100644
--- a/src/plugins/sflow/sflow_vapi.h
+++ b/src/plugins/sflow/sflow_vapi.h
@@ -18,6 +18,8 @@
#include <vnet/vnet.h>
#include <sflow/sflow_common.h>
+#ifdef SFLOW_USE_VAPI
+
#define SFLOW_VAPI_POLL_INTERVAL 5
#define SFLOW_VAPI_MAX_REQUEST_Q 8
#define SFLOW_VAPI_MAX_RESPONSE_Q 16
@@ -41,6 +43,7 @@ int
sflow_vapi_check_for_linux_if_index_results (sflow_vapi_client_t *vac,
sflow_per_interface_data_t *itfs);
+#endif /* SFLOW_USE_VAPI */
#endif /* __included_sflow_vapi_h__ */
/*