diff --git a/common/include/vxlan.h b/common/include/vxlan.h index 942c2f3..14e7548 100644 --- a/common/include/vxlan.h +++ b/common/include/vxlan.h @@ -12,7 +12,9 @@ extern "C" #include "tuple.h" /* - * VXLAN Header: + ****************************************************************************** + * Standard VXLAN Header: + ****************************************************************************** * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 @@ -28,87 +30,123 @@ extern "C" * to zero on transmission and ignored on receipt. * Reserved fields (24 bits and 8 bits): * MUST be set to zero on transmission and ignored on receipt. + * + ****************************************************************************** + * SCE VXLAN Header: + ****************************************************************************** + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |R|R|R|R|I|R|R|R| Reserved |S| Traffic Link ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | high | type | low |D|T|SF index |T| Reserved | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + * Flags : 8 bits + * Reserved : 7 bits + * S (StateLess) : 1 bit + * + * Traffic Link ID : 16 bits + * + * vlan_id_half_high : 8 bits + * link_layer_type : 4 bits // 二层报文封装格式 + * vlan_id_half_low : 4 bits + * + * dir : 1 bit + * traffic : 1 bit + * sf_index : 5 bits // max value 32 + * online_test : 1 bit + * + * Reserved : 8 bit */ struct vxlan_hdr { - uint8_t flags; - uint8_t reserved[3]; - - // VNI 3 Bytes - uint8_t vlan_id_half_high; - - uint8_t link_layer_type : 4; // 二层报文封装格式 - uint8_t vlan_id_half_low : 4; - - uint8_t dir : 1; - uint8_t traffic : 1; - uint8_t sf_index : 5; // max value 32 - uint8_t online_test : 1; - - // Reserved 1 Bytes - uint8_t r7 : 1; - uint8_t r6 : 1; - uint8_t r5 : 1; - uint8_t r4 : 1; - uint8_t vni_flag : 1; - uint8_t r2 : 1; - uint8_t r1 : 1; - uint8_t r0 : 1; + uint16_t flags_reserved; + uint16_t link_id; + uint16_t vlan_id; + uint16_t user_ctx; } __attribute__((__packed__)); -enum vni_opt -{ - VNI_OPT_DIR = 0x80, - VNI_OPT_TRAFFIC = 0x40, - VNI_OPT_SFINDEX = 0x3f, -}; - -#define VXLAN_FLAGS 0x8 +#define VXLAN_DEFAULT_FLAGS 0x8 #define VXLAN_DST_PORT 4789 -#define VXLAN_FRAME_HDR_LEN (sizeof(struct ethhdr) + sizeof(struct ip) + sizeof(struct udphdr) + sizeof(struct vxlan_hdr)) +#define VXLAN_FRAME_HDR_LEN ((int)(sizeof(struct ethhdr) + sizeof(struct ip) + sizeof(struct udphdr) + sizeof(struct vxlan_hdr))) -static inline void vxlan_set_opt(struct vxlan_hdr *hdr, enum vni_opt opt, uint8_t val) +#define VXLAN_FLAGS_MASK 0xFF00 +#define VXLAN_STATELESS_MASK 0x0001 +#define VXLAN_DIR_MASK 0x8000 +#define VXLAN_TRAFFIC_MASK 0x4000 +#define VXLAN_SF_INDEX_MASK 0x3E00 + +static inline void vxlan_set_flags(struct vxlan_hdr *hdr, uint8_t flags) { - switch (opt) - { - case VNI_OPT_DIR: - hdr->dir = (!!val); - break; - case VNI_OPT_TRAFFIC: - hdr->traffic = (!!val); - break; - case VNI_OPT_SFINDEX: - hdr->sf_index = (0x1f & val); - break; - default: - break; - } + hdr->flags_reserved = htons((ntohs(hdr->flags_reserved) & ~VXLAN_FLAGS_MASK) | (flags << 8)); } -static inline uint8_t vxlan_get_opt(struct vxlan_hdr *hdr, enum vni_opt opt) +static inline void vxlan_set_dir(struct vxlan_hdr *hdr, uint8_t val) { - switch (opt) - { - case VNI_OPT_DIR: - return hdr->dir; - case VNI_OPT_TRAFFIC: - return hdr->traffic; - case VNI_OPT_SFINDEX: - return hdr->sf_index; - default: - return 0; - } + hdr->user_ctx = htons((ntohs(hdr->user_ctx) & ~VXLAN_DIR_MASK) | ((!!val) << 15)); +} + +static inline void vxlan_set_traffic(struct vxlan_hdr *hdr, uint8_t val) +{ + hdr->user_ctx = htons((ntohs(hdr->user_ctx) & ~VXLAN_TRAFFIC_MASK) | ((!!val) << 14)); +} + +static inline void vxlan_set_sf_index(struct vxlan_hdr *hdr, uint8_t val) +{ + hdr->user_ctx = htons((ntohs(hdr->user_ctx) & ~VXLAN_SF_INDEX_MASK) | ((val & 0x1F) << 9)); +} + +static inline void vxlan_set_link_id(struct vxlan_hdr *hdr, uint16_t val) +{ + hdr->link_id = htons(val); +} + +static inline void vxlan_set_stateless(struct vxlan_hdr *hdr, uint8_t val) +{ + hdr->flags_reserved = htons((ntohs(hdr->flags_reserved) & ~VXLAN_STATELESS_MASK) | (!!val)); +} + +static inline uint8_t vxlan_get_flags(struct vxlan_hdr *hdr) +{ + return ((ntohs(hdr->flags_reserved) & VXLAN_FLAGS_MASK) >> 8); +} + +static inline uint8_t vxlan_get_dir(struct vxlan_hdr *hdr) +{ + return ((ntohs(hdr->user_ctx) & VXLAN_DIR_MASK) >> 15); +} + +static inline uint8_t vxlan_get_traffic(struct vxlan_hdr *hdr) +{ + return ((ntohs(hdr->user_ctx) & VXLAN_TRAFFIC_MASK) >> 14); +} + +static inline uint8_t vxlan_get_sf_index(struct vxlan_hdr *hdr) +{ + return ((ntohs(hdr->user_ctx) & VXLAN_SF_INDEX_MASK) >> 9); +} + +static inline uint16_t vxlan_get_link_id(struct vxlan_hdr *hdr) +{ + return ntohs(hdr->link_id); +} + +static inline uint8_t vxlan_get_stateless(struct vxlan_hdr *hdr) +{ + return ntohs(hdr->flags_reserved) & VXLAN_STATELESS_MASK; } // return 0 : success // return -1 : error -int vxlan_frame_decode(struct vxlan_hdr **vxlan_hdr, const char *data, uint16_t len); +int vxlan_frame_decode(struct vxlan_hdr **vxlan_hdr, const char *data, int len); void vxlan_frame_encode(char *buff, const u_char eth_src_mac[], const u_char eth_dst_mac[], const in_addr_t ip_src_addr, const in_addr_t ip_dst_addr, uint16_t ip_id, uint16_t udp_src_port, uint16_t udp_pld_len, - uint8_t vni_opt_dir, uint8_t vni_opt_traffic, uint8_t vni_opt_sf_index); + uint8_t dir, uint8_t traffic, uint8_t sf_index, uint16_t link_id); uint16_t calculate_vxlan_source_port(struct four_tuple *innermost_tuple4); diff --git a/common/src/vxlan.cpp b/common/src/vxlan.cpp index d5c86d7..d53d036 100644 --- a/common/src/vxlan.cpp +++ b/common/src/vxlan.cpp @@ -69,7 +69,7 @@ static inline void udp_header_encode(struct udphdr *udp_hdr, uint16_t udp_sport, // return 0 : success // return -1 : error -int vxlan_frame_decode(struct vxlan_hdr **vxlan_hdr, const char *data, uint16_t len) +int vxlan_frame_decode(struct vxlan_hdr **vxlan_hdr, const char *data, int len) { if (len < VXLAN_FRAME_HDR_LEN) { @@ -103,7 +103,7 @@ void vxlan_frame_encode(char *buff, const u_char eth_src_mac[], const u_char eth_dst_mac[], const in_addr_t ip_src_addr, const in_addr_t ip_dst_addr, uint16_t ip_id, uint16_t udp_src_port, uint16_t udp_pld_len, - uint8_t vni_opt_dir, uint8_t vni_opt_traffic, uint8_t vni_opt_sf_index) + uint8_t dir, uint8_t traffic, uint8_t sf_index, uint16_t link_id) { struct ethhdr *eth_hdr = (struct ethhdr *)buff; struct ip *ip_hdr = (struct ip *)((char *)eth_hdr + sizeof(struct ethhdr)); @@ -112,10 +112,11 @@ void vxlan_frame_encode(char *buff, // MUST be set to zero memset(vxlan_hdr, 0, sizeof(struct vxlan_hdr)); - vxlan_hdr->flags = VXLAN_FLAGS; - vxlan_set_opt(vxlan_hdr, VNI_OPT_DIR, vni_opt_dir); - vxlan_set_opt(vxlan_hdr, VNI_OPT_TRAFFIC, vni_opt_traffic); - vxlan_set_opt(vxlan_hdr, VNI_OPT_SFINDEX, vni_opt_sf_index); + vxlan_set_flags(vxlan_hdr, VXLAN_DEFAULT_FLAGS); + vxlan_set_dir(vxlan_hdr, dir); + vxlan_set_traffic(vxlan_hdr, traffic); + vxlan_set_sf_index(vxlan_hdr, sf_index); + vxlan_set_link_id(vxlan_hdr, link_id); eth_header_encode(eth_hdr, eth_src_mac, eth_dst_mac, ETH_P_IP); ip_header_encode(ip_hdr, ip_src_addr, ip_dst_addr, ip_id, IPPROTO_UDP, sizeof(struct udphdr) + sizeof(struct vxlan_hdr) + udp_pld_len); diff --git a/common/test/CMakeLists.txt b/common/test/CMakeLists.txt index 24073e0..f31c21e 100644 --- a/common/test/CMakeLists.txt +++ b/common/test/CMakeLists.txt @@ -30,6 +30,14 @@ add_executable(gtest_utils gtest_utils.cpp) target_include_directories(gtest_utils PUBLIC ${CMAKE_SOURCE_DIR}/common/include) target_link_libraries(gtest_utils common gtest) +############################################################################### +# gtest_vxlan +############################################################################### + +add_executable(gtest_vxlan gtest_vxlan.cpp) +target_include_directories(gtest_vxlan PUBLIC ${CMAKE_SOURCE_DIR}/common/include) +target_link_libraries(gtest_vxlan common gtest) + ############################################################################### # gtest_health_check_table ############################################################################### @@ -47,4 +55,5 @@ gtest_discover_tests(gtest_session_table) gtest_discover_tests(gtest_control_packet) gtest_discover_tests(gtest_packet) gtest_discover_tests(gtest_utils) +gtest_discover_tests(gtest_vxlan) gtest_discover_tests(gtest_health_check_table) diff --git a/common/test/gtest_vxlan.cpp b/common/test/gtest_vxlan.cpp new file mode 100644 index 0000000..a6e838b --- /dev/null +++ b/common/test/gtest_vxlan.cpp @@ -0,0 +1,84 @@ +#include + +#include "vxlan.h" + +static inline void hexdump(const char *data, int len) +{ + for (int i = 0; i < len; i++) + { + printf("%02x ", data[i]); + } + printf("\n"); +} + +TEST(VXLAN, TEST1) +{ + char buff[8] = {0}; + struct vxlan_hdr *hdr = (struct vxlan_hdr *)buff; + + vxlan_set_flags(hdr, VXLAN_DEFAULT_FLAGS); + vxlan_set_dir(hdr, 0); + vxlan_set_traffic(hdr, 0); + vxlan_set_sf_index(hdr, 0); + vxlan_set_link_id(hdr, 0); + vxlan_set_stateless(hdr, 0); + + EXPECT_TRUE(vxlan_get_flags(hdr) == VXLAN_DEFAULT_FLAGS); + EXPECT_TRUE(vxlan_get_dir(hdr) == 0); + EXPECT_TRUE(vxlan_get_traffic(hdr) == 0); + EXPECT_TRUE(vxlan_get_sf_index(hdr) == 0); + EXPECT_TRUE(vxlan_get_link_id(hdr) == 0); + EXPECT_TRUE(vxlan_get_stateless(hdr) == 0); + + hexdump(buff, 8); +} + +TEST(VXLAN, TEST2) +{ + char buff[8] = {0}; + struct vxlan_hdr *hdr = (struct vxlan_hdr *)buff; + + vxlan_set_flags(hdr, VXLAN_DEFAULT_FLAGS); + vxlan_set_dir(hdr, 1); + vxlan_set_traffic(hdr, 1); + vxlan_set_sf_index(hdr, 1); + vxlan_set_link_id(hdr, 1); + vxlan_set_stateless(hdr, 1); + + EXPECT_TRUE(vxlan_get_flags(hdr) == VXLAN_DEFAULT_FLAGS); + EXPECT_TRUE(vxlan_get_dir(hdr) == 1); + EXPECT_TRUE(vxlan_get_traffic(hdr) == 1); + EXPECT_TRUE(vxlan_get_sf_index(hdr) == 1); + EXPECT_TRUE(vxlan_get_link_id(hdr) == 1); + EXPECT_TRUE(vxlan_get_stateless(hdr) == 1); + + hexdump(buff, 8); +} + +TEST(VXLAN, TEST3) +{ + char buff[8] = {0}; + struct vxlan_hdr *hdr = (struct vxlan_hdr *)buff; + + vxlan_set_flags(hdr, VXLAN_DEFAULT_FLAGS); + vxlan_set_dir(hdr, 1); + vxlan_set_traffic(hdr, 1); + vxlan_set_sf_index(hdr, 31); + vxlan_set_link_id(hdr, 65535); + vxlan_set_stateless(hdr, 1); + + EXPECT_TRUE(vxlan_get_flags(hdr) == VXLAN_DEFAULT_FLAGS); + EXPECT_TRUE(vxlan_get_dir(hdr) == 1); + EXPECT_TRUE(vxlan_get_traffic(hdr) == 1); + EXPECT_TRUE(vxlan_get_sf_index(hdr) == 31); + EXPECT_TRUE(vxlan_get_link_id(hdr) == 65535); + EXPECT_TRUE(vxlan_get_stateless(hdr) == 1); + + hexdump(buff, 8); +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file diff --git a/conf/sce.conf b/conf/sce.conf index 2071001..e5c0fa7 100644 --- a/conf/sce.conf +++ b/conf/sce.conf @@ -2,6 +2,7 @@ nr_worker_threads=8 cpu_affinity_mask=2,3,4-9 firewall_sids=1001 +stateless_sids=900 enable_debug=0 enable_send_log=0 ts_update_interval_ms=1 diff --git a/platform/include/global_metrics.h b/platform/include/global_metrics.h index 01a50b5..d127dde 100644 --- a/platform/include/global_metrics.h +++ b/platform/include/global_metrics.h @@ -84,6 +84,9 @@ struct thread_metrics uint64_t session_new; // 累计值 uint64_t session_free; // 累计值 + + // stateless inject + struct throughput_metrics stateless_inject; // 累计值 }; struct metrics_config diff --git a/platform/include/packet_io.h b/platform/include/packet_io.h index 978d2f7..b7fc174 100644 --- a/platform/include/packet_io.h +++ b/platform/include/packet_io.h @@ -32,6 +32,7 @@ struct metadata char *raw_data; // refer to current packet data int raw_len; uint16_t l7offset; + uint16_t link_id; int direction; // 1: E2I; 0: I2E int is_ctrl_pkt; diff --git a/platform/include/sce.h b/platform/include/sce.h index fd5b012..736001d 100644 --- a/platform/include/sce.h +++ b/platform/include/sce.h @@ -93,6 +93,7 @@ struct sce_ctx int enable_debug; int enable_send_log; int firewall_sids; + int stateless_sids; int nr_worker_threads; int ts_update_interval_ms; int cpu_affinity_mask[MAX_THREAD_NUM]; diff --git a/platform/src/global_metrics.cpp b/platform/src/global_metrics.cpp index 3a935e2..e90477d 100644 --- a/platform/src/global_metrics.cpp +++ b/platform/src/global_metrics.cpp @@ -119,6 +119,10 @@ enum SCE_STAT_FIELD STAT_SESSION_NEW, STAT_SESSION_FREE, + // stateless inject + STAT_STATELESS_INJECT_PKT, + STAT_STATELESS_INJECT_B, + // max STAT_MAX, }; @@ -236,6 +240,10 @@ static const char *stat_map[] = [STAT_SESSION_NEW] = "session_new", [STAT_SESSION_FREE] = "session_free", + // stateless inject + [STAT_STATELESS_INJECT_PKT] = "stateless_inject_P", + [STAT_STATELESS_INJECT_B] = "stateless_inject_B", + [STAT_MAX] = NULL}; static void global_metrics_parse_config(const char *profile, struct metrics_config *config) @@ -435,6 +443,9 @@ void global_metrics_dump(struct global_metrics *global_metrics) sum->session_new += thread->session_new; sum->session_free += thread->session_free; + sum->stateless_inject.n_pkts += thread->stateless_inject.n_pkts; + sum->stateless_inject.n_bytes += thread->stateless_inject.n_bytes; + memset(thread, 0, sizeof(struct thread_metrics)); ATOMIC_SET(&(global_metrics->thread_metrics_flag[i]), THREAD_METRICS_CACHE_IS_FREE); } @@ -548,5 +559,9 @@ void global_metrics_dump(struct global_metrics *global_metrics) FS_operate(global_metrics->fs_handle, global_metrics->fs_id[STAT_SESSION_NEW], 0, FS_OP_SET, sum->session_new); FS_operate(global_metrics->fs_handle, global_metrics->fs_id[STAT_SESSION_FREE], 0, FS_OP_SET, sum->session_free); + // stateless inject + FS_operate(global_metrics->fs_handle, global_metrics->fs_id[STAT_STATELESS_INJECT_PKT], 0, FS_OP_SET, sum->stateless_inject.n_pkts); + FS_operate(global_metrics->fs_handle, global_metrics->fs_id[STAT_STATELESS_INJECT_B], 0, FS_OP_SET, sum->stateless_inject.n_bytes); + FS_passive_output(global_metrics->fs_handle); } diff --git a/platform/src/packet_io.cpp b/platform/src/packet_io.cpp index 2cd58d7..86767f9 100644 --- a/platform/src/packet_io.cpp +++ b/platform/src/packet_io.cpp @@ -117,6 +117,12 @@ int mbuff_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta) return -1; } + if (marsio_buff_get_metadata(rx_buff, MR_BUFF_LINK_ID, &(meta->link_id), sizeof(meta->link_id)) <= 0) + { + LOG_ERROR("%s: unable to get link_id from metadata", LOG_TAG_PKTIO); + return -1; + } + // 1: E2I // 0: I2E if (marsio_buff_get_metadata(rx_buff, MR_BUFF_DIR, &(meta->direction), sizeof(meta->direction)) <= 0) @@ -181,7 +187,27 @@ int mbuff_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta) } } - // need't set MR_BUFF_DIR, set MR_BUFF_ROUTE_CTX instead + if (meta->link_id) + { + if (marsio_buff_set_metadata(tx_buff, MR_BUFF_LINK_ID, &(meta->link_id), sizeof(meta->link_id)) != 0) + { + LOG_ERROR("%s: unable to set link_id from metadata", LOG_TAG_PKTIO); + return -1; + } + } + + /* + * for stateless inject packet, set direction is necessary; + * if later set route_ctx, dir will be overwrite by route_ctx. + * + * direction : 1 (E2I) + * direction : 0 (I2E) + */ + if (marsio_buff_set_metadata(tx_buff, MR_BUFF_DIR, &(meta->direction), sizeof(meta->direction)) != 0) + { + LOG_ERROR("%s: unable to set buff_dir from metadata", LOG_TAG_PKTIO); + return -1; + } if (meta->is_ctrl_pkt) { @@ -526,7 +552,7 @@ static inline int send_packet_to_sf(struct session_ctx *session_ctx, marsio_buff packet_io->config.dev_endpoint_l3_mac, sf->sf_dst_mac, packet_io->config.dev_endpoint_l3_ip, sf->sf_dst_ip, thread_ctx->tx_packets_ipid % 65535, session_ctx->vxlan_src_port, meta->raw_len, - meta->direction, meta->is_decrypted, sf->sf_index); + meta->direction, meta->is_decrypted, sf->sf_index, meta->link_id); nsend = marsio_buff_datalen(mbuff); marsio_buff_set_metadata(mbuff, MR_BUFF_REHASH_INDEX, &rehash_index, sizeof(rehash_index)); PACKET_TRACE_ON_NEW(packet_io->instance, mbuff); @@ -1215,6 +1241,7 @@ static void handle_inject_vxlan_packet(marsio_buff_t *rx_buff, struct thread_ctx struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics; struct packet_io *packet_io = thread_ctx->ref_io; int thread_index = thread_ctx->thread_index; + struct sce_ctx *sce_ctx = thread_ctx->ref_sce_ctx; struct metadata meta; struct vxlan_hdr *vxlan_hdr = NULL; @@ -1237,9 +1264,19 @@ static void handle_inject_vxlan_packet(marsio_buff_t *rx_buff, struct thread_ctx meta.raw_len = raw_len - VXLAN_FRAME_HDR_LEN; meta.l7offset = 0; meta.is_ctrl_pkt = 0; - sf_index = vxlan_get_opt(vxlan_hdr, VNI_OPT_SFINDEX); - meta.direction = vxlan_get_opt(vxlan_hdr, VNI_OPT_DIR); - meta.is_decrypted = vxlan_get_opt(vxlan_hdr, VNI_OPT_TRAFFIC); + sf_index = vxlan_get_sf_index(vxlan_hdr); + meta.direction = vxlan_get_dir(vxlan_hdr); + meta.is_decrypted = vxlan_get_traffic(vxlan_hdr); + meta.link_id = vxlan_get_link_id(vxlan_hdr); + if (vxlan_get_stateless(vxlan_hdr)) + { + meta.sids.num = 1; + meta.sids.elems[0] = sce_ctx->stateless_sids; + THROUGHPUT_METRICS_INC(&(thread_metrics->stateless_inject), 1, meta.raw_len); + marsio_buff_adj(rx_buff, raw_len - meta.raw_len); + action_nf_inject(rx_buff, &meta, NULL, thread_ctx); + return; + } session_ctx = inject_packet_search_session(session_table, meta.raw_data, meta.raw_len, thread_ctx); if (session_ctx == NULL) diff --git a/platform/src/sce.cpp b/platform/src/sce.cpp index dcd92a3..5cb729c 100644 --- a/platform/src/sce.cpp +++ b/platform/src/sce.cpp @@ -74,6 +74,7 @@ struct sce_ctx *sce_ctx_create(const char *profile) MESA_load_profile_int_def(profile, "system", "enable_debug", (int *)&(sce_ctx->enable_debug), 0); MESA_load_profile_int_def(profile, "system", "enable_send_log", (int *)&(sce_ctx->enable_send_log), 0); MESA_load_profile_int_def(profile, "system", "firewall_sids", (int *)&(sce_ctx->firewall_sids), 1001); + MESA_load_profile_int_def(profile, "system", "stateless_sids", (int *)&(sce_ctx->stateless_sids), 2000); MESA_load_profile_int_def(profile, "system", "nr_worker_threads", (int *)&(sce_ctx->nr_worker_threads), 8); MESA_load_profile_uint_range(profile, "system", "cpu_affinity_mask", MAX_THREAD_NUM, (unsigned int *)sce_ctx->cpu_affinity_mask); MESA_load_profile_int_def(profile, "system", "ts_update_interval_ms", (int *)&(sce_ctx->ts_update_interval_ms), 1); diff --git a/test/gmock_marsio.cpp b/test/gmock_marsio.cpp index 68c5b55..28af25c 100644 --- a/test/gmock_marsio.cpp +++ b/test/gmock_marsio.cpp @@ -169,6 +169,9 @@ int marsio_buff_set_metadata(marsio_buff_t *m, enum mr_buff_metadata_type type, mrb_metadata->link_db_index = route_ctx->link_db_index; mrb_metadata->link_id = route_ctx->link_id; return 0; + case MR_BUFF_LINK_ID: + mrb_metadata->link_id = *(uint16_t *)data; + return 0; case MR_BUFF_SESSION_ID: mrb_metadata->session_id = *(uint64_t *)data; return 0; @@ -178,6 +181,9 @@ int marsio_buff_set_metadata(marsio_buff_t *m, enum mr_buff_metadata_type type, case MR_BUFF_USER_0: mrb_metadata->user_data_0 = *(uint16_t *)data; return 0; + case MR_BUFF_DIR: + mrb_metadata->dir = *(uint8_t *)data; + return 0; default: return -1; } @@ -238,6 +244,13 @@ int marsio_buff_get_metadata(marsio_buff_t *m, enum mr_buff_metadata_type type, } *(uint16_t *)(data) = (uint16_t)mrb_metadata->payload_offset; return sizeof(uint16_t); + case MR_BUFF_LINK_ID: + if (sz_data < sizeof(uint16_t)) + { + return -1; + } + *(uint16_t *)(data) = (uint16_t)mrb_metadata->link_id; + return sizeof(uint16_t); case MR_BUFF_USER_0: if (sz_data < sizeof(uint16_t)) { diff --git a/test/test_data/conf/sce.conf b/test/test_data/conf/sce.conf index c3a97ec..c1f34f8 100644 --- a/test/test_data/conf/sce.conf +++ b/test/test_data/conf/sce.conf @@ -2,6 +2,7 @@ nr_worker_threads=1 cpu_affinity_mask=2 firewall_sids=1001 +stateless_sids=2000 enable_debug=0 enable_send_log=0 ts_update_interval_ms=1 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 294c7d7..19cf1c3 100644 --- a/test/test_data/log/test_ctr_pkt_active_ok.fs2 +++ b/test/test_data/log/test_ctr_pkt_active_ok.fs2 @@ -23,7 +23,7 @@ speed/s 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 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 1 0 1 0 -speed/s 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 +speed/s 0 0 0 0 0 0 0 ________________________________________________________________________________________________________________________________________________ diff --git a/test/test_data/log/test_ctr_pkt_opening_ok.fs2 b/test/test_data/log/test_ctr_pkt_opening_ok.fs2 index d370534..15b123c 100644 --- a/test/test_data/log/test_ctr_pkt_opening_ok.fs2 +++ b/test/test_data/log/test_ctr_pkt_opening_ok.fs2 @@ -23,7 +23,7 @@ speed/s 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 99 1 99 1 0 0 0 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 0 0 0 0 -speed/s 0 0 0 0 0 + ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B +sum 0 0 0 0 0 0 0 +speed/s 0 0 0 0 0 0 0 ________________________________________________________________________________________________________________________________________________ diff --git a/test/test_data/log/test_data_pkt_error_bypass_ok.fs2 b/test/test_data/log/test_data_pkt_error_bypass_ok.fs2 index 5a20c7b..fc3c74d 100644 --- a/test/test_data/log/test_data_pkt_error_bypass_ok.fs2 +++ b/test/test_data/log/test_data_pkt_error_bypass_ok.fs2 @@ -23,7 +23,7 @@ speed/s 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 0 0 0 0 0 0 0 0 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 0 0 0 0 -speed/s 0 0 0 0 0 + ctrl_error curr_sessions session_logs session_new session_free stateless_inject_P stateless_inject_B +sum 0 0 0 0 0 0 0 +speed/s 0 0 0 0 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 96decd7..9e6a683 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 @@ -23,7 +23,7 @@ speed/s 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 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 1 0 1 0 -speed/s 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 +speed/s 0 0 0 0 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 7ccc191..4abed90 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 @@ -23,7 +23,7 @@ speed/s 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 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 1 0 1 0 -speed/s 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 +speed/s 0 0 0 0 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 6ab9f03..72a0acc 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 @@ -23,7 +23,7 @@ speed/s 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 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 1 0 1 0 -speed/s 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 +speed/s 0 0 0 0 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 859ed7f..5df28c6 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 @@ -23,7 +23,7 @@ speed/s 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 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 1 0 1 0 -speed/s 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 +speed/s 0 0 0 0 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 40ac09b..a4dd3a6 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 @@ -23,7 +23,7 @@ speed/s 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 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 1 0 1 0 -speed/s 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 +speed/s 0 0 0 0 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 4fd8f0c..064ef23 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 @@ -23,7 +23,7 @@ speed/s 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 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 1 0 1 0 -speed/s 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 +speed/s 0 0 0 0 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 d9e3a8a..62aefe3 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 @@ -23,7 +23,7 @@ speed/s 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 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 1 0 1 0 -speed/s 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 +speed/s 0 0 0 0 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 609f7df..71c5194 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 @@ -23,7 +23,7 @@ speed/s 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 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 1 0 1 0 -speed/s 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 +speed/s 0 0 0 0 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 b1fd9c0..fc5f73e 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 @@ -23,7 +23,7 @@ speed/s 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 speed/s 0 0 0 0 0 0 0 0 - ctrl_error curr_sessions session_logs session_new session_free -sum 0 1 0 1 0 -speed/s 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 +speed/s 0 0 0 0 0 0 0 ________________________________________________________________________________________________________________________________________________