diff options
-rw-r--r-- | cmake/Modules/FindCollectd.cmake | 10 | ||||
-rw-r--r-- | ctrl/facemgr/src/facelet.c | 6 | ||||
-rw-r--r-- | ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c | 5 | ||||
-rw-r--r-- | scripts/functions.sh | 4 | ||||
-rw-r--r-- | telemetry/vpp-collectd/CMakeLists.txt | 2 | ||||
-rw-r--r-- | telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt | 9 | ||||
-rw-r--r-- | telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c | 30 | ||||
-rw-r--r-- | telemetry/vpp-collectd/vpp/CMakeLists.txt | 22 | ||||
-rw-r--r-- | telemetry/vpp-collectd/vpp/vpp.c | 33 |
9 files changed, 59 insertions, 62 deletions
diff --git a/cmake/Modules/FindCollectd.cmake b/cmake/Modules/FindCollectd.cmake index 76d2df43f..244fd14e5 100644 --- a/cmake/Modules/FindCollectd.cmake +++ b/cmake/Modules/FindCollectd.cmake @@ -25,21 +25,15 @@ find_path(COLLECTD_INCLUDE_DIR collectd.h DOC "Find the collectd includes" ) -find_path(COLLECTD_COMMON_INCLUDE_DIR common.h - HINTS ${COLLECTD_SEARCH_PATH_LIST} - PATH_SUFFIXES include/collectd/core/daemon/ utils/common/ - DOC "Find the collectd includes" -) - find_path(COLLECTD_CONFIG_INCLUDE_DIR config.h HINTS ${COLLECTD_SEARCH_PATH_LIST} PATH_SUFFIXES include/collectd/core/ DOC "Find the collectd includes" ) -message(STATUS ${COLLECTD_INCLUDE_DIR} ${COLLECTD_COMMON_INCLUDE_DIR} ${COLLECTD_CONFIG_INCLUDE_DIR}) +message(STATUS ${COLLECTD_INCLUDE_DIR} ${COLLECTD_CONFIG_INCLUDE_DIR}) -set(COLLECTD_INCLUDE_DIRS ${COLLECTD_INCLUDE_DIR} ${COLLECTD_COMMON_INCLUDE_DIR} ${COLLECTD_CONFIG_INCLUDE_DIR}) +set(COLLECTD_INCLUDE_DIRS ${COLLECTD_INCLUDE_DIR} ${COLLECTD_CONFIG_INCLUDE_DIR}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Collectd DEFAULT_MSG COLLECTD_INCLUDE_DIRS) diff --git a/ctrl/facemgr/src/facelet.c b/ctrl/facemgr/src/facelet.c index 0cf44d4dc..9e9f3f67f 100644 --- a/ctrl/facemgr/src/facelet.c +++ b/ctrl/facemgr/src/facelet.c @@ -356,8 +356,10 @@ facelet_create_from_face(face_t * face) facelet->error = 0; /* TODO Consistency check between face type and found attributes */ - if (facelet_validate_face(facelet) < 0) + if (facelet_validate_face(facelet) < 0) { + ERROR("[facelet_create_from_face] Cannot validate face"); goto ERR_FACE; + } facelet->bj_done = false; facelet->au_done = false; @@ -367,7 +369,7 @@ facelet_create_from_face(face_t * face) /* We need to get route set */ facelet->routes = route_set_create(); if (!facelet->routes) { - ERROR("[facelet_create] Cannot create route set"); + ERROR("[facelet_create_from_face] Cannot create route set"); goto ERR_ROUTE_SET; } facelet->routes_done = false; diff --git a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c index 508c0713b..74a0cd62b 100644 --- a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c +++ b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c @@ -642,6 +642,11 @@ int hl_callback(interface_t * interface, int fd, void * unused) /* We can ignore faces on localhost */ facelet_t * facelet = facelet_create_from_face(&f->face); + if (!facelet) { + ERROR("[hl_callback] Could not create facelet... skipping"); + continue; + } + foreach_route(r, data->polled_routes) { if (r->face_id != f->id) continue; diff --git a/scripts/functions.sh b/scripts/functions.sh index 7258800b2..adf3fd1fc 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -23,6 +23,8 @@ export PATH=:${CMAKE_INSTALL_DIR}/bin:${PATH} PACKAGECLOUD_RELEASE_REPO_DEB="https://packagecloud.io/install/repositories/fdio/release/script.deb.sh" PACKAGECLOUD_RELEASE_REPO_RPM="https://packagecloud.io/install/repositories/fdio/release/script.rpm.sh" +PACKAGECLOUD_HICN_REPO_DEB="https://packagecloud.io/install/repositories/fdio/hicn/script.deb.sh" +PACKAGECLOUD_HICN_REPO_RPM="https://packagecloud.io/install/repositories/fdio/hicn/script.rpm.sh" VPP_GIT_REPO="https://github.com/FDio/vpp" VPP_BRANCH="stable/2005" @@ -107,8 +109,10 @@ function setup_fdio_repo() { if [ "${DISTRIB_ID}" == "ubuntu" ]; then curl -s ${PACKAGECLOUD_RELEASE_REPO_DEB} | sudo bash + curl -s ${PACKAGECLOUD_HICN_REPO_DEB} | sudo bash elif [ "${DISTRIB_ID}" == "centos" ]; then curl -s ${PACKAGECLOUD_RELEASE_REPO_RPM} | sudo bash + curl -s ${PACKAGECLOUD_HICN_REPO_RPM} | sudo bash curl -L ${LATEST_EPEL_REPO} > /tmp/epel-release-latest-7.noarch.rpm rpm -ivh /tmp/epel-release-latest-7.noarch.rpm || true else diff --git a/telemetry/vpp-collectd/CMakeLists.txt b/telemetry/vpp-collectd/CMakeLists.txt index ef09fb980..8f82745f2 100644 --- a/telemetry/vpp-collectd/CMakeLists.txt +++ b/telemetry/vpp-collectd/CMakeLists.txt @@ -13,7 +13,7 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) -set (COLLECTD_PLUGINS hicn-collectd-plugins) +set(COLLECTD_PLUGINS hicn-collectd-plugins) project(hicn-collectd-plugins) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Modules/") diff --git a/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt b/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt index fc39b9385..3703515dc 100644 --- a/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt +++ b/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt @@ -18,7 +18,7 @@ find_package(Collectd REQUIRED) find_package(Vpp REQUIRED) if(${CMAKE_SOURCE_DIR}/vpp-collectd STREQUAL ${PROJECT_SOURCE_DIR}) - message (STATUS "not compiling in the same folder") + message (STATUS "not compiling in the same folder") find_package(HicnPlugin REQUIRED) find_package(VapiSafe REQUIRED) else() @@ -29,17 +29,16 @@ else() endif() list(APPEND SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/vpp_hicn.c -) + ${CMAKE_CURRENT_SOURCE_DIR}/vpp_hicn.c) -list (APPEND INCLUDE_DIRS +list(APPEND INCLUDE_DIRS ${COLLECTD_INCLUDE_DIRS} ${HICNPLUGIN_INCLUDE_DIRS} ${SAFE_VAPI_INCLUDE_DIRS} ${VPP_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) -list (APPEND LIBRARIES +list(APPEND LIBRARIES ${VPP_LIBRARY_VAPICLIENT} ${SAFE_VAPI_LIBRARIES}) diff --git a/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c b/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c index 591b8f584..4228ac6e6 100644 --- a/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c +++ b/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c @@ -13,25 +13,9 @@ * limitations under the License. */ -#if !HAVE_CONFIG_H -#include <stdlib.h> -#include <string.h> - -#ifndef __USE_ISOC99 /* required for NAN */ -#define DISABLE_ISOC99 1 -#define __USE_ISOC99 1 -#endif /* !defined(__USE_ISOC99) */ - -#if DISABLE_ISOC99 -#undef DISABLE_ISOC99 -#undef __USE_ISOC99 -#endif /* DISABLE_ISOC99 */ -#endif /* ! HAVE_CONFIG */ - /* Keep order as it is */ #include <config.h> #include <collectd.h> -#include <common.h> #include <plugin.h> #define counter_t vpp_counter_t @@ -42,6 +26,15 @@ DEFINE_VAPI_MSG_IDS_HICN_API_JSON vapi_ctx_t vapi_ctx; +#define STATIC_ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) + +#define IS_TRUE(s) \ + ((strcasecmp("true", (s)) == 0) || (strcasecmp("yes", (s)) == 0) || \ + (strcasecmp("on", (s)) == 0)) +#define IS_FALSE(s) \ + ((strcasecmp("false", (s)) == 0) || (strcasecmp("no", (s)) == 0) || \ + (strcasecmp("off", (s)) == 0)) + /************** OPTIONS ***********************************/ static const char *config_keys[2] = { "Verbose", @@ -188,6 +181,11 @@ static data_set_t dtx_ds = { /**********************************************************/ /********** UTILITY FUNCTIONS *****************************/ /**********************************************************/ +char *sstrncpy(char *dest, const char *src, size_t n) { + strncpy(dest, src, n); + dest[n - 1] = '\0'; + return dest; +} /* * Utility function used by the read callback to populate a diff --git a/telemetry/vpp-collectd/vpp/CMakeLists.txt b/telemetry/vpp-collectd/vpp/CMakeLists.txt index 36248b17a..464ab42d8 100644 --- a/telemetry/vpp-collectd/vpp/CMakeLists.txt +++ b/telemetry/vpp-collectd/vpp/CMakeLists.txt @@ -14,22 +14,20 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) # Dependencies - -list(APPEND SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/vpp.c -) - find_package(Vpp REQUIRED) find_package(Collectd REQUIRED) -list (APPEND INCLUDE_DIRS - ${COLLECTD_INCLUDE_DIRS} - ${VPP_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR}) +list(APPEND SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/vpp.c) + +list(APPEND INCLUDE_DIRS + ${COLLECTD_INCLUDE_DIRS} + ${VPP_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR}) -list (APPEND LIBRARIES - ${VPP_LIBRARY_VPPAPICLIENT} - ${VPP_LIBRARY_INFRA}) +list(APPEND LIBRARIES + ${VPP_LIBRARY_VPPAPICLIENT} + ${VPP_LIBRARY_INFRA}) build_library(vpp SHARED diff --git a/telemetry/vpp-collectd/vpp/vpp.c b/telemetry/vpp-collectd/vpp/vpp.c index ba838a050..8bf5182a8 100644 --- a/telemetry/vpp-collectd/vpp/vpp.c +++ b/telemetry/vpp-collectd/vpp/vpp.c @@ -13,25 +13,9 @@ * limitations under the License. */ -#if !HAVE_CONFIG_H -#include <stdlib.h> -#include <string.h> - -#ifndef __USE_ISOC99 /* required for NAN */ -#define DISABLE_ISOC99 1 -#define __USE_ISOC99 1 -#endif /* !defined(__USE_ISOC99) */ - -#if DISABLE_ISOC99 -#undef DISABLE_ISOC99 -#undef __USE_ISOC99 -#endif /* DISABLE_ISOC99 */ -#endif /* ! HAVE_CONFIG */ - /* Keep order as it is */ #include <config.h> #include <collectd.h> -#include <common.h> #include <plugin.h> #define counter_t vpp_counter_t @@ -39,6 +23,15 @@ #include <vppinfra/vec.h> #undef counter_t +#define STATIC_ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) + +#define IS_TRUE(s) \ + ((strcasecmp("true", (s)) == 0) || (strcasecmp("yes", (s)) == 0) || \ + (strcasecmp("on", (s)) == 0)) +#define IS_FALSE(s) \ + ((strcasecmp("false", (s)) == 0) || (strcasecmp("no", (s)) == 0) || \ + (strcasecmp("off", (s)) == 0)) + /************** OPTIONS ***********************************/ static const char *config_keys[2] = { "Verbose", @@ -164,6 +157,11 @@ static data_set_t if_tx_broadcast_ds = { /**********************************************************/ /********** UTILITY FUNCTIONS *****************************/ /**********************************************************/ +char *sstrncpy(char *dest, const char *src, size_t n) { + strncpy(dest, src, n); + dest[n - 1] = '\0'; + return dest; +} /* * Utility function used by the read callback to populate a @@ -327,8 +325,7 @@ static int vpp_read(void) { } value_t values[1] = { - (value_t){.derive = res[i].simple_counter_vec[k][j]} - }; + (value_t){.derive = res[i].simple_counter_vec[k][j]}}; err = submit(interfaces[j], data_set.type, values, 1, ×tamp); |