diff options
| author | liuchang <[email protected]> | 2023-03-22 12:47:22 +0000 |
|---|---|---|
| committer | liuchang <[email protected]> | 2023-03-22 12:47:22 +0000 |
| commit | 16528f0f938ccbaad67491f83bbaa54c773b5e19 (patch) | |
| tree | 0343ad90c0f85d499014b8ae11aefde74b3ac118 | |
| parent | 69e07b600b2d5f2b20910743dee4863d90155145 (diff) | |
add package aboutv0.0.0
| -rw-r--r-- | .gitlab-ci.yml | 20 | ||||
| -rw-r--r-- | CMakeLists.txt | 4 | ||||
| -rw-r--r-- | cmake/Package.cmake | 4 | ||||
| -rw-r--r-- | cmake/PostInstall.in | 2 | ||||
| -rw-r--r-- | cmake/PostUninstall.in | 2 | ||||
| -rw-r--r-- | cmake/PreInstall.sh | 10 | ||||
| -rw-r--r-- | cmake/PreUninstall.in | 1 | ||||
| -rw-r--r-- | cmake/PreUninstall.sh | 8 | ||||
| -rw-r--r-- | common/test/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | conf/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | conf/table_info.json (renamed from conf/table_info.conf) | 0 | ||||
| -rw-r--r-- | script/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | script/sce.service | 7 | ||||
| -rw-r--r-- | shaping/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | shaping/test/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | shaping/test/test_conf/main.conf | 40 | ||||
| -rw-r--r-- | shaping/test/test_conf/shaping_maat.json | 76 | ||||
| -rw-r--r-- | shaping/test/test_conf/table_info.json | 24 | ||||
| -rw-r--r-- | shaping/test/test_conf/zlog.conf | 10 |
19 files changed, 188 insertions, 32 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2c6a69a..86753c7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -101,7 +101,7 @@ develop_build_debug_for_centos7: PULP3_REPO_NAME: tsg-testing-x86_64.el7 PULP3_DIST_NAME: tsg-testing-x86_64.el7 artifacts: - name: "shaping_master-$CI_COMMIT_REF_NAME-debug" + name: "shaping_engine-$CI_COMMIT_REF_NAME-debug" paths: - build/*.rpm only: @@ -119,7 +119,7 @@ develop_build_release_for_centos7: PULP3_REPO_NAME: tsg-testing-x86_64.el7 PULP3_DIST_NAME: tsg-testing-x86_64.el7 artifacts: - name: "shaping_master-$CI_COMMIT_REF_NAME-release" + name: "shaping_engine-$CI_COMMIT_REF_NAME-release" paths: - build/*.rpm only: @@ -136,7 +136,7 @@ release_build_debug_for_centos7: PULP3_DIST_NAME: tsg-stable-x86_64.el7 extends: .build_by_travis_for_centos7 artifacts: - name: "shaping_master-$CI_COMMIT_REF_NAME-release" + name: "shaping_engine-$CI_COMMIT_REF_NAME-release" paths: - build/*.rpm only: @@ -149,12 +149,12 @@ release_build_release_for_centos7: PACKAGE: 1 UPLOAD_RPM: 1 UPLOAD_SYMBOL_FILES: 1 - SYMBOL_TARGET: shaping_master + SYMBOL_TARGET: shaping_engine PULP3_REPO_NAME: tsg-stable-x86_64.el7 PULP3_DIST_NAME: tsg-stable-x86_64.el7 extends: .build_by_travis_for_centos7 artifacts: - name: "shaping_master-$CI_COMMIT_REF_NAME-release" + name: "shaping_engine-$CI_COMMIT_REF_NAME-release" paths: - build/*.rpm only: @@ -192,7 +192,7 @@ develop_build_debug_for_centos8: PULP3_REPO_NAME: tsg-testing-x86_64.el8 PULP3_DIST_NAME: tsg-testing-x86_64.el8 artifacts: - name: "shaping_master-$CI_COMMIT_REF_NAME-debug" + name: "shaping_engine-$CI_COMMIT_REF_NAME-debug" paths: - build/*.rpm only: @@ -210,7 +210,7 @@ develop_build_release_for_centos8: PULP3_REPO_NAME: tsg-testing-x86_64.el8 PULP3_DIST_NAME: tsg-testing-x86_64.el8 artifacts: - name: "shaping_master-$CI_COMMIT_REF_NAME-release" + name: "shaping_engine-$CI_COMMIT_REF_NAME-release" paths: - build/*.rpm only: @@ -227,7 +227,7 @@ release_build_debug_for_centos8: PULP3_DIST_NAME: tsg-stable-x86_64.el8 extends: .build_by_travis_for_centos8 artifacts: - name: "shaping_master-$CI_COMMIT_REF_NAME-release" + name: "shaping_engine-$CI_COMMIT_REF_NAME-release" paths: - build/*.rpm only: @@ -240,12 +240,12 @@ release_build_release_for_centos8: PACKAGE: 1 UPLOAD_RPM: 1 UPLOAD_SYMBOL_FILES: 1 - SYMBOL_TARGET: shaping_master + SYMBOL_TARGET: shaping_engine PULP3_REPO_NAME: tsg-stable-x86_64.el8 PULP3_DIST_NAME: tsg-stable-x86_64.el8 extends: .build_by_travis_for_centos8 artifacts: - name: "shaping_master-$CI_COMMIT_REF_NAME-release" + name: "shaping_engine-$CI_COMMIT_REF_NAME-release" paths: - build/*.rpm only: diff --git a/CMakeLists.txt b/CMakeLists.txt index 7203df1..5d1afbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,8 +56,8 @@ add_custom_target("install-program" COMMAND ${CMAKE_COMMAND} ARGS -DCOMPONENT=Pr add_custom_target("install-profile" COMMAND ${CMAKE_COMMAND} ARGS -DCOMPONENT=Profile -P cmake_install.cmake) enable_testing() -#add_subdirectory(conf) +add_subdirectory(conf) add_subdirectory(vendor) add_subdirectory(common) add_subdirectory(shaping) -#add_subdirectory(test) +add_subdirectory(script) diff --git a/cmake/Package.cmake b/cmake/Package.cmake index f32a9bc..c83b5d8 100644 --- a/cmake/Package.cmake +++ b/cmake/Package.cmake @@ -1,7 +1,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(MY_RPM_NAME_PREFIX "${lib_name}-debug") + set(MY_RPM_NAME_PREFIX "shaping_engine-debug") else() - set(MY_RPM_NAME_PREFIX "${lib_name}") + set(MY_RPM_NAME_PREFIX "shaping_engine") endif() message(STATUS "Package: ${MY_RPM_NAME_PREFIX}") diff --git a/cmake/PostInstall.in b/cmake/PostInstall.in new file mode 100644 index 0000000..66bfb75 --- /dev/null +++ b/cmake/PostInstall.in @@ -0,0 +1,2 @@ +%systemd_post shaping_engine.service +/sbin/ldconfig
\ No newline at end of file diff --git a/cmake/PostUninstall.in b/cmake/PostUninstall.in new file mode 100644 index 0000000..da68b07 --- /dev/null +++ b/cmake/PostUninstall.in @@ -0,0 +1,2 @@ +%systemd_postun_with_restart shaping_engine.service +/sbin/ldconfig
\ No newline at end of file diff --git a/cmake/PreInstall.sh b/cmake/PreInstall.sh deleted file mode 100644 index 9ebc7d6..0000000 --- a/cmake/PreInstall.sh +++ /dev/null @@ -1,10 +0,0 @@ -DST=${RPM_INSTALL_PREFIX} - -mkdir -p ${DST}/plug/platform/ -touch ${DST}/plug/conflist.inf - - -if [[ -z `grep -rn 'shaping_master.inf' ${DST}/plug/conflist.inf` ]];then - sed -i '/\[platform\]/a\./plug/platform/shaping_master/shaping_master.inf' ${DST}/plug/conflist.inf -fi - diff --git a/cmake/PreUninstall.in b/cmake/PreUninstall.in new file mode 100644 index 0000000..f94eeda --- /dev/null +++ b/cmake/PreUninstall.in @@ -0,0 +1 @@ +%systemd_preun shaping_engine.service
\ No newline at end of file diff --git a/cmake/PreUninstall.sh b/cmake/PreUninstall.sh deleted file mode 100644 index 09da4b6..0000000 --- a/cmake/PreUninstall.sh +++ /dev/null @@ -1,8 +0,0 @@ -if [ $1 == 0 ]; then - DST=${RPM_INSTALL_PREFIX} - - touch ${DST}/plug/conflist.inf - - sed -i '/shaping_master.inf/d' ${DST}/plug/conflist.inf -fi - diff --git a/common/test/CMakeLists.txt b/common/test/CMakeLists.txt index 28d29bf..00dd805 100644 --- a/common/test/CMakeLists.txt +++ b/common/test/CMakeLists.txt @@ -64,5 +64,6 @@ gtest_discover_tests(gtest_addr_tuple4) gtest_discover_tests(gtest_session_table) gtest_discover_tests(gtest_raw_packet) gtest_discover_tests(gtest_ctrl_packet) +gtest_discover_tests(gtest_tcp_pure_ctrl_pkt) gtest_discover_tests(gtest_utils) gtest_discover_tests(gtest_libavl) diff --git a/conf/CMakeLists.txt b/conf/CMakeLists.txt new file mode 100644 index 0000000..b278878 --- /dev/null +++ b/conf/CMakeLists.txt @@ -0,0 +1,4 @@ +install(FILES main.conf DESTINATION conf COMPONENT Profile) +install(FILES shaping_maat.json DESTINATION conf COMPONENT Profile) +install(FILES table_info.json DESTINATION conf COMPONENT Profile) +install(FILES zlog.conf DESTINATION conf COMPONENT Profile)
\ No newline at end of file diff --git a/conf/table_info.conf b/conf/table_info.json index 55f55ae..55f55ae 100644 --- a/conf/table_info.conf +++ b/conf/table_info.json diff --git a/script/CMakeLists.txt b/script/CMakeLists.txt new file mode 100644 index 0000000..c836fda --- /dev/null +++ b/script/CMakeLists.txt @@ -0,0 +1,2 @@ +install(FILES service/shaping_engine.service DESTINATION /usr/lib/systemd/system/ COMPONENT Program) +#install(FILES tmpfiles/sce.conf DESTINATION /usr/lib/tmpfiles.d/ COMPONENT Profile)
\ No newline at end of file diff --git a/script/sce.service b/script/sce.service new file mode 100644 index 0000000..6f8543e --- /dev/null +++ b/script/sce.service @@ -0,0 +1,7 @@ +[Unit] +Description=TSG Shaping Engine +After=network.target + +[Service] +WorkingDirectory=/opt/tsg/shaping_engine/ +ExecStart=/opt/tsg/sce/bin/shaping_engine
\ No newline at end of file diff --git a/shaping/CMakeLists.txt b/shaping/CMakeLists.txt index 0171de8..e27398f 100644 --- a/shaping/CMakeLists.txt +++ b/shaping/CMakeLists.txt @@ -12,4 +12,6 @@ target_link_libraries(shaping_engine PUBLIC maat4) target_link_libraries(shaping_engine PUBLIC mrzcpd) target_link_libraries(shaping_engine PUBLIC swarmkv) +install(TARGETS shaping_engine RUNTIME DESTINATION bin COMPONENT Program) + add_subdirectory(test)
\ No newline at end of file diff --git a/shaping/test/CMakeLists.txt b/shaping/test/CMakeLists.txt index de8bcd9..1b527b8 100644 --- a/shaping/test/CMakeLists.txt +++ b/shaping/test/CMakeLists.txt @@ -23,3 +23,6 @@ target_link_libraries(gtest_shaper common shaper pthread gtest) include(GoogleTest) gtest_discover_tests(gtest_shaper_maat) +gtest_discover_tests(gtest_shaper) + +file(COPY ./test_conf/ DESTINATION ./conf/)
\ No newline at end of file diff --git a/shaping/test/test_conf/main.conf b/shaping/test/test_conf/main.conf new file mode 100644 index 0000000..e134a70 --- /dev/null +++ b/shaping/test/test_conf/main.conf @@ -0,0 +1,40 @@ +[SYSTEM] +WORK_THREAD_NUM=2 +ENABLE_CPU_AFFINITY=1 +CPU_AFFINITY_MASK=1-2 + +[MARSIO] +DEV_INTERFACE="eth_interface" +RX_BRUST_MAX=1 +APP_SYMBOL="shaping" + +[MAAT] +INPUT_MODE=1 +TABLE_INFO="conf/table_info.conf" +JSON_FILE="conf/shaping_maat.json" +REDIS_DB_IDX=0 +REDIS_IP="127.0.0.1" +REDIS_PORT="6379" + + +[SWARMKV] +SWARMKV_CLUSTER_NAME="shaping" +SWARMKV_NODE_IP="127.0.0.1" +SWARMKV_NODE_PORT=5210 +SWARMKV_CONSUL_IP="127.0.0.1" +SWARMKV_CONSUL_PORT=8500 +SWARMKV_CLUSTER_ANNOUNCE_IP="127.0.0.1" +SWARMKV_CLUSTER_ANNOUNCE_PORT=8501 +SWARMKV_HEALTH_CHECK_PORT=0 +SWARMKV_HEALTH_CHECK_ANNOUNCE_PORT=1111 + +#[METRIC] +#TELEGRAF_IP="127.0.0.1" +#TELEGRAF_PORT=6667 + +[CONFIG] +#PROFILE_QUEUE_LEN_PER_PRIORITY_MAX=128 +SESSION_QUEUE_LEN_MAX=128 +QUEUEING_SESSIONS_PER_PRIORITY_PER_THREAD_MAX=1024 +POLLING_NODE_NUM_MAX={"polling_node_num_max":[ 3, 2, 2, 1, 1, 1, 1, 1, 1, 1 ]} + diff --git a/shaping/test/test_conf/shaping_maat.json b/shaping/test/test_conf/shaping_maat.json new file mode 100644 index 0000000..9d518f9 --- /dev/null +++ b/shaping/test/test_conf/shaping_maat.json @@ -0,0 +1,76 @@ +{
+ "compile_table": "TRAFFIC_SHAPING_COMPILE",
+ "group2compile_table": "GROUP_SHAPING_COMPILE_RELATION",
+ "group2group_table": "GROUP_GROUP_RELATION",
+ "rules": [
+ {
+ "compile_id": 182,
+ "service": 2,
+ "action": 32,
+ "do_blacklist": 0,
+ "do_log": 1,
+ "effective_rage": 0,
+ "user_region": "{\"priority\":1,\"fair_factor\":10,\"profile_chain\":[1]}",
+ "is_valid": "yes",
+ "groups": [
+ {
+ "group_name":"OBJ_SRC_IP_ADDR",
+ "virtual_table":"TSG_SECURITY_SOURCE_ADDR",
+ "not_flag" : 0,
+ "regions": [
+ {
+ "table_name": "TSG_OBJ_IP_ADDR",
+ "table_type": "ip_plus",
+ "table_content": {
+ "saddr_format": "range",
+ "addr_type": "ipv4",
+ "src_ip1": "192.168.50.67",
+ "src_ip2": "192.168.50.67",
+ "sport_format": "range",
+ "src_port1": "0",
+ "src_port2": "65535",
+ "protocol": 0,
+ "direction": "double"
+ }
+ }
+ ]
+ },
+ {
+ "group_name":"OBJ_DST_IP_ADDR",
+ "virtual_table":"TSG_SECURITY_DESTINATION_ADDR",
+ "not_flag" : 0,
+ "regions": [
+ {
+ "table_name": "TSG_OBJ_IP_ADDR",
+ "table_type": "ip_plus",
+ "table_content": {
+ "saddr_format": "range",
+ "addr_type": "ipv4",
+ "src_ip1": "192.168.42.43",
+ "src_ip2": "192.168.42.43",
+ "sport_format": "range",
+ "src_port1": "5678",
+ "src_port2": "5678",
+ "protocol": 0,
+ "direction": "double"
+ }
+ }
+ ]
+ }
+
+ ]
+ }
+ ],
+ "plugin_table": [
+ {
+ "table_name": "TRAFFIC_SHAPING_PROFILE",
+ "table_content": [
+ "1\t{\"value\":\"local_host\",\"host_fairness\":1}\t[{\"direction\":\"incoming\",\"bandwidth\":102400},{\"direction\":\"outcoming\",\"bandwidth\":102400}]\t{\"enabled\":1,\"algorithm\":\"codel\"}\tnull\t{}\t1",
+ "3\t{\"value\":\"local_host\",\"host_fairness\":1}\t[{\"direction\":\"incoming\",\"bandwidth\":10240},{\"direction\":\"outcoming\",\"bandwidth\":10240}]\t{\"enabled\":1,\"algorithm\":\"codel\"}\tnull\t{}\t1",
+ "4\t{\"value\":\"local_host\",\"host_fairness\":1}\t[{\"direction\":\"incoming\",\"bandwidth\":10240},{\"direction\":\"outcoming\",\"bandwidth\":10240}]\t{\"enabled\":1,\"algorithm\":\"codel\"}\tnull\t{}\t1",
+ "5\t{\"value\":\"local_host\",\"host_fairness\":1}\t[{\"direction\":\"incoming\",\"bandwidth\":10240},{\"direction\":\"outcoming\",\"bandwidth\":10240}]\t{\"enabled\":1,\"algorithm\":\"codel\"}\tnull\t{}\t1",
+ "6\t{\"value\":\"local_host\",\"host_fairness\":1}\t[{\"direction\":\"incoming\",\"bandwidth\":10240},{\"direction\":\"outcoming\",\"bandwidth\":10240}]\t{\"enabled\":1,\"algorithm\":\"codel\"}\tnull\t{}\t1"
+ ]
+ }
+ ]
+}
diff --git a/shaping/test/test_conf/table_info.json b/shaping/test/test_conf/table_info.json new file mode 100644 index 0000000..55f55ae --- /dev/null +++ b/shaping/test/test_conf/table_info.json @@ -0,0 +1,24 @@ +[ + { + "table_id": 0, + "table_name": "TRAFFIC_SHAPING_COMPILE", + "table_type": "plugin", + "valid_column": 8, + "custom": { + "key": 1, + "ley_type": "integer" + } + }, + { + "table_id": 1, + "table_name": "TRAFFIC_SHAPING_PROFILE", + "table_type": "plugin", + "valid_column": 7, + "custom": { + "key": 1, + "key_type": "string" + } + } + + +]
\ No newline at end of file diff --git a/shaping/test/test_conf/zlog.conf b/shaping/test/test_conf/zlog.conf new file mode 100644 index 0000000..a7a988d --- /dev/null +++ b/shaping/test/test_conf/zlog.conf @@ -0,0 +1,10 @@ +[global] +default format = "%d(%c), %V, %F, %U, %m%n" + +[levels] +DEBUG=10 +INFO=20 +FATAL=30 + +[rules] +shaping.fatal "./log/shaping.log.%d(%F)"; |
