diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9e7ea0d..c5bbe39 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ image: "git.mesalab.cn:7443/mesa_platform/build-env:master" variables: GIT_STRATEGY: "clone" BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/ - INSTALL_PREFIX: "/opt/tsg/traffic-steering-service" + INSTALL_PREFIX: "/opt/tsg/sce" TESTING_VERSION_BUILD: 0 stages: @@ -52,7 +52,7 @@ develop_build_debug: PULP3_REPO_NAME: tsg-testing-x86_64.el7 PULP3_DIST_NAME: tsg-testing-x86_64.el7 artifacts: - name: "traffic-steering-service-develop-$CI_COMMIT_REF_NAME-debug" + name: "sce-develop-$CI_COMMIT_REF_NAME-debug" paths: - build/*.rpm only: @@ -71,7 +71,7 @@ develop_build_release: PULP3_REPO_NAME: tsg-testing-x86_64.el7 PULP3_DIST_NAME: tsg-testing-x86_64.el7 artifacts: - name: "traffic-steering-service-develop-$CI_COMMIT_REF_NAME-release" + name: "sce-develop-$CI_COMMIT_REF_NAME-release" paths: - build/*.rpm only: @@ -88,7 +88,7 @@ release_build_debug: PULP3_DIST_NAME: tsg-stable-x86_64.el7 extends: .build_by_travis artifacts: - name: "traffic-steering-service-install-$CI_COMMIT_REF_NAME-debug" + name: "sce-install-$CI_COMMIT_REF_NAME-debug" paths: - build/*.rpm only: @@ -104,7 +104,7 @@ release_build_release: PULP3_DIST_NAME: tsg-stable-x86_64.el7 extends: .build_by_travis artifacts: - name: "traffic-steering-service-install-$CI_COMMIT_REF_NAME-release" + name: "sce-install-$CI_COMMIT_REF_NAME-release" paths: - build/*.rpm only: diff --git a/CMakeLists.txt b/CMakeLists.txt index 8336773..8f17360 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -project(traffic-steering-service) +project(sce) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) include(Version) diff --git a/ci/travis.sh b/ci/travis.sh index 5b80946..8f1c415 100644 --- a/ci/travis.sh +++ b/ci/travis.sh @@ -34,6 +34,12 @@ env | sort # Install dependency from YUM yum install -y libasan +yum install -y mrzcpd +yum install -y libmaatframe-devel +yum install -y libMESA_handle_logger-devel +yum install -y libMESA_prof_load-devel +yum install -y librulescan-devel +yum install -y libasan if [ $ASAN_OPTION ]; then source /opt/rh/devtoolset-7/enable @@ -57,7 +63,7 @@ if [ -n "${PACKAGE}" ]; then fi if [ -n "${UPLOAD_SYMBOL_FILES}" ]; then - rpm -i traffic-steering-service*debuginfo*.rpm - cp /usr/lib/debug/opt/tsg/traffic-steering-service/bin/traffic-steering-service.debug /tmp/traffic-steering-service.debuginfo.${CI_COMMIT_SHORT_SHA} - sentry-cli upload-dif -t elf /tmp/traffic-steering-service.debuginfo.${CI_COMMIT_SHORT_SHA} + rpm -i sce*debuginfo*.rpm + cp /usr/lib/debug/opt/tsg/sce/bin/sce.debug /tmp/sce.debuginfo.${CI_COMMIT_SHORT_SHA} + sentry-cli upload-dif -t elf /tmp/sce.debuginfo.${CI_COMMIT_SHORT_SHA} fi diff --git a/cmake/Package.cmake b/cmake/Package.cmake index 1e03266..3f4c7bc 100644 --- a/cmake/Package.cmake +++ b/cmake/Package.cmake @@ -1,7 +1,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(CPACK_PACKAGE_NAME "traffic-steering-service-debug") + set(CPACK_PACKAGE_NAME "sce-debug") else() - set(CPACK_PACKAGE_NAME "traffic-steering-service") + set(CPACK_PACKAGE_NAME "sce") endif() message(STATUS "Package: ${CPACK_PACKAGE_NAME}") @@ -25,9 +25,9 @@ set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PreUninstall.i # Must uninstall the debug package before install release package if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(CPACK_RPM_PACKAGE_CONFLICTS "traffic-steering-service") + set(CPACK_RPM_PACKAGE_CONFLICTS "sce") else() - set(CPACK_RPM_PACKAGE_CONFLICTS "traffic-steering-service-debug") + set(CPACK_RPM_PACKAGE_CONFLICTS "sce-debug") endif() include(CPack) \ No newline at end of file diff --git a/cmake/PostInstall.in b/cmake/PostInstall.in index 54c05db..52cb49d 100644 --- a/cmake/PostInstall.in +++ b/cmake/PostInstall.in @@ -1,2 +1,2 @@ -%systemd_post traffic-steering-service.service +%systemd_post sce.service /sbin/ldconfig \ No newline at end of file diff --git a/cmake/PostUninstall.in b/cmake/PostUninstall.in index ce64035..c3a3906 100644 --- a/cmake/PostUninstall.in +++ b/cmake/PostUninstall.in @@ -1,2 +1,2 @@ -%systemd_postun_with_restart traffic-steering-service.service +%systemd_postun_with_restart sce.service /sbin/ldconfig \ No newline at end of file diff --git a/cmake/PreUninstall.in b/cmake/PreUninstall.in index 542bc80..88f89dc 100644 --- a/cmake/PreUninstall.in +++ b/cmake/PreUninstall.in @@ -1 +1 @@ -%systemd_preun traffic-steering-service.service \ No newline at end of file +%systemd_preun sce.service \ No newline at end of file diff --git a/common/include/log.h b/common/include/log.h index 97d3a6e..0cdcfdf 100644 --- a/common/include/log.h +++ b/common/include/log.h @@ -8,16 +8,22 @@ extern "C" #include -#define LOG_DEBUG(format, ...) \ - { \ +#define LOG_DEBUG(format, ...) \ + { \ fprintf(stdout, "DEBUG " format "\n", ##__VA_ARGS__); \ - fflush(stdout); \ + fflush(stdout); \ } -#define LOG_ERROR(format, ...) \ - { \ +#define LOG_INFO(format, ...) \ + { \ + fprintf(stdout, "INFO " format "\n", ##__VA_ARGS__); \ + fflush(stdout); \ + } + +#define LOG_ERROR(format, ...) \ + { \ fprintf(stderr, "ERROR " format "\n", ##__VA_ARGS__); \ - fflush(stderr); \ + fflush(stderr); \ } #ifdef __cpluscplus diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt index dfec65e..affcd5e 100644 --- a/platform/CMakeLists.txt +++ b/platform/CMakeLists.txt @@ -1,7 +1,11 @@ -add_executable(traffic-steering-service src/main.cpp) +add_executable(sce src/main.cpp src/policy.cpp) -target_include_directories(traffic-steering-service PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include/) -target_link_libraries(traffic-steering-service common) -target_link_libraries(traffic-steering-service pthread) +target_include_directories(sce PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include/) +target_link_libraries(sce PUBLIC common) +target_link_libraries(sce PUBLIC pthread) +target_link_libraries(sce PUBLIC MESA_handle_logger) +target_link_libraries(sce PUBLIC MESA_prof_load) +target_link_libraries(sce PUBLIC maatframe) +target_link_libraries(sce PUBLIC cjson) -install(TARGETS traffic-steering-service RUNTIME DESTINATION bin COMPONENT Program) \ No newline at end of file +install(TARGETS sce RUNTIME DESTINATION bin COMPONENT Program) \ No newline at end of file diff --git a/script/CMakeLists.txt b/script/CMakeLists.txt index d509af6..b46517c 100644 --- a/script/CMakeLists.txt +++ b/script/CMakeLists.txt @@ -1 +1 @@ -install(FILES service/traffic-steering-service.service DESTINATION /usr/lib/systemd/system/ COMPONENT Program) \ No newline at end of file +install(FILES service/sce.service DESTINATION /usr/lib/systemd/system/ COMPONENT Program) \ No newline at end of file diff --git a/script/service/sce.service b/script/service/sce.service new file mode 100644 index 0000000..b5bacb2 --- /dev/null +++ b/script/service/sce.service @@ -0,0 +1,6 @@ +[Unit] +Description=TSG Service Chaining Engine +After=network.target + +[Service] +ExecStart=/opt/tsg/sce/bin/sce \ No newline at end of file diff --git a/script/service/traffic-steering-service.service b/script/service/traffic-steering-service.service deleted file mode 100644 index daba5f2..0000000 --- a/script/service/traffic-steering-service.service +++ /dev/null @@ -1,6 +0,0 @@ -[Unit] -Description=Traffic Steering Service -After=network.target - -[Service] -ExecStart=/opt/tsg/traffic-steering-service/bin/traffic-steering-service \ No newline at end of file diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 6799ed0..5bc633f 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -18,4 +18,36 @@ set_property(TARGET gtest PROPERTY INTERFACE_LINK_LIBRARIES pthread) add_library(gmock STATIC IMPORTED GLOBAL) add_dependencies(gmock googletest) set_property(TARGET gmock PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libgmock.a) -set_property(TARGET gmock PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) \ No newline at end of file +set_property(TARGET gmock PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) + +# cjson +ExternalProject_Add(cJSON PREFIX cJSON + URL ${CMAKE_CURRENT_SOURCE_DIR}/cJSON-1.7.7.tar.gz + URL_MD5 715009c99728bf81d6c97352718650ff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DBUILD_SHARED_AND_STATIC_LIBS=1) + +ExternalProject_Get_Property(cJSON INSTALL_DIR) +file(MAKE_DIRECTORY ${INSTALL_DIR}/include) + +add_library(cjson SHARED IMPORTED GLOBAL) +add_dependencies(cjson cJSON) +set_property(TARGET cjson PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib64/libcjson.a) +set_property(TARGET cjson PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) + +# MESA Framework +set(MESA_FRAMEWORK_LIB_DIR /opt/MESA/lib) +set(MESA_FRAMEWORK_INCLUDE_DIR /opt/MESA/include) + +add_library(MESA_handle_logger SHARED IMPORTED GLOBAL) +set_property(TARGET MESA_handle_logger PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libMESA_handle_logger.so) +set_property(TARGET MESA_handle_logger PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR}) + +add_library(MESA_prof_load SHARED IMPORTED GLOBAL) +set_property(TARGET MESA_prof_load PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libMESA_prof_load.so) +set_property(TARGET MESA_prof_load PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR}) + +add_library(maatframe SHARED IMPORTED GLOBAL) +set_property(TARGET maatframe PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libmaatframe.so) +set_property(TARGET maatframe PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR}) \ No newline at end of file diff --git a/vendor/cJSON-1.7.7.tar.gz b/vendor/cJSON-1.7.7.tar.gz new file mode 100644 index 0000000..c2350cf Binary files /dev/null and b/vendor/cJSON-1.7.7.tar.gz differ