1) we rely on Netlink PSAMPLE and USERSOCK make sure we have headers
2) sflow plugin is not available on FreeBSD, due to Netlink features
3) preprocessor flag SFLOW_USE_VAPI controls whether the sflow plugin
will attempt to contact the linux-cp plugin using the binary VAPI. It
has to be a preprocessor flag so it can suppress the "#include"
statements that define that linux-cp api, because those include files
will be missing if linux-cp is excluded from the build.
The "excluded_plugins" list can be used with:
make VPP_EXCLUDED_PLUGINS=linux-cp build build-release
Type: fix
Fixes:
e40f8a90bb0c39986c198fca8ad9b0b3c1658401
Change-Id: If44929d285d27db7862910ecb4ec11ddd4591fd2
Signed-off-by: [email protected]
# 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
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);
#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
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;
#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__);
#include <sflow/sflow_vapi.h>
+#ifdef SFLOW_USE_VAPI
+
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vpp/app/version.h>
}
return false;
}
+
+#endif /* SFLOW_USE_VAPI */
+
/*
* fd.io coding-style-patch-verification: ON
*
#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
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__ */
/*