summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2024-09-23 16:50:09 +0800
committerluwenpeng <[email protected]>2024-09-27 19:11:47 +0800
commit5799de529955798ed0727c088ffa25f1e4e51445 (patch)
tree818422edc9c400d84a5393bfe4e581496825019d
parent7ef8e44bca6bac3c905ed8d6a11cadd6edac156b (diff)
TSG-22348 feature: adapt maat support UUID
-rw-r--r--ci/travis.sh1
-rw-r--r--common/CMakeLists.txt2
-rw-r--r--common/include/control_packet.h5
-rw-r--r--common/include/utils.h24
-rw-r--r--common/src/control_packet.cpp20
-rw-r--r--common/src/kafka.cpp21
-rw-r--r--common/src/utils.cpp59
-rw-r--r--common/test/gtest_control_packet.cpp227
-rw-r--r--common/test/gtest_health_check_table.cpp88
-rw-r--r--common/test/gtest_utils.cpp141
-rw-r--r--conf/sce.conf5
-rw-r--r--platform/include/health_check.h4
-rw-r--r--platform/include/packet_trace.h83
-rw-r--r--platform/include/policy.h8
-rw-r--r--platform/include/sce.h2
-rw-r--r--platform/include/sf_metrics.h8
-rw-r--r--platform/include/sf_status.h4
-rw-r--r--platform/src/health_check.cpp30
-rw-r--r--platform/src/packet_io.cpp72
-rw-r--r--platform/src/policy.cpp581
-rw-r--r--platform/src/sce.cpp2
-rw-r--r--platform/src/sf_metrics.cpp18
-rw-r--r--platform/src/sf_status.cpp6
-rw-r--r--platform/test/gtest_policy.cpp726
-rw-r--r--platform/test/gtest_sf_metrics.cpp46
-rw-r--r--platform/test/gtest_sf_status.cpp17
-rw-r--r--platform/test/test_resource/sce.conf5
-rw-r--r--platform/test/test_resource/sce.json373
-rw-r--r--resource/sce.json371
-rw-r--r--resource/table_info.conf20
-rw-r--r--test/gtest_ctrl_pkt_active.cpp9
-rw-r--r--test/gtest_data_pkt_error_bypass.cpp2
-rw-r--r--test/gtest_data_pkt_mirr_block.cpp11
-rw-r--r--test/gtest_data_pkt_mirr_bypass.cpp11
-rw-r--r--test/gtest_data_pkt_mirr_forward.cpp11
-rw-r--r--test/gtest_data_pkt_mirr_rx_drop.cpp11
-rw-r--r--test/gtest_data_pkt_stee_block.cpp11
-rw-r--r--test/gtest_data_pkt_stee_bypass.cpp11
-rw-r--r--test/gtest_data_pkt_stee_forward.cpp11
-rw-r--r--test/gtest_data_pkt_stee_rx_egress.cpp11
-rw-r--r--test/gtest_mix_pkt_stee_forward.cpp22
-rw-r--r--test/test_data/conf/sce.conf5
-rw-r--r--test/test_data/log/test_ctr_pkt_active_ok.fs24
-rw-r--r--test/test_data/log/test_data_pkt_mirr_block_ok.fs24
-rw-r--r--test/test_data/log/test_data_pkt_mirr_bypass_ok.fs24
-rw-r--r--test/test_data/log/test_data_pkt_mirr_forward_ok.fs24
-rw-r--r--test/test_data/log/test_data_pkt_mirr_rx_drop_ok.fs24
-rw-r--r--test/test_data/log/test_data_pkt_stee_block_ok.fs24
-rw-r--r--test/test_data/log/test_data_pkt_stee_bypass_ok.fs24
-rw-r--r--test/test_data/log/test_data_pkt_stee_forward_ok.fs24
-rw-r--r--test/test_data/log/test_data_pkt_stee_rx_egress_ok.fs24
-rw-r--r--test/test_data/log/test_mix_pkt_stee_forward_ok.fs24
-rw-r--r--test/test_data/resource/data_pkt_mirr_block.json46
-rw-r--r--test/test_data/resource/data_pkt_mirr_bypass.json46
-rw-r--r--test/test_data/resource/data_pkt_mirr_forward.json46
-rw-r--r--test/test_data/resource/data_pkt_stee_block.json46
-rw-r--r--test/test_data/resource/data_pkt_stee_bypass.json46
-rw-r--r--test/test_data/resource/data_pkt_stee_forward.json46
-rw-r--r--test/test_data/resource/mix_pkt_stee_forward.json90
-rw-r--r--test/test_data/resource/sce0.json46
60 files changed, 2504 insertions, 1043 deletions
diff --git a/ci/travis.sh b/ci/travis.sh
index 4a7b6bd..aceff23 100644
--- a/ci/travis.sh
+++ b/ci/travis.sh
@@ -45,6 +45,7 @@ yum install -y libibverbs # required by mrzcpd
yum install -y libbreakpad_mini-devel
yum install -y librdkafka-1.2.2.1218b3c
yum install -y librdkafka-devel-1.2.2.1218b3c
+yum install -y libuuid-devel
if [ $ASAN_OPTION ] && [ -f "/opt/rh/devtoolset-7/enable" ]; then
source /opt/rh/devtoolset-7/enable
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 247786b..d5b0902 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -1,6 +1,6 @@
add_library(common src/session_table.cpp src/packet.cpp src/control_packet.cpp src/bfd.cpp src/utils.cpp src/vxlan.cpp src/log.cpp src/timestamp.cpp src/mpack.cpp src/kafka.cpp)
target_link_libraries(common PUBLIC cjson)
-target_link_libraries(common PUBLIC MESA_handle_logger rdkafka)
+target_link_libraries(common PUBLIC MESA_handle_logger rdkafka uuid)
target_include_directories(common PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
diff --git a/common/include/control_packet.h b/common/include/control_packet.h
index d955ec5..e36aad9 100644
--- a/common/include/control_packet.h
+++ b/common/include/control_packet.h
@@ -6,7 +6,7 @@ extern "C"
{
#endif
-#include <stdint.h>
+#include "utils.h"
enum session_state
{
@@ -36,8 +36,7 @@ struct control_packet
uint64_t session_id;
enum session_state state;
char method[32];
- uint64_t rule_ids[32];
- int rule_id_num;
+ struct uuid_array rule_uuid_array;
};
const char *session_state_to_string(enum session_state state);
diff --git a/common/include/utils.h b/common/include/utils.h
index 8319ed1..8a64a3e 100644
--- a/common/include/utils.h
+++ b/common/include/utils.h
@@ -33,25 +33,29 @@ extern "C"
#include <stdint.h>
#include <sys/types.h>
#include <netinet/in.h>
+#include <uuid/uuid.h>
/******************************************************************************
- * mutable_array
+ * uuid_array
******************************************************************************/
-struct mutable_array
+#define UUID_STRING_SIZE 37
+#define MAX_RULE_NUM 128
+
+struct uuid_array
{
- uint64_t elems[128];
+ uuid_t uuids[MAX_RULE_NUM];
int num;
int size;
};
-void mutable_array_init(struct mutable_array *array);
-void mutable_array_add_elem(struct mutable_array *array, uint64_t elem);
-void mutable_array_del_elem(struct mutable_array *array, uint64_t elem);
-int mutable_array_is_full(struct mutable_array *array);
-int mutable_array_count_elem(struct mutable_array *array);
-int mutable_array_exist_elem(struct mutable_array *array, uint64_t elem);
-int mutable_array_index_elem(struct mutable_array *array, int index);
+void uuid_array_init(struct uuid_array *array);
+void uuid_array_append(struct uuid_array *array, uuid_t uuid);
+void uuid_array_remove(struct uuid_array *array, uuid_t uuid);
+int uuid_array_contains(struct uuid_array *array, uuid_t uuid);
+int uuid_array_is_full(struct uuid_array *array);
+int uuid_array_get_count(struct uuid_array *array);
+uuid_t *uuid_array_get_at(struct uuid_array *array, int index);
/******************************************************************************
* device
diff --git a/common/src/control_packet.cpp b/common/src/control_packet.cpp
index 27d3539..58e7f60 100644
--- a/common/src/control_packet.cpp
+++ b/common/src/control_packet.cpp
@@ -57,7 +57,9 @@ const char *session_state_to_string(enum session_state state)
enum control_packet_state control_packet_parse(struct control_packet *handler, const char *data, size_t length)
{
memset(handler, 0, sizeof(struct control_packet));
+ uuid_array_init(&handler->rule_uuid_array);
+ int rule_id_num;
mpack_tree_t tree;
mpack_node_t root;
mpack_node_t temp;
@@ -186,17 +188,18 @@ enum control_packet_state control_packet_parse(struct control_packet *handler, c
state = CTRL_PKT_INVALID_RULE_IDS;
goto error_out;
}
- handler->rule_id_num = MIN(mpack_node_array_length(temp), (int)(sizeof(handler->rule_ids) / sizeof(handler->rule_ids[0])));
- if (handler->rule_id_num <= 0)
+ rule_id_num = MIN(mpack_node_array_length(temp), MAX_RULE_NUM);
+ if (rule_id_num <= 0)
{
LOG_ERROR("%s: unexpected control packet: (invalid rule id num) %ld", LOG_TAG_CTRLPKT, mpack_node_array_length(temp));
state = CTRL_PKT_INVALID_RULE_IDS;
goto error_out;
}
- for (int i = 0; i < handler->rule_id_num; i++)
+ for (int i = 0; i < rule_id_num; i++)
{
item = mpack_node_array_at(temp, i);
- handler->rule_ids[i] = mpack_node_u64(item);
+ assert(mpack_node_bin_size(item) == 16);
+ uuid_array_append(&handler->rule_uuid_array, *(uuid_t *)mpack_node_bin_data(item));
}
success_out:
@@ -219,15 +222,18 @@ void control_packet_dump(struct control_packet *handler)
{
if (handler)
{
+ int count = uuid_array_get_count(&handler->rule_uuid_array);
LOG_INFO("%s: tsync : %s", LOG_TAG_POLICY, handler->tsync);
LOG_INFO("%s: session_id : %lu", LOG_TAG_POLICY, handler->session_id);
LOG_INFO("%s: state : %s", LOG_TAG_POLICY, session_state_to_string(handler->state));
LOG_INFO("%s: method : %s", LOG_TAG_POLICY, handler->method);
- LOG_INFO("%s: rule_id_num : %d", LOG_TAG_POLICY, handler->rule_id_num);
+ LOG_INFO("%s: rule_id_num : %d", LOG_TAG_POLICY, count);
- for (int i = 0; i < handler->rule_id_num; i++)
+ for (int i = 0; i < count; i++)
{
- LOG_INFO("%s: rule_ids[%03d] : %lu", LOG_TAG_POLICY, i, handler->rule_ids[i]);
+ char rule_uuid_str[UUID_STRING_SIZE] = {0};
+ uuid_unparse(*uuid_array_get_at(&handler->rule_uuid_array, i), rule_uuid_str);
+ LOG_INFO("%s: rule_ids[%03d] : %s", LOG_TAG_POLICY, i, rule_uuid_str);
}
}
}
diff --git a/common/src/kafka.cpp b/common/src/kafka.cpp
index 4fb0e68..737a2e2 100644
--- a/common/src/kafka.cpp
+++ b/common/src/kafka.cpp
@@ -11,6 +11,7 @@
struct config
{
+ int enable_debug;
char brokerlist[MAX_SYMBOL_LEN];
char sasl_username[MAX_SYMBOL_LEN];
char sasl_passwd[MAX_SYMBOL_LEN];
@@ -84,6 +85,14 @@ static struct per_producer_per_topic *per_producer_per_topic_new(const char *bro
LOG_ERROR("%s: failed to set kafka client.id, %s", LOG_TAG_KAFKA, err_str);
goto error_out;
}
+
+ // bootstrap.servers
+ if (rd_kafka_conf_set(conf, "bootstrap.servers", brokerlist, err_str, sizeof(err_str)) != RD_KAFKA_CONF_OK)
+ {
+ LOG_ERROR("%s: failed to set kafka bootstrap.servers, %s", LOG_TAG_KAFKA, err_str);
+ goto error_out;
+ }
+
if (strlen(sasl_username) > 0 && strlen(sasl_passwd) > 0)
{
if (rd_kafka_conf_set(conf, "security.protocol", "sasl_plaintext", err_str, sizeof(err_str)) != RD_KAFKA_CONF_OK)
@@ -125,12 +134,6 @@ static struct per_producer_per_topic *per_producer_per_topic_new(const char *bro
goto error_out;
}
- if (rd_kafka_brokers_add(pppt->producer, brokerlist) == 0)
- {
- LOG_ERROR("%s: failed to add kafka brokers", LOG_TAG_KAFKA);
- goto error_out;
- }
-
pppt->topic = rd_kafka_topic_new(pppt->producer, topic_name, NULL);
if (pppt->topic == NULL)
{
@@ -163,6 +166,7 @@ struct kafka *kafka_create(const char *profile)
return NULL;
}
+ MESA_load_profile_int_def(profile, "kafka", "enable_debug", &handle->cfg.enable_debug, 0);
MESA_load_profile_string_def(profile, "kafka", "brokerlist", handle->cfg.brokerlist, sizeof(handle->cfg.brokerlist), "");
MESA_load_profile_string_def(profile, "kafka", "sasl_username", handle->cfg.sasl_username, sizeof(handle->cfg.sasl_username), "");
MESA_load_profile_string_def(profile, "kafka", "sasl_passwd", handle->cfg.sasl_passwd, sizeof(handle->cfg.sasl_passwd), "");
@@ -237,7 +241,10 @@ int kafka_send(struct kafka *handle, enum topic_idx idx, const char *data, int l
}
else
{
- LOG_DEBUG("%s: success to produce message with topic [%d], %s", LOG_TAG_KAFKA, idx, data);
+ if (handle->cfg.enable_debug)
+ {
+ LOG_DEBUG("%s: success to produce message with topic [%d], %s", LOG_TAG_KAFKA, idx, data);
+ }
return 0;
}
}
diff --git a/common/src/utils.cpp b/common/src/utils.cpp
index 773b1f2..8fb944a 100644
--- a/common/src/utils.cpp
+++ b/common/src/utils.cpp
@@ -12,38 +12,38 @@
#include "log.h"
/******************************************************************************
- * mutable_array
+ * uuid_array
******************************************************************************/
-void mutable_array_init(struct mutable_array *array)
+void uuid_array_init(struct uuid_array *array)
{
- memset(array, 0, sizeof(mutable_array));
+ memset(array, 0, sizeof(uuid_array));
array->num = 0;
- array->size = sizeof(array->elems) / sizeof(array->elems[0]);
+ array->size = sizeof(array->uuids) / sizeof(array->uuids[0]);
}
-void mutable_array_add_elem(struct mutable_array *array, uint64_t elem)
+void uuid_array_append(struct uuid_array *array, uuid_t uuid)
{
if (array->num < array->size)
{
- array->elems[array->num] = elem;
+ uuid_copy(array->uuids[array->num], uuid);
array->num++;
}
else
{
- LOG_ERROR("%s: fixed num array add elem too much !!!", LOG_TAG_UTILS);
+ LOG_ERROR("%s: uuid array add elem too much !!!", LOG_TAG_UTILS);
}
}
-void mutable_array_del_elem(struct mutable_array *array, uint64_t elem)
+void uuid_array_remove(struct uuid_array *array, uuid_t uuid)
{
for (int i = 0; i < array->num; i++)
{
- if (array->elems[i] == elem)
+ if (uuid_compare(array->uuids[i], uuid) == 0)
{
if (i + 1 != array->size)
{
- memmove(&(array->elems[i]), &(array->elems[i + 1]), sizeof(array->elems[0]) * (array->num - i - 1));
+ memmove(&(array->uuids[i]), &(array->uuids[i + 1]), sizeof(array->uuids[0]) * (array->num - i - 1));
}
i--;
array->num--;
@@ -51,7 +51,20 @@ void mutable_array_del_elem(struct mutable_array *array, uint64_t elem)
}
}
-int mutable_array_is_full(struct mutable_array *array)
+int uuid_array_contains(struct uuid_array *array, uuid_t uuid)
+{
+ for (int i = 0; i < array->num; i++)
+ {
+ if (uuid_compare(array->uuids[i], uuid) == 0)
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+int uuid_array_is_full(struct uuid_array *array)
{
if (array->num == array->size)
{
@@ -63,7 +76,7 @@ int mutable_array_is_full(struct mutable_array *array)
}
}
-int mutable_array_count_elem(struct mutable_array *array)
+int uuid_array_get_count(struct uuid_array *array)
{
if (array)
{
@@ -75,27 +88,17 @@ int mutable_array_count_elem(struct mutable_array *array)
}
}
-int mutable_array_exist_elem(struct mutable_array *array, uint64_t elem)
-{
- for (int i = 0; i < array->num; i++)
- {
- if (array->elems[i] == elem)
- {
- return 1;
- }
- }
-
- return 0;
-}
-
-int mutable_array_index_elem(struct mutable_array *array, int index)
+uuid_t *uuid_array_get_at(struct uuid_array *array, int index)
{
if (index >= array->num)
{
assert(0);
+ return NULL;
+ }
+ else
+ {
+ return &(array->uuids[index]);
}
-
- return array->elems[index];
}
/******************************************************************************
diff --git a/common/test/gtest_control_packet.cpp b/common/test/gtest_control_packet.cpp
index b010b63..3473b82 100644
--- a/common/test/gtest_control_packet.cpp
+++ b/common/test/gtest_control_packet.cpp
@@ -9,18 +9,23 @@ static u_char control_packet_active0[] = {
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x83, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x92, 0xCD, 0x04, 0x57, 0xCD, 0x08, 0xAE, 0xA6, 0x73,
- 0x68, 0x61, 0x70, 0x65, 0x72, 0x81, 0xA8, 0x72, 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x92,
- 0xCD, 0x0D, 0x05, 0xCD, 0x11, 0x5C, 0xA5, 0x70, 0x72, 0x6F, 0x78, 0x79, 0x82, 0xA8, 0x72, 0x75,
- 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x92, 0xCD, 0x15, 0xB3, 0xCD, 0x1A, 0x0A, 0xAD, 0x74, 0x63,
- 0x70, 0x5F, 0x68, 0x61, 0x6E, 0x64, 0x73, 0x68, 0x61, 0x6B, 0x65, 0xDC, 0x00, 0x24, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xA3, 0x31,
- 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31,
- 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31,
- 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31,
- 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0x92, 0xCD, 0x15, 0xB3, 0xCD, 0x1A,
- 0x0A, 0x92, 0xCD, 0x15, 0xB3, 0xCD, 0x1A, 0x0A, 0x92, 0xCD, 0x15, 0xB3, 0xCD, 0x1A, 0x0A, 0x92,
- 0x01, 0x01, 0x92, 0x01, 0x01};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x92, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xA6, 0x73, 0x68, 0x61,
+ 0x70, 0x65, 0x72, 0x81, 0xA8, 0x72, 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x92, 0xC4, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
+ 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0xA5, 0x70, 0x72, 0x6F, 0x78, 0x79, 0x82, 0xA8, 0x72, 0x75, 0x6C, 0x65, 0x5F, 0x69,
+ 0x64, 0x73, 0x92, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x05, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xAD, 0x74, 0x63, 0x70, 0x5F, 0x68, 0x61, 0x6E, 0x64,
+ 0x73, 0x68, 0x61, 0x6B, 0x65, 0xDC, 0x00, 0x24, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33,
+ 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33,
+ 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33,
+ 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33, 0xA3, 0x31, 0x32, 0x33,
+ 0xA3, 0x31, 0x32, 0x33, 0x92, 0xCD, 0x15, 0xB3, 0xCD, 0x1A, 0x0A, 0x92, 0xCD, 0x15, 0xB3, 0xCD,
+ 0x1A, 0x0A, 0x92, 0xCD, 0x15, 0xB3, 0xCD, 0x1A, 0x0A, 0x92, 0x01, 0x01, 0x92, 0x01, 0x01};
static u_char control_packet_active1[] = {
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
@@ -28,13 +33,45 @@ static u_char control_packet_active1[] = {
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x7F};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
static u_char control_packet_opening[] = {
0x83, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA7, 0x6F, 0x70, 0x65, 0x6E, 0x69, 0x6E, 0x67};
+static u_char control_packet_send[] = {
+ 0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0x01, 0xA5, 0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63,
+ 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0xAA, 0x6C, 0x6F, 0x67, 0x5F,
+ 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73,
+ 0x63, 0x65, 0x83, 0xAC, 0x73, 0x63, 0x5F, 0x72, 0x75, 0x6C, 0x65, 0x5F, 0x6C, 0x69, 0x73, 0x74,
+ 0x92, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0xAA, 0x73, 0x63, 0x5F, 0x72, 0x73, 0x70, 0x5F, 0x72, 0x61, 0x77,
+ 0x92, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x03, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0xB0, 0x73, 0x63, 0x5F, 0x72, 0x73, 0x70, 0x5F, 0x64, 0x65, 0x63,
+ 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x92, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04};
+
+static uuid_t uuid1;
+static uuid_t uuid2;
+static uuid_t uuid3;
+static uuid_t uuid4;
+static uuid_t uuid5;
+static uuid_t uuid6;
+
+static const char *uuid1_str = "00000000-0000-0000-0000-000000000001";
+static const char *uuid2_str = "00000000-0000-0000-0000-000000000002";
+static const char *uuid3_str = "00000000-0000-0000-0000-000000000003";
+static const char *uuid4_str = "00000000-0000-0000-0000-000000000004";
+static const char *uuid5_str = "00000000-0000-0000-0000-000000000005";
+static const char *uuid6_str = "00000000-0000-0000-0000-000000000006";
+
+#if 1
TEST(CONTROL_PACKET, PACKAGE0)
{
char *data;
@@ -73,10 +110,9 @@ TEST(CONTROL_PACKET, PACKAGE0)
mpack_write_cstr(&writer, "rule_ids");
mpack_build_array(&writer);
- mpack_write_u64(&writer, 1111);
- mpack_write_u64(&writer, 2222);
+ mpack_write_bin(&writer, (const char *)&uuid1, sizeof(uuid1));
+ mpack_write_bin(&writer, (const char *)&uuid2, sizeof(uuid2));
mpack_complete_array(&writer);
-
mpack_complete_map(&writer);
}
@@ -87,8 +123,8 @@ TEST(CONTROL_PACKET, PACKAGE0)
mpack_write_cstr(&writer, "rule_ids");
mpack_build_array(&writer);
- mpack_write_u64(&writer, 3333);
- mpack_write_u64(&writer, 4444);
+ mpack_write_bin(&writer, (const char *)&uuid3, sizeof(uuid3));
+ mpack_write_bin(&writer, (const char *)&uuid4, sizeof(uuid4));
mpack_complete_array(&writer);
mpack_complete_map(&writer);
@@ -101,8 +137,8 @@ TEST(CONTROL_PACKET, PACKAGE0)
mpack_write_cstr(&writer, "rule_ids");
mpack_build_array(&writer);
- mpack_write_u64(&writer, 5555);
- mpack_write_u64(&writer, 6666);
+ mpack_write_bin(&writer, (const char *)&uuid5, sizeof(uuid5));
+ mpack_write_bin(&writer, (const char *)&uuid6, sizeof(uuid6));
mpack_complete_array(&writer);
mpack_write_cstr(&writer, "tcp_handshake");
@@ -183,7 +219,9 @@ TEST(CONTROL_PACKET, PACKAGE0)
free(data);
}
+#endif
+#if 1
TEST(CONTROL_PACKET, PACKAGE1)
{
char *data;
@@ -222,7 +260,7 @@ TEST(CONTROL_PACKET, PACKAGE1)
mpack_write_cstr(&writer, "rule_ids");
mpack_build_array(&writer);
- mpack_write_u64(&writer, 995199);
+ mpack_write_bin(&writer, (const char *)&uuid1, sizeof(uuid1));
mpack_complete_array(&writer);
mpack_complete_map(&writer);
@@ -247,7 +285,9 @@ TEST(CONTROL_PACKET, PACKAGE1)
free(data);
}
+#endif
+#if 1
TEST(CONTROL_PACKET, PACKAGE2)
{
char *data;
@@ -286,9 +326,12 @@ TEST(CONTROL_PACKET, PACKAGE2)
free(data);
}
+#endif
+#if 1
TEST(CONTROL_PACKET, PARSE0)
{
+ char rule_uuid_str[UUID_STRING_SIZE];
struct control_packet handler;
EXPECT_TRUE(control_packet_parse(&handler, (const char *)control_packet_active0, sizeof(control_packet_active0)) == CTRL_PKT_SUCCESS);
control_packet_dump(&handler);
@@ -297,13 +340,20 @@ TEST(CONTROL_PACKET, PARSE0)
EXPECT_TRUE(handler.session_id == 18446744073709551615);
EXPECT_TRUE(handler.state == SESSION_STATE_ACTIVE);
EXPECT_STREQ(handler.method, "policy_update");
- EXPECT_TRUE(handler.rule_id_num == 2);
- EXPECT_TRUE(handler.rule_ids[0] == 1111);
- EXPECT_TRUE(handler.rule_ids[1] == 2222);
+ EXPECT_TRUE(uuid_array_get_count(&handler.rule_uuid_array) == 2);
+
+ uuid_unparse(*uuid_array_get_at(&handler.rule_uuid_array, 0), rule_uuid_str);
+ EXPECT_STREQ(rule_uuid_str, uuid1_str);
+
+ uuid_unparse(*uuid_array_get_at(&handler.rule_uuid_array, 1), rule_uuid_str);
+ EXPECT_STREQ(rule_uuid_str, uuid2_str);
}
+#endif
+#if 1
TEST(CONTROL_PACKET, PARSE1)
{
+ char rule_uuid_str[UUID_STRING_SIZE];
struct control_packet handler;
EXPECT_TRUE(control_packet_parse(&handler, (const char *)control_packet_active1, sizeof(control_packet_active1)) == CTRL_PKT_SUCCESS);
control_packet_dump(&handler);
@@ -312,10 +362,14 @@ TEST(CONTROL_PACKET, PARSE1)
EXPECT_TRUE(handler.session_id == 290484492702581737);
EXPECT_TRUE(handler.state == SESSION_STATE_ACTIVE);
EXPECT_STREQ(handler.method, "policy_update");
- EXPECT_TRUE(handler.rule_id_num == 1);
- EXPECT_TRUE(handler.rule_ids[0] == 995199);
+ EXPECT_TRUE(uuid_array_get_count(&handler.rule_uuid_array) == 1);
+
+ uuid_unparse(*uuid_array_get_at(&handler.rule_uuid_array, 0), rule_uuid_str);
+ EXPECT_STREQ(rule_uuid_str, uuid1_str);
}
+#endif
+#if 1
TEST(CONTROL_PACKET, PARSE2)
{
struct control_packet handler;
@@ -326,11 +380,130 @@ TEST(CONTROL_PACKET, PARSE2)
EXPECT_TRUE(handler.session_id == 290484492702581737);
EXPECT_TRUE(handler.state == SESSION_STATE_OPENING);
EXPECT_STREQ(handler.method, "");
- EXPECT_TRUE(handler.rule_id_num == 0);
+ EXPECT_TRUE(uuid_array_get_count(&handler.rule_uuid_array) == 0);
+}
+#endif
+
+#if 1
+TEST(CONTROL_PACKET, SEND)
+{
+ uint64_t session_id = 1;
+
+ struct uuid_array rule_uuid_array;
+ uuid_array_init(&rule_uuid_array);
+ uuid_array_append(&rule_uuid_array, uuid1);
+ uuid_array_append(&rule_uuid_array, uuid2);
+ int rule_num = uuid_array_get_count(&rule_uuid_array);
+
+ struct uuid_array sf_uuid_array;
+ uuid_array_init(&sf_uuid_array);
+ uuid_array_append(&sf_uuid_array, uuid3);
+ uuid_array_append(&sf_uuid_array, uuid4);
+ int sf_num = uuid_array_get_count(&sf_uuid_array);
+
+ char *data;
+ size_t size;
+ mpack_writer_t writer;
+ mpack_writer_init_growable(&writer, &data, &size);
+
+ // write the example on the msgpack homepage
+ mpack_build_map(&writer); // root begin
+
+ // tsync
+ mpack_write_cstr(&writer, "tsync");
+ mpack_write_cstr(&writer, "2.0");
+
+ // session_id
+ mpack_write_cstr(&writer, "session_id");
+ mpack_write_u64(&writer, session_id);
+
+ // state
+ mpack_write_cstr(&writer, "state");
+ mpack_write_cstr(&writer, "active");
+
+ // method
+ mpack_write_cstr(&writer, "method");
+ mpack_write_cstr(&writer, "log_update");
+
+ // params
+ {
+ mpack_write_cstr(&writer, "params");
+ mpack_build_map(&writer); // params value begin
+
+ // sce
+ {
+ mpack_write_cstr(&writer, "sce");
+ mpack_build_map(&writer); // sce value begin
+
+ {
+ mpack_write_cstr(&writer, "sc_rule_list");
+ mpack_build_array(&writer); // sc_rule_list begin
+ for (int i = 0; i < rule_num; i++)
+ {
+ mpack_write_bin(&writer, (const char *)uuid_array_get_at(&rule_uuid_array, i), sizeof(uuid_t));
+ }
+ mpack_complete_array(&writer); // sc_rule_list end
+ }
+
+ {
+ mpack_write_cstr(&writer, "sc_rsp_raw");
+ mpack_build_array(&writer); // sc_rsp_raw begin
+ for (int i = 0; i < sf_num; i++)
+ {
+ mpack_write_bin(&writer, (const char *)uuid_array_get_at(&sf_uuid_array, i), sizeof(uuid_t));
+ }
+ mpack_complete_array(&writer); // sc_rsp_raw end
+ }
+
+ {
+ mpack_write_cstr(&writer, "sc_rsp_decrypted");
+ mpack_build_array(&writer); // sc_rsp_decrypted begin
+ for (int i = 0; i < sf_num; i++)
+ {
+ mpack_write_bin(&writer, (const char *)uuid_array_get_at(&sf_uuid_array, i), sizeof(uuid_t));
+ }
+ mpack_complete_array(&writer); // sc_rsp_decrypted end
+ }
+
+ mpack_complete_map(&writer); // sce value end
+ }
+
+ mpack_complete_map(&writer); // params value end
+ }
+
+ mpack_complete_map(&writer); // root end
+
+ // finish writing
+ if (mpack_writer_destroy(&writer) != mpack_ok)
+ {
+ assert(0);
+ if (data)
+ {
+ free(data);
+ data = NULL;
+ }
+ }
+
+ for (size_t i = 0; i < size; i++)
+ {
+ printf("%02X, ", data[i]);
+ }
+ printf("\n");
+
+ EXPECT_STREQ(data, (const char *)control_packet_send);
+ free(data);
}
+#endif
int main(int argc, char **argv)
{
+ uuid_parse(uuid1_str, uuid1);
+ uuid_parse(uuid2_str, uuid2);
+ uuid_parse(uuid3_str, uuid3);
+ uuid_parse(uuid4_str, uuid4);
+ uuid_parse(uuid5_str, uuid5);
+ uuid_parse(uuid6_str, uuid6);
+
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} \ No newline at end of file
diff --git a/common/test/gtest_health_check_table.cpp b/common/test/gtest_health_check_table.cpp
index f48892d..f7dcb4e 100644
--- a/common/test/gtest_health_check_table.cpp
+++ b/common/test/gtest_health_check_table.cpp
@@ -5,6 +5,13 @@
#include "policy.h"
#include "health_check.h"
+uuid_t sf_uuid1;
+uuid_t sf_uuid2;
+uuid_t sf_uuid3;
+uuid_t sf_uuid4;
+uuid_t sf_uuid5;
+uuid_t sf_uuid6;
+
TEST(HEALTH_CHECK_TABLE, INSERT)
{
uint64_t session_id1 = 0;
@@ -22,7 +29,7 @@ TEST(HEALTH_CHECK_TABLE, INSERT)
snprintf(policy1.address, sizeof(policy1.address), "1.1.1.1");
policy1.retires = 11;
policy1.interval_ms = 111;
- EXPECT_TRUE((session_id1 = health_check_session_add(1, 0, &policy1)) > 0);
+ EXPECT_TRUE((session_id1 = health_check_session_add(&sf_uuid1, 0, &policy1)) > 0);
struct health_check policy2;
memset(&policy2, 0, sizeof(policy2));
@@ -30,8 +37,8 @@ TEST(HEALTH_CHECK_TABLE, INSERT)
snprintf(policy2.address, sizeof(policy2.address), "2.2.2.2");
policy2.retires = 22;
policy2.interval_ms = 222;
- EXPECT_TRUE((session_id2 = health_check_session_add(2, 0, &policy2)) > 0);
- EXPECT_TRUE((session_id3 = health_check_session_add(3, 0, &policy2)) > 0);
+ EXPECT_TRUE((session_id2 = health_check_session_add(&sf_uuid2, 0, &policy2)) > 0);
+ EXPECT_TRUE((session_id3 = health_check_session_add(&sf_uuid3, 0, &policy2)) > 0);
struct health_check policy3;
memset(&policy3, 0, sizeof(policy3));
@@ -39,15 +46,15 @@ TEST(HEALTH_CHECK_TABLE, INSERT)
snprintf(policy3.address, sizeof(policy3.address), "2001:0db8:0000:0000:0000:8a2e:0370:7334");
policy3.retires = 33;
policy3.interval_ms = 333;
- EXPECT_TRUE((session_id4 = health_check_session_add(4, 0, &policy3)) > 0);
- EXPECT_TRUE((session_id5 = health_check_session_add(5, 0, &policy3)) > 0);
+ EXPECT_TRUE((session_id4 = health_check_session_add(&sf_uuid4, 0, &policy3)) > 0);
+ EXPECT_TRUE((session_id5 = health_check_session_add(&sf_uuid5, 0, &policy3)) > 0);
// TEST Delete By Session ID
- EXPECT_TRUE(health_check_session_del(session_id1, 1, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id2, 2, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id3, 3, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id4, 4, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id5, 5, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id1, &sf_uuid1, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id2, &sf_uuid2, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id3, &sf_uuid3, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id4, &sf_uuid4, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id5, &sf_uuid5, 0) == 0);
}
TEST(HEALTH_CHECK_TABLE, GET_STATUS)
@@ -63,7 +70,7 @@ TEST(HEALTH_CHECK_TABLE, GET_STATUS)
snprintf(policy1.address, sizeof(policy1.address), "4.4.4.4");
policy1.retires = 5;
policy1.interval_ms = 300;
- EXPECT_TRUE((session_id1 = health_check_session_add(1, 0, &policy1)) > 0);
+ EXPECT_TRUE((session_id1 = health_check_session_add(&sf_uuid1, 0, &policy1)) > 0);
struct health_check policy2;
memset(&policy2, 0, sizeof(policy2));
@@ -71,7 +78,7 @@ TEST(HEALTH_CHECK_TABLE, GET_STATUS)
snprintf(policy2.address, sizeof(policy2.address), "5.5.5.5");
policy2.retires = 5;
policy2.interval_ms = 300;
- EXPECT_TRUE((session_id2 = health_check_session_add(2, 0, &policy2)) > 0);
+ EXPECT_TRUE((session_id2 = health_check_session_add(&sf_uuid2, 0, &policy2)) > 0);
struct health_check policy3;
memset(&policy3, 0, sizeof(policy3));
@@ -79,7 +86,7 @@ TEST(HEALTH_CHECK_TABLE, GET_STATUS)
snprintf(policy3.address, sizeof(policy3.address), "6.6.6.6");
policy3.retires = 5;
policy3.interval_ms = 300;
- EXPECT_TRUE((session_id3 = health_check_session_add(3, 0, &policy3)) > 0);
+ EXPECT_TRUE((session_id3 = health_check_session_add(&sf_uuid3, 0, &policy3)) > 0);
// TEST get status
EXPECT_TRUE(health_check_session_get_status(session_id1) == 0);
@@ -88,9 +95,9 @@ TEST(HEALTH_CHECK_TABLE, GET_STATUS)
EXPECT_TRUE(health_check_session_get_status(7) == -1);
// TEST Delete By Session ID
- EXPECT_TRUE(health_check_session_del(session_id1, 1, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id2, 2, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id3, 3, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id1, &sf_uuid1, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id2, &sf_uuid2, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id3, &sf_uuid3, 0) == 0);
}
TEST(HEALTH_CHECK_TABLE, SET_STATUS)
@@ -106,7 +113,7 @@ TEST(HEALTH_CHECK_TABLE, SET_STATUS)
snprintf(policy1.address, sizeof(policy1.address), "7.7.7.7");
policy1.retires = 5;
policy1.interval_ms = 300;
- EXPECT_TRUE((session_id1 = health_check_session_add(1, 0, &policy1)) > 0);
+ EXPECT_TRUE((session_id1 = health_check_session_add(&sf_uuid1, 0, &policy1)) > 0);
struct health_check policy2;
memset(&policy2, 0, sizeof(policy2));
@@ -114,7 +121,7 @@ TEST(HEALTH_CHECK_TABLE, SET_STATUS)
snprintf(policy2.address, sizeof(policy2.address), "8.8.8.8");
policy2.retires = 5;
policy2.interval_ms = 300;
- EXPECT_TRUE((session_id2 = health_check_session_add(2, 0, &policy2)) > 0);
+ EXPECT_TRUE((session_id2 = health_check_session_add(&sf_uuid2, 0, &policy2)) > 0);
struct health_check policy3;
memset(&policy3, 0, sizeof(policy3));
@@ -122,7 +129,7 @@ TEST(HEALTH_CHECK_TABLE, SET_STATUS)
snprintf(policy3.address, sizeof(policy3.address), "9.9.9.9");
policy3.retires = 5;
policy3.interval_ms = 300;
- EXPECT_TRUE((session_id3 = health_check_session_add(3, 0, &policy3)) > 0);
+ EXPECT_TRUE((session_id3 = health_check_session_add(&sf_uuid3, 0, &policy3)) > 0);
// TEST get status
EXPECT_TRUE(health_check_session_get_status(session_id1) == 0);
@@ -141,9 +148,9 @@ TEST(HEALTH_CHECK_TABLE, SET_STATUS)
EXPECT_TRUE(health_check_session_get_status(session_id3) == 1);
// TEST Delete By Session ID
- EXPECT_TRUE(health_check_session_del(session_id1, 1, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id2, 2, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id3, 3, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id1, &sf_uuid1, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id2, &sf_uuid2, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id3, &sf_uuid3, 0) == 0);
}
#if 0
@@ -163,7 +170,7 @@ TEST(HEALTH_CHECK_TABLE, DELETE)
snprintf(policy1.address, sizeof(policy1.address), "10.10.10.10");
policy1.retires = 5;
policy1.interval_ms = 300;
- EXPECT_TRUE((session_id1 = health_check_session_add(1, 0, &policy1)) > 0);
+ EXPECT_TRUE((session_id1 = health_check_session_add(&sf_uuid1, 0, &policy1)) > 0);
struct health_check policy2;
memset(&policy2, 0, sizeof(policy2));
@@ -171,8 +178,8 @@ TEST(HEALTH_CHECK_TABLE, DELETE)
snprintf(policy2.address, sizeof(policy2.address), "11.11.11.11");
policy2.retires = 5;
policy2.interval_ms = 300;
- EXPECT_TRUE((session_id2 = health_check_session_add(2, 0, &policy2)) > 0);
- EXPECT_TRUE((session_id3 = health_check_session_add(3, 0, &policy2)) > 0);
+ EXPECT_TRUE((session_id2 = health_check_session_add(&sf_uuid2, 0, &policy2)) > 0);
+ EXPECT_TRUE((session_id3 = health_check_session_add(&sf_uuid3, 0, &policy2)) > 0);
struct health_check policy3;
memset(&policy3, 0, sizeof(policy3));
@@ -180,25 +187,32 @@ TEST(HEALTH_CHECK_TABLE, DELETE)
snprintf(policy3.address, sizeof(policy3.address), "12.12.12.12");
policy3.retires = 5;
policy3.interval_ms = 300;
- EXPECT_TRUE((session_id4 = health_check_session_add(4, 0, &policy3)) > 0);
- EXPECT_TRUE((session_id5 = health_check_session_add(5, 0, &policy3)) > 0);
- EXPECT_TRUE((session_id6 = health_check_session_add(6, 0, &policy3)) > 0);
+ EXPECT_TRUE((session_id4 = health_check_session_add(&sf_uuid4, 0, &policy3)) > 0);
+ EXPECT_TRUE((session_id5 = health_check_session_add(&sf_uuid5, 0, &policy3)) > 0);
+ EXPECT_TRUE((session_id6 = health_check_session_add(&sf_uuid6, 0, &policy3)) > 0);
// TEST Delete By Session ID
- EXPECT_TRUE(health_check_session_del(session_id1, 1, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id1, 1, 0) == -1);
- EXPECT_TRUE(health_check_session_del(session_id2, 2, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id3, 3, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id3, 3, 0) == -1);
- EXPECT_TRUE(health_check_session_del(session_id5, 4, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id5, 5, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id6, 6, 0) == 0);
- EXPECT_TRUE(health_check_session_del(session_id6, 6, 0) == -1);
+ EXPECT_TRUE(health_check_session_del(session_id1, &sf_uuid1, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id1, &sf_uuid1, 0) == -1);
+ EXPECT_TRUE(health_check_session_del(session_id2, &sf_uuid2, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id3, &sf_uuid3, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id3, &sf_uuid3, 0) == -1);
+ EXPECT_TRUE(health_check_session_del(session_id5, &sf_uuid4, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id5, &sf_uuid5, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id6, &sf_uuid6, 0) == 0);
+ EXPECT_TRUE(health_check_session_del(session_id6, &sf_uuid6, 0) == -1);
}
#endif
int main(int argc, char **argv)
{
+ uuid_parse("00000000-0000-0000-0000-000000000001", sf_uuid1);
+ uuid_parse("00000000-0000-0000-0000-000000000002", sf_uuid2);
+ uuid_parse("00000000-0000-0000-0000-000000000003", sf_uuid3);
+ uuid_parse("00000000-0000-0000-0000-000000000004", sf_uuid4);
+ uuid_parse("00000000-0000-0000-0000-000000000005", sf_uuid5);
+ uuid_parse("00000000-0000-0000-0000-000000000006", sf_uuid6);
+
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} \ No newline at end of file
diff --git a/common/test/gtest_utils.cpp b/common/test/gtest_utils.cpp
index 9b50c62..0cb312b 100644
--- a/common/test/gtest_utils.cpp
+++ b/common/test/gtest_utils.cpp
@@ -2,38 +2,117 @@
#include "utils.h"
-TEST(UTILS, FIXED_NUM_ARRAY)
+TEST(UUID_ARRAY, FULL)
{
- struct mutable_array array;
- mutable_array_init(&array);
-
- mutable_array_add_elem(&array, 1);
- mutable_array_add_elem(&array, 2);
- mutable_array_add_elem(&array, 3);
- mutable_array_add_elem(&array, 1);
- mutable_array_add_elem(&array, 2);
-
- EXPECT_TRUE(mutable_array_count_elem(&array) == 5);
- EXPECT_TRUE(mutable_array_index_elem(&array, 0) == 1);
- EXPECT_TRUE(mutable_array_index_elem(&array, 1) == 2);
- EXPECT_TRUE(mutable_array_index_elem(&array, 2) == 3);
- EXPECT_TRUE(mutable_array_index_elem(&array, 3) == 1);
- EXPECT_TRUE(mutable_array_index_elem(&array, 4) == 2);
-
- mutable_array_del_elem(&array, 3); // 1,2,1,2
- EXPECT_TRUE(mutable_array_count_elem(&array) == 4);
- EXPECT_TRUE(mutable_array_index_elem(&array, 0) == 1);
- EXPECT_TRUE(mutable_array_index_elem(&array, 1) == 2);
- EXPECT_TRUE(mutable_array_index_elem(&array, 2) == 1);
- EXPECT_TRUE(mutable_array_index_elem(&array, 3) == 2);
-
- mutable_array_del_elem(&array, 2); // 1,1
- EXPECT_TRUE(mutable_array_count_elem(&array) == 2);
- EXPECT_TRUE(mutable_array_index_elem(&array, 0) == 1);
- EXPECT_TRUE(mutable_array_index_elem(&array, 1) == 1);
-
- mutable_array_del_elem(&array, 1);
- EXPECT_TRUE(mutable_array_count_elem(&array) == 0);
+ uuid_t uuid;
+ uuid_parse("00000000-0000-0000-0000-000000000001", uuid);
+
+ struct uuid_array array;
+ uuid_array_init(&array);
+ EXPECT_TRUE(uuid_array_is_full(&array) == 0);
+
+ for (int i = 0; i < MAX_RULE_NUM; i++)
+ {
+ uuid_array_append(&array, uuid);
+ if (i == MAX_RULE_NUM - 1)
+ {
+ EXPECT_TRUE(uuid_array_is_full(&array) == 1);
+ }
+ else
+ {
+ EXPECT_TRUE(uuid_array_is_full(&array) == 0);
+ }
+ }
+
+ EXPECT_TRUE(uuid_array_is_full(&array) == 1);
+}
+
+TEST(UUID_ARRAY, COUNT)
+{
+ uuid_t uuid;
+ uuid_parse("00000000-0000-0000-0000-000000000001", uuid);
+
+ struct uuid_array array;
+ uuid_array_init(&array);
+ EXPECT_TRUE(uuid_array_get_count(&array) == 0);
+
+ for (int i = 0; i < MAX_RULE_NUM; i++)
+ {
+ uuid_array_append(&array, uuid);
+ EXPECT_TRUE(uuid_array_get_count(&array) == i + 1);
+ }
+
+ EXPECT_TRUE(uuid_array_get_count(&array) == MAX_RULE_NUM);
+}
+
+TEST(UUID_ARRAY, CONTAINS)
+{
+ uuid_t uuid1;
+ uuid_t uuid2;
+ uuid_t uuid3;
+ uuid_t uuid4;
+ uuid_parse("00000000-0000-0000-0000-000000000001", uuid1);
+ uuid_parse("00000000-0000-0000-0000-000000000002", uuid2);
+ uuid_parse("00000000-0000-0000-0000-000000000003", uuid3);
+ uuid_parse("00000000-0000-0000-0000-000000000004", uuid4);
+
+ struct uuid_array array;
+ uuid_array_init(&array);
+
+ EXPECT_TRUE(uuid_array_contains(&array, uuid1) == 0);
+ EXPECT_TRUE(uuid_array_contains(&array, uuid2) == 0);
+ EXPECT_TRUE(uuid_array_contains(&array, uuid3) == 0);
+ EXPECT_TRUE(uuid_array_contains(&array, uuid4) == 0);
+
+ uuid_array_append(&array, uuid1);
+ uuid_array_append(&array, uuid2);
+ uuid_array_append(&array, uuid3);
+
+ EXPECT_TRUE(uuid_array_contains(&array, uuid1) == 1);
+ EXPECT_TRUE(uuid_array_contains(&array, uuid2) == 1);
+ EXPECT_TRUE(uuid_array_contains(&array, uuid3) == 1);
+ EXPECT_TRUE(uuid_array_contains(&array, uuid4) == 0);
+}
+
+TEST(UUID_ARRAY, REMOVE)
+{
+ uuid_t uuid1;
+ uuid_t uuid2;
+ uuid_t uuid3;
+ uuid_parse("00000000-0000-0000-0000-000000000001", uuid1);
+ uuid_parse("00000000-0000-0000-0000-000000000002", uuid2);
+ uuid_parse("00000000-0000-0000-0000-000000000003", uuid3);
+
+ struct uuid_array array;
+ uuid_array_init(&array);
+
+ uuid_array_append(&array, uuid1);
+ uuid_array_append(&array, uuid2);
+ uuid_array_append(&array, uuid3);
+ uuid_array_append(&array, uuid1);
+ uuid_array_append(&array, uuid2);
+
+ EXPECT_TRUE(uuid_array_get_count(&array) == 5);
+ EXPECT_TRUE(uuid_compare(*uuid_array_get_at(&array, 0), uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(*uuid_array_get_at(&array, 1), uuid2) == 0);
+ EXPECT_TRUE(uuid_compare(*uuid_array_get_at(&array, 2), uuid3) == 0);
+ EXPECT_TRUE(uuid_compare(*uuid_array_get_at(&array, 3), uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(*uuid_array_get_at(&array, 4), uuid2) == 0);
+
+ uuid_array_remove(&array, uuid3); // 1,2,1,2
+ EXPECT_TRUE(uuid_array_get_count(&array) == 4);
+ EXPECT_TRUE(uuid_compare(*uuid_array_get_at(&array, 0), uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(*uuid_array_get_at(&array, 1), uuid2) == 0);
+ EXPECT_TRUE(uuid_compare(*uuid_array_get_at(&array, 2), uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(*uuid_array_get_at(&array, 3), uuid2) == 0);
+
+ uuid_array_remove(&array, uuid2); // 1,1
+ EXPECT_TRUE(uuid_array_get_count(&array) == 2);
+ EXPECT_TRUE(uuid_compare(*uuid_array_get_at(&array, 0), uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(*uuid_array_get_at(&array, 1), uuid1) == 0);
+
+ uuid_array_remove(&array, uuid1);
+ EXPECT_TRUE(uuid_array_get_count(&array) == 0);
}
TEST(UTILS, DEVICE)
diff --git a/conf/sce.conf b/conf/sce.conf
index ddb585d..9130cf2 100644
--- a/conf/sce.conf
+++ b/conf/sce.conf
@@ -17,7 +17,7 @@ breakpad_minidump_dir=/run/sce/crashreport
breakpad_upload_tools=/opt/tsg/framework/bin/minidump_upload
[maat]
-# 0:json 1:redis 2:iris
+# 0:json 1:redis
input_mode=1
# LOG_LEVEL_TRACE = 0; LOG_LEVEL_DEBUG = 1; LOG_LEVEL_INFO = 2;
# LOG_LEVEL_WARN = 3; LOG_LEVEL_ERROR = 4; LOG_LEVEL_FATAL = 5;
@@ -29,8 +29,6 @@ deferred_load=0
stat_file=log/maat.fs2
table_info=resource/table_info.conf
accept_path=/opt/tsg/etc/tsg_device_tag.json
-inc_cfg_dir=resource/inc/
-ful_cfg_dir=resource/ful/
json_cfg_file=resource/sce.json
foreign_cont_dir=resource/foreign_files
redis_db_idx=0
@@ -88,6 +86,7 @@ gateway=127.0.0.1
icmp_cycle_time_s=10
[kafka]
+enable_debug=0
brokerlist=192.168.40.224:9092
sasl_username=admin
sasl_passwd=galaxy2019
diff --git a/platform/include/health_check.h b/platform/include/health_check.h
index ea0f6f9..b794e67 100644
--- a/platform/include/health_check.h
+++ b/platform/include/health_check.h
@@ -13,11 +13,11 @@ void health_check_session_init(const char *profile, struct kafka *kfk);
// return 0 : success
// return -1 : key exist
// struct health_check *policy : need deep copy
-uint64_t health_check_session_add(int profile_id, int vsys_id, const struct health_check *policy);
+uint64_t health_check_session_add(uuid_t *sf_uuid, int vsys_id, const struct health_check *policy);
// return 0 : success
// return -1 : key not exist
-int health_check_session_del(uint64_t session_id, int profile_id, int vsys_id);
+int health_check_session_del(uint64_t session_id, uuid_t *sf_uuid, int vsys_id);
// return 1 : active
// return 0 : inactive
diff --git a/platform/include/packet_trace.h b/platform/include/packet_trace.h
index 471d88a..a31437d 100644
--- a/platform/include/packet_trace.h
+++ b/platform/include/packet_trace.h
@@ -51,14 +51,17 @@ extern "C"
* bypass(invalid policy)
*/
-static inline int rule_id_tostring(struct mutable_array *rule_ids, char *buffer, int size)
+static inline int rule_id_tostring(struct uuid_array *array, char *buffer, int size)
{
+ char uuid_str[UUID_STRING_SIZE] = {0};
int used = 0;
+ int num = uuid_array_get_count(array);
used += snprintf(buffer + used, size - used, "[");
- for (int i = 0; i < rule_ids->num; i++)
+ for (int i = 0; i < num; i++)
{
- used += snprintf(buffer + used, size - used, "%lu", rule_ids->elems[i]);
- if (i < rule_ids->num - 1)
+ uuid_unparse(*uuid_array_get_at(array, i), uuid_str);
+ used += snprintf(buffer + used, size - used, "%s", uuid_str);
+ if (i < num - 1)
{
used += snprintf(buffer + used, size - used, ", ");
}
@@ -69,11 +72,13 @@ static inline int rule_id_tostring(struct mutable_array *rule_ids, char *buffer,
static inline int sf_id_tostring(struct selected_chaining *chain, char *buffer, int size)
{
+ char uuid_str[UUID_STRING_SIZE] = {0};
int used = 0;
used += snprintf(buffer + used, size - used, "[");
for (int i = 0; i < chain->chaining_used; i++)
{
- used += snprintf(buffer + used, size - used, "%d", chain->chaining[i].sf_profile_id);
+ uuid_unparse(chain->chaining[i].sf_uuid, uuid_str);
+ used += snprintf(buffer + used, size - used, "%s", uuid_str);
if (i < chain->chaining_used - 1)
{
used += snprintf(buffer + used, size - used, ", ");
@@ -111,52 +116,55 @@ static inline int sf_id_tostring(struct selected_chaining *chain, char *buffer,
} \
} while (0)
-#define PACKET_TRACE_ON_POLICY(mr_ins, mr_buff, rule_ids, chain) \
+#define PACKET_TRACE_ON_POLICY(mr_ins, mr_buff, rule_uuid_array, chain) \
do \
{ \
if (marsio_dp_trace_measurements_can_emit(mr_ins, mr_buff, DP_TRACE_MEASUREMENT_TYPE_TRACE)) \
{ \
- char rule_id_str[1024] = {0}; \
- char sf_id_str[1024] = {0}; \
+ char rule_ids_str[1024] = {0}; \
+ char sf_ids_str[1024] = {0}; \
char buff[4096] = {0}; \
- rule_id_tostring(rule_ids, rule_id_str, sizeof(rule_id_str)); \
- sf_id_tostring(chain, sf_id_str, sizeof(sf_id_str)); \
- snprintf(buff, sizeof(buff), "sc rule list=%s, SFP list=%s", rule_id_str, sf_id_str); \
+ rule_id_tostring(rule_uuid_array, rule_ids_str, sizeof(rule_ids_str)); \
+ sf_id_tostring(chain, sf_ids_str, sizeof(sf_ids_str)); \
+ snprintf(buff, sizeof(buff), "sc rule list=%s, SFP list=%s", rule_ids_str, sf_ids_str); \
marsio_dp_trace_measurement_emit_str(mr_ins, mr_buff, DP_TRACE_MEASUREMENT_TYPE_TRACE, "Policy", buff); \
} \
} while (0)
-#define PACKET_TELEMETRY_ON_POLICY(mr_ins, mr_buff, rule_ids, chain) \
+#define PACKET_TELEMETRY_ON_POLICY(mr_ins, mr_buff, rule_uuid_array, chain) \
do \
{ \
if (marsio_dp_trace_measurements_can_emit(mr_ins, mr_buff, DP_TRACE_MEASUREMENT_TYPE_TELEMETRY)) \
{ \
- char rule_id_str[1024] = {0}; \
- char sf_id_str[1024] = {0}; \
+ char rule_ids_str[1024] = {0}; \
+ char sf_ids_str[1024] = {0}; \
char buff[4096] = {0}; \
- rule_id_tostring(rule_ids, rule_id_str, sizeof(rule_id_str)); \
- sf_id_tostring(chain, sf_id_str, sizeof(sf_id_str)); \
- snprintf(buff, sizeof(buff), "sc rule list=%s, SFP list=%s", rule_id_str, sf_id_str); \
+ rule_id_tostring(rule_uuid_array, rule_ids_str, sizeof(rule_ids_str)); \
+ sf_id_tostring(chain, sf_ids_str, sizeof(sf_ids_str)); \
+ snprintf(buff, sizeof(buff), "sc rule list=%s, SFP list=%s", rule_ids_str, sf_ids_str); \
marsio_dp_trace_measurement_emit_str(mr_ins, mr_buff, DP_TRACE_MEASUREMENT_TYPE_TELEMETRY, "Policy", buff); \
} \
} while (0)
-#define PACKET_TRACE_ON_CHAIN(mr_ins, mr_buff, sf, meta) \
- do \
- { \
- if (marsio_dp_trace_measurements_can_emit(mr_ins, mr_buff, DP_TRACE_MEASUREMENT_TYPE_TRACE)) \
- { \
- char buff[2048] = {0}; \
- snprintf(buff, sizeof(buff), "sc rule id=%lu, sf id=%d, fwd type=%s, pkt dir=%s, pkt type=%s, state=%s %s", \
- (sf)->rule_id, \
- (sf)->sf_profile_id, \
- forward_type_tostring((sf)->sff_forward_type), \
- ((meta)->direction ? "E2I" : "I2E"), \
- ((meta)->is_decrypted ? "decrypted" : "raw"), \
- ((sf)->sf_action == SESSION_ACTION_FORWARD ? "success" : "failure"), \
- ((sf)->sf_action == SESSION_ACTION_FORWARD ? "" : action_desc_tostring((sf)->sf_action_desc))); \
- marsio_dp_trace_measurement_emit_str(mr_ins, mr_buff, DP_TRACE_MEASUREMENT_TYPE_TRACE, "Forwarder", buff); \
- } \
+#define PACKET_TRACE_ON_CHAIN(mr_ins, mr_buff, sf, meta) \
+ do \
+ { \
+ if (marsio_dp_trace_measurements_can_emit(mr_ins, mr_buff, DP_TRACE_MEASUREMENT_TYPE_TRACE)) \
+ { \
+ char buff[2048] = {0}; \
+ char rule_uuid_str[UUID_STRING_SIZE] = {0}; \
+ char sf_uuid_str[UUID_STRING_SIZE] = {0}; \
+ uuid_unparse((sf)->rule_uuid, rule_uuid_str); \
+ uuid_unparse((sf)->sf_uuid, sf_uuid_str); \
+ snprintf(buff, sizeof(buff), "sc rule id=%s, sf id=%s, fwd type=%s, pkt dir=%s, pkt type=%s, state=%s %s", \
+ rule_uuid_str, sf_uuid_str, \
+ forward_type_tostring((sf)->sff_forward_type), \
+ ((meta)->direction ? "E2I" : "I2E"), \
+ ((meta)->is_decrypted ? "decrypted" : "raw"), \
+ ((sf)->sf_action == SESSION_ACTION_FORWARD ? "success" : "failure"), \
+ ((sf)->sf_action == SESSION_ACTION_FORWARD ? "" : action_desc_tostring((sf)->sf_action_desc))); \
+ marsio_dp_trace_measurement_emit_str(mr_ins, mr_buff, DP_TRACE_MEASUREMENT_TYPE_TRACE, "Forwarder", buff); \
+ } \
} while (0)
#define PACKET_TELEMETRY_ON_CHAIN(mr_ins, mr_buff, sf, meta) \
@@ -165,9 +173,12 @@ static inline int sf_id_tostring(struct selected_chaining *chain, char *buffer,
if (marsio_dp_trace_measurements_can_emit(mr_ins, mr_buff, DP_TRACE_MEASUREMENT_TYPE_TELEMETRY)) \
{ \
char buff[2048] = {0}; \
- snprintf(buff, sizeof(buff), "sc rule id=%lu, sf id=%d, type=%s, action=%s", \
- (sf)->rule_id, \
- (sf)->sf_profile_id, \
+ char rule_uuid_str[UUID_STRING_SIZE] = {0}; \
+ char sf_uuid_str[UUID_STRING_SIZE] = {0}; \
+ uuid_unparse((sf)->rule_uuid, rule_uuid_str); \
+ uuid_unparse((sf)->sf_uuid, sf_uuid_str); \
+ snprintf(buff, sizeof(buff), "sc rule id=%s, sf id=%s, type=%s, action=%s", \
+ rule_uuid_str, sf_uuid_str, \
forward_type_tostring((sf)->sff_forward_type), \
action_desc_tostring((sf)->sf_action_desc)); \
marsio_dp_trace_measurement_emit_str(mr_ins, mr_buff, DP_TRACE_MEASUREMENT_TYPE_TELEMETRY, "Forwarder", buff); \
diff --git a/platform/include/policy.h b/platform/include/policy.h
index d1f4849..4949fe5 100644
--- a/platform/include/policy.h
+++ b/platform/include/policy.h
@@ -82,15 +82,15 @@ struct connectivity
struct selected_sf
{
- uint64_t rule_id;
+ uuid_t rule_uuid;
int rule_vsys_id;
enum traffic_type traffic_type;
- int sff_profile_id;
+ uuid_t sff_uuid;
enum forward_type sff_forward_type;
int sf_vsys_id;
- int sf_profile_id;
+ uuid_t sf_uuid;
enum session_action sf_action;
enum action_desc sf_action_desc;
struct connectivity sf_connectivity;
@@ -135,7 +135,7 @@ int policy_enforcer_register(struct policy_enforcer *enforcer);
int policy_enforce_chaining_size(struct policy_enforcer *enforcer);
// direction 1: E2I
// direction 0: I2E
-void policy_enforce_select_chainings(struct policy_enforcer *enforcer, struct session_ctx *s_ctx, struct packet *data_pkt, uint64_t rule_id, int direction);
+void policy_enforce_select_chainings(struct policy_enforcer *enforcer, struct session_ctx *s_ctx, struct packet *data_pkt, uuid_t *rule_uuid, int direction);
#ifdef __cplusplus
}
diff --git a/platform/include/sce.h b/platform/include/sce.h
index 15c3e80..72a0da6 100644
--- a/platform/include/sce.h
+++ b/platform/include/sce.h
@@ -59,7 +59,7 @@ struct session_ctx
uint16_t vxlan_src_port;
struct four_tuple inner_tuple4;
- struct mutable_array rule_ids;
+ struct uuid_array rule_uuid_array;
// route ctx
struct route_ctx decrypted_e2i_route_ctx;
diff --git a/platform/include/sf_metrics.h b/platform/include/sf_metrics.h
index 4481d7d..eb4549b 100644
--- a/platform/include/sf_metrics.h
+++ b/platform/include/sf_metrics.h
@@ -6,14 +6,14 @@ extern "C"
{
#endif
-#include <stdint.h>
+#include "utils.h"
#include "kafka.h"
struct sf_metrics_key
{
- uint64_t rule_id;
- uint32_t sf_profile_id;
- uint32_t sff_profile_id;
+ uuid_t rule_uuid;
+ uuid_t sf_uuid;
+ uuid_t sff_uuid;
uint32_t vsys_id;
};
diff --git a/platform/include/sf_status.h b/platform/include/sf_status.h
index 90f42b8..7a78173 100644
--- a/platform/include/sf_status.h
+++ b/platform/include/sf_status.h
@@ -6,13 +6,13 @@ extern "C"
{
#endif
+#include "utils.h"
#include "kafka.h"
-#include <stdint.h>
struct sf_status_key
{
uint32_t vsys_id;
- uint32_t sf_profile_id;
+ uuid_t sf_uuid;
};
struct sf_status *sf_status_create(const char *profile, struct kafka *kfk);
diff --git a/platform/src/health_check.cpp b/platform/src/health_check.cpp
index abe3730..88ee293 100644
--- a/platform/src/health_check.cpp
+++ b/platform/src/health_check.cpp
@@ -46,7 +46,7 @@ struct session_iterm
struct health_check policy; // value1: deep copy
int is_active; // value2
- int profile_id; // value3
+ uuid_t sf_uuid; // value3
int vsys_id; // value4
UT_hash_handle hh1; /* handle for first hash table */
@@ -457,7 +457,7 @@ static uint64_t health_check_get_session_id()
// return >0 : session id
// return 0 : fail
// struct health_check *policy : need deep copy
-uint64_t health_check_session_add(int profile_id, int vsys_id, const struct health_check *policy)
+uint64_t health_check_session_add(uuid_t *sf_uuid, int vsys_id, const struct health_check *policy)
{
uint64_t session_id = 0;
uint8_t mac[ETH_ALEN] = {0};
@@ -481,7 +481,7 @@ uint64_t health_check_session_add(int profile_id, int vsys_id, const struct heal
tmp->vsys_id = vsys_id;
tmp->session_id = session_id;
- tmp->profile_id = profile_id;
+ uuid_copy(tmp->sf_uuid, *sf_uuid);
memcpy(&tmp->policy, policy, sizeof(struct health_check));
HASH_ADD(hh1, g_handle.root_by_id, session_id, sizeof(tmp->session_id), tmp);
@@ -498,13 +498,15 @@ uint64_t health_check_session_add(int profile_id, int vsys_id, const struct heal
health_check_method_table_set_mac(&g_handle_none, tmp->policy.address, mac);
}
- LOG_DEBUG("health check session table insert: profile id [%d] session id [%lu] address [%s] success", profile_id, session_id, policy->address);
+ char sf_uuid_str[UUID_STRING_SIZE] = {0};
+ uuid_unparse(*sf_uuid, sf_uuid_str);
+ LOG_DEBUG("health check session table insert: profile id [%s] session id [%lu] address [%s] success", sf_uuid_str, session_id, policy->address);
return session_id;
}
// return 0 : success
// return -1 : key not exist
-int health_check_session_del(uint64_t session_id, int profile_id, int vsys_id)
+int health_check_session_del(uint64_t session_id, uuid_t *sf_uuid, int vsys_id)
{
int ret = 0;
struct session_iterm *tmp = NULL;
@@ -536,13 +538,15 @@ end:
HASH_DELETE(hh1, g_handle.root_by_id, tmp);
struct sf_status_key key = {0};
key.vsys_id = vsys_id;
- key.sf_profile_id = profile_id;
+ uuid_copy(key.sf_uuid, *sf_uuid);
sf_status_delete(g_sf_status, &key);
pthread_rwlock_unlock(&g_handle.rwlock);
free(tmp);
tmp = NULL;
- LOG_DEBUG("health check session table delete: profile id [%d] session id [%lu] success", profile_id, session_id);
+ char sf_uuid_str[UUID_STRING_SIZE] = {0};
+ uuid_unparse(*sf_uuid, sf_uuid_str);
+ LOG_DEBUG("health check session table delete: profile id [%s] session id [%lu] success", sf_uuid_str, session_id);
return 0;
}
@@ -667,7 +671,7 @@ static void *_health_check_session_foreach(void *arg)
struct sf_status_key key = {0};
key.vsys_id = node->vsys_id;
- key.sf_profile_id = node->profile_id;
+ uuid_copy(key.sf_uuid, node->sf_uuid);
sf_status_update(g_sf_status, &key, is_active, 0);
if (node->is_active != is_active) {
node->is_active = is_active;
@@ -743,6 +747,7 @@ int health_check_session_get_mac(uint64_t session_id, u_char mac_buff[])
struct session_iterm *tmp = NULL;
uint8_t mac[ETH_ALEN] = {0};
uint8_t init_mac[ETH_ALEN] = {0};
+ char sf_uuid_str[UUID_STRING_SIZE] = {0};
if (enable == 0)
{
@@ -757,9 +762,10 @@ int health_check_session_get_mac(uint64_t session_id, u_char mac_buff[])
return -1;
}
+ uuid_unparse(tmp->sf_uuid, sf_uuid_str);
str_method = health_check_method_str(tmp->policy.method);
if (tmp->policy.method == HEALTH_CHECK_METHOD_BFD && tmp->is_active == 0) {
- LOG_DEBUG("health check session id [%lu] profile id [%d] health check method [%s] active is down", session_id, tmp->profile_id, str_method);
+ LOG_DEBUG("health check session id [%lu] profile id [%s] health check method [%s] active is down", session_id, sf_uuid_str, str_method);
pthread_rwlock_unlock(&g_handle.rwlock);
return -1;
}
@@ -773,20 +779,20 @@ int health_check_session_get_mac(uint64_t session_id, u_char mac_buff[])
if (memcmp(mac, init_mac, ETH_ALEN) == 0) {
if (strlen(gateway_address) == 0) {
- LOG_DEBUG("health check session id [%lu] profile id [%d] health check method [%s] get mac [null]", session_id, tmp->profile_id, str_method);
+ LOG_DEBUG("health check session id [%lu] profile id [%s] health check method [%s] get mac [null]", session_id, sf_uuid_str, str_method);
pthread_rwlock_unlock(&g_handle.rwlock);
return -1;
}
health_check_method_table_get_mac(&g_handle_none, gateway_address, mac);
if (memcmp(mac, init_mac, ETH_ALEN) == 0) {
- LOG_DEBUG("health check session id [%lu] profile id [%d] health check method [%s] get mac [null]", session_id, tmp->profile_id, str_method);
+ LOG_DEBUG("health check session id [%lu] profile id [%s] health check method [%s] get mac [null]", session_id, sf_uuid_str, str_method);
pthread_rwlock_unlock(&g_handle.rwlock);
return -1;
}
}
memcpy(mac_buff, mac, ETH_ALEN);
- LOG_DEBUG("health check session id [%lu] profile id [%d] health check method [%s] get mac [%02x:%02x:%02x:%02x:%02x:%02x]", session_id, tmp->profile_id, str_method, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ LOG_DEBUG("health check session id [%lu] profile id [%s] health check method [%s] get mac [%02x:%02x:%02x:%02x:%02x:%02x]", session_id, sf_uuid_str, str_method, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
pthread_rwlock_unlock(&g_handle.rwlock);
return 0;
} \ No newline at end of file
diff --git a/platform/src/packet_io.cpp b/platform/src/packet_io.cpp
index f8a73e7..34dc5d5 100644
--- a/platform/src/packet_io.cpp
+++ b/platform/src/packet_io.cpp
@@ -668,9 +668,9 @@ static inline void action_mirr_forward(struct session_ctx *session_ctx, marsio_b
THROUGHPUT_METRICS_INC(&(thread_metrics->mirr_tx), 1, meta->raw_len);
THROUGHPUT_METRICS_INC(&sf->tx, 1, nsend);
struct sf_metrics_key key = {0};
- key.rule_id = sf->rule_id;
- key.sff_profile_id = sf->sff_profile_id;
- key.sf_profile_id = sf->sf_profile_id;
+ uuid_copy(key.rule_uuid, sf->rule_uuid);
+ uuid_copy(key.sff_uuid, sf->sff_uuid);
+ uuid_copy(key.sf_uuid, sf->sf_uuid);
key.vsys_id = sf->rule_vsys_id;
sf_metrics_input(sf_metrics, thread_index, &key, 0, 0, 1, nsend);
}
@@ -703,23 +703,30 @@ static inline void action_stee_forward(struct session_ctx *session_ctx, marsio_b
THROUGHPUT_METRICS_INC(&(thread_metrics->stee_tx), 1, meta->raw_len);
THROUGHPUT_METRICS_INC(&sf->tx, 1, nsend);
struct sf_metrics_key key = {0};
- key.rule_id = sf->rule_id;
- key.sff_profile_id = sf->sff_profile_id;
- key.sf_profile_id = sf->sf_profile_id;
+ uuid_copy(key.rule_uuid, sf->rule_uuid);
+ uuid_copy(key.sff_uuid, sf->sff_uuid);
+ uuid_copy(key.sf_uuid, sf->sf_uuid);
key.vsys_id = sf->rule_vsys_id;
sf_metrics_input(sf_metrics, thread_index, &key, 0, 0, 1, nsend);
}
static void action_sf_chaining(struct thread_ctx *thread_ctx, struct session_ctx *session_ctx, struct selected_chaining *chaining, marsio_buff_t *rx_buff, struct metadata *meta, int next_sf_index)
{
+ char rule_uuid_str[UUID_STRING_SIZE];
+ char sff_uuid_str[UUID_STRING_SIZE];
+ char sf_uuid_str[UUID_STRING_SIZE];
+
int sf_index;
for (sf_index = next_sf_index; sf_index < chaining->chaining_used; sf_index++)
{
struct selected_sf *sf = &(chaining->chaining[sf_index]);
- LOG_DEBUG("%s: session: %lu %s execute chaining [%d/%d]: policy %lu->%d->%d, action %s->%s->%s->%s",
+ uuid_unparse(sf->rule_uuid, rule_uuid_str);
+ uuid_unparse(sf->sff_uuid, sff_uuid_str);
+ uuid_unparse(sf->sf_uuid, sf_uuid_str);
+ LOG_DEBUG("%s: session: %lu %s execute chaining [%d/%d]: policy %s->%s->%s, action %s->%s->%s->%s",
LOG_TAG_POLICY, session_ctx->session_id, session_ctx->session_addr,
sf_index, chaining->chaining_used,
- sf->rule_id, sf->sff_profile_id, sf->sf_profile_id,
+ rule_uuid_str, sff_uuid_str, sf_uuid_str,
(meta->is_decrypted ? "decrypted" : "raw"), (meta->direction ? "E2I" : "I2E"), forward_type_tostring(sf->sff_forward_type), action_desc_tostring(sf->sf_action_desc));
PACKET_TRACE_ON_CHAIN(thread_ctx->ref_io->instance, rx_buff, sf, meta);
@@ -786,10 +793,11 @@ static int send_ctrl_packet(struct session_ctx *session_ctx, struct thread_ctx *
{
struct sce_ctx *sce_ctx = thread_ctx->ref_sce_ctx;
struct packet_io *packet_io = thread_ctx->ref_io;
- struct mutable_array *rule_ids = &session_ctx->rule_ids;
+ struct uuid_array *rule_uuid_array = &session_ctx->rule_uuid_array;
struct selected_chaining *chaining_raw = session_ctx->chaining_raw;
struct selected_chaining *chaining_decrypted = session_ctx->chaining_decrypted;
int thread_index = thread_ctx->thread_index;
+ int num = uuid_array_get_count(rule_uuid_array);
char *data;
size_t size;
@@ -828,9 +836,9 @@ static int send_ctrl_packet(struct session_ctx *session_ctx, struct thread_ctx *
{
mpack_write_cstr(&writer, "sc_rule_list");
mpack_build_array(&writer); // sc_rule_list begin
- for (int i = 0; i < rule_ids->num; i++)
+ for (int i = 0; i < num; i++)
{
- mpack_write_u64(&writer, mutable_array_index_elem(rule_ids, i));
+ mpack_write_bin(&writer, (const char *)uuid_array_get_at(rule_uuid_array, i), sizeof(uuid_t));
}
mpack_complete_array(&writer); // sc_rule_list end
}
@@ -843,7 +851,7 @@ static int send_ctrl_packet(struct session_ctx *session_ctx, struct thread_ctx *
struct selected_sf *sf = &(chaining_raw->chaining[i]);
if (sf->sf_action == SESSION_ACTION_FORWARD)
{
- mpack_write_u64(&writer, sf->sf_profile_id);
+ mpack_write_bin(&writer, (const char *)&sf->sf_uuid, sizeof(uuid_t));
}
if (sf->sf_action == SESSION_ACTION_BLOCK && sf->sff_forward_type == FORWARD_TYPE_STEERING)
{
@@ -861,7 +869,7 @@ static int send_ctrl_packet(struct session_ctx *session_ctx, struct thread_ctx *
struct selected_sf *sf = &(chaining_decrypted->chaining[i]);
if (sf->sf_action == SESSION_ACTION_FORWARD)
{
- mpack_write_u64(&writer, sf->sf_profile_id);
+ mpack_write_bin(&writer, (const char *)&sf->sf_uuid, sizeof(uuid_t));
}
if (sf->sf_action == SESSION_ACTION_BLOCK && sf->sff_forward_type == FORWARD_TYPE_STEERING)
{
@@ -942,12 +950,19 @@ static void dump_sf_metrics(struct session_ctx *session_ctx, struct selected_cha
return;
}
+ char rule_uuid_str[UUID_STRING_SIZE];
+ char sff_uuid_str[UUID_STRING_SIZE];
+ char sf_uuid_str[UUID_STRING_SIZE];
+
for (int i = 0; i < chaining->chaining_used; i++)
{
struct selected_sf *sf = &(chaining->chaining[i]);
- LOG_INFO("%s: session %lu %s metrics: policy %lu->%d->%d action %s->%s->%s rx_pkts %lu rx_bytes %lu tx_pkts %lu tx_bytes %lu",
+ uuid_unparse(sf->rule_uuid, rule_uuid_str);
+ uuid_unparse(sf->sff_uuid, sff_uuid_str);
+ uuid_unparse(sf->sf_uuid, sf_uuid_str);
+ LOG_INFO("%s: session %lu %s metrics: policy %s->%s->%s action %s->%s->%s rx_pkts %lu rx_bytes %lu tx_pkts %lu tx_bytes %lu",
LOG_TAG_SFMETRICS, session_ctx->session_id, session_ctx->session_addr,
- sf->rule_id, sf->sff_profile_id, sf->sf_profile_id,
+ rule_uuid_str, sff_uuid_str, sf_uuid_str,
traffic_type_tostring(sf->traffic_type), forward_type_tostring(sf->sff_forward_type), action_desc_tostring(sf->sf_action_desc),
sf->rx.n_pkts, sf->rx.n_bytes, sf->tx.n_pkts, sf->tx.n_bytes);
}
@@ -964,24 +979,23 @@ static void handle_policy_mutil_hits(struct session_ctx *session_ctx, struct con
struct policy_enforcer *enforcer = thread_ctx->ref_enforcer;
struct sce_ctx *sce_ctx = thread_ctx->ref_sce_ctx;
- for (int i = 0; i < ctrl_pkt->rule_id_num; i++)
+ int num = uuid_array_get_count(&ctrl_pkt->rule_uuid_array);
+ for (int i = 0; i < num; i++)
{
- uint64_t rule_id = ctrl_pkt->rule_ids[i];
- if (mutable_array_exist_elem(&session_ctx->rule_ids, rule_id))
+ uuid_t *rule_uuid_ptr = uuid_array_get_at(&ctrl_pkt->rule_uuid_array, i);
+ if (uuid_array_contains(&session_ctx->rule_uuid_array, *rule_uuid_ptr))
{
continue;
}
else
{
- policy_enforce_select_chainings(enforcer, session_ctx, data_pkt, rule_id, direction);
+ policy_enforce_select_chainings(enforcer, session_ctx, data_pkt, rule_uuid_ptr, direction);
if (sce_ctx->enable_debug)
{
selected_chaining_bref(session_ctx->chaining_raw);
selected_chaining_bref(session_ctx->chaining_decrypted);
}
-
- mutable_array_add_elem(&session_ctx->rule_ids, rule_id);
}
}
}
@@ -1213,8 +1227,8 @@ static void handle_data_packet(marsio_buff_t *rx_buff, struct thread_ctx *thread
{
THROUGHPUT_METRICS_INC(&(thread_metrics->raw_rx), 1, meta.raw_len);
}
- PACKET_TRACE_ON_POLICY(thread_ctx->ref_io->instance, rx_buff, &session_ctx->rule_ids, chaining);
- PACKET_TELEMETRY_ON_POLICY(thread_ctx->ref_io->instance, rx_buff, &session_ctx->rule_ids, chaining);
+ PACKET_TRACE_ON_POLICY(thread_ctx->ref_io->instance, rx_buff, &session_ctx->rule_uuid_array, chaining);
+ PACKET_TELEMETRY_ON_POLICY(thread_ctx->ref_io->instance, rx_buff, &session_ctx->rule_uuid_array, chaining);
action_sf_chaining(thread_ctx, session_ctx, chaining, rx_buff, &meta, 0);
return;
@@ -1243,6 +1257,7 @@ static void handle_inject_vxlan_packet(marsio_buff_t *rx_buff, struct thread_ctx
struct vxlan_hdr *vxlan_hdr = NULL;
struct session_ctx *session_ctx = NULL;
struct selected_chaining *chaining = NULL;
+ char sf_uuid_str[UUID_STRING_SIZE];
memset(&meta, 0, sizeof(struct metadata));
int sf_index = 0;
@@ -1300,8 +1315,9 @@ static void handle_inject_vxlan_packet(marsio_buff_t *rx_buff, struct thread_ctx
if (chaining->chaining[sf_index].sff_forward_type == FORWARD_TYPE_MIRRORING)
{
- LOG_DEBUG("%s: unexpected inject packet, session %lu %s with sf_profile_id %d executes mirror and does not require reflow, drop !!!",
- LOG_TAG_PKTIO, session_ctx->session_id, session_ctx->session_addr, chaining->chaining[sf_index].sf_profile_id);
+ uuid_unparse(chaining->chaining[sf_index].sf_uuid, sf_uuid_str);
+ LOG_DEBUG("%s: unexpected inject packet, session %lu %s with sf_uuid %s executes mirror and does not require reflow, drop !!!",
+ LOG_TAG_PKTIO, session_ctx->session_id, session_ctx->session_addr, sf_uuid_str);
THROUGHPUT_METRICS_INC(&(thread_metrics->mirr_rx_drop), 1, meta.raw_len);
goto error_block;
}
@@ -1311,9 +1327,9 @@ static void handle_inject_vxlan_packet(marsio_buff_t *rx_buff, struct thread_ctx
THROUGHPUT_METRICS_INC(&sf->rx, 1, raw_len);
THROUGHPUT_METRICS_INC(&(thread_metrics->stee_rx), 1, meta.raw_len);
struct sf_metrics_key key = {0};
- key.rule_id = sf->rule_id;
- key.sff_profile_id = sf->sff_profile_id;
- key.sf_profile_id = sf->sf_profile_id;
+ uuid_copy(key.rule_uuid, sf->rule_uuid);
+ uuid_copy(key.sff_uuid, sf->sff_uuid);
+ uuid_copy(key.sf_uuid, sf->sf_uuid);
key.vsys_id = sf->rule_vsys_id;
sf_metrics_input(sf_metrics, thread_index, &key, 1, raw_len, 0, 0);
}
diff --git a/platform/src/policy.cpp b/platform/src/policy.cpp
index 7fc12af..2298241 100644
--- a/platform/src/policy.cpp
+++ b/platform/src/policy.cpp
@@ -14,6 +14,10 @@
#include "sce.h"
#include "utarray.h"
+#define TABLE_NAME_SC "SERVICE_CHAINING_RULE"
+#define TABLE_NAME_SFF "SERVICE_FUNCTION_FORWARDER_PROFILE"
+#define TABLE_NAME_SF "SERVICE_FUNCTION_PROFILE"
+
/******************************************************************************
* Struct policy_enforcer
******************************************************************************/
@@ -24,7 +28,6 @@ enum input_mode
{
MAAT_INPUT_JSON = 0,
MAAT_INPUT_REDIS = 1,
- MAAT_INPUT_FILE = 2,
};
struct policy_config
@@ -43,8 +46,6 @@ struct policy_config
char table_info[2048];
char accept_tags[2048];
char accept_path[2048];
- char inc_cfg_dir[2048];
- char ful_cfg_dir[2048];
char json_cfg_file[2048];
char foreign_cont_dir[2048];
@@ -58,10 +59,6 @@ struct policy_enforcer
{
struct policy_config config;
struct maat *maat;
-
- int compile_table_id; // SERVICE_CHAINING_COMPILE table id
- int sff_table_id; // SERVICE_FUNCTION_FORWARDER_PROFILE table id
- int sf_table_id; // SERVICE_FUNCTION_PROFILE table id
};
/******************************************************************************
@@ -70,13 +67,12 @@ struct policy_enforcer
struct chaining_param
{
- uint64_t rule_id;
+ uuid_t rule_uuid;
int ref_cnt;
int vsys_id;
enum traffic_type traffic_type;
- int *sff_profile_ids;
- int sff_profile_ids_num;
+ struct uuid_array sff_uuid_array;
};
/******************************************************************************
@@ -117,15 +113,14 @@ struct load_balance
struct sff_param
{
- int sff_profile_id;
+ uuid_t sff_uuid;
int sff_ref_cnt;
enum forward_type sff_forward_type;
struct load_balance sff_ldbc;
struct exception sff_exception;
- int *sf_profile_ids;
- int sf_profile_ids_num;
+ struct uuid_array sf_uuid_array;
};
/******************************************************************************
@@ -153,7 +148,7 @@ struct effective_range
struct sf_param
{
int sf_vsys_id;
- int sf_profile_id;
+ uuid_t sf_uuid;
int sf_ref_cnt;
enum admin_status sf_admin_status;
@@ -268,8 +263,6 @@ static void policy_enforcer_config(const char *profile, struct policy_config *co
MESA_load_profile_string_def(profile, "MAAT", "stat_file", config->stat_file, sizeof(config->stat_file), "log/maat.fs2");
MESA_load_profile_string_def(profile, "MAAT", "table_info", config->table_info, sizeof(config->table_info), "resource/table_info.conf");
MESA_load_profile_string_def(profile, "MAAT", "accept_path", config->accept_path, sizeof(config->accept_path), "/opt/tsg/etc/tsg_device_tag.json");
- MESA_load_profile_string_def(profile, "MAAT", "inc_cfg_dir", config->inc_cfg_dir, sizeof(config->inc_cfg_dir), "resource/inc/");
- MESA_load_profile_string_def(profile, "MAAT", "ful_cfg_dir", config->ful_cfg_dir, sizeof(config->ful_cfg_dir), "resource/ful/");
MESA_load_profile_string_def(profile, "MAAT", "json_cfg_file", config->json_cfg_file, sizeof(config->json_cfg_file), "resource/sce.json");
MESA_load_profile_string_def(profile, "MAAT", "foreign_cont_dir", config->foreign_cont_dir, sizeof(config->foreign_cont_dir), "resource/sce_files");
@@ -284,7 +277,7 @@ static void policy_enforcer_config(const char *profile, struct policy_config *co
parser_effective_range(config->accept_tags, config->data_center, config->device_group);
}
- LOG_DEBUG("%s: MAAT->input_mode : %s", LOG_TAG_POLICY, (config->input_mode == MAAT_INPUT_REDIS ? "redis" : (config->input_mode == MAAT_INPUT_JSON ? "json" : (config->input_mode == MAAT_INPUT_FILE ? "file" : "unknown"))));
+ LOG_DEBUG("%s: MAAT->input_mode : %s", LOG_TAG_POLICY, (config->input_mode == MAAT_INPUT_REDIS ? "redis" : "json"));
LOG_DEBUG("%s: MAAT->log_level : %d", LOG_TAG_POLICY, config->log_level);
LOG_DEBUG("%s: MAAT->stat_switch : %d", LOG_TAG_POLICY, config->stat_switch);
LOG_DEBUG("%s: MAAT->perf_switch : %d", LOG_TAG_POLICY, config->perf_switch);
@@ -297,8 +290,6 @@ static void policy_enforcer_config(const char *profile, struct policy_config *co
LOG_DEBUG("%s: MAAT->accept_tags : %s", LOG_TAG_POLICY, config->accept_tags);
LOG_DEBUG("%s: MAAT->device_group : %s", LOG_TAG_POLICY, config->device_group);
LOG_DEBUG("%s: MAAT->data_center : %s", LOG_TAG_POLICY, config->data_center);
- LOG_DEBUG("%s: MAAT->inc_cfg_dir : %s", LOG_TAG_POLICY, config->inc_cfg_dir);
- LOG_DEBUG("%s: MAAT->ful_cfg_dir : %s", LOG_TAG_POLICY, config->ful_cfg_dir);
LOG_DEBUG("%s: MAAT->json_cfg_file : %s", LOG_TAG_POLICY, config->json_cfg_file);
LOG_DEBUG("%s: MAAT->foreign_cont_dir : %s", LOG_TAG_POLICY, config->foreign_cont_dir);
@@ -312,24 +303,17 @@ static void policy_enforcer_config(const char *profile, struct policy_config *co
* Private API -- MAAT Callback
******************************************************************************/
-static void chaining_param_new_cb(const char *table_name, int table_id, const char *key, const char *table_line, void **ad, long argl, void *argp)
+static void chaining_param_new_cb(const char *table_name, const char *key, const char *table_line, void **ad, long argl, void *argp)
{
int iter = 0;
cJSON *json = NULL;
+ cJSON *object = NULL;
+ cJSON *array = NULL;
cJSON *item = NULL;
- cJSON *element = NULL;
- size_t user_region_offset = 0;
- size_t user_region_len = 0;
+ uuid_t sff_uuid;
struct chaining_param *param = NULL;
- if (maat_helper_read_column(table_line, 7, &user_region_offset, &user_region_len) < 0)
- {
- LOG_ERROR("%s: unexpected chaining rule: (invalid user region) %s", LOG_TAG_POLICY, table_line);
- return;
- }
-
- char *json_str = (char *)calloc(user_region_len + 1, sizeof(char));
- memcpy(json_str, table_line + user_region_offset, user_region_len);
+ char *json_str = strdup(table_line);
json = cJSON_Parse(json_str);
if (json == NULL)
{
@@ -338,21 +322,30 @@ static void chaining_param_new_cb(const char *table_name, int table_id, const ch
}
param = (struct chaining_param *)calloc(1, sizeof(struct chaining_param));
- param->rule_id = *((uint64_t *)key);
+ uuid_parse(key, param->rule_uuid);
+ uuid_array_init(&param->sff_uuid_array);
param->ref_cnt = 1;
+ // action_parameter
+ object = cJSON_GetObjectItem(json, "action_parameter");
+ if (!object || !cJSON_IsObject(object))
+ {
+ LOG_ERROR("%s: unexpected chaining rule: (invalid action_parameter param) %s", LOG_TAG_POLICY, table_line);
+ goto error_out;
+ }
+
// vsys_id
- item = cJSON_GetObjectItem(json, "vsys_id");
+ item = cJSON_GetObjectItem(object, "vsys_id");
if (!item || !cJSON_IsNumber(item))
{
LOG_ERROR("%s: unexpected chaining rule: (invalid vsys_id param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
param->vsys_id = item->valueint;
- LOG_DEBUG("%s: parse chaining rule: %lu, vsys_id: %d", LOG_TAG_POLICY, param->rule_id, param->vsys_id);
+ LOG_DEBUG("%s: parse chaining rule: %s, vsys_id: %d", LOG_TAG_POLICY, key, param->vsys_id);
// targeted_traffic
- item = cJSON_GetObjectItem(json, "targeted_traffic");
+ item = cJSON_GetObjectItem(object, "targeted_traffic");
if (!item || !cJSON_IsString(item))
{
LOG_ERROR("%s: unexpected chaining rule: (invalid targeted_traffic param) %s", LOG_TAG_POLICY, table_line);
@@ -371,32 +364,39 @@ static void chaining_param_new_cb(const char *table_name, int table_id, const ch
LOG_ERROR("%s: unexpected chaining rule: (invalid targeted_traffic param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- LOG_DEBUG("%s: parse chaining rule: %lu, targeted_traffic: %s", LOG_TAG_POLICY, param->rule_id, traffic_type_tostring(param->traffic_type));
+ LOG_DEBUG("%s: parse chaining rule: %s, targeted_traffic: %s", LOG_TAG_POLICY, key, traffic_type_tostring(param->traffic_type));
// sff_profiles
- item = cJSON_GetObjectItem(json, "sff_profiles");
- if (!item || !cJSON_IsArray(item) || !cJSON_GetArraySize(item))
+ array = cJSON_GetObjectItem(object, "sff_profiles");
+ if (!array || !cJSON_IsArray(array) || !cJSON_GetArraySize(array))
{
LOG_ERROR("%s: unexpected chaining rule: (invalid sff_profiles param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- param->sff_profile_ids_num = cJSON_GetArraySize(item);
- param->sff_profile_ids = (int *)calloc(param->sff_profile_ids_num, sizeof(int));
- cJSON_ArrayForEach(element, item)
+ cJSON_ArrayForEach(item, array)
{
- if (!cJSON_IsNumber(element))
+ if (!cJSON_IsString(item))
{
LOG_ERROR("%s: unexpected chaining rule: (invalid sff_profiles param) %s", LOG_TAG_POLICY, table_line);
continue;
}
- LOG_DEBUG("%s: parse chaining rule: %lu, sff_profiles[%d/%d]: %d", LOG_TAG_POLICY, param->rule_id, iter, param->sff_profile_ids_num, element->valueint);
- param->sff_profile_ids[iter] = element->valueint;
+ if (uuid_array_is_full(&param->sff_uuid_array))
+ {
+ LOG_ERROR("%s: unexpected chaining rule: (sff_profiles is full) %s", LOG_TAG_POLICY, table_line);
+ break;
+ }
+
+ LOG_DEBUG("%s: parse chaining rule: %s, sff_profiles[%d]: %s", LOG_TAG_POLICY, key, iter, item->valuestring);
+
+ uuid_parse(item->valuestring, sff_uuid);
+ uuid_array_append(&param->sff_uuid_array, sff_uuid);
+
iter++;
}
*ad = param;
- LOG_INFO("%s: Add chaining rule: %lu", LOG_TAG_POLICY, param->rule_id);
+ LOG_INFO("%s: Add chaining rule: %s", LOG_TAG_POLICY, key);
cJSON_Delete(json);
free(json_str);
@@ -417,17 +417,12 @@ error_out:
if (param)
{
- if (param->sff_profile_ids)
- {
- free(param->sff_profile_ids);
- param->sff_profile_ids = NULL;
- }
free(param);
param = NULL;
}
}
-static void chaining_param_free_cb(int table_id, void **ad, long argl, void *argp)
+static void chaining_param_free_cb(const char *table_name, void **ad, long argl, void *argp)
{
struct chaining_param *param = (struct chaining_param *)*ad;
if (param == NULL)
@@ -437,12 +432,10 @@ static void chaining_param_free_cb(int table_id, void **ad, long argl, void *arg
if ((__sync_sub_and_fetch(&param->ref_cnt, 1) == 0))
{
- LOG_INFO("%s: Del chaining rule: %lu", LOG_TAG_POLICY, param->rule_id);
- if (param->sff_profile_ids)
- {
- free(param->sff_profile_ids);
- param->sff_profile_ids = NULL;
- }
+ char rule_uuid_str[UUID_STRING_SIZE] = {0};
+ uuid_unparse(param->rule_uuid, rule_uuid_str);
+ LOG_INFO("%s: Del chaining rule: %s", LOG_TAG_POLICY, rule_uuid_str);
+
free(param);
param = NULL;
@@ -450,7 +443,7 @@ static void chaining_param_free_cb(int table_id, void **ad, long argl, void *arg
}
}
-static void chaining_param_dup_cb(int table_id, void **to, void **from, long argl, void *argp)
+static void chaining_param_dup_cb(const char *table_name, void **to, void **from, long argl, void *argp)
{
struct chaining_param *param = (struct chaining_param *)*from;
if (param)
@@ -466,68 +459,74 @@ static void chaining_param_dup_cb(int table_id, void **to, void **from, long arg
static void chaining_param_free(struct chaining_param *param)
{
- chaining_param_free_cb(0, (void **)&param, 0, NULL);
+ chaining_param_free_cb(NULL, (void **)&param, 0, NULL);
}
-static void sff_param_new_cb(const char *table_name, int table_id, const char *key, const char *table_line, void **ad, long argl, void *argp)
+static void sff_param_new_cb(const char *table_name, const char *key, const char *table_line, void **ad, long argl, void *argp)
{
int iter = 0;
- struct sff_param *param = NULL;
- cJSON *root1 = NULL;
- cJSON *root2 = NULL;
+ cJSON *json = NULL;
+ cJSON *object = NULL;
+ cJSON *array = NULL;
cJSON *item = NULL;
+ uuid_t sf_uuid;
+ struct sff_param *param = NULL;
- int profile_id = 0;
- int type = 0;
- char load_balance_method[32] = {0};
- char load_balance_localization[8] = {0};
- char failure_action[16] = {0};
- char unavailability_action[64] = {0};
- char service_func_profiles[128] = {0};
- int is_valid = 0;
-
- if (sscanf(table_line, "%d\t%d\t%s\t%s\t%s\t%s\t%s\t%d",
- &profile_id, &type,
- load_balance_method, load_balance_localization, failure_action, unavailability_action, service_func_profiles,
- &is_valid) != 8)
- {
- LOG_ERROR("%s: unexpected sff profile: %s", LOG_TAG_POLICY, table_line);
- return;
+ char *json_str = strdup(table_line);
+ json = cJSON_Parse(json_str);
+ if (json == NULL)
+ {
+ LOG_ERROR("%s: unexpected sff profile: (invalid json format) %s", LOG_TAG_POLICY, table_line);
+ goto error_out;
}
param = (struct sff_param *)calloc(1, sizeof(struct sff_param));
- param->sff_profile_id = *((int *)key);
+ uuid_parse(key, param->sff_uuid);
+ uuid_array_init(&param->sf_uuid_array);
param->sff_ref_cnt = 1;
// type
- switch (type)
+ item = cJSON_GetObjectItem(json, "type");
+ if (!item || !cJSON_IsNumber(item))
+ {
+ LOG_ERROR("%s: unexpected sff profile: (invalid type param) %s", LOG_TAG_POLICY, table_line);
+ goto error_out;
+ }
+ if (item->valueint == 1)
{
- case 1:
param->sff_forward_type = FORWARD_TYPE_STEERING;
- break;
- case 2:
+ }
+ else if (item->valueint == 2)
+ {
param->sff_forward_type = FORWARD_TYPE_MIRRORING;
- break;
- default:
+ }
+ else
+ {
LOG_ERROR("%s: unexpected sff profile: (invalid type param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- LOG_DEBUG("%s: parse sff profile: %d, type: %s", LOG_TAG_POLICY, param->sff_profile_id, forward_type_tostring(param->sff_forward_type));
+ LOG_DEBUG("%s: parse sff profile: %s, type: %s", LOG_TAG_POLICY, key, forward_type_tostring(param->sff_forward_type));
// load_balance_method
- if (0 == strcasecmp(load_balance_method, "hash-int-ip"))
+ item = cJSON_GetObjectItem(json, "load_balance_method");
+ if (!item || !cJSON_IsString(item))
+ {
+ LOG_ERROR("%s: unexpected sff profile: (invalid load_balance_method param) %s", LOG_TAG_POLICY, table_line);
+ goto error_out;
+ }
+ if (0 == strcasecmp(item->valuestring, "hash-int-ip"))
{
param->sff_ldbc.method = LDBC_METHOD_HASH_INT_IP;
}
- else if (0 == strcasecmp(load_balance_method, "hash-ext-ip"))
+ else if (0 == strcasecmp(item->valuestring, "hash-ext-ip"))
{
param->sff_ldbc.method = LDBC_METHOD_HASH_EXT_IP;
}
- else if (0 == strcasecmp(load_balance_method, "hash-int-ip-and-ext-ip"))
+ else if (0 == strcasecmp(item->valuestring, "hash-int-ip-and-ext-ip"))
{
param->sff_ldbc.method = LDBC_METHOD_HASH_INT_IP_AND_EXT_IP;
}
- else if (0 == strcasecmp(load_balance_method, "hash-innermost-int-ip"))
+ else if (0 == strcasecmp(item->valuestring, "hash-innermost-int-ip"))
{
param->sff_ldbc.method = LDBC_METHOD_HASH_INNERMOST_INT_IP;
}
@@ -537,14 +536,20 @@ static void sff_param_new_cb(const char *table_name, int table_id, const char *k
LOG_ERROR("%s: unexpected sff profile: (invalid load_balance_method param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- LOG_DEBUG("%s: parse sff profile: %d, load_balance_method: %s", LOG_TAG_POLICY, param->sff_profile_id, load_balance_method);
+ LOG_DEBUG("%s: parse sff profile: %s, load_balance_method: %s", LOG_TAG_POLICY, key, item->valuestring);
// load_balance_localization
- if (0 == strcasecmp(load_balance_localization, "nearby"))
+ item = cJSON_GetObjectItem(json, "load_balance_localization");
+ if (!item || !cJSON_IsString(item))
+ {
+ LOG_ERROR("%s: unexpected sff profile: (invalid load_balance_localization param) %s", LOG_TAG_POLICY, table_line);
+ goto error_out;
+ }
+ if (0 == strcasecmp(item->valuestring, "nearby"))
{
param->sff_ldbc.localiza = LDBC_LOCALIZATION_NEARBY;
}
- else if (0 == strcasecmp(load_balance_localization, "global"))
+ else if (0 == strcasecmp(item->valuestring, "global"))
{
param->sff_ldbc.localiza = LDBC_LOCALIZATION_GLOBAL;
}
@@ -553,18 +558,24 @@ static void sff_param_new_cb(const char *table_name, int table_id, const char *k
LOG_ERROR("%s: unexpected sff profile: (invalid load_balance_localization param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- LOG_DEBUG("%s: parse sff profile: %d, load_balance_localization: %s", LOG_TAG_POLICY, param->sff_profile_id, load_balance_localization);
+ LOG_DEBUG("%s: parse sff profile: %s, load_balance_localization: %s", LOG_TAG_POLICY, key, item->valuestring);
// failure_action
- if (0 == strcasecmp(failure_action, "bypass"))
+ item = cJSON_GetObjectItem(json, "failure_action");
+ if (!item || !cJSON_IsString(item))
+ {
+ LOG_ERROR("%s: unexpected sff profile: (invalid failure_action param) %s", LOG_TAG_POLICY, table_line);
+ goto error_out;
+ }
+ if (0 == strcasecmp(item->valuestring, "bypass"))
{
param->sff_exception.fail_action = FAILURE_ACTION_BYPASS;
}
- else if (0 == strcasecmp(failure_action, "block"))
+ else if (0 == strcasecmp(item->valuestring, "block"))
{
param->sff_exception.fail_action = FAILURE_ACTION_BLOCK;
}
- else if (0 == strcasecmp(failure_action, "re-dispatch"))
+ else if (0 == strcasecmp(item->valuestring, "re-dispatch"))
{
param->sff_exception.fail_action = FAILURE_ACTION_RE_DISPATCH;
}
@@ -573,18 +584,18 @@ static void sff_param_new_cb(const char *table_name, int table_id, const char *k
LOG_ERROR("%s: unexpected sff profile: (invalid failure_action param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- LOG_DEBUG("%s: parse sff profile: %d, failure_action: %s", LOG_TAG_POLICY, param->sff_profile_id, failure_action);
+ LOG_DEBUG("%s: parse sff profile: %s, failure_action: %s", LOG_TAG_POLICY, key, item->valuestring);
// unavailability_action
if (param->sff_exception.fail_action == FAILURE_ACTION_RE_DISPATCH)
{
- root1 = cJSON_Parse(unavailability_action);
- if (root1 == NULL)
+ object = cJSON_GetObjectItem(json, "unavailability_action");
+ if (!object || !cJSON_IsObject(object))
{
LOG_ERROR("%s: unexpected sff profile: (invalid unavailability_action param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- item = cJSON_GetObjectItem(root1, "action");
+ item = cJSON_GetObjectItem(object, "action");
if (!item || !cJSON_IsString(item))
{
LOG_ERROR("%s: unexpected chaining rule: (invalid unavailability_action->action param) %s", LOG_TAG_POLICY, table_line);
@@ -603,70 +614,73 @@ static void sff_param_new_cb(const char *table_name, int table_id, const char *k
LOG_ERROR("%s: unexpected chaining rule: (invalid unavailability_action->action param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- LOG_DEBUG("%s: parse sff profile: %d, unavailability_action->action: %s", LOG_TAG_POLICY, param->sff_profile_id, item->valuestring);
+ LOG_DEBUG("%s: parse sff profile: %s, unavailability_action->action: %s", LOG_TAG_POLICY, key, item->valuestring);
- item = cJSON_GetObjectItem(root1, "health_service_func_lt");
+ item = cJSON_GetObjectItem(object, "health_service_func_lt");
if (item && cJSON_IsNumber(item))
{
param->sff_exception.health_service_func_lt = item->valueint;
- LOG_DEBUG("%s: parse sff profile: %d, unavailability_action->health_service_func_lt: %d", LOG_TAG_POLICY, param->sff_profile_id, item->valueint);
+ LOG_DEBUG("%s: parse sff profile: %s, unavailability_action->health_service_func_lt: %d", LOG_TAG_POLICY, key, item->valueint);
}
}
// service_func_profiles
- root2 = cJSON_Parse(service_func_profiles);
- if (root2 == NULL || !cJSON_IsArray(root2) || !cJSON_GetArraySize(root2))
+ array = cJSON_GetObjectItem(json, "service_func_profiles");
+ if (array == NULL || !cJSON_IsArray(array) || !cJSON_GetArraySize(array))
{
LOG_ERROR("%s: unexpected sff profile: (invalid service_func_profiles param) %s", LOG_TAG_POLICY, table_line);
- return;
+ goto error_out;
}
- param->sf_profile_ids_num = cJSON_GetArraySize(root2);
- param->sf_profile_ids = (int *)calloc(param->sf_profile_ids_num, sizeof(int));
- cJSON_ArrayForEach(item, root2)
+ cJSON_ArrayForEach(item, array)
{
- if (!cJSON_IsNumber(item))
+ if (!cJSON_IsString(item))
{
LOG_ERROR("%s: unexpected sff profile: (invalid service_func_profiles param) %s", LOG_TAG_POLICY, table_line);
continue;
}
- LOG_DEBUG("%s: parse sff profile: %d, service_func_profiles[%d/%d] = %d", LOG_TAG_POLICY, param->sff_profile_id, iter, param->sf_profile_ids_num, item->valueint);
- param->sf_profile_ids[iter] = item->valueint;
+
+ if (uuid_array_is_full(&param->sf_uuid_array))
+ {
+ LOG_ERROR("%s: unexpected sff profile: (service_func_profiles is full) %s", LOG_TAG_POLICY, table_line);
+ break;
+ }
+
+ LOG_DEBUG("%s: parse sff profile: %s, service_func_profiles[%d] = %s", LOG_TAG_POLICY, key, iter, item->valuestring);
+
+ uuid_parse(item->valuestring, sf_uuid);
+ uuid_array_append(&param->sf_uuid_array, sf_uuid);
+
iter++;
}
*ad = param;
- LOG_INFO("%s: Add sff profile: %d", LOG_TAG_POLICY, param->sff_profile_id);
+ LOG_INFO("%s: Add sff profile: %s", LOG_TAG_POLICY, key);
- cJSON_Delete(root1);
- cJSON_Delete(root2);
+ cJSON_Delete(json);
+ free(json_str);
return;
error_out:
- if (root1)
+ if (json)
{
- cJSON_Delete(root1);
- root1 = NULL;
+ cJSON_Delete(json);
+ json = NULL;
}
- if (root2)
+ if (json_str)
{
- cJSON_Delete(root2);
- root2 = NULL;
+ free(json_str);
+ json_str = NULL;
}
if (param)
{
- if (param->sf_profile_ids)
- {
- free(param->sf_profile_ids);
- param->sf_profile_ids = NULL;
- }
free(param);
param = NULL;
}
}
-static void sff_param_free_cb(int table_id, void **ad, long argl, void *argp)
+static void sff_param_free_cb(const char *table_name, void **ad, long argl, void *argp)
{
struct sff_param *param = (struct sff_param *)*ad;
if (param == NULL)
@@ -676,12 +690,10 @@ static void sff_param_free_cb(int table_id, void **ad, long argl, void *argp)
if ((__sync_sub_and_fetch(&param->sff_ref_cnt, 1) == 0))
{
- LOG_INFO("%s: Del sff profile: %d", LOG_TAG_POLICY, param->sff_profile_id);
- if (param->sf_profile_ids)
- {
- free(param->sf_profile_ids);
- param->sf_profile_ids = NULL;
- }
+ char sff_uuid_str[UUID_STRING_SIZE] = {0};
+ uuid_unparse(param->sff_uuid, sff_uuid_str);
+ LOG_INFO("%s: Del sff profile: %s", LOG_TAG_POLICY, sff_uuid_str);
+
free(param);
param = NULL;
@@ -689,7 +701,7 @@ static void sff_param_free_cb(int table_id, void **ad, long argl, void *argp)
}
}
-static void sff_param_dup_cb(int table_id, void **to, void **from, long argl, void *argp)
+static void sff_param_dup_cb(const char *table_name, void **to, void **from, long argl, void *argp)
{
struct sff_param *param = (struct sff_param *)*from;
if (param)
@@ -705,45 +717,45 @@ static void sff_param_dup_cb(int table_id, void **to, void **from, long argl, vo
static void sff_param_free(struct sff_param *param)
{
- sff_param_free_cb(0, (void **)&param, 0, NULL);
+ sff_param_free_cb(NULL, (void **)&param, 0, NULL);
}
-static void sf_param_new_cb(const char *table_name, int table_id, const char *key, const char *table_line, void **ad, long argl, void *argp)
+static void sf_param_new_cb(const char *table_name, const char *key, const char *table_line, void **ad, long argl, void *argp)
{
- struct sf_param *param = NULL;
- cJSON *root0 = NULL;
- cJSON *root1 = NULL;
- cJSON *root2 = NULL;
+ cJSON *json = NULL;
+ cJSON *object = NULL;
cJSON *item = NULL;
+ struct sf_param *param = NULL;
- int vsys_id = 0;
- int is_valid = 0;
- int profile_id = 0;
- int admin_status = 0;
- char connectivity[128] = {0};
- char health_check[128] = {0};
- char device_group[EFFECTIVE_RANGE_MAX_SIZE] = {0};
-
- if (sscanf(table_line, "%d\t%s\t%d\t%s\t%s\t%d\t%d",
- &profile_id, device_group, &admin_status, connectivity, health_check, &vsys_id, &is_valid) != 7)
+ char *json_str = strdup(table_line);
+ json = cJSON_Parse(json_str);
+ if (json == NULL)
{
- LOG_ERROR("%s: unexpected sf profile: %s", LOG_TAG_POLICY, table_line);
- return;
+ LOG_ERROR("%s: unexpected sf profile: (invalid json format) %s", LOG_TAG_POLICY, table_line);
+ goto error_out;
}
param = (struct sf_param *)calloc(1, sizeof(struct sf_param));
- param->sf_vsys_id = vsys_id;
- param->sf_profile_id = *((int *)key);
+ uuid_parse(key, param->sf_uuid);
param->sf_ref_cnt = 1;
+ // vsys_id
+ item = cJSON_GetObjectItem(json, "vsys_id");
+ if (!item || !cJSON_IsNumber(item))
+ {
+ LOG_ERROR("%s: unexpected sf profile: (invalid vsys_id param) %s", LOG_TAG_POLICY, table_line);
+ goto error_out;
+ }
+ param->sf_vsys_id = item->valueint;
+
// device_group
- root0 = cJSON_Parse(device_group);
- if (root0 == NULL)
+ object = cJSON_GetObjectItem(json, "device_group");
+ if (!object || !cJSON_IsObject(object))
{
LOG_ERROR("%s: unexpected sf profile: (invalid device_group param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- item = cJSON_GetObjectItem(root0, "tag");
+ item = cJSON_GetObjectItem(object, "tag");
if (!item || !cJSON_IsString(item))
{
LOG_ERROR("%s: unexpected sf profile: (invalid device_group->tag param) %s", LOG_TAG_POLICY, table_line);
@@ -762,39 +774,45 @@ static void sf_param_new_cb(const char *table_name, int table_id, const char *ke
LOG_ERROR("%s: unexpected sf profile: (invalid device_group->tag param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- item = cJSON_GetObjectItem(root0, "value");
+ item = cJSON_GetObjectItem(object, "value");
if (!item || !cJSON_IsString(item))
{
LOG_ERROR("%s: unexpected sf profile: (invalid device_group->value param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
memcpy(param->sf_effective_range.value, item->valuestring, MIN(strlen(item->valuestring), EFFECTIVE_RANGE_MAX_SIZE));
- LOG_DEBUG("%s: parse sf profile: %d, device_group->tag: %s, device_group->value: %s", LOG_TAG_POLICY, param->sf_profile_id, effective_type_to_string(param->sf_effective_range.type), param->sf_effective_range.value);
+ LOG_DEBUG("%s: parse sf profile: %s, device_group->tag: %s, device_group->value: %s", LOG_TAG_POLICY, key, effective_type_to_string(param->sf_effective_range.type), param->sf_effective_range.value);
// admin_status
- switch (admin_status)
+ item = cJSON_GetObjectItem(json, "admin_status");
+ if (!item || !cJSON_IsNumber(item))
+ {
+ LOG_ERROR("%s: unexpected sf profile: (invalid admin_status param) %s", LOG_TAG_POLICY, table_line);
+ goto error_out;
+ }
+ if (item->valueint == 1)
{
- case 1:
param->sf_admin_status = ADMMIN_STATUS_ACTIVE;
- break;
- case 0:
+ }
+ else if (item->valueint == 0)
+ {
param->sf_admin_status = ADMMIN_STATUS_INACTIVE;
- break;
- default:
+ }
+ else
+ {
LOG_ERROR("%s: unexpected sf profile: (invalid admin_status param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- LOG_DEBUG("%s: parse sf profile: %d, admin_status: %s", LOG_TAG_POLICY, param->sf_profile_id, admin_status_to_string(param->sf_admin_status));
+ LOG_DEBUG("%s: parse sf profile: %s, admin_status: %s", LOG_TAG_POLICY, key, admin_status_to_string(param->sf_admin_status));
// connectivity
- root1 = cJSON_Parse(connectivity);
- if (root1 == NULL)
+ object = cJSON_GetObjectItem(json, "connectivity");
+ if (!object || !cJSON_IsObject(object))
{
LOG_ERROR("%s: unexpected sf profile: (invalid connectivity param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
-
- item = cJSON_GetObjectItem(root1, "method");
+ item = cJSON_GetObjectItem(object, "method");
if (!item || !cJSON_IsString(item))
{
LOG_ERROR("%s: unexpected sf profile: (invalid connectivity->method param) %s", LOG_TAG_POLICY, table_line);
@@ -817,48 +835,48 @@ static void sf_param_new_cb(const char *table_name, int table_id, const char *ke
LOG_ERROR("%s: unexpected sf profile: (invalid connectivity->method param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- LOG_DEBUG("%s: parse sf profile: %d, connectivity->method: %s", LOG_TAG_POLICY, param->sf_profile_id, encapsulate_method_tostring(param->sf_connectivity.method));
+ LOG_DEBUG("%s: parse sf profile: %s, connectivity->method: %s", LOG_TAG_POLICY, key, encapsulate_method_tostring(param->sf_connectivity.method));
if (param->sf_connectivity.method == ENCAPSULATE_METHOD_LAYER2_SWITCH || param->sf_connectivity.method == ENCAPSULATE_METHOD_LAYER3_SWITCH)
{
- item = cJSON_GetObjectItem(root1, "int_vlan_tag");
+ item = cJSON_GetObjectItem(object, "int_vlan_tag");
if (!item || !cJSON_IsNumber(item))
{
LOG_ERROR("%s: unexpected sf profile: (invalid connectivity->int_vlan_tag param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
param->sf_connectivity.int_vlan_tag = item->valueint;
- LOG_DEBUG("%s: parse sf profile: %d, connectivity->int_vlan_tag: %d", LOG_TAG_POLICY, param->sf_profile_id, item->valueint);
+ LOG_DEBUG("%s: parse sf profile: %s, connectivity->int_vlan_tag: %d", LOG_TAG_POLICY, key, item->valueint);
- item = cJSON_GetObjectItem(root1, "ext_vlan_tag");
+ item = cJSON_GetObjectItem(object, "ext_vlan_tag");
if (!item || !cJSON_IsNumber(item))
{
LOG_ERROR("%s: unexpected sf profile: (invalid connectivity->ext_vlan_tag param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
param->sf_connectivity.ext_vlan_tag = item->valueint;
- LOG_DEBUG("%s: parse sf profile: %d, connectivity->ext_vlan_tag: %d", LOG_TAG_POLICY, param->sf_profile_id, item->valueint);
+ LOG_DEBUG("%s: parse sf profile: %s, connectivity->ext_vlan_tag: %d", LOG_TAG_POLICY, key, item->valueint);
}
else if (param->sf_connectivity.method == ENCAPSULATE_METHOD_VXLAN_G)
{
- item = cJSON_GetObjectItem(root1, "dest_ip");
+ item = cJSON_GetObjectItem(object, "dest_ip");
if (!item || !cJSON_IsString(item))
{
LOG_ERROR("%s: unexpected sf profile: (invalid connectivity->dest_ip param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
memcpy(param->sf_connectivity.dest_ip, item->valuestring, strlen(item->valuestring));
- LOG_DEBUG("%s: parse sf profile: %d, connectivity->dest_ip: %s", LOG_TAG_POLICY, param->sf_profile_id, item->valuestring);
+ LOG_DEBUG("%s: parse sf profile: %s, connectivity->dest_ip: %s", LOG_TAG_POLICY, key, item->valuestring);
}
// health_check
- root2 = cJSON_Parse(health_check);
- if (root2 == NULL)
+ object = cJSON_GetObjectItem(json, "health_check");
+ if (!object || !cJSON_IsObject(object))
{
LOG_ERROR("%s: unexpected sf profile: (invalid health_check param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- item = cJSON_GetObjectItem(root2, "method");
+ item = cJSON_GetObjectItem(object, "method");
if (!item || !cJSON_IsString(item))
{
LOG_ERROR("%s: unexpected sf profile: (invalid health_check->method param) %s", LOG_TAG_POLICY, table_line);
@@ -885,7 +903,7 @@ static void sf_param_new_cb(const char *table_name, int table_id, const char *ke
LOG_ERROR("%s: unexpected sf profile: (invalid health_check->method param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
- LOG_DEBUG("%s: parse sf profile: %d, health_check->method: %s", LOG_TAG_POLICY, param->sf_profile_id, item->valuestring);
+ LOG_DEBUG("%s: parse sf profile: %s, health_check->method: %s", LOG_TAG_POLICY, key, item->valuestring);
if ((param->sf_health_check.method == HEALTH_CHECK_METHOD_BFD && param->sf_connectivity.method == ENCAPSULATE_METHOD_VXLAN_G) ||
(param->sf_health_check.method == HEALTH_CHECK_METHOD_NONE && param->sf_connectivity.method == ENCAPSULATE_METHOD_VXLAN_G))
@@ -895,66 +913,59 @@ static void sf_param_new_cb(const char *table_name, int table_id, const char *ke
if (param->sf_health_check.method == HEALTH_CHECK_METHOD_HTTP)
{
- item = cJSON_GetObjectItem(root2, "url");
+ item = cJSON_GetObjectItem(object, "url");
if (!item || !cJSON_IsString(item))
{
LOG_ERROR("%s: unexpected sf profile: (invalid health_check->url param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
memcpy(param->sf_health_check.url, item->valuestring, strlen(item->valuestring));
- LOG_DEBUG("%s: parse sf profile: %d, health_check->url: %s", LOG_TAG_POLICY, param->sf_profile_id, item->valuestring);
+ LOG_DEBUG("%s: parse sf profile: %s, health_check->url: %s", LOG_TAG_POLICY, key, item->valuestring);
}
if (param->sf_health_check.method == HEALTH_CHECK_METHOD_HTTP || param->sf_health_check.method == HEALTH_CHECK_METHOD_BFD || param->sf_health_check.method == HEALTH_CHECK_METHOD_IN_BAND_BFD)
{
- item = cJSON_GetObjectItem(root2, "interval_ms");
+ item = cJSON_GetObjectItem(object, "interval_ms");
if (!item || !cJSON_IsNumber(item))
{
LOG_ERROR("%s: unexpected sf profile: (invalid health_check->interval_ms param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
param->sf_health_check.interval_ms = item->valueint;
- LOG_DEBUG("%s: parse sf profile: %d, health_check->interval_ms: %d", LOG_TAG_POLICY, param->sf_profile_id, item->valueint);
+ LOG_DEBUG("%s: parse sf profile: %s, health_check->interval_ms: %d", LOG_TAG_POLICY, key, item->valueint);
- item = cJSON_GetObjectItem(root2, "retires");
+ item = cJSON_GetObjectItem(object, "retires");
if (!item || !cJSON_IsNumber(item))
{
LOG_ERROR("%s: unexpected sf profile: (invalid health_check->retires param) %s", LOG_TAG_POLICY, table_line);
goto error_out;
}
param->sf_health_check.retires = item->valueint;
- LOG_DEBUG("%s: parse sf profile: %d, health_check->retires: %d", LOG_TAG_POLICY, param->sf_profile_id, item->valueint);
+ LOG_DEBUG("%s: parse sf profile: %s, health_check->retires: %d", LOG_TAG_POLICY, key, item->valueint);
}
if (param->sf_connectivity.method != ENCAPSULATE_METHOD_LAYER2_SWITCH)
{
- param->health_check_session_id = health_check_session_add(param->sf_profile_id, param->sf_vsys_id, &param->sf_health_check);
+ param->health_check_session_id = health_check_session_add(&param->sf_uuid, param->sf_vsys_id, &param->sf_health_check);
}
*ad = param;
- LOG_INFO("%s: Add sf profile: %d", LOG_TAG_POLICY, param->sf_profile_id);
+ LOG_INFO("%s: Add sf profile: %s", LOG_TAG_POLICY, key);
- cJSON_Delete(root0);
- cJSON_Delete(root1);
- cJSON_Delete(root2);
+ cJSON_Delete(json);
+ free(json_str);
return;
error_out:
- if (root0)
- {
- cJSON_Delete(root0);
- root0 = NULL;
- }
-
- if (root1)
+ if (json)
{
- cJSON_Delete(root1);
- root1 = NULL;
+ cJSON_Delete(json);
+ json = NULL;
}
- if (root2)
+ if (json_str)
{
- cJSON_Delete(root2);
- root2 = NULL;
+ free(json_str);
+ json_str = NULL;
}
if (param)
@@ -964,7 +975,7 @@ error_out:
}
}
-static void sf_param_free_cb(int table_id, void **ad, long argl, void *argp)
+static void sf_param_free_cb(const char *table_name, void **ad, long argl, void *argp)
{
struct sf_param *param = (struct sf_param *)*ad;
if (param == NULL)
@@ -976,9 +987,13 @@ static void sf_param_free_cb(int table_id, void **ad, long argl, void *argp)
{
if (param->sf_connectivity.method != ENCAPSULATE_METHOD_LAYER2_SWITCH)
{
- health_check_session_del(param->health_check_session_id, param->sf_profile_id, param->sf_vsys_id);
+ health_check_session_del(param->health_check_session_id, &param->sf_uuid, param->sf_vsys_id);
}
- LOG_INFO("%s: Del sf profile: %d", LOG_TAG_POLICY, param->sf_profile_id);
+
+ char sf_uuid_str[UUID_STRING_SIZE] = {0};
+ uuid_unparse(param->sf_uuid, sf_uuid_str);
+ LOG_INFO("%s: Del sf profile: %s", LOG_TAG_POLICY, sf_uuid_str);
+
free(param);
param = NULL;
@@ -986,7 +1001,7 @@ static void sf_param_free_cb(int table_id, void **ad, long argl, void *argp)
}
}
-static void sf_param_dup_cb(int table_id, void **to, void **from, long argl, void *argp)
+static void sf_param_dup_cb(const char *table_name, void **to, void **from, long argl, void *argp)
{
struct sf_param *param = (struct sf_param *)*from;
if (param)
@@ -1002,7 +1017,7 @@ static void sf_param_dup_cb(int table_id, void **to, void **from, long argl, voi
static void sf_param_free(struct sf_param *param)
{
- sf_param_free_cb(0, (void **)&param, 0, NULL);
+ sf_param_free_cb(NULL, (void **)&param, 0, NULL);
}
/******************************************************************************
@@ -1015,11 +1030,11 @@ static void selected_sf_init(struct selected_sf *selected_sf)
{
memset(selected_sf, 0, sizeof(struct selected_sf));
selected_sf->rule_vsys_id = 0;
- selected_sf->rule_id = 0;
+ uuid_clear(selected_sf->rule_uuid);
selected_sf->traffic_type = TRAFFIC_TYPE_NONE;
- selected_sf->sff_profile_id = -1;
+ uuid_clear(selected_sf->sff_uuid);
selected_sf->sff_forward_type = FORWARD_TYPE_NONE;
- selected_sf->sf_profile_id = -1;
+ uuid_clear(selected_sf->sf_uuid);
selected_sf->sf_action = SESSION_ACTION_BYPASS;
selected_sf->sf_action_desc = ACTION_BYPASS_DUE_DEFAULT;
}
@@ -1028,7 +1043,7 @@ static void selected_sf_init(struct selected_sf *selected_sf)
static void selected_sf_set_info(struct selected_sf *selected_sf, struct sf_param *sf_param)
{
selected_sf->sf_vsys_id = sf_param->sf_vsys_id;
- selected_sf->sf_profile_id = sf_param->sf_profile_id;
+ uuid_copy(selected_sf->sf_uuid, sf_param->sf_uuid);
selected_sf->sf_connectivity = sf_param->sf_connectivity;
if (selected_sf->sf_connectivity.method == ENCAPSULATE_METHOD_VXLAN_G)
@@ -1173,6 +1188,7 @@ static int handle_fail_action(struct exception *sff_exception, struct selected_s
static void select_sf_by_ldbc(struct sff_param *sff_param, struct selected_sf *selected_sf, struct session_ctx *s_ctx, UT_array *sf_array, uint64_t hash)
{
+ char sf_uuid_str[UUID_STRING_SIZE] = {0};
struct thread_metrics *thread_metrics = &s_ctx->ref_thread_ctx->thread_metrics;
while (utarray_len(sf_array))
@@ -1180,9 +1196,10 @@ static void select_sf_by_ldbc(struct sff_param *sff_param, struct selected_sf *s
unsigned int sf_index = (unsigned int)(hash % utarray_len(sf_array));
struct sf_param *sf_param = (struct sf_param *)utarray_eltptr(sf_array, sf_index);
+ uuid_unparse(sf_param->sf_uuid, sf_uuid_str);
if (sf_param->sf_connectivity.method == ENCAPSULATE_METHOD_LAYER2_SWITCH)
{
- LOG_INFO("%s: session %lu %s select sf by ldbc, sf_profile_id %d to be selected", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf_param->sf_profile_id);
+ LOG_INFO("%s: session %lu %s select sf by ldbc, sf_uuid %s to be selected", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf_uuid_str);
selected_sf_set_action(selected_sf, ACTION_FORWAED_DUE_SELECTED_SF);
selected_sf_set_info(selected_sf, sf_param);
return;
@@ -1192,7 +1209,7 @@ static void select_sf_by_ldbc(struct sff_param *sff_param, struct selected_sf *s
if (health_check_session_get_mac(sf_param->health_check_session_id, selected_sf->sf_dst_mac) == 0)
{
ATOMIC_INC(&(thread_metrics->sf_active));
- LOG_INFO("%s: session %lu %s select sf by ldbc, sf_profile_id %d to be selected", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf_param->sf_profile_id);
+ LOG_INFO("%s: session %lu %s select sf by ldbc, sf_uuid %s to be selected", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf_uuid_str);
selected_sf_set_action(selected_sf, ACTION_FORWAED_DUE_SELECTED_SF);
selected_sf_set_info(selected_sf, sf_param);
return;
@@ -1202,13 +1219,13 @@ static void select_sf_by_ldbc(struct sff_param *sff_param, struct selected_sf *s
ATOMIC_INC(&(thread_metrics->sf_inactive));
if (handle_fail_action(&sff_param->sff_exception, selected_sf, utarray_len(sf_array) - 1) == 0)
{
- LOG_INFO("%s: session %lu %s select sf by re-dispatch, sf_profile_id %d to be excluded", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf_param->sf_profile_id);
+ LOG_INFO("%s: session %lu %s select sf by re-dispatch, sf_uuid %s to be excluded", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf_uuid_str);
utarray_erase(sf_array, sf_index, 1);
continue;
}
else
{
- LOG_INFO("%s: session %lu %s select sf by fail-action, sf_profile_id %d to be selected", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf_param->sf_profile_id);
+ LOG_INFO("%s: session %lu %s select sf by fail-action, sf_uuid %s to be selected", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf_uuid_str);
selected_sf_set_info(selected_sf, sf_param);
return;
}
@@ -1220,31 +1237,34 @@ static void select_sf_by_ldbc(struct sff_param *sff_param, struct selected_sf *s
static void select_sf_from_sff(struct policy_enforcer *enforcer, struct sff_param *sff_param, struct selected_sf *selected_sf, struct session_ctx *s_ctx, uint64_t packet_hash)
{
- int profile_id;
+ char sf_uuid_str[UUID_STRING_SIZE] = {0};
+ uuid_t *sf_uuid_ptr;
UT_array *sf_array;
UT_icd sf_icd = {sizeof(struct sf_param), NULL, NULL, NULL};
utarray_new(sf_array, &sf_icd);
- for (int i = 0; i < sff_param->sf_profile_ids_num; i++)
+ int sf_uuid_num = uuid_array_get_count(&sff_param->sf_uuid_array);
+ for (int i = 0; i < sf_uuid_num; i++)
{
- profile_id = sff_param->sf_profile_ids[i];
- struct sf_param *sf = (struct sf_param *)maat_plugin_table_get_ex_data(enforcer->maat, enforcer->sf_table_id, (const char *)&profile_id, sizeof(profile_id));
+ sf_uuid_ptr = uuid_array_get_at(&sff_param->sf_uuid_array, i);
+ uuid_unparse(*sf_uuid_ptr, sf_uuid_str);
+ struct sf_param *sf = (struct sf_param *)maat_plugin_table_get_ex_data(enforcer->maat, TABLE_NAME_SF, (const char *)sf_uuid_str, strlen(sf_uuid_str));
if (sf == NULL)
{
- LOG_ERROR("%s: failed to get sf parameter of profile %d", LOG_TAG_POLICY, profile_id);
+ LOG_ERROR("%s: failed to get sf parameter of profile %s", LOG_TAG_POLICY, sf_uuid_str);
continue;
}
if (select_sf_by_admin_status(sf) == 0)
{
- LOG_INFO("%s: session %lu %s select sf by admin-status, sf_profile_id %d to be excluded", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf->sf_profile_id);
+ LOG_INFO("%s: session %lu %s select sf by admin-status, sf_uuid %s to be excluded", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf_uuid_str);
sf_param_free(sf);
continue;
}
if (select_sf_by_localization(enforcer, sff_param, sf) == 0)
{
- LOG_INFO("%s: session %lu %s select sf by localization, sf_profile_id %d to be excluded", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf->sf_profile_id);
+ LOG_INFO("%s: session %lu %s select sf by localization, sf_uuid %s to be excluded", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, sf_uuid_str);
sf_param_free(sf);
continue;
}
@@ -1369,6 +1389,10 @@ void selected_chaining_destory(struct selected_chaining *chaining)
void selected_chaining_dump(struct selected_chaining *chaining)
{
+ char rule_uuid_str[UUID_STRING_SIZE] = {0};
+ char sff_uuid_str[UUID_STRING_SIZE] = {0};
+ char sf_uuid_str[UUID_STRING_SIZE] = {0};
+
if (chaining == NULL)
{
LOG_DEBUG("%s: selected_chaining: NULL", LOG_TAG_POLICY);
@@ -1381,13 +1405,16 @@ void selected_chaining_dump(struct selected_chaining *chaining)
for (int i = 0; i < chaining->chaining_used; i++)
{
struct selected_sf *node = &(chaining->chaining[i]);
- LOG_DEBUG("%s: session %lu %s selected_chaining->node[%d]->rule_id : %lu", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, i, node->rule_id);
+ uuid_unparse(node->rule_uuid, rule_uuid_str);
+ uuid_unparse(node->sff_uuid, sff_uuid_str);
+ uuid_unparse(node->sf_uuid, sf_uuid_str);
+ LOG_DEBUG("%s: session %lu %s selected_chaining->node[%d]->rule_uuid : %s", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, i, rule_uuid_str);
LOG_DEBUG("%s: session %lu %s selected_chaining->node[%d]->traffic_type : %s", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, i, traffic_type_tostring(node->traffic_type));
// sff
- LOG_DEBUG("%s: session %lu %s selected_chaining->node[%d]->sff_profile_id : %d", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, i, node->sff_profile_id);
+ LOG_DEBUG("%s: session %lu %s selected_chaining->node[%d]->sff_uuid : %s", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, i, sff_uuid_str);
LOG_DEBUG("%s: session %lu %s selected_chaining->node[%d]->sff_forward_type : %s", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, i, forward_type_tostring(node->sff_forward_type));
// sf
- LOG_DEBUG("%s: session %lu %s selected_chaining->node[%d]->sf_profile_id : %d", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, i, node->sf_profile_id);
+ LOG_DEBUG("%s: session %lu %s selected_chaining->node[%d]->sf_uuid : %s", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, i, sf_uuid_str);
LOG_DEBUG("%s: session %lu %s selected_chaining->node[%d]->sf_action_desc : %s", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, i, action_desc_tostring(node->sf_action_desc));
LOG_DEBUG("%s: session %lu %s selected_chaining->node[%d]->sf_connectivity->encapsulate_method : %s", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, i, encapsulate_method_tostring(node->sf_connectivity.method));
LOG_DEBUG("%s: session %lu %s selected_chaining->node[%d]->sf_connectivity->int_vlan_tag : %d", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, i, node->sf_connectivity.int_vlan_tag);
@@ -1403,6 +1430,10 @@ void selected_chaining_bref(struct selected_chaining *chaining)
return;
}
+ char rule_uuid_str[UUID_STRING_SIZE] = {0};
+ char sff_uuid_str[UUID_STRING_SIZE] = {0};
+ char sf_uuid_str[UUID_STRING_SIZE] = {0};
+
char buff[4096] = {0};
int buff_used = 0;
int buff_size = sizeof(buff);
@@ -1416,9 +1447,14 @@ void selected_chaining_bref(struct selected_chaining *chaining)
{
buff_used += snprintf(buff + buff_used, buff_size - buff_used, ",");
}
+
+ uuid_unparse(node->rule_uuid, rule_uuid_str);
+ uuid_unparse(node->sff_uuid, sff_uuid_str);
+ uuid_unparse(node->sf_uuid, sf_uuid_str);
+
buff_used += snprintf(buff + buff_used, buff_size - buff_used,
- "\"node[%d]\":{\"policy\":\"%lu->%d->%d\",\"action\":\"%s->%s->%s\"}",
- i, node->rule_id, node->sff_profile_id, node->sf_profile_id,
+ "\"node[%d]\":{\"policy\":\"%s->%s->%s\",\"action\":\"%s->%s->%s\"}",
+ i, rule_uuid_str, sff_uuid_str, sf_uuid_str,
traffic_type_tostring(node->traffic_type), forward_type_tostring(node->sff_forward_type), action_desc_tostring(node->sf_action_desc));
}
}
@@ -1444,7 +1480,7 @@ void selected_chaining_uniq(struct selected_chaining *chaining)
is_exist = 0;
for (j = 0; j < i; j++)
{
- if (chaining->chaining[i].sf_profile_id == chaining->chaining[j].sf_profile_id && chaining->chaining[i].sf_action == chaining->chaining[j].sf_action)
+ if (uuid_compare(chaining->chaining[i].sf_uuid, chaining->chaining[j].sf_uuid) == 0 && chaining->chaining[i].sf_action == chaining->chaining[j].sf_action)
{
is_exist = 1;
break;
@@ -1527,19 +1563,6 @@ struct policy_enforcer *policy_enforcer_create(const char *instance, const char
}
maat_options_set_redis(opts, enforcer->config.redis_server, redis_port_select, enforcer->config.redis_db_idx);
break;
- case MAAT_INPUT_FILE:
- if (!strlen(enforcer->config.ful_cfg_dir))
- {
- LOG_ERROR("%s: invalid ful_cfg_dir", LOG_TAG_POLICY);
- goto error_out;
- }
- if (!strlen(enforcer->config.inc_cfg_dir))
- {
- LOG_ERROR("%s: invalid inc_cfg_dir", LOG_TAG_POLICY);
- goto error_out;
- }
- maat_options_set_iris(opts, enforcer->config.ful_cfg_dir, enforcer->config.inc_cfg_dir);
- break;
default:
LOG_ERROR("%s: invalid input_mode %d", LOG_TAG_POLICY, enforcer->config.input_mode);
goto error_out;
@@ -1606,54 +1629,34 @@ void policy_enforcer_destory(struct policy_enforcer *enforcer)
int policy_enforcer_register(struct policy_enforcer *enforcer)
{
LOG_INFO("%s: register policy callback ...", LOG_TAG_POLICY);
- enforcer->compile_table_id = maat_get_table_id(enforcer->maat, "SERVICE_CHAINING_COMPILE");
- if (enforcer->compile_table_id < 0)
- {
- LOG_ERROR("%s: register SERVICE_CHAINING_COMPILE table failed", LOG_TAG_POLICY);
- return -1;
- }
-
- enforcer->sff_table_id = maat_get_table_id(enforcer->maat, "SERVICE_FUNCTION_FORWARDER_PROFILE");
- if (enforcer->sff_table_id < 0)
- {
- LOG_ERROR("%s: register SERVICE_FUNCTION_FORWARDER_PROFILE table ailed", LOG_TAG_POLICY);
- return -1;
- }
- enforcer->sf_table_id = maat_get_table_id(enforcer->maat, "SERVICE_FUNCTION_PROFILE");
- if (enforcer->sf_table_id < 0)
- {
- LOG_ERROR("%s: register SERVICE_FUNCTION_PROFILE table failed", LOG_TAG_POLICY);
- return -1;
- }
-
- if (maat_plugin_table_ex_schema_register(enforcer->maat, "SERVICE_CHAINING_COMPILE",
+ if (maat_plugin_table_ex_schema_register(enforcer->maat, TABLE_NAME_SC,
chaining_param_new_cb,
chaining_param_free_cb,
chaining_param_dup_cb,
0, enforcer) != 0)
{
- LOG_ERROR("%s: register SERVICE_CHAINING_COMPILE plugin extension callbacks failed", LOG_TAG_POLICY);
+ LOG_ERROR("%s: register %s plugin extension callbacks failed", LOG_TAG_POLICY, TABLE_NAME_SC);
return -1;
}
- if (maat_plugin_table_ex_schema_register(enforcer->maat, "SERVICE_FUNCTION_FORWARDER_PROFILE",
+ if (maat_plugin_table_ex_schema_register(enforcer->maat, TABLE_NAME_SFF,
sff_param_new_cb,
sff_param_free_cb,
sff_param_dup_cb,
0, enforcer) != 0)
{
- LOG_ERROR("%s: register SERVICE_FUNCTION_FORWARDER_PROFILE plugin extension callbacks failed", LOG_TAG_POLICY);
+ LOG_ERROR("%s: register %s plugin extension callbacks failed", LOG_TAG_POLICY, TABLE_NAME_SFF);
return -1;
}
- if (maat_plugin_table_ex_schema_register(enforcer->maat, "SERVICE_FUNCTION_PROFILE",
+ if (maat_plugin_table_ex_schema_register(enforcer->maat, TABLE_NAME_SF,
sf_param_new_cb,
sf_param_free_cb,
sf_param_dup_cb,
0, enforcer) != 0)
{
- LOG_ERROR("%s: register SERVICE_FUNCTION_PROFILE plugin extension callbacks failed", LOG_TAG_POLICY);
+ LOG_ERROR("%s: register %s plugin extension callbacks failed", LOG_TAG_POLICY, TABLE_NAME_SF);
return -1;
}
LOG_INFO("%s: register policy callback success", LOG_TAG_POLICY);
@@ -1666,14 +1669,19 @@ int policy_enforce_chaining_size(struct policy_enforcer *enforcer)
return enforcer->config.max_chaining_size;
}
-void policy_enforce_select_chainings(struct policy_enforcer *enforcer, struct session_ctx *s_ctx, struct packet *data_pkt, uint64_t rule_id, int direction)
+void policy_enforce_select_chainings(struct policy_enforcer *enforcer, struct session_ctx *s_ctx, struct packet *data_pkt, uuid_t *rule_uuid_ptr, int direction)
{
- int sff_profile_id;
+ char rule_uuid_str[UUID_STRING_SIZE] = {0};
+ char sff_id_str[UUID_STRING_SIZE] = {0};
+ char sf_uuid_str[UUID_STRING_SIZE] = {0};
+
+ uuid_t *sff_uuid_ptr;
struct selected_chaining *chaining = NULL;
- struct chaining_param *chaining_param = (struct chaining_param *)maat_plugin_table_get_ex_data(enforcer->maat, enforcer->compile_table_id, (const char *)&rule_id, sizeof(rule_id));
+ uuid_unparse(*rule_uuid_ptr, rule_uuid_str);
+ struct chaining_param *chaining_param = (struct chaining_param *)maat_plugin_table_get_ex_data(enforcer->maat, TABLE_NAME_SC, (const char *)rule_uuid_str, strlen(rule_uuid_str));
if (chaining_param == NULL)
{
- LOG_ERROR("%s: session %lu %s failed to get chaining parameter of policy %lu", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, rule_id);
+ LOG_ERROR("%s: session %lu %s failed to get chaining parameter of policy %s", LOG_TAG_POLICY, s_ctx->session_id, s_ctx->session_addr, rule_uuid_str);
return;
}
@@ -1685,28 +1693,30 @@ void policy_enforce_select_chainings(struct policy_enforcer *enforcer, struct se
{
chaining = s_ctx->chaining_decrypted;
}
- LOG_INFO("%s: session %lu %s enforce %s chaining: rule_id %lu", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, traffic_type_tostring(chaining_param->traffic_type), rule_id);
+ LOG_INFO("%s: session %lu %s enforce %s chaining: rule_uuid %s", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, traffic_type_tostring(chaining_param->traffic_type), rule_uuid_str);
- for (int i = 0; i < chaining_param->sff_profile_ids_num && chaining->chaining_used < chaining->chaining_size; i++)
+ int sff_uuid_num = uuid_array_get_count(&chaining_param->sff_uuid_array);
+ for (int i = 0; i < sff_uuid_num && chaining->chaining_used < chaining->chaining_size; i++)
{
struct selected_sf *selected_sf = &(chaining->chaining[chaining->chaining_used]);
selected_sf_init(selected_sf);
- sff_profile_id = chaining_param->sff_profile_ids[i];
- struct sff_param *sff_param = (struct sff_param *)maat_plugin_table_get_ex_data(enforcer->maat, enforcer->sff_table_id, (const char *)&sff_profile_id, sizeof(sff_profile_id));
+ sff_uuid_ptr = uuid_array_get_at(&chaining_param->sff_uuid_array, i);
+ uuid_unparse(*sff_uuid_ptr, sff_id_str);
+ struct sff_param *sff_param = (struct sff_param *)maat_plugin_table_get_ex_data(enforcer->maat, TABLE_NAME_SFF, (const char *)sff_id_str, strlen(sff_id_str));
if (sff_param == NULL)
{
- LOG_ERROR("%s: session %lu %s failed to get sff parameter of profile %d, bypass current sff !!!", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, sff_profile_id);
+ LOG_ERROR("%s: session %lu %s failed to get sff parameter of profile %s, bypass current sff !!!", LOG_TAG_POLICY, chaining->session_id, chaining->session_addr, sff_id_str);
continue;
}
// sc info
- selected_sf->rule_id = rule_id;
+ uuid_copy(selected_sf->rule_uuid, *rule_uuid_ptr);
selected_sf->rule_vsys_id = chaining_param->vsys_id;
selected_sf->traffic_type = chaining_param->traffic_type;
// sff info
- selected_sf->sff_profile_id = sff_profile_id;
+ uuid_copy(selected_sf->sff_uuid, *sff_uuid_ptr);
selected_sf->sff_forward_type = sff_param->sff_forward_type;
// sf_index
@@ -1715,16 +1725,19 @@ void policy_enforce_select_chainings(struct policy_enforcer *enforcer, struct se
uint64_t packet_hash = packet_get_hash(data_pkt, sff_param->sff_ldbc.method, direction);
select_sf_from_sff(enforcer, sff_param, selected_sf, s_ctx, packet_hash);
- LOG_INFO("%s: session %lu %s enforce chaining [%d/%d]: policy: %lu->%d->%d, action: %s->%s->%s",
+ uuid_unparse(selected_sf->sf_uuid, sf_uuid_str);
+ LOG_INFO("%s: session %lu %s enforce chaining [%d/%d]: policy: %s->%s->%s, action: %s->%s->%s",
LOG_TAG_POLICY, chaining->session_id, chaining->session_addr,
selected_sf->sf_index, chaining->chaining_size,
- selected_sf->rule_id, selected_sf->sff_profile_id, selected_sf->sf_profile_id,
+ rule_uuid_str, sff_id_str, sf_uuid_str,
traffic_type_tostring(chaining_param->traffic_type), forward_type_tostring(selected_sf->sff_forward_type), action_desc_tostring(selected_sf->sf_action_desc));
chaining->chaining_used++;
sff_param_free(sff_param);
}
+ uuid_array_append(&s_ctx->rule_uuid_array, *rule_uuid_ptr);
+
selected_chaining_uniq(chaining);
chaining_param_free(chaining_param);
}
diff --git a/platform/src/sce.cpp b/platform/src/sce.cpp
index fab0db8..ea235f2 100644
--- a/platform/src/sce.cpp
+++ b/platform/src/sce.cpp
@@ -26,7 +26,7 @@ struct session_ctx *session_ctx_new()
struct session_ctx *session_ctx = (struct session_ctx *)calloc(1, sizeof(struct session_ctx));
assert(session_ctx != NULL);
- mutable_array_init(&session_ctx->rule_ids);
+ uuid_array_init(&session_ctx->rule_uuid_array);
return session_ctx;
}
diff --git a/platform/src/sf_metrics.cpp b/platform/src/sf_metrics.cpp
index 4b0f894..60e8d06 100644
--- a/platform/src/sf_metrics.cpp
+++ b/platform/src/sf_metrics.cpp
@@ -226,9 +226,9 @@ void sf_metrics_input(struct sf_metrics *handle, uint16_t thr_idx, struct sf_met
{
node = (struct metric *)calloc(1, sizeof(struct metric));
node->key.vsys_id = key->vsys_id;
- node->key.rule_id = key->rule_id;
- node->key.sff_profile_id = key->sff_profile_id;
- node->key.sf_profile_id = key->sf_profile_id;
+ uuid_copy(node->key.rule_uuid, key->rule_uuid);
+ uuid_copy(node->key.sff_uuid, key->sff_uuid);
+ uuid_copy(node->key.sf_uuid, key->sf_uuid);
node->recv_pkts = rx_pkts;
node->recv_bytes = rx_bytes;
@@ -254,6 +254,9 @@ void sf_metrics_output(struct sf_metrics *handle, uint16_t thr_idx)
struct metric *temp = NULL;
struct metric *node = NULL;
+ char rule_uuid_str[UUID_STRING_SIZE] = {0};
+ char sff_uuid_str[UUID_STRING_SIZE] = {0};
+ char sf_uuid_str[UUID_STRING_SIZE] = {0};
HASH_ITER(hh, handle->root[thr_idx], node, temp)
{
if (node->sent_pkts == 0 && node->recv_pkts == 0 &&
@@ -262,11 +265,14 @@ void sf_metrics_output(struct sf_metrics *handle, uint16_t thr_idx)
continue;
}
+ uuid_unparse(node->key.rule_uuid, rule_uuid_str);
+ uuid_unparse(node->key.sff_uuid, sff_uuid_str);
+ uuid_unparse(node->key.sf_uuid, sf_uuid_str);
const struct field tags[] = {
{"vsys_id", FIELD_VALUE_INTEGER, {.value_longlong = node->key.vsys_id}},
- {"rule_id", FIELD_VALUE_INTEGER, {.value_longlong = (long long)node->key.rule_id}},
- {"sff_profile_id", FIELD_VALUE_INTEGER, {.value_longlong = node->key.sff_profile_id}},
- {"sf_profile_id", FIELD_VALUE_INTEGER, {.value_longlong = node->key.sf_profile_id}},
+ {"rule_uuid", FIELD_VALUE_CSTRING, {.value_str = rule_uuid_str}},
+ {"sff_profile_uuid", FIELD_VALUE_CSTRING, {.value_str = sff_uuid_str}},
+ {"sf_profile_uuid", FIELD_VALUE_CSTRING, {.value_str = sf_uuid_str}},
};
fieldstat_easy_counter_incrby(handle->fs, thr_idx, handle->sent_pkts_idx, tags, sizeof(tags) / sizeof(tags[0]), node->sent_pkts);
diff --git a/platform/src/sf_status.cpp b/platform/src/sf_status.cpp
index 21a49de..50f54f4 100644
--- a/platform/src/sf_status.cpp
+++ b/platform/src/sf_status.cpp
@@ -140,7 +140,7 @@ void sf_status_update(struct sf_status *handle, const struct sf_status_key *key,
{
temp = (struct metric *)calloc(1, sizeof(struct metric));
temp->key.vsys_id = key->vsys_id;
- temp->key.sf_profile_id = key->sf_profile_id;
+ uuid_copy(temp->key.sf_uuid, key->sf_uuid);
temp->sf_status = sf_status;
temp->sf_latency = sf_latency;
HASH_ADD(hh, handle->htable, key, sizeof(struct sf_status_key), temp);
@@ -154,13 +154,15 @@ void sf_status_output(struct sf_status *handle)
return;
}
+ char sf_uuid_str[UUID_STRING_SIZE] = {0};
struct metric *temp = NULL;
struct metric *node = NULL;
HASH_ITER(hh, handle->htable, node, temp)
{
+ uuid_unparse(node->key.sf_uuid, sf_uuid_str);
const struct field tags[] = {
{"vsys_id", FIELD_VALUE_INTEGER, {.value_longlong = node->key.vsys_id}},
- {"sf_profile_id", FIELD_VALUE_INTEGER, {.value_longlong = node->key.sf_profile_id}},
+ {"sf_profile_uuid", FIELD_VALUE_CSTRING, {.value_str = sf_uuid_str}},
};
fieldstat_easy_counter_set(handle->fs, 0, handle->sf_status_idx, tags, sizeof(tags) / sizeof(tags[0]), node->sf_status);
diff --git a/platform/test/gtest_policy.cpp b/platform/test/gtest_policy.cpp
index 892778b..1ea1441 100644
--- a/platform/test/gtest_policy.cpp
+++ b/platform/test/gtest_policy.cpp
@@ -14,6 +14,85 @@ unsigned char data1[] = {
0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd};
+uuid_t rule_uuid1;
+uuid_t rule_uuid2;
+uuid_t rule_uuid11;
+uuid_t rule_uuid12;
+
+uuid_t sff_uuid1;
+uuid_t sff_uuid2;
+uuid_t sff_uuid3;
+uuid_t sff_uuid4;
+uuid_t sff_uuid5;
+uuid_t sff_uuid6;
+uuid_t sff_uuid7;
+uuid_t sff_uuid8;
+uuid_t sff_uuid9;
+uuid_t sff_uuid10;
+
+uuid_t sf_uuid1;
+uuid_t sf_uuid2;
+uuid_t sf_uuid3;
+uuid_t sf_uuid4;
+uuid_t sf_uuid5;
+uuid_t sf_uuid6;
+uuid_t sf_uuid7;
+uuid_t sf_uuid8;
+
+const char rule_uuid1_str[] = "00000000-0000-0000-1111-000000000001";
+const char rule_uuid2_str[] = "00000000-0000-0000-1111-000000000002";
+const char rule_uuid11_str[] = "00000000-0000-0000-1111-000000000011";
+const char rule_uuid12_str[] = "00000000-0000-0000-1111-000000000012";
+
+const char sff_uuid1_str[] = "00000000-0000-0000-2222-000000000001";
+const char sff_uuid2_str[] = "00000000-0000-0000-2222-000000000002";
+const char sff_uuid3_str[] = "00000000-0000-0000-2222-000000000003";
+const char sff_uuid4_str[] = "00000000-0000-0000-2222-000000000004";
+const char sff_uuid5_str[] = "00000000-0000-0000-2222-000000000005";
+const char sff_uuid6_str[] = "00000000-0000-0000-2222-000000000006";
+const char sff_uuid7_str[] = "00000000-0000-0000-2222-000000000007";
+const char sff_uuid8_str[] = "00000000-0000-0000-2222-000000000008";
+const char sff_uuid9_str[] = "00000000-0000-0000-2222-000000000009";
+const char sff_uuid10_str[] = "00000000-0000-0000-2222-000000000010";
+
+const char sf_uuid1_str[] = "00000000-0000-0000-3333-000000000001";
+const char sf_uuid2_str[] = "00000000-0000-0000-3333-000000000002";
+const char sf_uuid3_str[] = "00000000-0000-0000-3333-000000000003";
+const char sf_uuid4_str[] = "00000000-0000-0000-3333-000000000004";
+const char sf_uuid5_str[] = "00000000-0000-0000-3333-000000000005";
+const char sf_uuid6_str[] = "00000000-0000-0000-3333-000000000006";
+const char sf_uuid7_str[] = "00000000-0000-0000-3333-000000000007";
+const char sf_uuid8_str[] = "00000000-0000-0000-3333-000000000008";
+
+static void uuid_init()
+{
+ uuid_parse(rule_uuid1_str, rule_uuid1);
+ uuid_parse(rule_uuid2_str, rule_uuid2);
+ uuid_parse(rule_uuid11_str, rule_uuid11);
+ uuid_parse(rule_uuid12_str, rule_uuid12);
+
+ uuid_parse(sff_uuid1_str, sff_uuid1);
+ uuid_parse(sff_uuid2_str, sff_uuid2);
+ uuid_parse(sff_uuid3_str, sff_uuid3);
+ uuid_parse(sff_uuid4_str, sff_uuid4);
+ uuid_parse(sff_uuid5_str, sff_uuid5);
+ uuid_parse(sff_uuid6_str, sff_uuid6);
+ uuid_parse(sff_uuid7_str, sff_uuid7);
+ uuid_parse(sff_uuid8_str, sff_uuid8);
+ uuid_parse(sff_uuid9_str, sff_uuid9);
+ uuid_parse(sff_uuid10_str, sff_uuid10);
+
+ uuid_parse(sf_uuid1_str, sf_uuid1);
+ uuid_parse(sf_uuid2_str, sf_uuid2);
+ uuid_parse(sf_uuid3_str, sf_uuid3);
+ uuid_parse(sf_uuid4_str, sf_uuid4);
+ uuid_parse(sf_uuid5_str, sf_uuid5);
+ uuid_parse(sf_uuid6_str, sf_uuid6);
+ uuid_parse(sf_uuid7_str, sf_uuid7);
+ uuid_parse(sf_uuid8_str, sf_uuid8);
+}
+
+#if 1
// 都不同
TEST(POLICY, SELECTED_CHAINING1)
{
@@ -22,21 +101,23 @@ TEST(POLICY, SELECTED_CHAINING1)
chainings = selected_chaining_create(3, 1, (char *)"1.1.1.1 11 2.2.2.2 22");
EXPECT_TRUE(chainings != nullptr);
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 1;
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 2;
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 3;
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid1);
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid2);
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid3);
selected_chaining_uniq(chainings);
selected_chaining_dump(chainings);
EXPECT_TRUE(chainings->chaining_used == 3);
- EXPECT_TRUE(chainings->chaining[0].sf_profile_id == 1);
- EXPECT_TRUE(chainings->chaining[1].sf_profile_id == 2);
- EXPECT_TRUE(chainings->chaining[2].sf_profile_id == 3);
+ EXPECT_TRUE(uuid_compare(chainings->chaining[0].sf_uuid, sf_uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(chainings->chaining[1].sf_uuid, sf_uuid2) == 0);
+ EXPECT_TRUE(uuid_compare(chainings->chaining[2].sf_uuid, sf_uuid3) == 0);
selected_chaining_destory(chainings);
}
+#endif
+#if 1
// 都相同
TEST(POLICY, SELECTED_CHAINING2)
{
@@ -45,19 +126,21 @@ TEST(POLICY, SELECTED_CHAINING2)
chainings = selected_chaining_create(3, 1, (char *)"1.1.1.1 11 2.2.2.2 22");
EXPECT_TRUE(chainings != nullptr);
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 1;
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 1;
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 1;
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid1);
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid1);
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid1);
selected_chaining_uniq(chainings);
selected_chaining_dump(chainings);
EXPECT_TRUE(chainings->chaining_used == 1);
- EXPECT_TRUE(chainings->chaining[0].sf_profile_id == 1);
+ EXPECT_TRUE(uuid_compare(chainings->chaining[0].sf_uuid, sf_uuid1) == 0);
selected_chaining_destory(chainings);
}
+#endif
+#if 1
// 两个相同 (1,2相同)
TEST(POLICY, SELECTED_CHAINING3)
{
@@ -66,20 +149,22 @@ TEST(POLICY, SELECTED_CHAINING3)
chainings = selected_chaining_create(3, 1, (char *)"1.1.1.1 11 2.2.2.2 22");
EXPECT_TRUE(chainings != nullptr);
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 1;
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 1;
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 2;
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid1);
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid1);
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid2);
selected_chaining_uniq(chainings);
selected_chaining_dump(chainings);
EXPECT_TRUE(chainings->chaining_used == 2);
- EXPECT_TRUE(chainings->chaining[0].sf_profile_id == 1);
- EXPECT_TRUE(chainings->chaining[1].sf_profile_id == 2);
+ EXPECT_TRUE(uuid_compare(chainings->chaining[0].sf_uuid, sf_uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(chainings->chaining[1].sf_uuid, sf_uuid2) == 0);
selected_chaining_destory(chainings);
}
+#endif
+#if 1
// 两个相同 (1,3相同)
TEST(POLICY, SELECTED_CHAINING4)
{
@@ -88,20 +173,22 @@ TEST(POLICY, SELECTED_CHAINING4)
chainings = selected_chaining_create(3, 1, (char *)"1.1.1.1 11 2.2.2.2 22");
EXPECT_TRUE(chainings != nullptr);
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 1;
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 2;
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 1;
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid1);
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid2);
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid1);
selected_chaining_uniq(chainings);
selected_chaining_dump(chainings);
EXPECT_TRUE(chainings->chaining_used == 2);
- EXPECT_TRUE(chainings->chaining[0].sf_profile_id == 1);
- EXPECT_TRUE(chainings->chaining[1].sf_profile_id == 2);
+ EXPECT_TRUE(uuid_compare(chainings->chaining[0].sf_uuid, sf_uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(chainings->chaining[1].sf_uuid, sf_uuid2) == 0);
selected_chaining_destory(chainings);
}
+#endif
+#if 1
// 两个相同 (2,3相同)
TEST(POLICY, SELECTED_CHAINING5)
{
@@ -110,20 +197,22 @@ TEST(POLICY, SELECTED_CHAINING5)
chainings = selected_chaining_create(3, 1, (char *)"1.1.1.1 11 2.2.2.2 22");
EXPECT_TRUE(chainings != nullptr);
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 2;
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 1;
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 1;
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid1);
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid2);
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid2);
selected_chaining_uniq(chainings);
selected_chaining_dump(chainings);
EXPECT_TRUE(chainings->chaining_used == 2);
- EXPECT_TRUE(chainings->chaining[0].sf_profile_id == 2);
- EXPECT_TRUE(chainings->chaining[1].sf_profile_id == 1);
+ EXPECT_TRUE(uuid_compare(chainings->chaining[0].sf_uuid, sf_uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(chainings->chaining[1].sf_uuid, sf_uuid2) == 0);
selected_chaining_destory(chainings);
}
+#endif
+#if 1
// 没有数据
TEST(POLICY, SELECTED_CHAINING6)
{
@@ -139,7 +228,9 @@ TEST(POLICY, SELECTED_CHAINING6)
selected_chaining_destory(chainings);
}
+#endif
+#if 1
// 只有一个
TEST(POLICY, SELECTED_CHAINING7)
{
@@ -148,16 +239,17 @@ TEST(POLICY, SELECTED_CHAINING7)
chainings = selected_chaining_create(3, 1, (char *)"1.1.1.1 11 2.2.2.2 22");
EXPECT_TRUE(chainings != nullptr);
- chainings->chaining[chainings->chaining_used++].sf_profile_id = 1;
+ uuid_copy(chainings->chaining[chainings->chaining_used++].sf_uuid, sf_uuid1);
selected_chaining_uniq(chainings);
selected_chaining_dump(chainings);
EXPECT_TRUE(chainings->chaining_used == 1);
- EXPECT_TRUE(chainings->chaining[0].sf_profile_id == 1);
+ EXPECT_TRUE(uuid_compare(chainings->chaining[0].sf_uuid, sf_uuid1) == 0);
selected_chaining_destory(chainings);
}
+#endif
#if 1
TEST(POLICY, POLICY_ENFORCER_RAW_TRAFFIC1)
@@ -170,6 +262,7 @@ TEST(POLICY, POLICY_ENFORCER_RAW_TRAFFIC1)
s_ctx.ref_thread_ctx = &t_ctx;
s_ctx.session_id = 1;
s_ctx.session_addr = (char *)"1.1.1.1 11 2.2.2.2 22";
+ uuid_array_init(&s_ctx.rule_uuid_array);
struct packet handler;
@@ -184,18 +277,18 @@ TEST(POLICY, POLICY_ENFORCER_RAW_TRAFFIC1)
int direction = 1;
s_ctx.chaining_raw = selected_chaining_create(64, s_ctx.session_id, s_ctx.session_addr);
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 1, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid1, direction);
/*
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 1, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 1, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
*/
EXPECT_TRUE(s_ctx.chaining_raw->chaining_used == 1);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].rule_id == 1);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sff_profile_id == 1);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[0].rule_uuid, rule_uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[0].sff_uuid, sff_uuid1) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_raw->chaining[0].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_action == SESSION_ACTION_BYPASS);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_action_desc == ACTION_BYPASS_DUE_FAILURE_ACTION);
@@ -222,6 +315,7 @@ TEST(POLICY, POLICY_ENFORCER_RAW_TRAFFIC2)
s_ctx.ref_thread_ctx = &t_ctx;
s_ctx.session_id = 1;
s_ctx.session_addr = (char *)"1.1.1.1 11 2.2.2.2 22";
+ uuid_array_init(&s_ctx.rule_uuid_array);
struct packet handler;
@@ -236,59 +330,59 @@ TEST(POLICY, POLICY_ENFORCER_RAW_TRAFFIC2)
int direction = 1;
s_ctx.chaining_raw = selected_chaining_create(64, s_ctx.session_id, s_ctx.session_addr);
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 2, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid2, direction);
/*
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 4 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 5 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 6 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 7 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 8 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 2, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 3, sf_profile_id -1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 4, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 5, sf_profile_id -1, sf_action block, sf_action_desc block_due_unavailable_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 6, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 7, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 8, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 9, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 10, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 4 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 5 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 6 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 7 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 8 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 2, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 3, sf_uuid -1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 4, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 5, sf_uuid -1, sf_action block, sf_action_desc block_due_unavailable_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 6, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 7, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 8, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 9, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 10, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
*/
EXPECT_TRUE(s_ctx.chaining_raw->chaining_used == 3);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].rule_id == 2);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sff_profile_id == 1);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[0].rule_uuid, rule_uuid2) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[0].sff_uuid, sff_uuid1) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_raw->chaining[0].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_action == SESSION_ACTION_BYPASS);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_action_desc == ACTION_BYPASS_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].rule_id == 2);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sff_profile_id == 3);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[1].rule_uuid, rule_uuid2) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[1].sff_uuid, sff_uuid3) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_raw->chaining[1].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].rule_id == 2);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sff_profile_id == 6);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sf_profile_id == 1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[2].rule_uuid, rule_uuid2) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[2].sff_uuid, sff_uuid6) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[2].sf_uuid, sf_uuid1) == 0);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
@@ -315,6 +409,7 @@ TEST(POLICY, POLICY_ENFORCER_RAW_TRAFFIC_MUTIL_HITS)
s_ctx.ref_thread_ctx = &t_ctx;
s_ctx.session_id = 1;
s_ctx.session_addr = (char *)"1.1.1.1 11 2.2.2.2 22";
+ uuid_array_init(&s_ctx.rule_uuid_array);
struct packet handler;
@@ -329,64 +424,64 @@ TEST(POLICY, POLICY_ENFORCER_RAW_TRAFFIC_MUTIL_HITS)
int direction = 1;
s_ctx.chaining_raw = selected_chaining_create(64, s_ctx.session_id, s_ctx.session_addr);
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 1, direction);
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 2, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid1, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid2, direction);
/*
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 1
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 1, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 4 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 5 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 6 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 7 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 8 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 2, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 3, sf_profile_id -1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 4, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 5, sf_profile_id -1, sf_action block, sf_action_desc block_due_unavailable_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 6, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 7, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 8, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 9, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 10, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 1
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 1, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 4 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 5 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 6 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 7 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 8 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 2, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 3, sf_uuid -1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 4, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 5, sf_uuid -1, sf_action block, sf_action_desc block_due_unavailable_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 6, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 7, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 8, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 9, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 10, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
*/
EXPECT_TRUE(s_ctx.chaining_raw->chaining_used == 3);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].rule_id == 1);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sff_profile_id == 1);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[0].rule_uuid, rule_uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[0].sff_uuid, sff_uuid1) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_raw->chaining[0].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_action == SESSION_ACTION_BYPASS);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_action_desc == ACTION_BYPASS_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].rule_id == 2);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sff_profile_id == 3);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[1].rule_uuid, rule_uuid2) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[1].sff_uuid, sff_uuid3) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_raw->chaining[1].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].rule_id == 2);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sff_profile_id == 6);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sf_profile_id == 1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[2].rule_uuid, rule_uuid2) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[2].sff_uuid, sff_uuid6) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[2].sf_uuid, sf_uuid1) == 0);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
@@ -413,6 +508,7 @@ TEST(POLICY, POLICY_ENFORCER_DECRYPTED_TRAFFIC1)
s_ctx.ref_thread_ctx = &t_ctx;
s_ctx.session_id = 1;
s_ctx.session_addr = (char *)"1.1.1.1 11 2.2.2.2 22";
+ uuid_array_init(&s_ctx.rule_uuid_array);
struct packet handler;
@@ -427,19 +523,19 @@ TEST(POLICY, POLICY_ENFORCER_DECRYPTED_TRAFFIC1)
int direction = 1;
s_ctx.chaining_decrypted = selected_chaining_create(64, s_ctx.session_id, s_ctx.session_addr);
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 11, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid11, direction);
/*
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 11
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 11, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 11
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 11, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
*/
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining_used == 1);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].rule_id == 11);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sff_profile_id == 1);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[0].rule_uuid, rule_uuid11) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[0].sff_uuid, sff_uuid1) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_decrypted->chaining[0].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_action == SESSION_ACTION_BYPASS);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_action_desc == ACTION_BYPASS_DUE_FAILURE_ACTION);
@@ -466,6 +562,7 @@ TEST(POLICY, POLICY_ENFORCER_DECRYPTED_TRAFFIC2)
s_ctx.ref_thread_ctx = &t_ctx;
s_ctx.session_id = 1;
s_ctx.session_addr = (char *)"1.1.1.1 11 2.2.2.2 22";
+ uuid_array_init(&s_ctx.rule_uuid_array);
struct packet handler;
@@ -480,60 +577,60 @@ TEST(POLICY, POLICY_ENFORCER_DECRYPTED_TRAFFIC2)
int direction = 1;
s_ctx.chaining_decrypted = selected_chaining_create(64, s_ctx.session_id, s_ctx.session_addr);
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 12, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid12, direction);
/*
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 4 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 5 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 6 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 7 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 8 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 2, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 3, sf_profile_id -1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 4, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 5, sf_profile_id -1, sf_action block, sf_action_desc block_due_unavailable_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 6, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 7, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 8, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 9, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 10, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 4 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 5 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 6 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 7 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 8 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 2, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 3, sf_uuid -1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 4, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 5, sf_uuid -1, sf_action block, sf_action_desc block_due_unavailable_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 6, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 7, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 8, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 9, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 10, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
*/
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining_used == 3);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].rule_id == 12);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sff_profile_id == 1);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[0].rule_uuid, rule_uuid12) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[0].sff_uuid, sff_uuid1) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_decrypted->chaining[0].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_action == SESSION_ACTION_BYPASS);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_action_desc == ACTION_BYPASS_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].rule_id == 12);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sff_profile_id == 3);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[1].rule_uuid, rule_uuid12) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[1].sff_uuid, sff_uuid3) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_decrypted->chaining[1].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].rule_id == 12);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sff_profile_id == 6);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sf_profile_id == 1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[2].rule_uuid, rule_uuid12) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[2].sff_uuid, sff_uuid6) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[2].sf_uuid, sf_uuid1) == 0);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
@@ -560,6 +657,7 @@ TEST(POLICY, POLICY_ENFORCER_DECRYPTED_TRAFFIC_MUTIL_HITS)
s_ctx.ref_thread_ctx = &t_ctx;
s_ctx.session_id = 1;
s_ctx.session_addr = (char *)"1.1.1.1 11 2.2.2.2 22";
+ uuid_array_init(&s_ctx.rule_uuid_array);
struct packet handler;
@@ -574,64 +672,64 @@ TEST(POLICY, POLICY_ENFORCER_DECRYPTED_TRAFFIC_MUTIL_HITS)
int direction = 1;
s_ctx.chaining_decrypted = selected_chaining_create(64, s_ctx.session_id, s_ctx.session_addr);
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 11, direction);
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 12, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid11, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid12, direction);
/*
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 11
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 11, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 4 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 5 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 6 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 7 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 8 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 2, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 3, sf_profile_id -1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 4, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 5, sf_profile_id -1, sf_action block, sf_action_desc block_due_unavailable_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 6, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 7, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 8, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 9, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 10, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 11
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 11, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 4 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 5 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 6 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 7 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 8 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 2, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 3, sf_uuid -1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 4, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 5, sf_uuid -1, sf_action block, sf_action_desc block_due_unavailable_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 6, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 7, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 8, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 9, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 10, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
*/
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining_used == 3);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].rule_id == 11);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sff_profile_id == 1);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[0].rule_uuid, rule_uuid11) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[0].sff_uuid, sff_uuid1) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_decrypted->chaining[0].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_action == SESSION_ACTION_BYPASS);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_action_desc == ACTION_BYPASS_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].rule_id == 12);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sff_profile_id == 3);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[1].rule_uuid, rule_uuid12) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[1].sff_uuid, sff_uuid3) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_decrypted->chaining[1].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].rule_id == 12);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sff_profile_id == 6);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sf_profile_id == 1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[2].rule_uuid, rule_uuid12) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[2].sff_uuid, sff_uuid6) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[2].sf_uuid, sf_uuid1) == 0);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
@@ -658,6 +756,7 @@ TEST(POLICY, POLICY_ENFORCER_MIX_TRAFFIC_MUTIL_HITS)
s_ctx.ref_thread_ctx = &t_ctx;
s_ctx.session_id = 1;
s_ctx.session_addr = (char *)"1.1.1.1 11 2.2.2.2 22";
+ uuid_array_init(&s_ctx.rule_uuid_array);
struct packet handler;
@@ -674,111 +773,111 @@ TEST(POLICY, POLICY_ENFORCER_MIX_TRAFFIC_MUTIL_HITS)
s_ctx.chaining_raw = selected_chaining_create(64, s_ctx.session_id, s_ctx.session_addr);
s_ctx.chaining_decrypted = selected_chaining_create(64, s_ctx.session_id, s_ctx.session_addr);
// raw traffic multi hits
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 1, direction);
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 2, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid1, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid2, direction);
// decrypted traffic multi hits
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 11, direction);
- policy_enforce_select_chainings(enforcer, &s_ctx, &handler, 12, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid11, direction);
+ policy_enforce_select_chainings(enforcer, &s_ctx, &handler, &rule_uuid12, direction);
/*
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 1
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 1, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 4 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 5 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 6 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 7 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 8 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 2, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 3, sf_profile_id -1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 4, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 5, sf_profile_id -1, sf_action block, sf_action_desc block_due_unavailable_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 6, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 7, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 8, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 9, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_id 2, sff_profile_id 10, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 11
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 11, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 1, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 4 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 5 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 6 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 7 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_profile_id 8 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 2, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 3, sf_profile_id -1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 4, sf_profile_id -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 1 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 2 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_profile_id 3 to be excluded
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 5, sf_profile_id -1, sf_action block, sf_action_desc block_due_unavailable_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 6, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 7, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 8, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 9, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_profile_id 1 to be selected
- POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_id 12, sff_profile_id 10, sf_profile_id 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 1
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 1, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 4 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 5 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 6 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 7 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 8 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 2, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 3, sf_uuid -1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 4, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 5, sf_uuid -1, sf_action block, sf_action_desc block_due_unavailable_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 6, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 7, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 8, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 9, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce raw chaining: rule_uuid 2, sff_uuid 10, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 11
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 11, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 1, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 4 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 5 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 6 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 7 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by admin-status, sf_uuid 8 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 2, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 3, sf_uuid -1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 4, sf_uuid -1, sf_action bypass, sf_action_desc bypass_due_health_sf_limit
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 1 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 2 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by localization, sf_uuid 3 to be excluded
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 5, sf_uuid -1, sf_action block, sf_action_desc block_due_unavailable_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 6, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 7, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 8, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 9, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 select sf by fail-action, sf_uuid 1 to be selected
+ POLICY: session 1 1.1.1.1 11 2.2.2.2 22 enforce decrypted chaining: rule_uuid 12, sff_uuid 10, sf_uuid 1, sf_action block, sf_action_desc block_due_failure_action
POLICY: session 1 1.1.1.1 11 2.2.2.2 22 selected_chaining_bref: chaining_size:64, chaining_used:3, {
- "node[0]":{"rule_id":1,"sff_profile_id":1,"sf_profile_id":-1,"traffic_type":"raw","sff_forward_type":"steering","sf_action":"bypass","reason":"bypass_due_failure_action"},
- "node[1]":{"rule_id":2,"sff_profile_id":3,"sf_profile_id":-1,"traffic_type":"raw","sff_forward_type":"steering","sf_action":"block","reason":"block_due_failure_action"},
- "node[2]":{"rule_id":2,"sff_profile_id":6,"sf_profile_id":1,"traffic_type":"raw","sff_forward_type":"steering","sf_action":"block","reason":"block_due_failure_action"}}
+ "node[0]":{"rule_uuid":1,"sff_uuid":1,"sf_uuid":-1,"traffic_type":"raw","sff_forward_type":"steering","sf_action":"bypass","reason":"bypass_due_failure_action"},
+ "node[1]":{"rule_uuid":2,"sff_uuid":3,"sf_uuid":-1,"traffic_type":"raw","sff_forward_type":"steering","sf_action":"block","reason":"block_due_failure_action"},
+ "node[2]":{"rule_uuid":2,"sff_uuid":6,"sf_uuid":1,"traffic_type":"raw","sff_forward_type":"steering","sf_action":"block","reason":"block_due_failure_action"}}
POLICY: session 1 1.1.1.1 11 2.2.2.2 22 selected_chaining_bref: chaining_size:64, chaining_used:3, {
- "node[0]":{"rule_id":11,"sff_profile_id":1,"sf_profile_id":-1,"traffic_type":"decrypted","sff_forward_type":"steering","sf_action":"bypass","reason":"bypass_due_failure_action"},
- "node[1]":{"rule_id":12,"sff_profile_id":3,"sf_profile_id":-1,"traffic_type":"decrypted","sff_forward_type":"steering","sf_action":"block","reason":"block_due_failure_action"},
- "node[2]":{"rule_id":12,"sff_profile_id":6,"sf_profile_id":1,"traffic_type":"decrypted","sff_forward_type":"steering","sf_action":"block","reason":"block_due_failure_action"}}
+ "node[0]":{"rule_uuid":11,"sff_uuid":1,"sf_uuid":-1,"traffic_type":"decrypted","sff_forward_type":"steering","sf_action":"bypass","reason":"bypass_due_failure_action"},
+ "node[1]":{"rule_uuid":12,"sff_uuid":3,"sf_uuid":-1,"traffic_type":"decrypted","sff_forward_type":"steering","sf_action":"block","reason":"block_due_failure_action"},
+ "node[2]":{"rule_uuid":12,"sff_uuid":6,"sf_uuid":1,"traffic_type":"decrypted","sff_forward_type":"steering","sf_action":"block","reason":"block_due_failure_action"}}
*/
// raw traffic
EXPECT_TRUE(s_ctx.chaining_raw->chaining_used == 3);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].rule_id == 1);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sff_profile_id == 1);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[0].rule_uuid, rule_uuid1) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[0].sff_uuid, sff_uuid1) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_raw->chaining[0].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_action == SESSION_ACTION_BYPASS);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[0].sf_action_desc == ACTION_BYPASS_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].rule_id == 2);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sff_profile_id == 3);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[1].rule_uuid, rule_uuid2) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[1].sff_uuid, sff_uuid3) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_raw->chaining[1].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[1].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].rule_id == 2);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sff_profile_id == 6);
- EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sf_profile_id == 1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[2].rule_uuid, rule_uuid2) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[2].sff_uuid, sff_uuid6) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_raw->chaining[2].sf_uuid, sf_uuid1) == 0);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_raw->chaining[2].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
@@ -789,21 +888,21 @@ TEST(POLICY, POLICY_ENFORCER_MIX_TRAFFIC_MUTIL_HITS)
// decrypted traffic
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining_used == 3);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].rule_id == 11);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sff_profile_id == 1);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[0].rule_uuid, rule_uuid11) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[0].sff_uuid, sff_uuid1) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_decrypted->chaining[0].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_action == SESSION_ACTION_BYPASS);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[0].sf_action_desc == ACTION_BYPASS_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].rule_id == 12);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sff_profile_id == 3);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sf_profile_id == -1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[1].rule_uuid, rule_uuid12) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[1].sff_uuid, sff_uuid3) == 0);
+ EXPECT_TRUE(uuid_is_null(s_ctx.chaining_decrypted->chaining[1].sf_uuid));
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[1].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].rule_id == 12);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sff_profile_id == 6);
- EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sf_profile_id == 1);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[2].rule_uuid, rule_uuid12) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[2].sff_uuid, sff_uuid6) == 0);
+ EXPECT_TRUE(uuid_compare(s_ctx.chaining_decrypted->chaining[2].sf_uuid, sf_uuid1) == 0);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sf_action == SESSION_ACTION_BLOCK);
EXPECT_TRUE(s_ctx.chaining_decrypted->chaining[2].sf_action_desc == ACTION_BLOCK_DUE_FAILURE_ACTION);
@@ -821,6 +920,7 @@ TEST(POLICY, POLICY_ENFORCER_MIX_TRAFFIC_MUTIL_HITS)
int main(int argc, char **argv)
{
+ uuid_init();
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} \ No newline at end of file
diff --git a/platform/test/gtest_sf_metrics.cpp b/platform/test/gtest_sf_metrics.cpp
index d8a4352..584135c 100644
--- a/platform/test/gtest_sf_metrics.cpp
+++ b/platform/test/gtest_sf_metrics.cpp
@@ -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();
} \ No newline at end of file
diff --git a/platform/test/gtest_sf_status.cpp b/platform/test/gtest_sf_status.cpp
index 8f1cfa7..79962f1 100644
--- a/platform/test/gtest_sf_status.cpp
+++ b/platform/test/gtest_sf_status.cpp
@@ -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);
}
diff --git a/platform/test/test_resource/sce.conf b/platform/test/test_resource/sce.conf
index b0e6c93..196cd70 100644
--- a/platform/test/test_resource/sce.conf
+++ b/platform/test/test_resource/sce.conf
@@ -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
diff --git a/platform/test/test_resource/sce.json b/platform/test/test_resource/sce.json
index 80ab78b..2bff1b4 100644
--- a/platform/test/test_resource/sce.json
+++ b/platform/test/test_resource/sce.json
@@ -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
+ }
]
}
]
diff --git a/resource/sce.json b/resource/sce.json
index dc2db94..25bb6c1 100644
--- a/resource/sce.json
+++ b/resource/sce.json
@@ -3,38 +3,363 @@
{
"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\":\"2.2.2.2\"}\t{\"method\":\"bfd\",\"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\":\"device_group\",\"value\":\"device_group_a\"}\t1\t{\"method\":\"layer3_switch\",\"int_vlan_tag\":10,\"ext_vlan_tag\":5}\t{\"method\":\"none\"}\t1\t1",
- "7\t{\"tag\":\"device_group\",\"value\":\"device_group_a\"}\t0\t{\"method\":\"layer3_switch\",\"int_vlan_tag\":10,\"ext_vlan_tag\":5}\t{\"method\":\"none\"}\t1\t1",
- "8\t{\"tag\":\"device_group\",\"value\":\"device_group_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": "2.2.2.2"
+ },
+ "health_check": {
+ "method": "bfd",
+ "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": "device_group",
+ "value": "device_group_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": "device_group",
+ "value": "device_group_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": "device_group",
+ "value": "device_group_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
+ }
]
}
]
diff --git a/resource/table_info.conf b/resource/table_info.conf
index 326a7ee..d5d0275 100644
--- a/resource/table_info.conf
+++ b/resource/table_info.conf
@@ -1,35 +1,29 @@
[
{
"table_id":0,
- "table_name":"SERVICE_CHAINING_COMPILE",
+ "table_name":"SERVICE_CHAINING_RULE",
"table_type":"plugin",
- "valid_column":9,
"custom":{
- "key":1,
- "key_type":"integer",
- "key_len":8
+ "key_type":"pointer",
+ "key_name":"uuid"
}
},
{
"table_id":1,
"table_name":"SERVICE_FUNCTION_FORWARDER_PROFILE",
"table_type":"plugin",
- "valid_column":8,
"custom":{
- "key":1,
- "key_type":"integer",
- "key_len":4
+ "key_type":"pointer",
+ "key_name":"uuid"
}
},
{
"table_id":2,
"table_name":"SERVICE_FUNCTION_PROFILE",
"table_type":"plugin",
- "valid_column":7,
"custom":{
- "key":1,
- "key_type":"integer",
- "key_len":4
+ "key_type":"pointer",
+ "key_name":"uuid"
}
}
] \ No newline at end of file
diff --git a/test/gtest_ctrl_pkt_active.cpp b/test/gtest_ctrl_pkt_active.cpp
index 16f357c..04d2c30 100644
--- a/test/gtest_ctrl_pkt_active.cpp
+++ b/test/gtest_ctrl_pkt_active.cpp
@@ -1,6 +1,6 @@
#include "gtest_utils.h"
-// 147 bytes
+// 160 bytes
static u_char ctrl_pkt_active[] = {
// Eth + IPv4 + TCP
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
@@ -9,11 +9,12 @@ static u_char ctrl_pkt_active[] = {
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00,
// msg payload
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
- 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x04, 0x00, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x7F};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
TEST(PACKET_IO, CTRL_PKT_ACTIVE)
{
@@ -21,7 +22,7 @@ TEST(PACKET_IO, CTRL_PKT_ACTIVE)
marsio_buff_t *dup_mbuf = NULL;
struct gtest_frame *gtest_frame = NULL;
- build_mbuf_for_ctrl_pkt(tx_mbuf, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581737, 54);
+ build_mbuf_for_ctrl_pkt(tx_mbuf, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581760, 54);
dup_mbuf = marsio_mbuff_dup(tx_mbuf);
gtest_frame = gtest_frame_new("sce0.json", "ctr_pkt_active");
diff --git a/test/gtest_data_pkt_error_bypass.cpp b/test/gtest_data_pkt_error_bypass.cpp
index 7d8744c..973996b 100644
--- a/test/gtest_data_pkt_error_bypass.cpp
+++ b/test/gtest_data_pkt_error_bypass.cpp
@@ -19,7 +19,7 @@ TEST(PACKET_IO, DATA_PKT_ERROR_BYPASS)
marsio_buff_t *dup_mbuf = NULL;
struct gtest_frame *gtest_frame = NULL;
- build_mbuf_for_data_pkt(tx_mbuf, data_pkt, sizeof(data_pkt), 290484492702581737, 0);
+ build_mbuf_for_data_pkt(tx_mbuf, data_pkt, sizeof(data_pkt), 290484492702581760, 0);
dup_mbuf = marsio_mbuff_dup(tx_mbuf);
gtest_frame = gtest_frame_new("sce0.json", "data_pkt_error_bypass");
diff --git a/test/gtest_data_pkt_mirr_block.cpp b/test/gtest_data_pkt_mirr_block.cpp
index 1073ddd..d61962c 100644
--- a/test/gtest_data_pkt_mirr_block.cpp
+++ b/test/gtest_data_pkt_mirr_block.cpp
@@ -1,6 +1,6 @@
#include "gtest_utils.h"
-// 147 bytes
+// 160 bytes
static u_char ctrl_pkt_active[] = {
// Eth + IPv4 + TCP
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
@@ -9,11 +9,12 @@ static u_char ctrl_pkt_active[] = {
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00,
// msg payload
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
- 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x04, 0x00, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x7F};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
// 145 bytes
static u_char data_pkt[] = {
@@ -36,8 +37,8 @@ TEST(PACKET_IO, DATA_PKT_MIRR_BLOCK)
marsio_buff_t *dup_mbuf2 = NULL;
struct gtest_frame *gtest_frame = NULL;
- build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581737, 54);
- build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581737, 0);
+ build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581760, 54);
+ build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581760, 0);
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
dup_mbuf2 = marsio_mbuff_dup(tx_mbuf2);
diff --git a/test/gtest_data_pkt_mirr_bypass.cpp b/test/gtest_data_pkt_mirr_bypass.cpp
index 36aa13c..339ea0a 100644
--- a/test/gtest_data_pkt_mirr_bypass.cpp
+++ b/test/gtest_data_pkt_mirr_bypass.cpp
@@ -1,6 +1,6 @@
#include "gtest_utils.h"
-// 147 bytes
+// 160 bytes
static u_char ctrl_pkt_active[] = {
// Eth + IPv4 + TCP
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
@@ -9,11 +9,12 @@ static u_char ctrl_pkt_active[] = {
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00,
// msg payload
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
- 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x04, 0x00, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x7F};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
// 145 bytes
static u_char data_pkt[] = {
@@ -36,8 +37,8 @@ TEST(PACKET_IO, DATA_PKT_MIRR_BYPASS)
marsio_buff_t *dup_mbuf2 = NULL;
struct gtest_frame *gtest_frame = NULL;
- build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581737, 54);
- build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581737, 0);
+ build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581760, 54);
+ build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581760, 0);
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
dup_mbuf2 = marsio_mbuff_dup(tx_mbuf2);
diff --git a/test/gtest_data_pkt_mirr_forward.cpp b/test/gtest_data_pkt_mirr_forward.cpp
index f407b39..0392546 100644
--- a/test/gtest_data_pkt_mirr_forward.cpp
+++ b/test/gtest_data_pkt_mirr_forward.cpp
@@ -1,6 +1,6 @@
#include "gtest_utils.h"
-// 147 bytes
+// 160 bytes
static u_char ctrl_pkt_active[] = {
// Eth + IPv4 + TCP
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
@@ -9,11 +9,12 @@ static u_char ctrl_pkt_active[] = {
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00,
// msg payload
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
- 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x04, 0x00, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x7F};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
// 145 bytes
static u_char data_pkt[] = {
@@ -39,8 +40,8 @@ TEST(PACKET_IO, DATA_PKT_MIRR_FORWARD)
struct gtest_frame *gtest_frame = NULL;
struct mr_instance *mr_instance = NULL;
- build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581737, 54);
- build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581737, 0);
+ build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581760, 54);
+ build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581760, 0);
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
dup_mbuf2 = marsio_mbuff_dup(tx_mbuf2);
diff --git a/test/gtest_data_pkt_mirr_rx_drop.cpp b/test/gtest_data_pkt_mirr_rx_drop.cpp
index ec8f5d0..9d18ce5 100644
--- a/test/gtest_data_pkt_mirr_rx_drop.cpp
+++ b/test/gtest_data_pkt_mirr_rx_drop.cpp
@@ -1,6 +1,6 @@
#include "gtest_utils.h"
-// 147 bytes
+// 160 bytes
static u_char ctrl_pkt_active[] = {
// Eth + IPv4 + TCP
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
@@ -9,11 +9,12 @@ static u_char ctrl_pkt_active[] = {
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00,
// msg payload
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
- 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x04, 0x00, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x7F};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
// 145 bytes
static u_char data_pkt[] = {
@@ -39,8 +40,8 @@ TEST(PACKET_IO, DATA_PKT_MIRR_RX_DROP)
struct gtest_frame *gtest_frame = NULL;
struct mr_instance *mr_instance = NULL;
- build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581737, 54);
- build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581737, 0);
+ build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581760, 54);
+ build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581760, 0);
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
dup_mbuf2 = marsio_mbuff_dup(tx_mbuf2);
diff --git a/test/gtest_data_pkt_stee_block.cpp b/test/gtest_data_pkt_stee_block.cpp
index 27b9a67..223c11d 100644
--- a/test/gtest_data_pkt_stee_block.cpp
+++ b/test/gtest_data_pkt_stee_block.cpp
@@ -1,6 +1,6 @@
#include "gtest_utils.h"
-// 147 bytes
+// 160 bytes
static u_char ctrl_pkt_active[] = {
// Eth + IPv4 + TCP
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
@@ -9,11 +9,12 @@ static u_char ctrl_pkt_active[] = {
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00,
// msg payload
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
- 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x04, 0x00, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x7F};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
// 145 bytes
static u_char data_pkt[] = {
@@ -35,8 +36,8 @@ TEST(PACKET_IO, DATA_PKT_STEE_BLOCK)
marsio_buff_t *dup_mbuf1 = NULL;
struct gtest_frame *gtest_frame = NULL;
- build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581737, 54);
- build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581737, 0);
+ build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581760, 54);
+ build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581760, 0);
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
gtest_frame = gtest_frame_new("data_pkt_stee_block.json", "data_pkt_stee_block");
diff --git a/test/gtest_data_pkt_stee_bypass.cpp b/test/gtest_data_pkt_stee_bypass.cpp
index ca4210e..2a84d34 100644
--- a/test/gtest_data_pkt_stee_bypass.cpp
+++ b/test/gtest_data_pkt_stee_bypass.cpp
@@ -1,6 +1,6 @@
#include "gtest_utils.h"
-// 147 bytes
+// 160 bytes
static u_char ctrl_pkt_active[] = {
// Eth + IPv4 + TCP
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
@@ -9,11 +9,12 @@ static u_char ctrl_pkt_active[] = {
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00,
// msg payload
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
- 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x04, 0x00, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x7F};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
// 145 bytes
static u_char data_pkt[] = {
@@ -36,8 +37,8 @@ TEST(PACKET_IO, DATA_PKT_STEE_BYPASS)
marsio_buff_t *dup_mbuf2 = NULL;
struct gtest_frame *gtest_frame = NULL;
- build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581737, 54);
- build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581737, 0);
+ build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581760, 54);
+ build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581760, 0);
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
dup_mbuf2 = marsio_mbuff_dup(tx_mbuf2);
diff --git a/test/gtest_data_pkt_stee_forward.cpp b/test/gtest_data_pkt_stee_forward.cpp
index ac21f6b..181474d 100644
--- a/test/gtest_data_pkt_stee_forward.cpp
+++ b/test/gtest_data_pkt_stee_forward.cpp
@@ -1,6 +1,6 @@
#include "gtest_utils.h"
-// 147 bytes
+// 160 bytes
static u_char ctrl_pkt_active[] = {
// Eth + IPv4 + TCP
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
@@ -9,11 +9,12 @@ static u_char ctrl_pkt_active[] = {
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00,
// msg payload
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
- 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x04, 0x00, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x7F};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
// 145 bytes
static u_char data_pkt[] = {
@@ -37,8 +38,8 @@ TEST(PACKET_IO, DATA_PKT_STEE_FORWARD)
struct gtest_frame *gtest_frame = NULL;
struct mr_instance *mr_instance = NULL;
- build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581737, 54);
- build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581737, 0);
+ build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581760, 54);
+ build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581760, 0);
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
dup_mbuf2 = marsio_mbuff_dup(tx_mbuf2);
diff --git a/test/gtest_data_pkt_stee_rx_egress.cpp b/test/gtest_data_pkt_stee_rx_egress.cpp
index 1d26ab3..1a07419 100644
--- a/test/gtest_data_pkt_stee_rx_egress.cpp
+++ b/test/gtest_data_pkt_stee_rx_egress.cpp
@@ -1,6 +1,6 @@
#include "gtest_utils.h"
-// 147 bytes
+// 160 bytes
static u_char ctrl_pkt_active[] = {
// Eth + IPv4 + TCP
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
@@ -9,11 +9,12 @@ static u_char ctrl_pkt_active[] = {
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00,
// msg payload
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
- 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x04, 0x00, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x7F};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
// 145 bytes
static u_char data_pkt[] = {
@@ -38,8 +39,8 @@ TEST(PACKET_IO, DATA_PKT_STEE_RX_EGRESS)
struct gtest_frame *gtest_frame = NULL;
struct mr_instance *mr_instance = NULL;
- build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581737, 54);
- build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581737, 0);
+ build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active, sizeof(ctrl_pkt_active), 290484492702581760, 54);
+ build_mbuf_for_data_pkt(tx_mbuf2, data_pkt, sizeof(data_pkt), 290484492702581760, 0);
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
dup_mbuf2 = marsio_mbuff_dup(tx_mbuf2);
diff --git a/test/gtest_mix_pkt_stee_forward.cpp b/test/gtest_mix_pkt_stee_forward.cpp
index 13e9c8e..785f923 100644
--- a/test/gtest_mix_pkt_stee_forward.cpp
+++ b/test/gtest_mix_pkt_stee_forward.cpp
@@ -1,6 +1,6 @@
#include "gtest_utils.h"
-// 147 bytes
+// 160 bytes
static u_char ctrl_pkt_active_for_raw_pkt[] = {
// Eth + IPv4 + TCP
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
@@ -9,13 +9,14 @@ static u_char ctrl_pkt_active_for_raw_pkt[] = {
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00,
// msg payload
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
- 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x04, 0x00, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x7F};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
-// 147 bytes
+// 160 bytes
static u_char ctrl_pkt_active_for_decrypted_pkt[] = {
// Eth + IPv4 + TCP
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
@@ -24,11 +25,12 @@ static u_char ctrl_pkt_active_for_decrypted_pkt[] = {
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00,
// msg payload
0x85, 0xA5, 0x74, 0x73, 0x79, 0x6E, 0x63, 0xA3, 0x32, 0x2E, 0x30, 0xAA, 0x73, 0x65, 0x73, 0x73,
- 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x03, 0xE9, 0xA5,
+ 0x69, 0x6F, 0x6E, 0x5F, 0x69, 0x64, 0xCF, 0x04, 0x08, 0x02, 0x1B, 0x68, 0x4C, 0x04, 0x00, 0xA5,
0x73, 0x74, 0x61, 0x74, 0x65, 0xA6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0xA6, 0x6D, 0x65, 0x74,
0x68, 0x6F, 0x64, 0xAD, 0x70, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x5F, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0xA6, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x73, 0x81, 0xA3, 0x73, 0x63, 0x65, 0x81, 0xA8, 0x72,
- 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xCE, 0x00, 0x0F, 0x2F, 0x80};
+ 0x75, 0x6C, 0x65, 0x5F, 0x69, 0x64, 0x73, 0x91, 0xC4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
// 145 bytes
static u_char raw_pkt[] = {
@@ -72,16 +74,16 @@ TEST(PACKET_IO, MIX_PKT_STEE_FORWARD)
struct mr_instance *mr_instance = NULL;
// build ctrl packet for raw packet
- build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active_for_raw_pkt, sizeof(ctrl_pkt_active_for_raw_pkt), 290484492702581737, 54);
+ build_mbuf_for_ctrl_pkt(tx_mbuf1, ctrl_pkt_active_for_raw_pkt, sizeof(ctrl_pkt_active_for_raw_pkt), 290484492702581760, 54);
// build raw packet
- build_mbuf_for_data_pkt(tx_mbuf2, raw_pkt, sizeof(raw_pkt), 290484492702581737, 0);
+ build_mbuf_for_data_pkt(tx_mbuf2, raw_pkt, sizeof(raw_pkt), 290484492702581760, 0);
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
dup_mbuf2 = marsio_mbuff_dup(tx_mbuf2);
// build ctrl packet for decrypted packet
- build_mbuf_for_ctrl_pkt(tx_mbuf3, ctrl_pkt_active_for_decrypted_pkt, sizeof(ctrl_pkt_active_for_decrypted_pkt), 290484492702581737, 54);
+ build_mbuf_for_ctrl_pkt(tx_mbuf3, ctrl_pkt_active_for_decrypted_pkt, sizeof(ctrl_pkt_active_for_decrypted_pkt), 290484492702581760, 54);
// build decrypted packet
- build_mbuf_for_data_pkt(tx_mbuf4, decrypted_pkt, sizeof(decrypted_pkt), 290484492702581737, 1);
+ build_mbuf_for_data_pkt(tx_mbuf4, decrypted_pkt, sizeof(decrypted_pkt), 290484492702581760, 1);
dup_mbuf3 = marsio_mbuff_dup(tx_mbuf3);
dup_mbuf4 = marsio_mbuff_dup(tx_mbuf4);
diff --git a/test/test_data/conf/sce.conf b/test/test_data/conf/sce.conf
index 83c7c1c..cb58c73 100644
--- a/test/test_data/conf/sce.conf
+++ b/test/test_data/conf/sce.conf
@@ -17,7 +17,7 @@ breakpad_minidump_dir=/run/sce/crashreport
breakpad_upload_tools=/opt/tsg/framework/bin/minidump_upload
[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;
@@ -29,8 +29,6 @@ deferred_load=0
stat_file=log/maat.fs2
table_info=resource/table_info.conf
accept_path=/opt/tsg/etc/tsg_device_tag.json
-inc_cfg_dir=resource/inc/
-ful_cfg_dir=resource/ful/
json_cfg_file=resource/sce.json
foreign_cont_dir=resource/foreign_files
redis_db_idx=0
@@ -84,6 +82,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
diff --git a/test/test_data/log/test_ctr_pkt_active_ok.fs2 b/test/test_data/log/test_ctr_pkt_active_ok.fs2
index 19cf1c3..5d8008d 100644
--- a/test/test_data/log/test_ctr_pkt_active_ok.fs2
+++ b/test/test_data/log/test_ctr_pkt_active_ok.fs2
@@ -1,6 +1,6 @@
============================================================Sat Mar 2 17:30:56 2024============================================================
dev_nf_rx_P dev_nf_rx_B dev_nf_tx_P dev_nf_tx_B kee_d_rx_P kee_d_rx_B kee_d_tx_P kee_d_tx_B
-sum 1 147 1 147 0 0 0 0
+sum 1 160 1 160 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
raw_rx_P raw_rx_B raw_tx_P raw_tx_B dec_rx_P dec_rx_B dec_tx_P dec_tx_B
sum 0 0 0 0 0 0 0 0
@@ -21,7 +21,7 @@ speed/s 0 0 0 0 0 0
sum 0 0 0 0 0 0 1 0
speed/s 0 0 0 0 0 0 0 0
ctrl_rx_P ctrl_rx_B ctrl_tx_P ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
-sum 1 147 1 147 0 1 0 0
+sum 1 160 1 160 0 1 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B
sum 0 1 0 1 0 0 0
diff --git a/test/test_data/log/test_data_pkt_mirr_block_ok.fs2 b/test/test_data/log/test_data_pkt_mirr_block_ok.fs2
index 9e6a683..11c0467 100644
--- a/test/test_data/log/test_data_pkt_mirr_block_ok.fs2
+++ b/test/test_data/log/test_data_pkt_mirr_block_ok.fs2
@@ -1,6 +1,6 @@
============================================================Sat Mar 2 17:34:59 2024============================================================
dev_nf_rx_P dev_nf_rx_B dev_nf_tx_P dev_nf_tx_B kee_d_rx_P kee_d_rx_B kee_d_tx_P kee_d_tx_B
-sum 2 292 2 292 0 0 0 0
+sum 2 305 2 305 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
raw_rx_P raw_rx_B raw_tx_P raw_tx_B dec_rx_P dec_rx_B dec_tx_P dec_tx_B
sum 1 145 1 145 0 0 0 0
@@ -21,7 +21,7 @@ speed/s 0 0 0 0 0 0
sum 0 0 0 0 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_rx_P ctrl_rx_B ctrl_tx_P ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
-sum 1 147 1 147 0 1 0 0
+sum 1 160 1 160 0 1 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B
sum 0 1 0 1 0 0 0
diff --git a/test/test_data/log/test_data_pkt_mirr_bypass_ok.fs2 b/test/test_data/log/test_data_pkt_mirr_bypass_ok.fs2
index 4abed90..c60db82 100644
--- a/test/test_data/log/test_data_pkt_mirr_bypass_ok.fs2
+++ b/test/test_data/log/test_data_pkt_mirr_bypass_ok.fs2
@@ -1,6 +1,6 @@
============================================================Sat Mar 2 17:34:24 2024============================================================
dev_nf_rx_P dev_nf_rx_B dev_nf_tx_P dev_nf_tx_B kee_d_rx_P kee_d_rx_B kee_d_tx_P kee_d_tx_B
-sum 2 292 2 292 0 0 0 0
+sum 2 305 2 305 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
raw_rx_P raw_rx_B raw_tx_P raw_tx_B dec_rx_P dec_rx_B dec_tx_P dec_tx_B
sum 1 145 1 145 0 0 0 0
@@ -21,7 +21,7 @@ speed/s 0 0 0 0 0 0
sum 0 0 0 0 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_rx_P ctrl_rx_B ctrl_tx_P ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
-sum 1 147 1 147 0 1 0 0
+sum 1 160 1 160 0 1 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B
sum 0 1 0 1 0 0 0
diff --git a/test/test_data/log/test_data_pkt_mirr_forward_ok.fs2 b/test/test_data/log/test_data_pkt_mirr_forward_ok.fs2
index 72a0acc..0417624 100644
--- a/test/test_data/log/test_data_pkt_mirr_forward_ok.fs2
+++ b/test/test_data/log/test_data_pkt_mirr_forward_ok.fs2
@@ -1,6 +1,6 @@
============================================================Sat Mar 2 17:35:26 2024============================================================
dev_nf_rx_P dev_nf_rx_B dev_nf_tx_P dev_nf_tx_B kee_d_rx_P kee_d_rx_B kee_d_tx_P kee_d_tx_B
-sum 2 292 2 292 0 0 0 0
+sum 2 305 2 305 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
raw_rx_P raw_rx_B raw_tx_P raw_tx_B dec_rx_P dec_rx_B dec_tx_P dec_tx_B
sum 1 145 1 145 0 0 0 0
@@ -21,7 +21,7 @@ speed/s 0 0 0 0 0 0
sum 0 0 0 0 0 0 1 0
speed/s 0 0 0 0 0 0 0 0
ctrl_rx_P ctrl_rx_B ctrl_tx_P ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
-sum 1 147 1 147 0 1 0 0
+sum 1 160 1 160 0 1 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B
sum 0 1 0 1 0 0 0
diff --git a/test/test_data/log/test_data_pkt_mirr_rx_drop_ok.fs2 b/test/test_data/log/test_data_pkt_mirr_rx_drop_ok.fs2
index 5df28c6..b8ba8bc 100644
--- a/test/test_data/log/test_data_pkt_mirr_rx_drop_ok.fs2
+++ b/test/test_data/log/test_data_pkt_mirr_rx_drop_ok.fs2
@@ -1,6 +1,6 @@
============================================================Sat Mar 2 17:36:09 2024============================================================
dev_nf_rx_P dev_nf_rx_B dev_nf_tx_P dev_nf_tx_B kee_d_rx_P kee_d_rx_B kee_d_tx_P kee_d_tx_B
-sum 2 292 2 292 0 0 0 0
+sum 2 305 2 305 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
raw_rx_P raw_rx_B raw_tx_P raw_tx_B dec_rx_P dec_rx_B dec_tx_P dec_tx_B
sum 1 145 1 145 0 0 0 0
@@ -21,7 +21,7 @@ speed/s 0 0 0 0 0 0
sum 0 0 0 0 1 145 1 0
speed/s 0 0 0 0 0 0 0 0
ctrl_rx_P ctrl_rx_B ctrl_tx_P ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
-sum 1 147 1 147 0 1 0 0
+sum 1 160 1 160 0 1 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B
sum 0 1 0 1 0 0 0
diff --git a/test/test_data/log/test_data_pkt_stee_block_ok.fs2 b/test/test_data/log/test_data_pkt_stee_block_ok.fs2
index a4dd3a6..a4a54d5 100644
--- a/test/test_data/log/test_data_pkt_stee_block_ok.fs2
+++ b/test/test_data/log/test_data_pkt_stee_block_ok.fs2
@@ -1,6 +1,6 @@
============================================================Sat Mar 2 17:32:36 2024============================================================
dev_nf_rx_P dev_nf_rx_B dev_nf_tx_P dev_nf_tx_B kee_d_rx_P kee_d_rx_B kee_d_tx_P kee_d_tx_B
-sum 2 292 1 147 0 0 0 0
+sum 2 305 1 160 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
raw_rx_P raw_rx_B raw_tx_P raw_tx_B dec_rx_P dec_rx_B dec_tx_P dec_tx_B
sum 1 145 0 0 0 0 0 0
@@ -21,7 +21,7 @@ speed/s 0 0 0 0 0 0
sum 0 0 0 0 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_rx_P ctrl_rx_B ctrl_tx_P ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
-sum 1 147 1 147 0 1 0 0
+sum 1 160 1 160 0 1 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B
sum 0 1 0 1 0 0 0
diff --git a/test/test_data/log/test_data_pkt_stee_bypass_ok.fs2 b/test/test_data/log/test_data_pkt_stee_bypass_ok.fs2
index 064ef23..08d3f1d 100644
--- a/test/test_data/log/test_data_pkt_stee_bypass_ok.fs2
+++ b/test/test_data/log/test_data_pkt_stee_bypass_ok.fs2
@@ -1,6 +1,6 @@
============================================================Sat Mar 2 17:32:04 2024============================================================
dev_nf_rx_P dev_nf_rx_B dev_nf_tx_P dev_nf_tx_B kee_d_rx_P kee_d_rx_B kee_d_tx_P kee_d_tx_B
-sum 2 292 2 292 0 0 0 0
+sum 2 305 2 305 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
raw_rx_P raw_rx_B raw_tx_P raw_tx_B dec_rx_P dec_rx_B dec_tx_P dec_tx_B
sum 1 145 1 145 0 0 0 0
@@ -21,7 +21,7 @@ speed/s 0 0 0 0 0 0
sum 0 0 0 0 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_rx_P ctrl_rx_B ctrl_tx_P ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
-sum 1 147 1 147 0 1 0 0
+sum 1 160 1 160 0 1 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B
sum 0 1 0 1 0 0 0
diff --git a/test/test_data/log/test_data_pkt_stee_forward_ok.fs2 b/test/test_data/log/test_data_pkt_stee_forward_ok.fs2
index 62aefe3..be4344d 100644
--- a/test/test_data/log/test_data_pkt_stee_forward_ok.fs2
+++ b/test/test_data/log/test_data_pkt_stee_forward_ok.fs2
@@ -1,6 +1,6 @@
============================================================Sat Mar 2 17:33:12 2024============================================================
dev_nf_rx_P dev_nf_rx_B dev_nf_tx_P dev_nf_tx_B kee_d_rx_P kee_d_rx_B kee_d_tx_P kee_d_tx_B
-sum 2 292 1 147 0 0 0 0
+sum 2 305 1 160 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
raw_rx_P raw_rx_B raw_tx_P raw_tx_B dec_rx_P dec_rx_B dec_tx_P dec_tx_B
sum 1 145 0 0 0 0 0 0
@@ -21,7 +21,7 @@ speed/s 0 0 0 0 0 0
sum 0 0 0 0 0 0 1 0
speed/s 0 0 0 0 0 0 0 0
ctrl_rx_P ctrl_rx_B ctrl_tx_P ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
-sum 1 147 1 147 0 1 0 0
+sum 1 160 1 160 0 1 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B
sum 0 1 0 1 0 0 0
diff --git a/test/test_data/log/test_data_pkt_stee_rx_egress_ok.fs2 b/test/test_data/log/test_data_pkt_stee_rx_egress_ok.fs2
index 71c5194..fa70ac4 100644
--- a/test/test_data/log/test_data_pkt_stee_rx_egress_ok.fs2
+++ b/test/test_data/log/test_data_pkt_stee_rx_egress_ok.fs2
@@ -1,6 +1,6 @@
============================================================Sat Mar 2 17:33:53 2024============================================================
dev_nf_rx_P dev_nf_rx_B dev_nf_tx_P dev_nf_tx_B kee_d_rx_P kee_d_rx_B kee_d_tx_P kee_d_tx_B
-sum 2 292 2 292 0 0 0 0
+sum 2 305 2 305 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
raw_rx_P raw_rx_B raw_tx_P raw_tx_B dec_rx_P dec_rx_B dec_tx_P dec_tx_B
sum 1 145 1 145 0 0 0 0
@@ -21,7 +21,7 @@ speed/s 0 0 0 0 0 0
sum 0 0 0 0 0 0 1 0
speed/s 0 0 0 0 0 0 0 0
ctrl_rx_P ctrl_rx_B ctrl_tx_P ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
-sum 1 147 1 147 0 1 0 0
+sum 1 160 1 160 0 1 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B
sum 0 1 0 1 0 0 0
diff --git a/test/test_data/log/test_mix_pkt_stee_forward_ok.fs2 b/test/test_data/log/test_mix_pkt_stee_forward_ok.fs2
index fc5f73e..28beab3 100644
--- a/test/test_data/log/test_mix_pkt_stee_forward_ok.fs2
+++ b/test/test_data/log/test_mix_pkt_stee_forward_ok.fs2
@@ -1,6 +1,6 @@
============================================================Sat Mar 2 17:38:11 2024============================================================
dev_nf_rx_P dev_nf_rx_B dev_nf_tx_P dev_nf_tx_B kee_d_rx_P kee_d_rx_B kee_d_tx_P kee_d_tx_B
-sum 4 584 2 294 0 0 0 0
+sum 4 610 2 320 0 0 0 0
speed/s 0 0 0 0 0 0 0 0
raw_rx_P raw_rx_B raw_tx_P raw_tx_B dec_rx_P dec_rx_B dec_tx_P dec_tx_B
sum 1 145 0 0 1 145 0 0
@@ -21,7 +21,7 @@ speed/s 0 0 0 0 0 0
sum 0 0 0 0 0 0 2 0
speed/s 0 0 0 0 0 0 0 0
ctrl_rx_P ctrl_rx_B ctrl_tx_P ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
-sum 2 294 2 294 0 2 0 0
+sum 2 320 2 320 0 2 0 0
speed/s 0 0 0 0 0 0 0 0
ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B
sum 0 1 0 1 0 0 0
diff --git a/test/test_data/resource/data_pkt_mirr_block.json b/test/test_data/resource/data_pkt_mirr_block.json
index b816a2c..9d223bd 100644
--- a/test/test_data/resource/data_pkt_mirr_block.json
+++ b/test/test_data/resource/data_pkt_mirr_block.json
@@ -3,19 +3,57 @@
{
"table_name": "SERVICE_FUNCTION_PROFILE",
"table_content": [
- "1\t{\"tag\":\"device_group\",\"value\":\"device_group_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1\t1"
+ {
+ "uuid": "00000000-0000-0000-3333-000000000001",
+ "device_group": {
+ "tag": "device_group",
+ "value": "device_group_a"
+ },
+ "admin_status": 1,
+ "connectivity": {
+ "method": "vxlan_g",
+ "dest_ip": "1.1.1.1"
+ },
+ "health_check": {
+ "method": "none"
+ },
+ "vsys_id": 1,
+ "is_valid": 1
+ }
]
},
{
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
"table_content": [
- "1\t2\thash-int-ip\tnearby\tblock\tnull\t[1]\t1"
+ {
+ "uuid": "00000000-0000-0000-2222-000000000001",
+ "type": 2,
+ "load_balance_method": "hash-int-ip",
+ "load_balance_localization": "nearby",
+ "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": [
- "995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\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
+ }
]
}
]
diff --git a/test/test_data/resource/data_pkt_mirr_bypass.json b/test/test_data/resource/data_pkt_mirr_bypass.json
index fbaa0c0..cc85fdd 100644
--- a/test/test_data/resource/data_pkt_mirr_bypass.json
+++ b/test/test_data/resource/data_pkt_mirr_bypass.json
@@ -3,19 +3,57 @@
{
"table_name": "SERVICE_FUNCTION_PROFILE",
"table_content": [
- "1\t{\"tag\":\"device_group\",\"value\":\"device_group_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1\t1"
+ {
+ "uuid": "00000000-0000-0000-3333-000000000001",
+ "device_group": {
+ "tag": "device_group",
+ "value": "device_group_a"
+ },
+ "admin_status": 1,
+ "connectivity": {
+ "method": "vxlan_g",
+ "dest_ip": "1.1.1.1"
+ },
+ "health_check": {
+ "method": "none"
+ },
+ "vsys_id": 1,
+ "is_valid": 1
+ }
]
},
{
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
"table_content": [
- "1\t2\thash-int-ip\tnearby\tbypass\tnull\t[1]\t1"
+ {
+ "uuid": "00000000-0000-0000-2222-000000000001",
+ "type": 2,
+ "load_balance_method": "hash-int-ip",
+ "load_balance_localization": "nearby",
+ "failure_action": "bypass",
+ "service_func_profiles": [
+ "00000000-0000-0000-3333-000000000001"
+ ],
+ "is_valid": 1
+ }
]
},
{
- "table_name": "SERVICE_CHAINING_COMPILE",
+ "table_name": "SERVICE_CHAINING_RULE",
"table_content": [
- "995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\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
+ }
]
}
]
diff --git a/test/test_data/resource/data_pkt_mirr_forward.json b/test/test_data/resource/data_pkt_mirr_forward.json
index a7b23a0..6ce2e09 100644
--- a/test/test_data/resource/data_pkt_mirr_forward.json
+++ b/test/test_data/resource/data_pkt_mirr_forward.json
@@ -3,19 +3,57 @@
{
"table_name": "SERVICE_FUNCTION_PROFILE",
"table_content": [
- "1\t{\"tag\":\"device_group\",\"value\":\"device_group_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1\t1"
+ {
+ "uuid": "00000000-0000-0000-3333-000000000001",
+ "device_group": {
+ "tag": "device_group",
+ "value": "device_group_a"
+ },
+ "admin_status": 1,
+ "connectivity": {
+ "method": "vxlan_g",
+ "dest_ip": "1.1.1.1"
+ },
+ "health_check": {
+ "method": "none"
+ },
+ "vsys_id": 1,
+ "is_valid": 1
+ }
]
},
{
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
"table_content": [
- "1\t2\thash-int-ip\tglobal\tbypass\tnull\t[1]\t1"
+ {
+ "uuid": "00000000-0000-0000-2222-000000000001",
+ "type": 2,
+ "load_balance_method": "hash-int-ip",
+ "load_balance_localization": "global",
+ "failure_action": "bypass",
+ "service_func_profiles": [
+ "00000000-0000-0000-3333-000000000001"
+ ],
+ "is_valid": 1
+ }
]
},
{
- "table_name": "SERVICE_CHAINING_COMPILE",
+ "table_name": "SERVICE_CHAINING_RULE",
"table_content": [
- "995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\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
+ }
]
}
]
diff --git a/test/test_data/resource/data_pkt_stee_block.json b/test/test_data/resource/data_pkt_stee_block.json
index ae1d247..d724a90 100644
--- a/test/test_data/resource/data_pkt_stee_block.json
+++ b/test/test_data/resource/data_pkt_stee_block.json
@@ -3,19 +3,57 @@
{
"table_name": "SERVICE_FUNCTION_PROFILE",
"table_content": [
- "1\t{\"tag\":\"device_group\",\"value\":\"device_group_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1\t1"
+ {
+ "uuid": "00000000-0000-0000-3333-000000000001",
+ "device_group": {
+ "tag": "device_group",
+ "value": "device_group_a"
+ },
+ "admin_status": 1,
+ "connectivity": {
+ "method": "vxlan_g",
+ "dest_ip": "1.1.1.1"
+ },
+ "health_check": {
+ "method": "none"
+ },
+ "vsys_id": 1,
+ "is_valid": 1
+ }
]
},
{
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
"table_content": [
- "1\t1\thash-int-ip\tnearby\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": "block",
+ "service_func_profiles": [
+ "00000000-0000-0000-3333-000000000001"
+ ],
+ "is_valid": 1
+ }
]
},
{
- "table_name": "SERVICE_CHAINING_COMPILE",
+ "table_name": "SERVICE_CHAINING_RULE",
"table_content": [
- "995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\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
+ }
]
}
]
diff --git a/test/test_data/resource/data_pkt_stee_bypass.json b/test/test_data/resource/data_pkt_stee_bypass.json
index 686d4be..7ba38c8 100644
--- a/test/test_data/resource/data_pkt_stee_bypass.json
+++ b/test/test_data/resource/data_pkt_stee_bypass.json
@@ -3,19 +3,57 @@
{
"table_name": "SERVICE_FUNCTION_PROFILE",
"table_content": [
- "1\t{\"tag\":\"device_group\",\"value\":\"device_group_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1\t1"
+ {
+ "uuid": "00000000-0000-0000-3333-000000000001",
+ "device_group": {
+ "tag": "device_group",
+ "value": "device_group_a"
+ },
+ "admin_status": 1,
+ "connectivity": {
+ "method": "vxlan_g",
+ "dest_ip": "1.1.1.1"
+ },
+ "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"
+ {
+ "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
+ }
]
},
{
- "table_name": "SERVICE_CHAINING_COMPILE",
+ "table_name": "SERVICE_CHAINING_RULE",
"table_content": [
- "995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\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
+ }
]
}
]
diff --git a/test/test_data/resource/data_pkt_stee_forward.json b/test/test_data/resource/data_pkt_stee_forward.json
index 9fe0da3..a390b17 100644
--- a/test/test_data/resource/data_pkt_stee_forward.json
+++ b/test/test_data/resource/data_pkt_stee_forward.json
@@ -3,19 +3,57 @@
{
"table_name": "SERVICE_FUNCTION_PROFILE",
"table_content": [
- "1\t{\"tag\":\"device_group\",\"value\":\"device_group_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1\t1"
+ {
+ "uuid": "00000000-0000-0000-3333-000000000001",
+ "device_group": {
+ "tag": "device_group",
+ "value": "device_group_a"
+ },
+ "admin_status": 1,
+ "connectivity": {
+ "method": "vxlan_g",
+ "dest_ip": "1.1.1.1"
+ },
+ "health_check": {
+ "method": "none"
+ },
+ "vsys_id": 1,
+ "is_valid": 1
+ }
]
},
{
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
"table_content": [
- "1\t1\thash-int-ip\tglobal\tbypass\tnull\t[1]\t1"
+ {
+ "uuid": "00000000-0000-0000-2222-000000000001",
+ "type": 1,
+ "load_balance_method": "hash-int-ip",
+ "load_balance_localization": "global",
+ "failure_action": "bypass",
+ "service_func_profiles": [
+ "00000000-0000-0000-3333-000000000001"
+ ],
+ "is_valid": 1
+ }
]
},
{
- "table_name": "SERVICE_CHAINING_COMPILE",
+ "table_name": "SERVICE_CHAINING_RULE",
"table_content": [
- "995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\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
+ }
]
}
]
diff --git a/test/test_data/resource/mix_pkt_stee_forward.json b/test/test_data/resource/mix_pkt_stee_forward.json
index 8722598..aae96fd 100644
--- a/test/test_data/resource/mix_pkt_stee_forward.json
+++ b/test/test_data/resource/mix_pkt_stee_forward.json
@@ -3,22 +3,98 @@
{
"table_name": "SERVICE_FUNCTION_PROFILE",
"table_content": [
- "1\t{\"tag\":\"device_group\",\"value\":\"device_group_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1\t1",
- "2\t{\"tag\":\"device_group\",\"value\":\"device_group_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"2.2.2.2\"}\t{\"method\":\"none\"}\t1\t1"
+ {
+ "uuid": "00000000-0000-0000-3333-000000000001",
+ "device_group": {
+ "tag": "device_group",
+ "value": "device_group_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": "device_group",
+ "value": "device_group_a"
+ },
+ "admin_status": 1,
+ "connectivity": {
+ "method": "vxlan_g",
+ "dest_ip": "2.2.2.2"
+ },
+ "health_check": {
+ "method": "none"
+ },
+ "vsys_id": 1,
+ "is_valid": 1
+ }
]
},
{
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
"table_content": [
- "1\t1\thash-int-ip\tglobal\tbypass\tnull\t[1]\t1",
- "2\t1\thash-ext-ip\tglobal\tbypass\tnull\t[1]\t1"
+ {
+ "uuid": "00000000-0000-0000-2222-000000000001",
+ "type": 1,
+ "load_balance_method": "hash-int-ip",
+ "load_balance_localization": "global",
+ "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-ext-ip",
+ "load_balance_localization": "global",
+ "failure_action": "bypass",
+ "service_func_profiles": [
+ "00000000-0000-0000-3333-000000000001"
+ ],
+ "is_valid": 1
+ }
]
},
{
- "table_name": "SERVICE_CHAINING_COMPILE",
+ "table_name": "SERVICE_CHAINING_RULE",
"table_content": [
- "995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t0\t1",
- "995200\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"decrypted\",\"sff_profiles\":[2]}\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": "decrypted",
+ "sff_profiles": [
+ "00000000-0000-0000-2222-000000000002"
+ ]
+ },
+ "is_valid": 1
+ }
]
}
]
diff --git a/test/test_data/resource/sce0.json b/test/test_data/resource/sce0.json
index 9fe0da3..a390b17 100644
--- a/test/test_data/resource/sce0.json
+++ b/test/test_data/resource/sce0.json
@@ -3,19 +3,57 @@
{
"table_name": "SERVICE_FUNCTION_PROFILE",
"table_content": [
- "1\t{\"tag\":\"device_group\",\"value\":\"device_group_a\"}\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1\t1"
+ {
+ "uuid": "00000000-0000-0000-3333-000000000001",
+ "device_group": {
+ "tag": "device_group",
+ "value": "device_group_a"
+ },
+ "admin_status": 1,
+ "connectivity": {
+ "method": "vxlan_g",
+ "dest_ip": "1.1.1.1"
+ },
+ "health_check": {
+ "method": "none"
+ },
+ "vsys_id": 1,
+ "is_valid": 1
+ }
]
},
{
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
"table_content": [
- "1\t1\thash-int-ip\tglobal\tbypass\tnull\t[1]\t1"
+ {
+ "uuid": "00000000-0000-0000-2222-000000000001",
+ "type": 1,
+ "load_balance_method": "hash-int-ip",
+ "load_balance_localization": "global",
+ "failure_action": "bypass",
+ "service_func_profiles": [
+ "00000000-0000-0000-3333-000000000001"
+ ],
+ "is_valid": 1
+ }
]
},
{
- "table_name": "SERVICE_CHAINING_COMPILE",
+ "table_name": "SERVICE_CHAINING_RULE",
"table_content": [
- "995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\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
+ }
]
}
]