TSG-22348 feature: adapt maat support UUID

This commit is contained in:
luwenpeng
2024-09-23 16:50:09 +08:00
parent 7ef8e44bca
commit 5799de5299
60 changed files with 2504 additions and 1043 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,15 @@
#include "kafka.h"
#include "sf_metrics.h"
uuid_t rule_uuid1;
uuid_t rule_uuid2;
uuid_t sff_uuid1;
uuid_t sff_uuid2;
uuid_t sf_uuid1;
uuid_t sf_uuid2;
#if 1
TEST(SF_METRICS, TEST1)
{
@@ -16,17 +25,17 @@ TEST(SF_METRICS, TEST1)
struct sf_metrics_key key1 = {0};
key1.vsys_id = 1;
key1.rule_id = 2;
key1.sff_profile_id = 3;
key1.sf_profile_id = 4;
uuid_copy(key1.rule_uuid, rule_uuid1);
uuid_copy(key1.sff_uuid, sff_uuid1);
uuid_copy(key1.sf_uuid, sf_uuid1);
struct sf_metrics_key key2 = {0};
key2.vsys_id = 4;
key2.rule_id = 3;
key2.sff_profile_id = 2;
key2.sf_profile_id = 1;
uuid_copy(key2.rule_uuid, rule_uuid2);
uuid_copy(key2.sff_uuid, sff_uuid2);
uuid_copy(key2.sf_uuid, sf_uuid2);
// thread 0
// uint64_t rx_pkts, uint64_t rx_bytes, uint64_t tx_pkts, uint64_t tx_bytes);
// rx_pkts, rx_bytes, tx_pkts, tx_bytes);
sf_metrics_input(metrics, thr_idx0, &key1, 1, 2, 2, 4);
sf_metrics_input(metrics, thr_idx0, &key2, 2, 4, 1, 2);
sf_metrics_output(metrics, thr_idx0);
@@ -62,17 +71,17 @@ TEST(SF_METRICS, TEST2)
struct sf_metrics_key key1 = {0};
key1.vsys_id = 1;
key1.rule_id = 2;
key1.sff_profile_id = 3;
key1.sf_profile_id = 4;
uuid_copy(key1.rule_uuid, rule_uuid1);
uuid_copy(key1.sff_uuid, sff_uuid1);
uuid_copy(key1.sf_uuid, sf_uuid1);
struct sf_metrics_key key2 = {0};
key2.vsys_id = 4;
key2.rule_id = 3;
key2.sff_profile_id = 2;
key2.sf_profile_id = 1;
uuid_copy(key2.rule_uuid, rule_uuid2);
uuid_copy(key2.sff_uuid, sff_uuid2);
uuid_copy(key2.sf_uuid, sf_uuid2);
// thread 0
// uint64_t rx_pkts, uint64_t rx_bytes, uint64_t tx_pkts, uint64_t tx_bytes);
// rx_pkts, rx_bytes, tx_pkts, tx_bytes);
sf_metrics_input(metrics, thr_idx0, &key1, 1, 2, 2, 4);
sf_metrics_input(metrics, thr_idx0, &key2, 2, 4, 1, 2);
sf_metrics_output(metrics, thr_idx0);
@@ -96,6 +105,15 @@ TEST(SF_METRICS, TEST2)
int main(int argc, char **argv)
{
uuid_parse("00000000-0000-0000-0000-000000000001", rule_uuid1);
uuid_parse("00000000-0000-0000-0000-000000000002", rule_uuid2);
uuid_parse("00000000-0000-0000-0000-000000000003", sff_uuid1);
uuid_parse("00000000-0000-0000-0000-000000000004", sff_uuid2);
uuid_parse("00000000-0000-0000-0000-000000000005", sf_uuid1);
uuid_parse("00000000-0000-0000-0000-000000000006", sf_uuid2);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@@ -4,6 +4,10 @@
TEST(SF_STATUS, TEST)
{
uuid_t sf_uuid1;
uuid_t sf_uuid2;
uuid_generate(sf_uuid1);
uuid_generate(sf_uuid2);
struct kafka *kfk = kafka_create("./test_resource/sce.conf");
EXPECT_TRUE(kfk != NULL);
struct sf_status *status = sf_status_create("./test_resource/sce.conf", kfk);
@@ -13,14 +17,15 @@ TEST(SF_STATUS, TEST)
struct sf_status_key key1 = {0};
key1.vsys_id = 11;
key1.sf_profile_id = 12;
uuid_copy(key1.sf_uuid, sf_uuid1);
struct sf_status_key key2 = {0};
key2.vsys_id = 21;
key2.sf_profile_id = 22;
key2.vsys_id = 22;
uuid_copy(key2.sf_uuid, sf_uuid2);
sf_status_update(status, &key1, 0, 1);
sf_status_update(status, &key2, 1, 2);
sf_status_update(status, &key1, 1, 2);
sf_status_update(status, &key2, 2, 1);
printf("\n========================================\n expect key1 + key2 \n========================================\n");
sf_status_output(status);
@@ -32,6 +37,8 @@ TEST(SF_STATUS, TEST)
printf("\n========================================\n expect no output \n========================================\n");
sf_status_output(status);
sleep(2);
sf_status_destory(status);
kafka_destroy(kfk);
}

View File

@@ -2,7 +2,7 @@
nr_worker_threads=8
[maat]
# 0:json 1:redis 2:iris
# 0:json 1:redis
input_mode=0
# LOG_LEVEL_TRACE = 0; LOG_LEVEL_DEBUG = 1; LOG_LEVEL_INFO = 2;
# LOG_LEVEL_WARN = 3; LOG_LEVEL_ERROR = 4; LOG_LEVEL_FATAL = 5;
@@ -14,8 +14,6 @@ deferred_load=0
stat_file=./maat.fs2
table_info=test_resource/table_info.conf
accept_path=/opt/tsg/etc/tsg_device_tag.json
inc_cfg_dir=test_resource/inc/
ful_cfg_dir=test_resource/ful/
json_cfg_file=test_resource/sce.json
foreign_cont_dir=test_resource/foreign_files
redis_db_idx=0
@@ -36,6 +34,7 @@ local_address=127.0.0.1
gateway=127.0.0.1
[kafka]
enable_debug=0
brokerlist=192.168.40.224:9092
sasl_username=admin
sasl_passwd=galaxy2019

View File

@@ -3,38 +3,365 @@
{
"table_name": "SERVICE_FUNCTION_PROFILE",
"table_content": [
"1\t{\"tag\":\"data_center\",\"value\":\"data_center_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1\t1",
"2\t{\"tag\":\"data_center\",\"value\":\"data_center_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"bfd\",\"address\":\"1.2.3.4\",\"port\":\"10000\",\"interval_ms\":100,\"retires\":5}\t1\t1",
"3\t{\"tag\":\"data_center\",\"value\":\"data_center_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"in_band_bfd\",\"address\":\"1.2.3.4\",\"port\":\"10000\",\"interval_ms\":100,\"retires\":5}\t1\t1",
"4\t{\"tag\":\"data_center\",\"value\":\"data_center_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"http\",\"url\":\"http://192.168.100.1:8080/health_check.index\",\"interval_ms\":100,\"retires\":5}\t1\t1",
"5\t{\"tag\":\"data_center\",\"value\":\"data_center_a\"}\t1\t{\"method\":\"layer2_switch\",\"int_vlan_tag\":10,\"ext_vlan_tag\":5}\t{\"method\":\"none\"}\t1\t1",
"6\t{\"tag\":\"data_center\",\"value\":\"data_center_a\"}\t1\t{\"method\":\"layer3_switch\",\"int_vlan_tag\":10,\"ext_vlan_tag\":5}\t{\"method\":\"none\"}\t1\t1",
"7\t{\"tag\":\"data_center\",\"value\":\"data_center_a\"}\t0\t{\"method\":\"layer3_switch\",\"int_vlan_tag\":10,\"ext_vlan_tag\":5}\t{\"method\":\"none\"}\t1\t1",
"8\t{\"tag\":\"data_center\",\"value\":\"data_center_b\"}\t0\t{\"method\":\"layer3_switch\",\"int_vlan_tag\":10,\"ext_vlan_tag\":5}\t{\"method\":\"none\"}\t1\t1"
{
"uuid": "00000000-0000-0000-3333-000000000001",
"device_group": {
"tag": "data_center",
"value": "data_center_a"
},
"admin_status": 1,
"connectivity": {
"method": "vxlan_g",
"dest_ip": "1.1.1.1"
},
"health_check": {
"method": "none"
},
"vsys_id": 1,
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-3333-000000000002",
"device_group": {
"tag": "data_center",
"value": "data_center_a"
},
"admin_status": 1,
"connectivity": {
"method": "vxlan_g",
"dest_ip": "1.1.1.1"
},
"health_check": {
"method": "bfd",
"address": "1.2.3.4",
"port": "10000",
"interval_ms": 100,
"retires": 5
},
"vsys_id": 1,
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-3333-000000000003",
"device_group": {
"tag": "data_center",
"value": "data_center_a"
},
"admin_status": 1,
"connectivity": {
"method": "vxlan_g",
"dest_ip": "1.1.1.1"
},
"health_check": {
"method": "in_band_bfd",
"address": "1.2.3.4",
"port": "10000",
"interval_ms": 100,
"retires": 5
},
"vsys_id": 1,
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-3333-000000000004",
"device_group": {
"tag": "data_center",
"value": "data_center_a"
},
"admin_status": 1,
"connectivity": {
"method": "vxlan_g",
"dest_ip": "1.1.1.1"
},
"health_check": {
"method": "http",
"url": "http://192.168.100.1:8080/health_check.index",
"interval_ms": 100,
"retires": 5
},
"vsys_id": 1,
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-3333-000000000005",
"device_group": {
"tag": "data_center",
"value": "data_center_a"
},
"admin_status": 1,
"connectivity": {
"method": "layer2_switch",
"int_vlan_tag": 10,
"ext_vlan_tag": 5
},
"health_check": {
"method": "none"
},
"vsys_id": 1,
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-3333-000000000006",
"device_group": {
"tag": "data_center",
"value": "data_center_a"
},
"admin_status": 1,
"connectivity": {
"method": "layer3_switch",
"int_vlan_tag": 10,
"ext_vlan_tag": 5
},
"health_check": {
"method": "none"
},
"vsys_id": 1,
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-3333-000000000007",
"device_group": {
"tag": "data_center",
"value": "data_center_a"
},
"admin_status": 0,
"connectivity": {
"method": "layer3_switch",
"int_vlan_tag": 10,
"ext_vlan_tag": 5
},
"health_check": {
"method": "none"
},
"vsys_id": 1,
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-3333-000000000008",
"device_group": {
"tag": "data_center",
"value": "data_center_b"
},
"admin_status": 0,
"connectivity": {
"method": "layer3_switch",
"int_vlan_tag": 10,
"ext_vlan_tag": 5
},
"health_check": {
"method": "none"
},
"vsys_id": 1,
"is_valid": 1
}
]
},
{
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
"table_content": [
"1\t1\thash-int-ip\tnearby\tbypass\tnull\t[1]\t1",
"2\t1\thash-int-ip\tnearby\tbypass\tnull\t[1,2,3,4,5,6,7,8]\t1",
"3\t1\thash-int-ip\tnearby\tblock\tnull\t[1]\t1",
"4\t1\thash-int-ip\tnearby\tre-dispatch\t{\"action\":\"bypass\",\"health_service_func_lt\":2}\t[1,2,3]\t1",
"5\t1\thash-int-ip\tnearby\tre-dispatch\t{\"action\":\"block\"}\t[1,2,3]\t1",
"6\t1\thash-int-ip\tglobal\tblock\tnull\t[1]\t1",
"7\t1\thash-ext-ip\tglobal\tblock\tnull\t[1]\t1",
"8\t1\thash-int-ip-and-ext-ip\tglobal\tblock\tnull\t[1]\t1",
"9\t1\thash-innermost-int-ip\tglobal\tblock\tnull\t[1]\t1",
"10\t2\thash-innermost-int-ip\tglobal\tblock\tnull\t[1]\t1"
{
"uuid": "00000000-0000-0000-2222-000000000001",
"type": 1,
"load_balance_method": "hash-int-ip",
"load_balance_localization": "nearby",
"failure_action": "bypass",
"service_func_profiles": [
"00000000-0000-0000-3333-000000000001"
],
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-2222-000000000002",
"type": 1,
"load_balance_method": "hash-int-ip",
"load_balance_localization": "nearby",
"failure_action": "bypass",
"service_func_profiles": [
"00000000-0000-0000-3333-000000000001",
"00000000-0000-0000-3333-000000000002",
"00000000-0000-0000-3333-000000000003",
"00000000-0000-0000-3333-000000000004",
"00000000-0000-0000-3333-000000000005",
"00000000-0000-0000-3333-000000000006",
"00000000-0000-0000-3333-000000000007",
"00000000-0000-0000-3333-000000000008"
],
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-2222-000000000003",
"type": 1,
"load_balance_method": "hash-int-ip",
"load_balance_localization": "nearby",
"failure_action": "block",
"service_func_profiles": [
"00000000-0000-0000-3333-000000000001"
],
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-2222-000000000004",
"type": 1,
"load_balance_method": "hash-int-ip",
"load_balance_localization": "nearby",
"failure_action": "re-dispatch",
"unavailability_action": {
"action": "bypass",
"health_service_func_lt": 2
},
"service_func_profiles": [
"00000000-0000-0000-3333-000000000001",
"00000000-0000-0000-3333-000000000002",
"00000000-0000-0000-3333-000000000003"
],
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-2222-000000000005",
"type": 1,
"load_balance_method": "hash-int-ip",
"load_balance_localization": "nearby",
"failure_action": "re-dispatch",
"unavailability_action": {
"action": "block"
},
"service_func_profiles": [
"00000000-0000-0000-3333-000000000001",
"00000000-0000-0000-3333-000000000002",
"00000000-0000-0000-3333-000000000003"
],
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-2222-000000000006",
"type": 1,
"load_balance_method": "hash-int-ip",
"load_balance_localization": "global",
"failure_action": "block",
"service_func_profiles": [
"00000000-0000-0000-3333-000000000001"
],
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-2222-000000000007",
"type": 1,
"load_balance_method": "hash-ext-ip",
"load_balance_localization": "global",
"failure_action": "block",
"service_func_profiles": [
"00000000-0000-0000-3333-000000000001"
],
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-2222-000000000008",
"type": 1,
"load_balance_method": "hash-int-ip-and-ext-ip",
"load_balance_localization": "global",
"failure_action": "block",
"service_func_profiles": [
"00000000-0000-0000-3333-000000000001"
],
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-2222-000000000009",
"type": 1,
"load_balance_method": "hash-innermost-int-ip",
"load_balance_localization": "global",
"failure_action": "block",
"service_func_profiles": [
"00000000-0000-0000-3333-000000000001"
],
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-2222-000000000010",
"type": 2,
"load_balance_method": "hash-innermost-int-ip",
"load_balance_localization": "global",
"failure_action": "block",
"service_func_profiles": [
"00000000-0000-0000-3333-000000000001"
],
"is_valid": 1
}
]
},
{
"table_name": "SERVICE_CHAINING_COMPILE",
"table_name": "SERVICE_CHAINING_RULE",
"table_content": [
"1\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t0\t1",
"2\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1,2,3,4,5,6,7,8,9,10]}\t0\t1",
"11\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"decrypted\",\"sff_profiles\":[1]}\t0\t1",
"12\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"decrypted\",\"sff_profiles\":[1,2,3,4,5,6,7,8,9,10]}\t0\t1"
{
"uuid": "00000000-0000-0000-1111-000000000001",
"log_option": "all",
"effective_range": {},
"action_parameter": {
"vsys_id": 1,
"targeted_traffic": "raw",
"sff_profiles": [
"00000000-0000-0000-2222-000000000001"
]
},
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-1111-000000000002",
"log_option": "all",
"effective_range": {},
"action_parameter": {
"vsys_id": 1,
"targeted_traffic": "raw",
"sff_profiles": [
"00000000-0000-0000-2222-000000000001",
"00000000-0000-0000-2222-000000000002",
"00000000-0000-0000-2222-000000000003",
"00000000-0000-0000-2222-000000000004",
"00000000-0000-0000-2222-000000000005",
"00000000-0000-0000-2222-000000000006",
"00000000-0000-0000-2222-000000000007",
"00000000-0000-0000-2222-000000000008",
"00000000-0000-0000-2222-000000000009",
"00000000-0000-0000-2222-000000000010"
]
},
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-1111-000000000011",
"log_option": "all",
"effective_range": {},
"action_parameter": {
"vsys_id": 1,
"targeted_traffic": "decrypted",
"sff_profiles": [
"00000000-0000-0000-2222-000000000001"
]
},
"is_valid": 1
},
{
"uuid": "00000000-0000-0000-1111-000000000012",
"log_option": "all",
"effective_range": {},
"action_parameter": {
"vsys_id": 1,
"targeted_traffic": "decrypted",
"sff_profiles": [
"00000000-0000-0000-2222-000000000001",
"00000000-0000-0000-2222-000000000002",
"00000000-0000-0000-2222-000000000003",
"00000000-0000-0000-2222-000000000004",
"00000000-0000-0000-2222-000000000005",
"00000000-0000-0000-2222-000000000006",
"00000000-0000-0000-2222-000000000007",
"00000000-0000-0000-2222-000000000008",
"00000000-0000-0000-2222-000000000009",
"00000000-0000-0000-2222-000000000010"
]
},
"is_valid": 1
}
]
}
]