TSG-14351 tsg-service-chaining-engine通过Mock Mrzcpd进行单元测试
This commit is contained in:
@@ -61,4 +61,5 @@ add_subdirectory(vendor)
|
||||
add_subdirectory(common)
|
||||
add_subdirectory(platform)
|
||||
add_subdirectory(script)
|
||||
add_subdirectory(resource)
|
||||
add_subdirectory(resource)
|
||||
add_subdirectory(test)
|
||||
@@ -1,6 +1,5 @@
|
||||
add_library(common src/addr_tuple4.cpp src/session_table.cpp src/raw_packet.cpp src/ctrl_packet.cpp src/bfd.cpp src/utils.cpp src/g_vxlan.cpp src/log.cpp src/timestamp.cpp)
|
||||
target_link_libraries(common PUBLIC cjson)
|
||||
target_link_libraries(common PUBLIC mrzcpd)
|
||||
target_link_libraries(common PUBLIC MESA_handle_logger)
|
||||
|
||||
target_include_directories(common PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
|
||||
@@ -92,14 +92,14 @@ void throughput_metrics_inc(struct throughput_metrics *iterm, uint64_t n_pkts, u
|
||||
|
||||
struct udp_hdr
|
||||
{
|
||||
u_int16_t uh_sport; /* source port */
|
||||
u_int16_t uh_dport; /* destination port */
|
||||
u_int16_t uh_ulen; /* udp length */
|
||||
u_int16_t uh_sum; /* udp checksum */
|
||||
uint16_t uh_sport; /* source port */
|
||||
uint16_t uh_dport; /* destination port */
|
||||
uint16_t uh_ulen; /* udp length */
|
||||
uint16_t uh_sum; /* udp checksum */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
void build_udp_header(const char *l3_hdr, int l3_hdr_len, struct udp_hdr *udp_hdr, u_int16_t udp_sport, u_int16_t udp_dport, int payload_len);
|
||||
void build_ip_header(struct ip *ip_hdr, u_int8_t next_protocol, const char *src_addr, const char *dst_addr, uint16_t payload_len);
|
||||
void build_udp_header(const char *l3_hdr, int l3_hdr_len, struct udp_hdr *udp_hdr, uint16_t udp_sport, uint16_t udp_dport, int payload_len);
|
||||
void build_ip_header(struct ip *ip_hdr, uint8_t next_protocol, const char *src_addr, const char *dst_addr, uint16_t payload_len);
|
||||
void build_ether_header(struct ethhdr *eth_hdr, uint16_t next_protocol, const char *src_mac, const char *dst_mac);
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
@@ -159,12 +159,12 @@ void throughput_metrics_inc(struct throughput_metrics *iterm, uint64_t n_pkts, u
|
||||
|
||||
#define CHECKSUM_CARRY(x) (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))
|
||||
|
||||
static int checksum(u_int16_t *addr, int len)
|
||||
static int checksum(uint16_t *addr, int len)
|
||||
{
|
||||
int sum = 0;
|
||||
int nleft = len;
|
||||
u_int16_t ans = 0;
|
||||
u_int16_t *w = addr;
|
||||
uint16_t ans = 0;
|
||||
uint16_t *w = addr;
|
||||
|
||||
while (nleft > 1)
|
||||
{
|
||||
@@ -181,7 +181,7 @@ static int checksum(u_int16_t *addr, int len)
|
||||
return sum;
|
||||
}
|
||||
|
||||
void build_udp_header(const char *l3_hdr, int l3_hdr_len, struct udp_hdr *udp_hdr, u_int16_t udp_sport, u_int16_t udp_dport, int payload_len)
|
||||
void build_udp_header(const char *l3_hdr, int l3_hdr_len, struct udp_hdr *udp_hdr, uint16_t udp_sport, uint16_t udp_dport, int payload_len)
|
||||
{
|
||||
memset(udp_hdr, 0, sizeof(struct udp_hdr));
|
||||
|
||||
@@ -193,13 +193,13 @@ void build_udp_header(const char *l3_hdr, int l3_hdr_len, struct udp_hdr *udp_hd
|
||||
udp_hdr->uh_ulen = htons(udp_hlen);
|
||||
udp_hdr->uh_sum = 0;
|
||||
|
||||
int sum = checksum((u_int16_t *)l3_hdr, l3_hdr_len);
|
||||
int sum = checksum((uint16_t *)l3_hdr, l3_hdr_len);
|
||||
sum += ntohs(IPPROTO_UDP + udp_hlen);
|
||||
sum += checksum((u_int16_t *)udp_hdr, udp_hlen);
|
||||
sum += checksum((uint16_t *)udp_hdr, udp_hlen);
|
||||
udp_hdr->uh_sum = CHECKSUM_CARRY(sum);
|
||||
}
|
||||
|
||||
void build_ip_header(struct ip *ip_hdr, u_int8_t next_protocol, const char *src_addr, const char *dst_addr, uint16_t payload_len)
|
||||
void build_ip_header(struct ip *ip_hdr, uint8_t next_protocol, const char *src_addr, const char *dst_addr, uint16_t payload_len)
|
||||
{
|
||||
memset(ip_hdr, 0, sizeof(struct ip));
|
||||
|
||||
@@ -215,7 +215,7 @@ void build_ip_header(struct ip *ip_hdr, u_int8_t next_protocol, const char *src_
|
||||
ip_hdr->ip_off = htons(0); /* fragmentation flags */
|
||||
ip_hdr->ip_sum = 0; /* do this later */
|
||||
|
||||
int sum = checksum((u_int16_t *)ip_hdr, 20);
|
||||
int sum = checksum((uint16_t *)ip_hdr, 20);
|
||||
ip_hdr->ip_sum = CHECKSUM_CARRY(sum);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ telegraf_bind_address=127.0.0.1
|
||||
telegraf_listen_port=8300
|
||||
|
||||
[bfdd]
|
||||
enable=1
|
||||
path=/run/run/frr/bfdd.vty
|
||||
device=eth0
|
||||
local_address=127.0.0.1
|
||||
|
||||
@@ -7,7 +7,6 @@ target_link_libraries(platform PUBLIC breakpad_mini)
|
||||
target_link_libraries(platform PUBLIC maatframe)
|
||||
target_link_libraries(platform PUBLIC mrzcpd)
|
||||
target_link_libraries(platform PUBLIC cjson)
|
||||
target_link_libraries(platform PUBLIC pthread)
|
||||
target_include_directories(platform PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include/)
|
||||
|
||||
add_executable(sce src/main.cpp)
|
||||
|
||||
@@ -6,6 +6,11 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
// only for gtest
|
||||
int mbuff_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta);
|
||||
int mbuff_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta);
|
||||
struct mr_instance *packet_io_get_mr_instance(struct packet_io *handle);
|
||||
|
||||
struct packet_io *packet_io_create(const char *profile, int thread_num, cpu_set_t *coremask);
|
||||
void packet_io_destory(struct packet_io *handle);
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ static struct session_table_addr g_handle_addr;
|
||||
static struct sf_status *g_sf_status = NULL;
|
||||
|
||||
int sleep_ms = 300;
|
||||
int enable = 1;
|
||||
char path[BFD_PATHLEN];
|
||||
char hc_dev_name[HC_DEV_NAME_LEN];
|
||||
char local_address[HC_LOCAL_ADDRESS_LEN];
|
||||
@@ -98,11 +99,17 @@ void health_check_session_init(const char *profile)
|
||||
{
|
||||
memset(&g_handle, 0, sizeof(g_handle));
|
||||
pthread_rwlock_init(&g_handle.rwlock, NULL);
|
||||
MESA_load_profile_int_def(profile, "bfdd", "enable", &enable, 1);
|
||||
MESA_load_profile_string_def(profile, "bfdd", "path", path, sizeof(path), "/var/run/frr/bfdd.vty");
|
||||
MESA_load_profile_string_def(profile, "bfdd", "device", hc_dev_name, sizeof(hc_dev_name), "eth0");
|
||||
MESA_load_profile_string_def(profile, "bfdd", "local_address", local_address, sizeof(local_address), "127.0.0.1");
|
||||
MESA_load_profile_string_def(profile, "bfdd", "gateway", gateway_address, sizeof(gateway_address), "127.0.0.1");
|
||||
|
||||
if (enable == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_sf_status = sf_status_create(profile);
|
||||
// TODO: 循环获取?
|
||||
get_mac_by_addr(gateway_address, default_gw_mac);
|
||||
@@ -204,6 +211,10 @@ uint64_t health_check_session_add(int profile_id, const struct health_check *pol
|
||||
struct node_addr *node = NULL;
|
||||
struct session_iterm *tmp = NULL;
|
||||
|
||||
if (enable == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
session_id = health_check_get_session_id();
|
||||
if (session_id == 0) {
|
||||
LOG_ERROR("health check get session id failed!");
|
||||
@@ -251,6 +262,11 @@ int health_check_session_del(uint64_t session_id, int profile_id)
|
||||
struct bfd_vtysh_client client;
|
||||
struct session_iterm *tmp = NULL;
|
||||
|
||||
if (enable == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
tmp = health_check_get_iterm_by_id(session_id);
|
||||
if (!tmp) {
|
||||
LOG_DEBUG("health check session table delete: session id [%lu] not exists", session_id);
|
||||
@@ -291,6 +307,11 @@ int health_check_session_get_status(uint64_t session_id)
|
||||
int status = 0;
|
||||
struct session_iterm *tmp = NULL;
|
||||
|
||||
if (enable == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
pthread_rwlock_rdlock(&g_handle.rwlock);
|
||||
HASH_FIND(hh1, g_handle.root_by_id, &session_id, sizeof(session_id), tmp);
|
||||
if (!tmp) {
|
||||
@@ -311,6 +332,11 @@ int health_check_session_set_status(uint64_t session_id, int is_active)
|
||||
{
|
||||
struct session_iterm *tmp = NULL;
|
||||
|
||||
if (enable == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
pthread_rwlock_wrlock(&g_handle.rwlock);
|
||||
HASH_FIND(hh1, g_handle.root_by_id, &session_id, sizeof(session_id), tmp);
|
||||
if (!tmp) {
|
||||
@@ -455,6 +481,10 @@ int health_check_session_get_mac(uint64_t session_id, char *mac_buff)
|
||||
struct session_iterm *tmp = NULL;
|
||||
uint8_t init_mac[HC_MAC_LEN] = {0};
|
||||
|
||||
if (enable == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
pthread_rwlock_rdlock(&g_handle.rwlock);
|
||||
HASH_FIND(hh1, g_handle.root_by_id, &session_id, sizeof(session_id), tmp);
|
||||
if (!tmp) {
|
||||
|
||||
@@ -53,7 +53,7 @@ struct packet_io
|
||||
|
||||
// return 0 : success
|
||||
// return -1 : error
|
||||
static int mbuff_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
|
||||
int mbuff_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
|
||||
{
|
||||
memset(meta, 0, sizeof(struct metadata));
|
||||
|
||||
@@ -119,7 +119,7 @@ static int mbuff_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
|
||||
|
||||
// return 0 : success
|
||||
// return -1 : error
|
||||
static int mbuff_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta)
|
||||
int mbuff_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta)
|
||||
{
|
||||
if (meta->session_id)
|
||||
{
|
||||
@@ -134,6 +134,7 @@ static int mbuff_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta)
|
||||
|
||||
if (meta->is_ctrl_pkt)
|
||||
{
|
||||
marsio_buff_set_ctrlbuf(tx_buff);
|
||||
if (marsio_buff_set_metadata(tx_buff, MR_BUFF_PAYLOAD_OFFSET, &(meta->l7offset), sizeof(meta->l7offset)) != 0)
|
||||
{
|
||||
LOG_ERROR("%s: unable to set l7offset for metadata", LOG_TAG_PKTIO);
|
||||
@@ -1267,3 +1268,15 @@ int packet_io_thread_polling_endpoint(struct packet_io *handle, struct thread_ct
|
||||
|
||||
return nr_recv;
|
||||
}
|
||||
|
||||
struct mr_instance *packet_io_get_mr_instance(struct packet_io *handle)
|
||||
{
|
||||
if (handle)
|
||||
{
|
||||
return handle->instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
84
test/CMakeLists.txt
Normal file
84
test/CMakeLists.txt
Normal file
@@ -0,0 +1,84 @@
|
||||
###############################################################################
|
||||
# gmock_marsio
|
||||
###############################################################################
|
||||
|
||||
add_library(gmock_marsio marsio.cpp)
|
||||
target_include_directories(gmock_marsio PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
###############################################################################
|
||||
# temp_platform
|
||||
###############################################################################
|
||||
|
||||
add_library(temp_platform
|
||||
${CMAKE_SOURCE_DIR}/platform/src/policy.cpp
|
||||
${CMAKE_SOURCE_DIR}/platform/src/health_check.cpp
|
||||
${CMAKE_SOURCE_DIR}/platform/src/sce.cpp
|
||||
${CMAKE_SOURCE_DIR}/platform/src/packet_io.cpp
|
||||
${CMAKE_SOURCE_DIR}/platform/src/global_metrics.cpp
|
||||
${CMAKE_SOURCE_DIR}/platform/src/sf_metrics.cpp
|
||||
${CMAKE_SOURCE_DIR}/platform/src/sf_status.cpp)
|
||||
target_include_directories(temp_platform PUBLIC ${CMAKE_SOURCE_DIR}/common/include)
|
||||
target_include_directories(temp_platform PUBLIC ${CMAKE_SOURCE_DIR}/platform/include)
|
||||
target_link_libraries(temp_platform PUBLIC common pthread cjson maatframe MESA_prof_load MESA_field_stat gmock_marsio)
|
||||
|
||||
###############################################################################
|
||||
# gtest_ctrl_pkt_opening
|
||||
###############################################################################
|
||||
|
||||
add_executable(gtest_ctrl_pkt_opening gtest_ctrl_pkt_opening.cpp)
|
||||
target_include_directories(gtest_ctrl_pkt_opening PUBLIC ${CMAKE_SOURCE_DIR}/common/include)
|
||||
target_include_directories(gtest_ctrl_pkt_opening PUBLIC ${CMAKE_SOURCE_DIR}/platform/include)
|
||||
target_link_libraries(gtest_ctrl_pkt_opening temp_platform gtest)
|
||||
|
||||
###############################################################################
|
||||
# gtest_ctrl_pkt_active
|
||||
###############################################################################
|
||||
|
||||
add_executable(gtest_ctrl_pkt_active gtest_ctrl_pkt_active.cpp)
|
||||
target_include_directories(gtest_ctrl_pkt_active PUBLIC ${CMAKE_SOURCE_DIR}/common/include)
|
||||
target_include_directories(gtest_ctrl_pkt_active PUBLIC ${CMAKE_SOURCE_DIR}/platform/include)
|
||||
target_link_libraries(gtest_ctrl_pkt_active temp_platform gtest)
|
||||
|
||||
###############################################################################
|
||||
# gtest_raw_pkt_stee_bypass
|
||||
###############################################################################
|
||||
|
||||
add_executable(gtest_raw_pkt_stee_bypass gtest_raw_pkt_stee_bypass.cpp)
|
||||
target_include_directories(gtest_raw_pkt_stee_bypass PUBLIC ${CMAKE_SOURCE_DIR}/common/include)
|
||||
target_include_directories(gtest_raw_pkt_stee_bypass PUBLIC ${CMAKE_SOURCE_DIR}/platform/include)
|
||||
target_link_libraries(gtest_raw_pkt_stee_bypass temp_platform gtest)
|
||||
|
||||
###############################################################################
|
||||
# gtest_raw_pkt_stee_block
|
||||
###############################################################################
|
||||
|
||||
add_executable(gtest_raw_pkt_stee_block gtest_raw_pkt_stee_block.cpp)
|
||||
target_include_directories(gtest_raw_pkt_stee_block PUBLIC ${CMAKE_SOURCE_DIR}/common/include)
|
||||
target_include_directories(gtest_raw_pkt_stee_block PUBLIC ${CMAKE_SOURCE_DIR}/platform/include)
|
||||
target_link_libraries(gtest_raw_pkt_stee_block temp_platform gtest)
|
||||
|
||||
###############################################################################
|
||||
# gtest_raw_pkt_stee_forward
|
||||
###############################################################################
|
||||
|
||||
add_executable(gtest_raw_pkt_stee_forward gtest_raw_pkt_stee_forward.cpp)
|
||||
target_include_directories(gtest_raw_pkt_stee_forward PUBLIC ${CMAKE_SOURCE_DIR}/common/include)
|
||||
target_include_directories(gtest_raw_pkt_stee_forward PUBLIC ${CMAKE_SOURCE_DIR}/platform/include)
|
||||
target_link_libraries(gtest_raw_pkt_stee_forward temp_platform gtest)
|
||||
|
||||
###############################################################################
|
||||
# gtest_discover_tests
|
||||
###############################################################################
|
||||
|
||||
include(GoogleTest)
|
||||
|
||||
gtest_discover_tests(gtest_ctrl_pkt_opening)
|
||||
gtest_discover_tests(gtest_ctrl_pkt_active)
|
||||
|
||||
gtest_discover_tests(gtest_raw_pkt_stee_bypass)
|
||||
gtest_discover_tests(gtest_raw_pkt_stee_block)
|
||||
gtest_discover_tests(gtest_raw_pkt_stee_forward)
|
||||
|
||||
file(COPY ./test_data/log/ DESTINATION ./log/)
|
||||
file(COPY ./test_data/conf/ DESTINATION ./conf/)
|
||||
file(COPY ./test_data/resource/ DESTINATION ./resource/)
|
||||
40
test/gtest_ctrl_pkt_active.cpp
Normal file
40
test/gtest_ctrl_pkt_active.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "gtest_utils.h"
|
||||
|
||||
// 185 bytes
|
||||
static u_char ctrl_pkt_active[] = {
|
||||
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
|
||||
0x00, 0xab, 0x76, 0x23, 0x40, 0x00, 0x7d, 0x06, 0x67, 0x66, 0xc0, 0xa8, 0x29, 0x40, 0x5d, 0xb8,
|
||||
0xd8, 0x22, 0xce, 0xec, 0x00, 0x50, 0xf8, 0x77, 0x0e, 0x1e, 0x47, 0x34, 0x32, 0xb9, 0x50, 0x18,
|
||||
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00, 0x7b, 0x22, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x3a, 0x22,
|
||||
0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x2c, 0x22, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x22,
|
||||
0x3a, 0x22, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22,
|
||||
0x2c, 0x22, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x3a, 0x7b, 0x22, 0x73, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x22, 0x3a, 0x5b, 0x39,
|
||||
0x39, 0x35, 0x31, 0x39, 0x39, 0x5d, 0x7d, 0x2c, 0x22, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x5f, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x32, 0x39, 0x30, 0x34, 0x38, 0x34, 0x34, 0x39, 0x32, 0x37,
|
||||
0x30, 0x32, 0x35, 0x38, 0x31, 0x37, 0x33, 0x37, 0x22, 0x2c, 0x22, 0x74, 0x73, 0x79, 0x6e, 0x63,
|
||||
0x22, 0x3a, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x7d, 0x00};
|
||||
|
||||
TEST(PACKET_IO, CTRL_PKT_ACTIVE)
|
||||
{
|
||||
marsio_buff_t *tx_mbuf = NULL;
|
||||
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);
|
||||
dup_mbuf = marsio_mbuff_dup(tx_mbuf);
|
||||
|
||||
gtest_frame = gtest_frame_new("sce0.json", "ctr_pkt_active");
|
||||
gtest_frame_run(gtest_frame, tx_mbuf, dup_mbuf, 1);
|
||||
|
||||
gtest_frame_log(gtest_frame);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &tx_mbuf, 1, 0, 0);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &dup_mbuf, 1, 0, 0);
|
||||
gtest_frame_free(gtest_frame);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
36
test/gtest_ctrl_pkt_opening.cpp
Normal file
36
test/gtest_ctrl_pkt_opening.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "gtest_utils.h"
|
||||
|
||||
// 122 bytes
|
||||
static u_char ctrl_pkt_opening[] = {
|
||||
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
|
||||
0x00, 0x6c, 0xff, 0xde, 0x40, 0x00, 0x33, 0x06, 0x27, 0xea, 0xc0, 0xa8, 0x29, 0x40, 0x5d, 0xb8,
|
||||
0xd8, 0x22, 0xce, 0xec, 0x00, 0x50, 0xf8, 0x77, 0x0d, 0xcf, 0x00, 0x00, 0x00, 0x00, 0x50, 0x18,
|
||||
0x03, 0xec, 0x08, 0xa7, 0x00, 0x00, 0x7b, 0x22, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x3a, 0x22,
|
||||
0x6f, 0x70, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x22, 0x2c, 0x22, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x5f, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x32, 0x39, 0x30, 0x34, 0x38, 0x34, 0x34, 0x39, 0x32,
|
||||
0x37, 0x30, 0x32, 0x35, 0x38, 0x31, 0x37, 0x33, 0x37, 0x22, 0x2c, 0x22, 0x74, 0x73, 0x79, 0x6e,
|
||||
0x63, 0x22, 0x3a, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x7d, 0x00};
|
||||
|
||||
TEST(PACKET_IO, CTRL_PKT_OPENING)
|
||||
{
|
||||
marsio_buff_t *tx_mbuf = NULL;
|
||||
marsio_buff_t *dup_mbuf = NULL;
|
||||
struct gtest_frame *gtest_frame = NULL;
|
||||
|
||||
build_mbuf_for_ctrl_pkt(tx_mbuf, ctrl_pkt_opening, sizeof(ctrl_pkt_opening), 290484492702581737, 54);
|
||||
dup_mbuf = marsio_mbuff_dup(tx_mbuf);
|
||||
|
||||
gtest_frame = gtest_frame_new("sce0.json", "ctr_pkt_opening");
|
||||
gtest_frame_run(gtest_frame, tx_mbuf, dup_mbuf, 1);
|
||||
|
||||
gtest_frame_log(gtest_frame);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &tx_mbuf, 1, 0, 0);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &dup_mbuf, 1, 0, 0);
|
||||
gtest_frame_free(gtest_frame);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
57
test/gtest_raw_pkt_stee_block.cpp
Normal file
57
test/gtest_raw_pkt_stee_block.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "gtest_utils.h"
|
||||
|
||||
// 185 bytes
|
||||
static u_char ctrl_pkt_active[] = {
|
||||
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
|
||||
0x00, 0xab, 0x76, 0x23, 0x40, 0x00, 0x7d, 0x06, 0x67, 0x66, 0xc0, 0xa8, 0x29, 0x40, 0x5d, 0xb8,
|
||||
0xd8, 0x22, 0xce, 0xec, 0x00, 0x50, 0xf8, 0x77, 0x0e, 0x1e, 0x47, 0x34, 0x32, 0xb9, 0x50, 0x18,
|
||||
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00, 0x7b, 0x22, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x3a, 0x22,
|
||||
0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x2c, 0x22, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x22,
|
||||
0x3a, 0x22, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22,
|
||||
0x2c, 0x22, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x3a, 0x7b, 0x22, 0x73, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x22, 0x3a, 0x5b, 0x39,
|
||||
0x39, 0x35, 0x31, 0x39, 0x39, 0x5d, 0x7d, 0x2c, 0x22, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x5f, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x32, 0x39, 0x30, 0x34, 0x38, 0x34, 0x34, 0x39, 0x32, 0x37,
|
||||
0x30, 0x32, 0x35, 0x38, 0x31, 0x37, 0x33, 0x37, 0x22, 0x2c, 0x22, 0x74, 0x73, 0x79, 0x6e, 0x63,
|
||||
0x22, 0x3a, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x7d, 0x00};
|
||||
|
||||
// 145 bytes
|
||||
static u_char raw_pkt[] = {
|
||||
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
|
||||
0x00, 0x83, 0x46, 0x1f, 0x40, 0x00, 0x40, 0x06, 0xd4, 0x92, 0xc0, 0xa8, 0x29, 0x40, 0x5d, 0xb8,
|
||||
0xd8, 0x22, 0xce, 0xec, 0x00, 0x50, 0xf8, 0x77, 0x0d, 0xcf, 0x47, 0x34, 0x32, 0xb9, 0x80, 0x18,
|
||||
0xfa, 0xf0, 0xad, 0xf4, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x45, 0xfc, 0x39, 0x3d, 0xc1, 0x1f,
|
||||
0x8d, 0x76, 0x47, 0x45, 0x54, 0x20, 0x2f, 0x20, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31,
|
||||
0x0d, 0x0a, 0x48, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0x77, 0x77, 0x77, 0x2e, 0x65, 0x78, 0x61, 0x6d,
|
||||
0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x0d, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67,
|
||||
0x65, 0x6e, 0x74, 0x3a, 0x20, 0x63, 0x75, 0x72, 0x6c, 0x2f, 0x37, 0x2e, 0x36, 0x31, 0x2e, 0x31,
|
||||
0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x3a, 0x20, 0x2a, 0x2f, 0x2a, 0x0d, 0x0a, 0x0d,
|
||||
0x0a};
|
||||
|
||||
TEST(PACKET_IO, RAW_PKT_STEE_BLOCK)
|
||||
{
|
||||
marsio_buff_t *tx_mbuf1 = NULL;
|
||||
marsio_buff_t *tx_mbuf2 = NULL;
|
||||
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_raw_pkt(tx_mbuf2, raw_pkt, sizeof(raw_pkt), 290484492702581737, 0);
|
||||
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
|
||||
|
||||
gtest_frame = gtest_frame_new("raw_pkt_stee_block.json", "raw_pkt_stee_block");
|
||||
gtest_frame_run(gtest_frame, tx_mbuf1, dup_mbuf1, 1);
|
||||
gtest_frame_run(gtest_frame, tx_mbuf2, NULL, 1);
|
||||
|
||||
gtest_frame_log(gtest_frame);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &tx_mbuf1, 1, 0, 0);
|
||||
// marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &tx_mbuf2, 1, 0, 0); /* tx_mbuf2 free by stee_block */
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &dup_mbuf1, 1, 0, 0);
|
||||
gtest_frame_free(gtest_frame);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
60
test/gtest_raw_pkt_stee_bypass.cpp
Normal file
60
test/gtest_raw_pkt_stee_bypass.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "gtest_utils.h"
|
||||
|
||||
// 185 bytes
|
||||
static u_char ctrl_pkt_active[] = {
|
||||
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
|
||||
0x00, 0xab, 0x76, 0x23, 0x40, 0x00, 0x7d, 0x06, 0x67, 0x66, 0xc0, 0xa8, 0x29, 0x40, 0x5d, 0xb8,
|
||||
0xd8, 0x22, 0xce, 0xec, 0x00, 0x50, 0xf8, 0x77, 0x0e, 0x1e, 0x47, 0x34, 0x32, 0xb9, 0x50, 0x18,
|
||||
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00, 0x7b, 0x22, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x3a, 0x22,
|
||||
0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x2c, 0x22, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x22,
|
||||
0x3a, 0x22, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22,
|
||||
0x2c, 0x22, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x3a, 0x7b, 0x22, 0x73, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x22, 0x3a, 0x5b, 0x39,
|
||||
0x39, 0x35, 0x31, 0x39, 0x39, 0x5d, 0x7d, 0x2c, 0x22, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x5f, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x32, 0x39, 0x30, 0x34, 0x38, 0x34, 0x34, 0x39, 0x32, 0x37,
|
||||
0x30, 0x32, 0x35, 0x38, 0x31, 0x37, 0x33, 0x37, 0x22, 0x2c, 0x22, 0x74, 0x73, 0x79, 0x6e, 0x63,
|
||||
0x22, 0x3a, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x7d, 0x00};
|
||||
|
||||
// 145 bytes
|
||||
static u_char raw_pkt[] = {
|
||||
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
|
||||
0x00, 0x83, 0x46, 0x1f, 0x40, 0x00, 0x40, 0x06, 0xd4, 0x92, 0xc0, 0xa8, 0x29, 0x40, 0x5d, 0xb8,
|
||||
0xd8, 0x22, 0xce, 0xec, 0x00, 0x50, 0xf8, 0x77, 0x0d, 0xcf, 0x47, 0x34, 0x32, 0xb9, 0x80, 0x18,
|
||||
0xfa, 0xf0, 0xad, 0xf4, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x45, 0xfc, 0x39, 0x3d, 0xc1, 0x1f,
|
||||
0x8d, 0x76, 0x47, 0x45, 0x54, 0x20, 0x2f, 0x20, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31,
|
||||
0x0d, 0x0a, 0x48, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0x77, 0x77, 0x77, 0x2e, 0x65, 0x78, 0x61, 0x6d,
|
||||
0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x0d, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67,
|
||||
0x65, 0x6e, 0x74, 0x3a, 0x20, 0x63, 0x75, 0x72, 0x6c, 0x2f, 0x37, 0x2e, 0x36, 0x31, 0x2e, 0x31,
|
||||
0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x3a, 0x20, 0x2a, 0x2f, 0x2a, 0x0d, 0x0a, 0x0d,
|
||||
0x0a};
|
||||
|
||||
TEST(PACKET_IO, RAW_PKT_STEE_BYPASS)
|
||||
{
|
||||
marsio_buff_t *tx_mbuf1 = NULL;
|
||||
marsio_buff_t *tx_mbuf2 = NULL;
|
||||
marsio_buff_t *dup_mbuf1 = NULL;
|
||||
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_raw_pkt(tx_mbuf2, raw_pkt, sizeof(raw_pkt), 290484492702581737, 0);
|
||||
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
|
||||
dup_mbuf2 = marsio_mbuff_dup(tx_mbuf2);
|
||||
|
||||
gtest_frame = gtest_frame_new("raw_pkt_stee_bypass.json", "raw_pkt_stee_bypass");
|
||||
gtest_frame_run(gtest_frame, tx_mbuf1, dup_mbuf1, 1);
|
||||
gtest_frame_run(gtest_frame, tx_mbuf2, dup_mbuf2, 1);
|
||||
|
||||
gtest_frame_log(gtest_frame);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &tx_mbuf1, 1, 0, 0);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &tx_mbuf2, 1, 0, 0);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &dup_mbuf1, 1, 0, 0);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &dup_mbuf2, 1, 0, 0);
|
||||
gtest_frame_free(gtest_frame);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
65
test/gtest_raw_pkt_stee_forward.cpp
Normal file
65
test/gtest_raw_pkt_stee_forward.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "gtest_utils.h"
|
||||
|
||||
// 185 bytes
|
||||
static u_char ctrl_pkt_active[] = {
|
||||
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
|
||||
0x00, 0xab, 0x76, 0x23, 0x40, 0x00, 0x7d, 0x06, 0x67, 0x66, 0xc0, 0xa8, 0x29, 0x40, 0x5d, 0xb8,
|
||||
0xd8, 0x22, 0xce, 0xec, 0x00, 0x50, 0xf8, 0x77, 0x0e, 0x1e, 0x47, 0x34, 0x32, 0xb9, 0x50, 0x18,
|
||||
0x04, 0x88, 0x7a, 0xe8, 0x00, 0x00, 0x7b, 0x22, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x3a, 0x22,
|
||||
0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x2c, 0x22, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x22,
|
||||
0x3a, 0x22, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22,
|
||||
0x2c, 0x22, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x3a, 0x7b, 0x22, 0x73, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x22, 0x3a, 0x5b, 0x39,
|
||||
0x39, 0x35, 0x31, 0x39, 0x39, 0x5d, 0x7d, 0x2c, 0x22, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x5f, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x32, 0x39, 0x30, 0x34, 0x38, 0x34, 0x34, 0x39, 0x32, 0x37,
|
||||
0x30, 0x32, 0x35, 0x38, 0x31, 0x37, 0x33, 0x37, 0x22, 0x2c, 0x22, 0x74, 0x73, 0x79, 0x6e, 0x63,
|
||||
0x22, 0x3a, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x7d, 0x00};
|
||||
|
||||
// 145 bytes
|
||||
static u_char raw_pkt[] = {
|
||||
0x48, 0x73, 0x97, 0x96, 0x38, 0x10, 0x0c, 0xa7, 0x5c, 0x64, 0x00, 0x01, 0x08, 0x00, 0x45, 0x00,
|
||||
0x00, 0x83, 0x46, 0x1f, 0x40, 0x00, 0x40, 0x06, 0xd4, 0x92, 0xc0, 0xa8, 0x29, 0x40, 0x5d, 0xb8,
|
||||
0xd8, 0x22, 0xce, 0xec, 0x00, 0x50, 0xf8, 0x77, 0x0d, 0xcf, 0x47, 0x34, 0x32, 0xb9, 0x80, 0x18,
|
||||
0xfa, 0xf0, 0xad, 0xf4, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x45, 0xfc, 0x39, 0x3d, 0xc1, 0x1f,
|
||||
0x8d, 0x76, 0x47, 0x45, 0x54, 0x20, 0x2f, 0x20, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31,
|
||||
0x0d, 0x0a, 0x48, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0x77, 0x77, 0x77, 0x2e, 0x65, 0x78, 0x61, 0x6d,
|
||||
0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x0d, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67,
|
||||
0x65, 0x6e, 0x74, 0x3a, 0x20, 0x63, 0x75, 0x72, 0x6c, 0x2f, 0x37, 0x2e, 0x36, 0x31, 0x2e, 0x31,
|
||||
0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x3a, 0x20, 0x2a, 0x2f, 0x2a, 0x0d, 0x0a, 0x0d,
|
||||
0x0a};
|
||||
|
||||
TEST(PACKET_IO, RAW_PKT_STEE_FORWARD)
|
||||
{
|
||||
marsio_buff_t *tx_mbuf1 = NULL;
|
||||
marsio_buff_t *tx_mbuf2 = NULL;
|
||||
marsio_buff_t *dup_mbuf1 = NULL;
|
||||
marsio_buff_t *dup_mbuf2 = NULL;
|
||||
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_raw_pkt(tx_mbuf2, raw_pkt, sizeof(raw_pkt), 290484492702581737, 0);
|
||||
dup_mbuf1 = marsio_mbuff_dup(tx_mbuf1);
|
||||
dup_mbuf2 = marsio_mbuff_dup(tx_mbuf2);
|
||||
|
||||
gtest_frame = gtest_frame_new("raw_pkt_stee_forward.json", "raw_pkt_stee_forward");
|
||||
mr_instance = packet_io_get_mr_instance(gtest_frame->sce_ctx->io);
|
||||
gtest_frame_run(gtest_frame, tx_mbuf1, dup_mbuf1, 1);
|
||||
marsio_set_recv_mbuff(mr_instance, tx_mbuf2);
|
||||
marsio_set_send_mbuff(mr_instance, NULL);
|
||||
EXPECT_TRUE(packet_io_thread_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1);
|
||||
EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0);
|
||||
|
||||
gtest_frame_log(gtest_frame);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &tx_mbuf1, 1, 0, 0);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &tx_mbuf2, 1, 0, 0);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &dup_mbuf1, 1, 0, 0);
|
||||
marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &dup_mbuf2, 1, 0, 0);
|
||||
gtest_frame_free(gtest_frame);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
231
test/gtest_utils.h
Normal file
231
test/gtest_utils.h
Normal file
@@ -0,0 +1,231 @@
|
||||
#ifndef _GTEST_UTILS_H
|
||||
#define _GTEST_UTILS_H
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "sce.h"
|
||||
#include "log.h"
|
||||
#include "marsio.h"
|
||||
#include "g_vxlan.h"
|
||||
#include "packet_io.h"
|
||||
#include "sf_metrics.h"
|
||||
#include "health_check.h"
|
||||
#include "global_metrics.h"
|
||||
|
||||
#define set_metadata(meta, id, offset, is_ctrl, is_decrypt) \
|
||||
{ \
|
||||
memset(&meta, 0, sizeof(meta)); \
|
||||
meta.write_ref = 0; \
|
||||
meta.session_id = id; \
|
||||
meta.raw_data = NULL; \
|
||||
meta.raw_len = 0; \
|
||||
meta.l7offset = offset; \
|
||||
meta.is_e2i_dir = 0; \
|
||||
meta.is_ctrl_pkt = is_ctrl; \
|
||||
meta.is_decrypted = is_decrypt; \
|
||||
memset(&meta.sids.elems, 1, sizeof(meta.sids.elems)); \
|
||||
meta.sids.num = 8; \
|
||||
memset(&meta.route_ctx.data, 1, 64); \
|
||||
meta.route_ctx.len = 64; \
|
||||
}
|
||||
|
||||
#define build_mbuf_for_inject_pkt(mbuf, data, len) \
|
||||
{ \
|
||||
marsio_buff_malloc_global(NULL, &mbuf, 1, 0, 0); \
|
||||
char *ptr = marsio_buff_append(mbuf, len); \
|
||||
EXPECT_TRUE(ptr != nullptr); \
|
||||
memcpy(ptr, data, len); \
|
||||
}
|
||||
|
||||
#define build_mbuf_for_raw_pkt(mbuf, data, len, id, is_decrypt) \
|
||||
{ \
|
||||
struct metadata meta; \
|
||||
set_metadata(meta, id, 0, 0, is_decrypt); \
|
||||
marsio_buff_malloc_global(NULL, &mbuf, 1, 0, 0); \
|
||||
EXPECT_TRUE(mbuff_set_metadata(mbuf, &meta) == 0); \
|
||||
char *ptr = marsio_buff_append(mbuf, len); \
|
||||
EXPECT_TRUE(ptr != nullptr); \
|
||||
memcpy(ptr, data, len); \
|
||||
}
|
||||
|
||||
#define build_mbuf_for_ctrl_pkt(mbuf, data, len, id, offset) \
|
||||
{ \
|
||||
struct metadata meta; \
|
||||
set_metadata(meta, id, offset, 1, 0); \
|
||||
marsio_buff_malloc_global(NULL, &mbuf, 1, 0, 0); \
|
||||
EXPECT_TRUE(mbuff_set_metadata(mbuf, &meta) == 0); \
|
||||
char *ptr = marsio_buff_append(mbuf, len); \
|
||||
EXPECT_TRUE(ptr != nullptr); \
|
||||
memcpy(ptr, data, len); \
|
||||
}
|
||||
|
||||
struct gtest_frame
|
||||
{
|
||||
struct sce_ctx *sce_ctx;
|
||||
char *json_file;
|
||||
char *desc;
|
||||
};
|
||||
|
||||
inline struct gtest_frame *gtest_frame_new(const char *json_file, const char *desc)
|
||||
{
|
||||
char cmdline[1024] = {0};
|
||||
const char *profile = "./conf/sce.conf";
|
||||
struct sce_ctx *sce_ctx = NULL;
|
||||
struct thread_ctx *thread_ctx = NULL;
|
||||
struct gtest_frame *instance = (struct gtest_frame *)calloc(1, sizeof(struct gtest_frame));
|
||||
|
||||
system("rm -rf `ls log/* | egrep -v '(*_ok.fs2)'`");
|
||||
|
||||
memset(&cmdline, 0, sizeof(cmdline));
|
||||
snprintf(cmdline, sizeof(cmdline), "sed -i \"s/json_cfg_file=.*/json_cfg_file=resource\\/%s/\" ./conf/sce.conf", json_file);
|
||||
system(cmdline);
|
||||
|
||||
EXPECT_TRUE(LOG_INIT("./conf/zlog.conf") == 0);
|
||||
health_check_session_init(profile);
|
||||
sce_ctx = sce_ctx_create(profile);
|
||||
EXPECT_TRUE(sce_ctx != nullptr);
|
||||
|
||||
thread_ctx = &sce_ctx->work_threads[0];
|
||||
thread_ctx->tid = 0;
|
||||
thread_ctx->thread_index = 0;
|
||||
thread_ctx->session_table = session_table_create();
|
||||
thread_ctx->sf_metrics = sf_metrics_create(profile);
|
||||
thread_ctx->ref_io = sce_ctx->io;
|
||||
thread_ctx->ref_metrics = sce_ctx->metrics;
|
||||
thread_ctx->ref_enforcer = sce_ctx->enforcer;
|
||||
thread_ctx->ref_sce_ctx = sce_ctx;
|
||||
thread_ctx->session_table_need_reset = 0;
|
||||
|
||||
EXPECT_TRUE(packet_io_thread_init(sce_ctx->io, thread_ctx) == 0);
|
||||
|
||||
instance->sce_ctx = sce_ctx;
|
||||
instance->json_file = strdup(json_file);
|
||||
instance->desc = strdup(desc);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
inline void gtest_frame_free(struct gtest_frame *instance)
|
||||
{
|
||||
if (instance)
|
||||
{
|
||||
struct sce_ctx *sce_ctx = instance->sce_ctx;
|
||||
struct thread_ctx *thread_ctx = &sce_ctx->work_threads[0];
|
||||
|
||||
session_table_destory(thread_ctx->session_table);
|
||||
sf_metrics_destory(thread_ctx->sf_metrics);
|
||||
|
||||
sce_ctx_destory(sce_ctx);
|
||||
LOG_CLOSE();
|
||||
|
||||
if (instance->json_file)
|
||||
{
|
||||
free(instance->json_file);
|
||||
instance->json_file = NULL;
|
||||
}
|
||||
|
||||
if (instance->desc)
|
||||
{
|
||||
free(instance->desc);
|
||||
instance->desc = NULL;
|
||||
}
|
||||
|
||||
free(instance);
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gtest_frame_run(struct gtest_frame *instance, marsio_buff_t *tx_mbuf, marsio_buff_t *expect_rx_mbuf, int is_poll_nf)
|
||||
{
|
||||
marsio_buff_t *rx_mbuf;
|
||||
struct sce_ctx *sce_ctx = instance->sce_ctx;
|
||||
struct thread_ctx *thread_ctx = &sce_ctx->work_threads[0];
|
||||
struct mr_instance *mr_instance = packet_io_get_mr_instance(sce_ctx->io);
|
||||
|
||||
marsio_set_recv_mbuff(mr_instance, tx_mbuf);
|
||||
marsio_set_send_mbuff(mr_instance, NULL);
|
||||
|
||||
if (is_poll_nf)
|
||||
{
|
||||
EXPECT_TRUE(packet_io_thread_polling_nf(sce_ctx->io, thread_ctx) == 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
EXPECT_TRUE(packet_io_thread_polling_endpoint(sce_ctx->io, thread_ctx) == 1);
|
||||
}
|
||||
|
||||
rx_mbuf = marsio_get_send_mbuff(mr_instance);
|
||||
EXPECT_TRUE(marsio_mbuff_cmp(rx_mbuf, expect_rx_mbuf) == 0);
|
||||
}
|
||||
|
||||
inline void gtest_frame_log(struct gtest_frame *instance)
|
||||
{
|
||||
struct stat temp_stat;
|
||||
char diffile[1024] = {0};
|
||||
char cmdline[1024] = {0};
|
||||
struct sce_ctx *sce_ctx = instance->sce_ctx;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
global_metrics_dump(sce_ctx->metrics);
|
||||
usleep(1);
|
||||
}
|
||||
memset(&cmdline, 0, sizeof(cmdline));
|
||||
snprintf(cmdline, sizeof(cmdline), "cp log/sce.fs2 log/test_%s.fs2", instance->desc);
|
||||
system(cmdline);
|
||||
|
||||
memset(&cmdline, 0, sizeof(cmdline));
|
||||
snprintf(cmdline, sizeof(cmdline), "diff -I '===' log/test_%s.fs2 log/test_%s_ok.fs2 > log/test_%s.diff", instance->desc, instance->desc, instance->desc);
|
||||
int ret = system(cmdline);
|
||||
printf("exec %s, return: %d\n", cmdline, ret);
|
||||
|
||||
memset(&diffile, 0, sizeof(diffile));
|
||||
snprintf(diffile, sizeof(diffile), "log/test_%s.diff", instance->desc);
|
||||
stat(diffile, &temp_stat);
|
||||
EXPECT_TRUE(temp_stat.st_size == 0);
|
||||
|
||||
memset(&cmdline, 0, sizeof(cmdline));
|
||||
snprintf(cmdline, sizeof(cmdline), "cp log/sce.log* log/test_%s.log", instance->desc);
|
||||
system(cmdline);
|
||||
}
|
||||
|
||||
inline int mbuff_cmp_payload(marsio_buff_t *raw_pkt, marsio_buff_t *vxlan_pkt)
|
||||
{
|
||||
struct g_vxlan *g_vxlan_hdr = NULL;
|
||||
int raw_pkt_len = marsio_buff_datalen(raw_pkt);
|
||||
char *raw_pkt_data = marsio_buff_mtod(raw_pkt);
|
||||
|
||||
int vxlan_pkt_len = marsio_buff_datalen(vxlan_pkt);
|
||||
char *vxlan_pkt_data = marsio_buff_mtod(vxlan_pkt);
|
||||
|
||||
if (raw_pkt_len + 50 != vxlan_pkt_len)
|
||||
{
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
if (g_vxlan_decode(&g_vxlan_hdr, vxlan_pkt_data, vxlan_pkt_len) != 0)
|
||||
{
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
if (memcmp(raw_pkt_data, vxlan_pkt_data + 50, raw_pkt_len) != 0)
|
||||
{
|
||||
goto error_out;
|
||||
}
|
||||
return 0;
|
||||
|
||||
error_out:
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
453
test/marsio.cpp
Normal file
453
test/marsio.cpp
Normal file
@@ -0,0 +1,453 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "marsio.h"
|
||||
|
||||
struct mr_instance
|
||||
{
|
||||
marsio_buff_t *current_recv_mbuff_ptr;
|
||||
marsio_buff_t *current_send_mbuff_ptr;
|
||||
};
|
||||
|
||||
struct mr_vdev
|
||||
{
|
||||
struct mr_instance *mr_instance;
|
||||
};
|
||||
|
||||
struct mr_sendpath
|
||||
{
|
||||
struct mr_instance *mr_instance;
|
||||
};
|
||||
|
||||
struct mrb_metadata_route_ctx
|
||||
{
|
||||
uint8_t dir;
|
||||
uint8_t link_id;
|
||||
uint16_t port_ingress;
|
||||
uint16_t port_egress;
|
||||
uint16_t link_db_index;
|
||||
uint32_t hash_usr;
|
||||
};
|
||||
|
||||
struct mrb_metadata
|
||||
{
|
||||
uint8_t dir : 1;
|
||||
uint8_t packet_create_from_nf : 1;
|
||||
uint8_t link_id : 6;
|
||||
|
||||
uint8_t is_ctrlbuf : 1;
|
||||
uint8_t un_used : 7;
|
||||
|
||||
uint16_t payload_offset;
|
||||
|
||||
uint64_t session_id;
|
||||
|
||||
uint8_t start_sid;
|
||||
uint8_t nr_sid;
|
||||
uint16_t cur_sid;
|
||||
uint16_t sids[8];
|
||||
|
||||
uint16_t port_ingress;
|
||||
uint16_t port_egress;
|
||||
|
||||
uint16_t link_db_index;
|
||||
};
|
||||
|
||||
struct mock_marsio_buff_t
|
||||
{
|
||||
struct mrb_metadata metadata;
|
||||
|
||||
char *raw_data;
|
||||
int raw_len;
|
||||
|
||||
int buff_size;
|
||||
char *buff_start;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct mr_instance *marsio_create()
|
||||
{
|
||||
struct mr_instance *instance = (struct mr_instance *)calloc(1, sizeof(struct mr_instance));
|
||||
instance->current_recv_mbuff_ptr = NULL;
|
||||
instance->current_send_mbuff_ptr = NULL;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
int marsio_destory(struct mr_instance *instance)
|
||||
{
|
||||
if (instance)
|
||||
{
|
||||
free(instance);
|
||||
instance = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct mr_vdev *marsio_open_device(struct mr_instance *instance, const char *devsym, unsigned int nr_rxstream, unsigned int nr_txstream)
|
||||
{
|
||||
struct mr_vdev *vdev = (struct mr_vdev *)calloc(1, sizeof(struct mr_vdev));
|
||||
vdev->mr_instance = instance;
|
||||
|
||||
return vdev;
|
||||
}
|
||||
|
||||
void marsio_close_device(struct mr_vdev *vdev)
|
||||
{
|
||||
if (vdev)
|
||||
{
|
||||
free(vdev);
|
||||
vdev = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void marsio_get_device_ether_addr(struct mr_vdev *vdev, void *str_ether_addr, uint8_t size)
|
||||
{
|
||||
}
|
||||
|
||||
struct mr_sendpath *marsio_sendpath_create_by_vdev(struct mr_vdev *dest_device)
|
||||
{
|
||||
struct mr_sendpath *sendpath = (struct mr_sendpath *)calloc(1, sizeof(struct mr_sendpath));
|
||||
sendpath->mr_instance = dest_device->mr_instance;
|
||||
|
||||
return sendpath;
|
||||
}
|
||||
|
||||
void marsio_sendpath_destory(struct mr_sendpath *sendpath)
|
||||
{
|
||||
if (sendpath)
|
||||
{
|
||||
free(sendpath);
|
||||
sendpath = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int marsio_init(struct mr_instance *instance, const char *appsym)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int marsio_option_set(struct mr_instance *instance, marsio_opt_type_t opt_type, void *opt, size_t sz_opt)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int marsio_thread_init(struct mr_instance *instance)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int marsio_poll_wait(struct mr_instance *instance, struct mr_vdev *vdevs[], unsigned int nr_vdevs, unsigned int tid, int timeout)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int marsio_buff_set_metadata(marsio_buff_t *m, enum mr_buff_metadata_type type, void *data, unsigned int sz_data)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
struct mrb_metadata *mrb_metadata = &mbuf->metadata;
|
||||
struct mrb_metadata_route_ctx *route_ctx = NULL;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case MR_BUFF_ROUTE_CTX:
|
||||
route_ctx = (struct mrb_metadata_route_ctx *)data;
|
||||
assert(route_ctx != NULL);
|
||||
|
||||
mrb_metadata->packet_create_from_nf = 1;
|
||||
mrb_metadata->dir = route_ctx->dir;
|
||||
mrb_metadata->port_ingress = route_ctx->port_ingress;
|
||||
mrb_metadata->port_egress = route_ctx->port_egress;
|
||||
mrb_metadata->link_db_index = route_ctx->link_db_index;
|
||||
mrb_metadata->link_id = route_ctx->link_id;
|
||||
return 0;
|
||||
case MR_BUFF_SESSION_ID:
|
||||
mrb_metadata->session_id = *(uint64_t *)data;
|
||||
return 0;
|
||||
case MR_BUFF_PAYLOAD_OFFSET:
|
||||
mrb_metadata->payload_offset = *(uint16_t *)data;
|
||||
return 0;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int marsio_buff_get_metadata(marsio_buff_t *m, enum mr_buff_metadata_type type, void *data, unsigned int sz_data)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
struct mrb_metadata *mrb_metadata = &mbuf->metadata;
|
||||
struct mrb_metadata_route_ctx *route_ctx = NULL;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case MR_BUFF_ROUTE_CTX:
|
||||
if (sz_data < sizeof(struct mrb_metadata_route_ctx))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
route_ctx = (struct mrb_metadata_route_ctx *)data;
|
||||
if (route_ctx != NULL)
|
||||
{
|
||||
route_ctx->dir = mrb_metadata->dir;
|
||||
route_ctx->port_ingress = mrb_metadata->port_ingress;
|
||||
route_ctx->port_egress = mrb_metadata->port_egress;
|
||||
route_ctx->link_db_index = mrb_metadata->link_db_index;
|
||||
route_ctx->link_id = mrb_metadata->link_id;
|
||||
route_ctx->hash_usr = 0;
|
||||
}
|
||||
return sizeof(struct mrb_metadata_route_ctx);
|
||||
case MR_BUFF_DIR:
|
||||
if (sz_data < sizeof(unsigned int))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
*(unsigned int *)(data) = (unsigned int)mrb_metadata->dir;
|
||||
return sizeof(unsigned int);
|
||||
case MR_BUFF_SESSION_ID:
|
||||
if (sz_data < sizeof(uint64_t))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
*(uint64_t *)(data) = (uint64_t)mrb_metadata->session_id;
|
||||
return sizeof(uint64_t);
|
||||
case MR_BUFF_PAYLOAD_OFFSET:
|
||||
if (sz_data < sizeof(uint16_t))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
*(uint16_t *)(data) = (uint16_t)mrb_metadata->payload_offset;
|
||||
return sizeof(uint16_t);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int marsio_buff_set_sid_list(marsio_buff_t *m, sid_t *slist, uint8_t sz_slist)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
struct mrb_metadata *mrb_metadata = &mbuf->metadata;
|
||||
|
||||
if (sz_slist > sizeof(mrb_metadata->sids) / sizeof(mrb_metadata->sids[0]))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < sz_slist; i++)
|
||||
{
|
||||
mrb_metadata->sids[i] = slist[i];
|
||||
}
|
||||
|
||||
mrb_metadata->start_sid = 0;
|
||||
mrb_metadata->nr_sid = sz_slist;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int marsio_buff_get_sid_list(marsio_buff_t *m, sid_t *out_slist, uint8_t sz_out_slist)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
struct mrb_metadata *mrb_metadata = &mbuf->metadata;
|
||||
|
||||
uint8_t out_i = 0;
|
||||
for (uint8_t i = mrb_metadata->start_sid; i < mrb_metadata->start_sid + mrb_metadata->nr_sid && out_i < sz_out_slist; i++, out_i++)
|
||||
{
|
||||
out_slist[out_i] = mrb_metadata->sids[i];
|
||||
}
|
||||
|
||||
return out_i;
|
||||
}
|
||||
|
||||
int marsio_buff_malloc_global(struct mr_instance *instance, marsio_buff_t *marsio_buff[], unsigned int nr_mbufs, int socket_id, int thread_id)
|
||||
{
|
||||
for (unsigned int i = 0; i < nr_mbufs; i++)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)calloc(1, sizeof(struct mock_marsio_buff_t) + 4096);
|
||||
|
||||
mbuf->buff_size = 4096;
|
||||
mbuf->buff_start = (char *)mbuf + sizeof(struct mock_marsio_buff_t);
|
||||
mbuf->raw_data = mbuf->buff_start + 50;
|
||||
|
||||
marsio_buff[i] = mbuf;
|
||||
}
|
||||
return nr_mbufs;
|
||||
}
|
||||
|
||||
void marsio_buff_free(struct mr_instance *instance, marsio_buff_t *marsio_buff[], unsigned int nr_mbufs, int socket_id, int thread_id)
|
||||
{
|
||||
for (unsigned int i = 0; i < nr_mbufs; i++)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)marsio_buff[i];
|
||||
if (mbuf == instance->current_recv_mbuff_ptr)
|
||||
{
|
||||
instance->current_recv_mbuff_ptr = NULL;
|
||||
}
|
||||
if (mbuf == instance->current_send_mbuff_ptr)
|
||||
{
|
||||
instance->current_send_mbuff_ptr = NULL;
|
||||
}
|
||||
if (mbuf)
|
||||
{
|
||||
memset(mbuf, 0, sizeof(struct mock_marsio_buff_t));
|
||||
|
||||
free(mbuf);
|
||||
mbuf = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *marsio_buff_mtod(marsio_buff_t *m)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
|
||||
return mbuf->raw_data;
|
||||
}
|
||||
|
||||
uint32_t marsio_buff_datalen(marsio_buff_t *m)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
|
||||
return mbuf->raw_len;
|
||||
}
|
||||
|
||||
char *marsio_buff_adj(marsio_buff_t *m, uint16_t len)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
|
||||
mbuf->raw_data += len;
|
||||
return mbuf->raw_data;
|
||||
}
|
||||
|
||||
char *marsio_buff_append(marsio_buff_t *m, uint16_t len)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
|
||||
mbuf->raw_len += len;
|
||||
return mbuf->raw_data;
|
||||
}
|
||||
|
||||
char *marsio_buff_prepend(marsio_buff_t *m, uint16_t len)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
|
||||
mbuf->raw_len += len;
|
||||
mbuf->raw_data -= len;
|
||||
return mbuf->raw_data;
|
||||
}
|
||||
|
||||
void marsio_buff_ctrlzone_reset(marsio_buff_t *m)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
struct mrb_metadata *mrb_metadata = &mbuf->metadata;
|
||||
|
||||
memset(mrb_metadata, 0, sizeof(struct mrb_metadata));
|
||||
}
|
||||
|
||||
int marsio_buff_is_ctrlbuf(marsio_buff_t *m)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
struct mrb_metadata *mrb_metadata = &mbuf->metadata;
|
||||
|
||||
return mrb_metadata->is_ctrlbuf;
|
||||
}
|
||||
|
||||
void marsio_buff_set_ctrlbuf(marsio_buff_t *m)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)m;
|
||||
struct mrb_metadata *mrb_metadata = &mbuf->metadata;
|
||||
|
||||
mrb_metadata->is_ctrlbuf = 1;
|
||||
}
|
||||
|
||||
int marsio_recv_burst(struct mr_vdev *vdev, queue_id_t qid, marsio_buff_t *mbufs[], int nr_mbufs)
|
||||
{
|
||||
mbufs[0] = vdev->mr_instance->current_recv_mbuff_ptr;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int marsio_send_burst(struct mr_sendpath *sendpath, queue_id_t qid, marsio_buff_t *mbufs[], int nr_mbufs)
|
||||
{
|
||||
assert(nr_mbufs == 1);
|
||||
sendpath->mr_instance->current_send_mbuff_ptr = mbufs[0];
|
||||
|
||||
return marsio_buff_datalen(mbufs[0]);
|
||||
}
|
||||
|
||||
// new add, only for gtest
|
||||
void marsio_set_recv_mbuff(struct mr_instance *instance, marsio_buff_t *mbuff)
|
||||
{
|
||||
instance->current_recv_mbuff_ptr = mbuff;
|
||||
}
|
||||
|
||||
void marsio_set_send_mbuff(struct mr_instance *instance, marsio_buff_t *mbuff)
|
||||
{
|
||||
instance->current_send_mbuff_ptr = mbuff;
|
||||
}
|
||||
|
||||
marsio_buff_t *marsio_get_recv_mbuff(struct mr_instance *instance)
|
||||
{
|
||||
return instance->current_recv_mbuff_ptr;
|
||||
}
|
||||
|
||||
marsio_buff_t *marsio_get_send_mbuff(struct mr_instance *instance)
|
||||
{
|
||||
return instance->current_send_mbuff_ptr;
|
||||
}
|
||||
|
||||
int marsio_mbuff_cmp(marsio_buff_t *mbuff1, marsio_buff_t *mbuff2)
|
||||
{
|
||||
struct mock_marsio_buff_t *mbuf1 = (struct mock_marsio_buff_t *)mbuff1;
|
||||
struct mock_marsio_buff_t *mbuf2 = (struct mock_marsio_buff_t *)mbuff2;
|
||||
|
||||
if (mbuf1 == mbuf2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mbuf1 && mbuf2)
|
||||
{
|
||||
if (memcmp(&mbuf1->metadata, &mbuf2->metadata, sizeof(struct mrb_metadata)) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mbuf1->raw_len != mbuf2->raw_len)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (memcmp(mbuf1->raw_data, mbuf2->raw_data, mbuf2->raw_len) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
marsio_buff_t *marsio_mbuff_dup(marsio_buff_t *m)
|
||||
{
|
||||
struct mock_marsio_buff_t *orig = (struct mock_marsio_buff_t *)m;
|
||||
struct mock_marsio_buff_t *mbuf = (struct mock_marsio_buff_t *)calloc(1, sizeof(struct mock_marsio_buff_t) + 4096);
|
||||
|
||||
mbuf->buff_size = 4096;
|
||||
mbuf->buff_start = (char *)mbuf + sizeof(struct mock_marsio_buff_t);
|
||||
mbuf->raw_data = mbuf->buff_start + 50;
|
||||
|
||||
memcpy(&mbuf->metadata, &orig->metadata, sizeof(struct mrb_metadata));
|
||||
memcpy(mbuf->raw_data, orig->raw_data, orig->raw_len);
|
||||
mbuf->raw_len = orig->raw_len;
|
||||
|
||||
return mbuf;
|
||||
}
|
||||
97
test/marsio.h
Normal file
97
test/marsio.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#ifndef _MARSIO_H
|
||||
#define _MARSIO_H
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef MARSIO_SOCKET_ID_ANY
|
||||
#define MARSIO_SOCKET_ID_ANY -1
|
||||
#endif
|
||||
|
||||
#ifndef MARSIO_LCORE_ID_ANY
|
||||
#define MARSIO_LCORE_ID_ANY -1
|
||||
#endif
|
||||
|
||||
#define MR_SID_LIST_MAXLEN 8
|
||||
|
||||
typedef uint16_t sid_t;
|
||||
typedef uint32_t queue_id_t;
|
||||
typedef void marsio_buff_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MARSIO_OPT_THREAD_NUM,
|
||||
MARSIO_OPT_THREAD_MASK,
|
||||
MARSIO_OPT_THREAD_AFFINITY_MODE,
|
||||
MARSIO_OPT_EXIT_WHEN_ERR,
|
||||
MARSIO_OPT_THREAD_MASK_IN_CPUSET,
|
||||
} marsio_opt_type_t;
|
||||
|
||||
enum mr_buff_metadata_type
|
||||
{
|
||||
MR_BUFF_REHASH_INDEX = 0,
|
||||
MR_BUFF_METADATA_VLAN_TCI = 1,
|
||||
MR_BUFF_ROUTE_CTX = 2,
|
||||
MR_BUFF_SESSION_ID = 3,
|
||||
MR_BUFF_DIR = 4,
|
||||
MR_BUFF_PAYLOAD_OFFSET = 5
|
||||
};
|
||||
|
||||
struct mr_instance *marsio_create();
|
||||
int marsio_destory(struct mr_instance *instance);
|
||||
|
||||
struct mr_vdev *marsio_open_device(struct mr_instance *instance, const char *devsym, unsigned int nr_rxstream, unsigned int nr_txstream);
|
||||
void marsio_close_device(struct mr_vdev *vdev);
|
||||
|
||||
void marsio_get_device_ether_addr(struct mr_vdev *vdev, void *str_ether_addr, uint8_t size);
|
||||
|
||||
struct mr_sendpath *marsio_sendpath_create_by_vdev(struct mr_vdev *dest_device);
|
||||
void marsio_sendpath_destory(struct mr_sendpath *sendpath);
|
||||
|
||||
int marsio_init(struct mr_instance *instance, const char *appsym);
|
||||
int marsio_option_set(struct mr_instance *instance, marsio_opt_type_t opt_type, void *opt, size_t sz_opt);
|
||||
int marsio_thread_init(struct mr_instance *instance);
|
||||
int marsio_poll_wait(struct mr_instance *instance, struct mr_vdev *vdevs[], unsigned int nr_vdevs, unsigned int tid, int timeout);
|
||||
|
||||
int marsio_buff_set_metadata(marsio_buff_t *m, enum mr_buff_metadata_type type, void *data, unsigned int sz_data);
|
||||
int marsio_buff_get_metadata(marsio_buff_t *m, enum mr_buff_metadata_type type, void *data, unsigned int sz_data);
|
||||
|
||||
int marsio_buff_set_sid_list(marsio_buff_t *m, sid_t *slist, uint8_t sz_slist);
|
||||
int marsio_buff_get_sid_list(marsio_buff_t *m, sid_t *out_slist, uint8_t sz_out_slist);
|
||||
|
||||
int marsio_buff_malloc_global(struct mr_instance *instance, marsio_buff_t *marsio_buff[], unsigned int nr_mbufs, int socket_id, int thread_id);
|
||||
void marsio_buff_free(struct mr_instance *instance, marsio_buff_t *marsio_buff[], unsigned int nr_mbufs, int socket_id, int thread_id);
|
||||
|
||||
char *marsio_buff_mtod(marsio_buff_t *m);
|
||||
uint32_t marsio_buff_datalen(marsio_buff_t *m);
|
||||
|
||||
char *marsio_buff_adj(marsio_buff_t *m, uint16_t len);
|
||||
char *marsio_buff_append(marsio_buff_t *m, uint16_t len);
|
||||
char *marsio_buff_prepend(marsio_buff_t *m, uint16_t len);
|
||||
|
||||
void marsio_buff_ctrlzone_reset(marsio_buff_t *m);
|
||||
|
||||
int marsio_buff_is_ctrlbuf(marsio_buff_t *m);
|
||||
void marsio_buff_set_ctrlbuf(marsio_buff_t *m);
|
||||
|
||||
int marsio_recv_burst(struct mr_vdev *vdev, queue_id_t qid, marsio_buff_t *mbufs[], int nr_mbufs);
|
||||
int marsio_send_burst(struct mr_sendpath *sendpath, queue_id_t qid, marsio_buff_t *mbufs[], int nr_mbufs);
|
||||
|
||||
// new add, only for gtest
|
||||
void marsio_set_recv_mbuff(struct mr_instance *instance, marsio_buff_t *mbuff);
|
||||
void marsio_set_send_mbuff(struct mr_instance *instance, marsio_buff_t *mbuff);
|
||||
marsio_buff_t *marsio_get_recv_mbuff(struct mr_instance *instance);
|
||||
marsio_buff_t *marsio_get_send_mbuff(struct mr_instance *instance);
|
||||
|
||||
int marsio_mbuff_cmp(marsio_buff_t *mbuff1, marsio_buff_t *mbuff2);
|
||||
marsio_buff_t *marsio_mbuff_dup(marsio_buff_t *m);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
74
test/test_data/conf/sce.conf
Normal file
74
test/test_data/conf/sce.conf
Normal file
@@ -0,0 +1,74 @@
|
||||
[system]
|
||||
nr_worker_threads=1
|
||||
cpu_affinity_mask=2
|
||||
firewall_sids=1001
|
||||
enable_debug=0
|
||||
enable_send_log=0
|
||||
ts_update_interval_ms=1
|
||||
|
||||
# Only when (disable_coredump == 1 || (enable_breakpad == 1 && enable_breakpad_upload == 1)) is satisfied, the core will not be generated locally
|
||||
disable_coredump=0
|
||||
enable_breakpad=0
|
||||
enable_breakpad_upload=0
|
||||
breakpad_upload_url=http://sentry.mesalab.cn:9000/api/3/minidump/?sentry_key=e8e446bb3bd8435c97f4c01770ca7025
|
||||
# must be /run/sce/crashreport,due to tmpfile limit
|
||||
breakpad_minidump_dir=/run/sce/crashreport
|
||||
breakpad_upload_tools=/opt/tsg/framework/bin/minidump_upload
|
||||
|
||||
[maat]
|
||||
# 0:json 1:redis 2:iris
|
||||
input_mode=0
|
||||
stat_switch=1
|
||||
perf_switch=1
|
||||
scan_detail=0
|
||||
deferred_load=0
|
||||
effect_interval_ms=1000
|
||||
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
|
||||
redis_server=127.0.0.1
|
||||
redis_port_range=6379
|
||||
max_chaining_size=32
|
||||
|
||||
[packet_io]
|
||||
# bypass_all_traffic:1 NF2NF and SF2SF
|
||||
bypass_all_traffic=0
|
||||
rx_burst_max=128
|
||||
app_symbol=sce
|
||||
dev_endpoint=eth_sf_endpoint
|
||||
dev_nf_interface=eth_nf_interface
|
||||
dev_endpoint_src_ip=192.168.100.1
|
||||
|
||||
# If the configuration file does not set src mac, get src mac through marsio_get_device_ether_addr();
|
||||
# If the configuration file has src mac set, use the src mac in the file
|
||||
# dev_endpoint_src_mac=aa:aa:aa:aa:aa:aa
|
||||
|
||||
[stat]
|
||||
output_file=log/sce.fs2
|
||||
statsd_server=127.0.0.1
|
||||
statsd_port=8100
|
||||
# 1 : FS_OUTPUT_STATSD
|
||||
# 2 : FS_OUTPUT_INFLUX_LINE
|
||||
statsd_format=1
|
||||
statsd_cycle=2
|
||||
prometheus_listen_port=9001
|
||||
prometheus_listen_url=/sce_prometheus
|
||||
|
||||
[metrics]
|
||||
# Kafka Topic: SERVICE-CHAINING-METRICS
|
||||
enable=0
|
||||
interval_s=1
|
||||
telegraf_bind_address=127.0.0.1
|
||||
telegraf_listen_port=8300
|
||||
|
||||
[bfdd]
|
||||
enable=0
|
||||
path=/run/run/frr/bfdd.vty
|
||||
device=eth0
|
||||
local_address=127.0.0.1
|
||||
gateway=127.0.0.1
|
||||
12
test/test_data/conf/zlog.conf
Normal file
12
test/test_data/conf/zlog.conf
Normal file
@@ -0,0 +1,12 @@
|
||||
# kill -s SIGHUP "pid"
|
||||
|
||||
[global]
|
||||
default format = "%d(%c), %V, %F, %U, %m%n"
|
||||
|
||||
[levels]
|
||||
DEBUG=10
|
||||
INFO=20
|
||||
FATAL=30
|
||||
|
||||
[rules]
|
||||
sce.debug "./log/sce.log.%d(%F)";
|
||||
23
test/test_data/log/test_ctr_pkt_active_ok.fs2
Normal file
23
test/test_data/log/test_ctr_pkt_active_ok.fs2
Normal file
@@ -0,0 +1,23 @@
|
||||
============================================================Thu Mar 30 09:36:37 2023============================================================
|
||||
nf_rx_pkt nf_rx_B nf_tx_pkt nf_tx_B endp_rx_pkt endp_rx_B endp_tx_pkt endp_tx_B
|
||||
sum 1 185 1 185 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
kee_d_rx_pkt kee_d_rx_B kee_d_tx_pkt kee_d_tx_B kee_u_rx_pkt kee_u_rx_B kee_u_rxdop_pkt kee_u_rxdop_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
mirr_bypass_pkt mirr_bypass_B mirr_block_pkt mirr_block_B mirr_rxdop_pkt mirr_rxdop_B mirro_tx_pkt mirro_tx_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
stee_bypass_pkt stee_bypass_B stee_block_pkt stee_block_B stee_rx_pkt stee_rx_B stee_tx_pkt stee_tx_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
miss_sess_pkt miss_sess_B err_bypass_pkt err_bypass_B err_block_pkt err_block_B endp_drop_pkt endp_drop_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
ctrl_rx_pkt ctrl_rx_B ctrl_tx_pkt ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
|
||||
sum 1 185 1 185 0 1 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
ctrl_error session_num session_logs sf_active sf_inactive
|
||||
sum 0 1 0 1 0
|
||||
speed/s 0 0 0 0 0
|
||||
________________________________________________________________________________________________________________________________________________
|
||||
23
test/test_data/log/test_ctr_pkt_opening_ok.fs2
Normal file
23
test/test_data/log/test_ctr_pkt_opening_ok.fs2
Normal file
@@ -0,0 +1,23 @@
|
||||
============================================================Thu Apr 6 02:12:33 2023============================================================
|
||||
nf_rx_pkt nf_rx_B nf_tx_pkt nf_tx_B endp_rx_pkt endp_rx_B endp_tx_pkt endp_tx_B
|
||||
sum 1 122 1 122 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
kee_d_rx_pkt kee_d_rx_B kee_d_tx_pkt kee_d_tx_B kee_u_rx_pkt kee_u_rx_B kee_u_rxdop_pkt kee_u_rxdop_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
mirr_bypass_pkt mirr_bypass_B mirr_block_pkt mirr_block_B mirr_rxdop_pkt mirr_rxdop_B mirro_tx_pkt mirro_tx_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
stee_bypass_pkt stee_bypass_B stee_block_pkt stee_block_B stee_rx_pkt stee_rx_B stee_tx_pkt stee_tx_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
miss_sess_pkt miss_sess_B err_bypass_pkt err_bypass_B err_block_pkt err_block_B endp_drop_pkt endp_drop_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
ctrl_rx_pkt ctrl_rx_B ctrl_tx_pkt ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
|
||||
sum 1 122 1 122 1 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
ctrl_error session_num session_logs sf_active sf_inactive
|
||||
sum 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0
|
||||
________________________________________________________________________________________________________________________________________________
|
||||
23
test/test_data/log/test_raw_pkt_stee_block_ok.fs2
Normal file
23
test/test_data/log/test_raw_pkt_stee_block_ok.fs2
Normal file
@@ -0,0 +1,23 @@
|
||||
============================================================Thu Apr 6 03:13:22 2023============================================================
|
||||
nf_rx_pkt nf_rx_B nf_tx_pkt nf_tx_B endp_rx_pkt endp_rx_B endp_tx_pkt endp_tx_B
|
||||
sum 2 330 1 185 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
kee_d_rx_pkt kee_d_rx_B kee_d_tx_pkt kee_d_tx_B kee_u_rx_pkt kee_u_rx_B kee_u_rxdop_pkt kee_u_rxdop_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
mirr_bypass_pkt mirr_bypass_B mirr_block_pkt mirr_block_B mirr_rxdop_pkt mirr_rxdop_B mirro_tx_pkt mirro_tx_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
stee_bypass_pkt stee_bypass_B stee_block_pkt stee_block_B stee_rx_pkt stee_rx_B stee_tx_pkt stee_tx_B
|
||||
sum 0 0 1 145 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
miss_sess_pkt miss_sess_B err_bypass_pkt err_bypass_B err_block_pkt err_block_B endp_drop_pkt endp_drop_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
ctrl_rx_pkt ctrl_rx_B ctrl_tx_pkt ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
|
||||
sum 1 185 1 185 0 1 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
ctrl_error session_num session_logs sf_active sf_inactive
|
||||
sum 0 1 0 0 0
|
||||
speed/s 0 0 0 0 0
|
||||
________________________________________________________________________________________________________________________________________________
|
||||
23
test/test_data/log/test_raw_pkt_stee_bypass_ok.fs2
Normal file
23
test/test_data/log/test_raw_pkt_stee_bypass_ok.fs2
Normal file
@@ -0,0 +1,23 @@
|
||||
============================================================Thu Apr 6 02:56:08 2023============================================================
|
||||
nf_rx_pkt nf_rx_B nf_tx_pkt nf_tx_B endp_rx_pkt endp_rx_B endp_tx_pkt endp_tx_B
|
||||
sum 2 330 2 330 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
kee_d_rx_pkt kee_d_rx_B kee_d_tx_pkt kee_d_tx_B kee_u_rx_pkt kee_u_rx_B kee_u_rxdop_pkt kee_u_rxdop_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
mirr_bypass_pkt mirr_bypass_B mirr_block_pkt mirr_block_B mirr_rxdop_pkt mirr_rxdop_B mirro_tx_pkt mirro_tx_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
stee_bypass_pkt stee_bypass_B stee_block_pkt stee_block_B stee_rx_pkt stee_rx_B stee_tx_pkt stee_tx_B
|
||||
sum 1 145 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
miss_sess_pkt miss_sess_B err_bypass_pkt err_bypass_B err_block_pkt err_block_B endp_drop_pkt endp_drop_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
ctrl_rx_pkt ctrl_rx_B ctrl_tx_pkt ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
|
||||
sum 1 185 1 185 0 1 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
ctrl_error session_num session_logs sf_active sf_inactive
|
||||
sum 0 1 0 0 0
|
||||
speed/s 0 0 0 0 0
|
||||
________________________________________________________________________________________________________________________________________________
|
||||
23
test/test_data/log/test_raw_pkt_stee_forward_ok.fs2
Normal file
23
test/test_data/log/test_raw_pkt_stee_forward_ok.fs2
Normal file
@@ -0,0 +1,23 @@
|
||||
============================================================Thu Apr 6 09:56:11 2023============================================================
|
||||
nf_rx_pkt nf_rx_B nf_tx_pkt nf_tx_B endp_rx_pkt endp_rx_B endp_tx_pkt endp_tx_B
|
||||
sum 2 330 1 185 0 0 1 195
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
kee_d_rx_pkt kee_d_rx_B kee_d_tx_pkt kee_d_tx_B kee_u_rx_pkt kee_u_rx_B kee_u_rxdop_pkt kee_u_rxdop_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
mirr_bypass_pkt mirr_bypass_B mirr_block_pkt mirr_block_B mirr_rxdop_pkt mirr_rxdop_B mirro_tx_pkt mirro_tx_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
stee_bypass_pkt stee_bypass_B stee_block_pkt stee_block_B stee_rx_pkt stee_rx_B stee_tx_pkt stee_tx_B
|
||||
sum 0 0 0 0 0 0 1 145
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
miss_sess_pkt miss_sess_B err_bypass_pkt err_bypass_B err_block_pkt err_block_B endp_drop_pkt endp_drop_B
|
||||
sum 0 0 0 0 0 0 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
ctrl_rx_pkt ctrl_rx_B ctrl_tx_pkt ctrl_tx_B ctrl_opening ctrl_active ctrl_closing ctrl_resetall
|
||||
sum 1 185 1 185 0 1 0 0
|
||||
speed/s 0 0 0 0 0 0 0 0
|
||||
ctrl_error session_num session_logs sf_active sf_inactive
|
||||
sum 0 1 0 1 0
|
||||
speed/s 0 0 0 0 0
|
||||
________________________________________________________________________________________________________________________________________________
|
||||
22
test/test_data/resource/raw_pkt_stee_block.json
Normal file
22
test/test_data/resource/raw_pkt_stee_block.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"plugin_table": [
|
||||
{
|
||||
"table_name": "SERVICE_FUNCTION_PROFILE",
|
||||
"table_content": [
|
||||
"1\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
|
||||
"table_content": [
|
||||
"1\t1\thash-int-ip\tnearby\tblock\tnull\t[1]\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||
"table_content": [
|
||||
"995199\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
22
test/test_data/resource/raw_pkt_stee_bypass.json
Normal file
22
test/test_data/resource/raw_pkt_stee_bypass.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"plugin_table": [
|
||||
{
|
||||
"table_name": "SERVICE_FUNCTION_PROFILE",
|
||||
"table_content": [
|
||||
"1\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
|
||||
"table_content": [
|
||||
"1\t1\thash-int-ip\tnearby\tbypass\tnull\t[1]\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||
"table_content": [
|
||||
"995199\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
22
test/test_data/resource/raw_pkt_stee_forward.json
Normal file
22
test/test_data/resource/raw_pkt_stee_forward.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"plugin_table": [
|
||||
{
|
||||
"table_name": "SERVICE_FUNCTION_PROFILE",
|
||||
"table_content": [
|
||||
"1\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
|
||||
"table_content": [
|
||||
"1\t1\thash-int-ip\tglobal\tbypass\tnull\t[1]\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||
"table_content": [
|
||||
"995199\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
22
test/test_data/resource/sce0.json
Normal file
22
test/test_data/resource/sce0.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"plugin_table": [
|
||||
{
|
||||
"table_name": "SERVICE_FUNCTION_PROFILE",
|
||||
"table_content": [
|
||||
"1\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "SERVICE_FUNCTION_FORWARDER_PROFILE",
|
||||
"table_content": [
|
||||
"1\t1\thash-int-ip\tglobal\tbypass\tnull\t[1]\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||
"table_content": [
|
||||
"995199\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
3
test/test_data/resource/table_info.conf
Normal file
3
test/test_data/resource/table_info.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
0 SERVICE_CHAINING_COMPILE plugin {"key":1,"valid":8}
|
||||
1 SERVICE_FUNCTION_FORWARDER_PROFILE plugin {"key":1,"valid":8}
|
||||
2 SERVICE_FUNCTION_PROFILE plugin {"key":1,"valid":6}
|
||||
BIN
test/test_pcap/sce.pcapng
Normal file
BIN
test/test_pcap/sce.pcapng
Normal file
Binary file not shown.
BIN
test/test_pcap/sf.pcapng
Normal file
BIN
test/test_pcap/sf.pcapng
Normal file
Binary file not shown.
Reference in New Issue
Block a user