diff options
author | 2025-01-23 11:04:19 +0100 | |
---|---|---|
committer | 2025-01-28 17:28:43 +0000 | |
commit | 9df756c324a8136c89f045df53f23449fb0ee412 (patch) | |
tree | 7742c385745271497475f88e68fb399b1ff99e06 | |
parent | 3ea20bf46ac2c37d7dd37825ee1e55745db0245f (diff) |
sflow: Update build rules
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: pim@ipng.nl
(cherry picked from commit d9b9a721fd1aa0198b5d0be54fe46ad0a3d773b7)
-rw-r--r-- | src/plugins/sflow/CMakeLists.txt | 19 | ||||
-rw-r--r-- | src/plugins/sflow/sflow.c | 2 | ||||
-rw-r--r-- | src/plugins/sflow/sflow.h | 5 | ||||
-rw-r--r-- | src/plugins/sflow/sflow_common.h | 2 | ||||
-rw-r--r-- | src/plugins/sflow/sflow_vapi.c | 5 | ||||
-rw-r--r-- | src/plugins/sflow/sflow_vapi.h | 3 |
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__ */ /* |