diff --git a/platform/src/packet_io.cpp b/platform/src/packet_io.cpp index c18142b..e572c7e 100644 --- a/platform/src/packet_io.cpp +++ b/platform/src/packet_io.cpp @@ -508,6 +508,7 @@ static void action_sf_chaining(struct thread_ctx *thread_ctx, struct session_ctx else { action_mirr_block(rx_buff, meta, sf, thread_ctx); + action_nf_inject(rx_buff, meta, NULL, thread_ctx); return; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2c47121..b2ea43f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -66,6 +66,60 @@ target_include_directories(gtest_raw_pkt_stee_forward PUBLIC ${CMAKE_SOURCE_DIR} 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_raw_pkt_stee_rx_egress +############################################################################### + +add_executable(gtest_raw_pkt_stee_rx_egress gtest_raw_pkt_stee_rx_egress.cpp) +target_include_directories(gtest_raw_pkt_stee_rx_egress PUBLIC ${CMAKE_SOURCE_DIR}/common/include) +target_include_directories(gtest_raw_pkt_stee_rx_egress PUBLIC ${CMAKE_SOURCE_DIR}/platform/include) +target_link_libraries(gtest_raw_pkt_stee_rx_egress temp_platform gtest) + +############################################################################### +# gtest_raw_pkt_mirr_bypass +############################################################################### + +add_executable(gtest_raw_pkt_mirr_bypass gtest_raw_pkt_mirr_bypass.cpp) +target_include_directories(gtest_raw_pkt_mirr_bypass PUBLIC ${CMAKE_SOURCE_DIR}/common/include) +target_include_directories(gtest_raw_pkt_mirr_bypass PUBLIC ${CMAKE_SOURCE_DIR}/platform/include) +target_link_libraries(gtest_raw_pkt_mirr_bypass temp_platform gtest) + +############################################################################### +# gtest_raw_pkt_mirr_block +############################################################################### + +add_executable(gtest_raw_pkt_mirr_block gtest_raw_pkt_mirr_block.cpp) +target_include_directories(gtest_raw_pkt_mirr_block PUBLIC ${CMAKE_SOURCE_DIR}/common/include) +target_include_directories(gtest_raw_pkt_mirr_block PUBLIC ${CMAKE_SOURCE_DIR}/platform/include) +target_link_libraries(gtest_raw_pkt_mirr_block temp_platform gtest) + +############################################################################### +# gtest_raw_pkt_mirr_forward +############################################################################### + +add_executable(gtest_raw_pkt_mirr_forward gtest_raw_pkt_mirr_forward.cpp) +target_include_directories(gtest_raw_pkt_mirr_forward PUBLIC ${CMAKE_SOURCE_DIR}/common/include) +target_include_directories(gtest_raw_pkt_mirr_forward PUBLIC ${CMAKE_SOURCE_DIR}/platform/include) +target_link_libraries(gtest_raw_pkt_mirr_forward temp_platform gtest) + +############################################################################### +# gtest_raw_pkt_mirr_rx_drop +############################################################################### + +add_executable(gtest_raw_pkt_mirr_rx_drop gtest_raw_pkt_mirr_rx_drop.cpp) +target_include_directories(gtest_raw_pkt_mirr_rx_drop PUBLIC ${CMAKE_SOURCE_DIR}/common/include) +target_include_directories(gtest_raw_pkt_mirr_rx_drop PUBLIC ${CMAKE_SOURCE_DIR}/platform/include) +target_link_libraries(gtest_raw_pkt_mirr_rx_drop temp_platform gtest) + +############################################################################### +# gtest_raw_pkt_error_bypass +############################################################################### + +add_executable(gtest_raw_pkt_error_bypass gtest_raw_pkt_error_bypass.cpp) +target_include_directories(gtest_raw_pkt_error_bypass PUBLIC ${CMAKE_SOURCE_DIR}/common/include) +target_include_directories(gtest_raw_pkt_error_bypass PUBLIC ${CMAKE_SOURCE_DIR}/platform/include) +target_link_libraries(gtest_raw_pkt_error_bypass temp_platform gtest) + ############################################################################### # gtest_discover_tests ############################################################################### @@ -78,6 +132,14 @@ 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) +gtest_discover_tests(gtest_raw_pkt_stee_rx_egress) + +gtest_discover_tests(gtest_raw_pkt_mirr_bypass) +gtest_discover_tests(gtest_raw_pkt_mirr_block) +gtest_discover_tests(gtest_raw_pkt_mirr_forward) +gtest_discover_tests(gtest_raw_pkt_mirr_rx_drop) + +gtest_discover_tests(gtest_raw_pkt_error_bypass) file(COPY ./test_data/log/ DESTINATION ./log/) file(COPY ./test_data/conf/ DESTINATION ./conf/) diff --git a/test/gtest_raw_pkt_error_bypass.cpp b/test/gtest_raw_pkt_error_bypass.cpp new file mode 100644 index 0000000..c3a781d --- /dev/null +++ b/test/gtest_raw_pkt_error_bypass.cpp @@ -0,0 +1,38 @@ +#include "gtest_utils.h" + +// 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_ERROR_BYPASS) +{ + marsio_buff_t *tx_mbuf = NULL; + marsio_buff_t *dup_mbuf = NULL; + struct gtest_frame *gtest_frame = NULL; + + build_mbuf_for_raw_pkt(tx_mbuf, raw_pkt, sizeof(raw_pkt), 290484492702581737, 0); + dup_mbuf = marsio_mbuff_dup(tx_mbuf); + + gtest_frame = gtest_frame_new("sce0.json", "raw_pkt_error_bypass"); + 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(); +} \ No newline at end of file diff --git a/test/gtest_raw_pkt_mirr_block.cpp b/test/gtest_raw_pkt_mirr_block.cpp new file mode 100644 index 0000000..6e852f0 --- /dev/null +++ b/test/gtest_raw_pkt_mirr_block.cpp @@ -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_MIRR_BLOCK) +{ + 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_mirr_block.json", "raw_pkt_mirr_block"); + 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(); +} \ No newline at end of file diff --git a/test/gtest_raw_pkt_mirr_bypass.cpp b/test/gtest_raw_pkt_mirr_bypass.cpp new file mode 100644 index 0000000..a5b2ad4 --- /dev/null +++ b/test/gtest_raw_pkt_mirr_bypass.cpp @@ -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_MIRR_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_mirr_bypass.json", "raw_pkt_mirr_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(); +} \ No newline at end of file diff --git a/test/gtest_raw_pkt_mirr_forward.cpp b/test/gtest_raw_pkt_mirr_forward.cpp new file mode 100644 index 0000000..c96375f --- /dev/null +++ b/test/gtest_raw_pkt_mirr_forward.cpp @@ -0,0 +1,69 @@ +#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_MIRR_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; + marsio_buff_t *temp_mbuf = 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_mirr_forward.json", "raw_pkt_mirr_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); + EXPECT_TRUE(packet_io_thread_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1); + temp_mbuf = marsio_get_send_mbuff(mr_instance); + EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, temp_mbuf) == 0); + EXPECT_TRUE(marsio_mbuff_cmp(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); + marsio_buff_free(packet_io_get_mr_instance(gtest_frame->sce_ctx->io), &temp_mbuf, 1, 0, 0); + gtest_frame_free(gtest_frame); +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file diff --git a/test/gtest_raw_pkt_mirr_rx_drop.cpp b/test/gtest_raw_pkt_mirr_rx_drop.cpp new file mode 100644 index 0000000..eb29c92 --- /dev/null +++ b/test/gtest_raw_pkt_mirr_rx_drop.cpp @@ -0,0 +1,78 @@ +#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_MIRR_RX_DROP) +{ + marsio_buff_t *tx_mbuf1 = NULL; + marsio_buff_t *tx_mbuf2 = NULL; + marsio_buff_t *dup_mbuf1 = NULL; + marsio_buff_t *dup_mbuf2 = NULL; + marsio_buff_t *temp_mbuf = 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_mirr_forward.json", "raw_pkt_mirr_rx_drop"); + mr_instance = packet_io_get_mr_instance(gtest_frame->sce_ctx->io); + + // recv ctrl_pkt_active from nf + // send ctrl_pkt_active to nf + gtest_frame_run(gtest_frame, tx_mbuf1, dup_mbuf1, 1); + // recv raw_pkt from nf + // send vxlan_pkt to sf + marsio_set_recv_mbuff(mr_instance, tx_mbuf2); + EXPECT_TRUE(packet_io_thread_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1); + temp_mbuf = marsio_get_send_mbuff(mr_instance); + EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, temp_mbuf) == 0); + EXPECT_TRUE(marsio_mbuff_cmp(dup_mbuf2, marsio_get_send_mbuff(mr_instance)) == 0); + // recv vxlan_pkt from sf + // send raw_pkt to nf + marsio_set_recv_mbuff(mr_instance, temp_mbuf); + EXPECT_TRUE(packet_io_thread_polling_endpoint(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1); + EXPECT_TRUE(marsio_get_send_mbuff(mr_instance) == NULL); + + 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(); +} \ No newline at end of file diff --git a/test/gtest_raw_pkt_stee_forward.cpp b/test/gtest_raw_pkt_stee_forward.cpp index a7b151b..3cd55a5 100644 --- a/test/gtest_raw_pkt_stee_forward.cpp +++ b/test/gtest_raw_pkt_stee_forward.cpp @@ -46,7 +46,6 @@ TEST(PACKET_IO, 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); diff --git a/test/gtest_raw_pkt_stee_rx_egress.cpp b/test/gtest_raw_pkt_stee_rx_egress.cpp new file mode 100644 index 0000000..c6ad863 --- /dev/null +++ b/test/gtest_raw_pkt_stee_rx_egress.cpp @@ -0,0 +1,76 @@ +#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_RX_EGRESS) +{ + marsio_buff_t *tx_mbuf1 = NULL; + marsio_buff_t *tx_mbuf2 = NULL; + marsio_buff_t *dup_mbuf1 = NULL; + marsio_buff_t *dup_mbuf2 = NULL; + marsio_buff_t *vxlan_mbuf = 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_rx_egress"); + mr_instance = packet_io_get_mr_instance(gtest_frame->sce_ctx->io); + + // recv ctrl_pkt_active from nf + // send ctrl_pkt_active to nf + gtest_frame_run(gtest_frame, tx_mbuf1, dup_mbuf1, 1); + // recv raw_pkt from nf + // send vxlan_pkt to sf + marsio_set_recv_mbuff(mr_instance, tx_mbuf2); + EXPECT_TRUE(packet_io_thread_polling_nf(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1); + vxlan_mbuf = marsio_get_send_mbuff(mr_instance); + EXPECT_TRUE(mbuff_cmp_payload(dup_mbuf2, vxlan_mbuf) == 0); + // recv vxlan_pkt from sf + // send raw_pkt to nf + marsio_set_recv_mbuff(mr_instance, vxlan_mbuf); + EXPECT_TRUE(packet_io_thread_polling_endpoint(gtest_frame->sce_ctx->io, >est_frame->sce_ctx->work_threads[0]) == 1); + EXPECT_TRUE(marsio_mbuff_cmp(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(); +} \ No newline at end of file diff --git a/test/gtest_utils.h b/test/gtest_utils.h index 6b6f148..22945dc 100644 --- a/test/gtest_utils.h +++ b/test/gtest_utils.h @@ -149,7 +149,6 @@ inline void gtest_frame_run(struct gtest_frame *instance, marsio_buff_t *tx_mbuf 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) { diff --git a/test/marsio.cpp b/test/marsio.cpp index b3e28ba..1a6c974 100644 --- a/test/marsio.cpp +++ b/test/marsio.cpp @@ -8,7 +8,9 @@ struct mr_instance { marsio_buff_t *current_recv_mbuff_ptr; - marsio_buff_t *current_send_mbuff_ptr; + marsio_buff_t *current_send_mbuff_ptr[128]; + int send_mbuff_ptr_index; + int send_mbuff_ptr_number; }; struct mr_vdev @@ -69,8 +71,8 @@ struct mock_marsio_buff_t 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; + instance->send_mbuff_ptr_index = 0; + instance->send_mbuff_ptr_number = 0; return instance; } @@ -283,14 +285,6 @@ void marsio_buff_free(struct mr_instance *instance, marsio_buff_t *marsio_buff[] 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)); @@ -320,6 +314,7 @@ 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; + mbuf->raw_len -= len; return mbuf->raw_data; } @@ -374,7 +369,9 @@ int marsio_recv_burst(struct mr_vdev *vdev, queue_id_t qid, marsio_buff_t *mbufs 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]; + sendpath->mr_instance->current_send_mbuff_ptr[sendpath->mr_instance->send_mbuff_ptr_index] = mbufs[0]; + sendpath->mr_instance->send_mbuff_ptr_index++; + sendpath->mr_instance->send_mbuff_ptr_number++; return marsio_buff_datalen(mbufs[0]); } @@ -387,7 +384,9 @@ 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) { - instance->current_send_mbuff_ptr = mbuff; + instance->current_send_mbuff_ptr[instance->send_mbuff_ptr_index] = mbuff; + instance->send_mbuff_ptr_index++; + instance->send_mbuff_ptr_number++; } marsio_buff_t *marsio_get_recv_mbuff(struct mr_instance *instance) @@ -397,7 +396,16 @@ marsio_buff_t *marsio_get_recv_mbuff(struct mr_instance *instance) marsio_buff_t *marsio_get_send_mbuff(struct mr_instance *instance) { - return instance->current_send_mbuff_ptr; + if (instance->send_mbuff_ptr_number) + { + marsio_buff_t *buff = instance->current_send_mbuff_ptr[instance->send_mbuff_ptr_index - instance->send_mbuff_ptr_number]; + instance->send_mbuff_ptr_number--; + return buff; + } + else + { + return NULL; + } } int marsio_mbuff_cmp(marsio_buff_t *mbuff1, marsio_buff_t *mbuff2) diff --git a/test/test_data/log/test_raw_pkt_error_bypass_ok.fs2 b/test/test_data/log/test_raw_pkt_error_bypass_ok.fs2 new file mode 100644 index 0000000..c2251c2 --- /dev/null +++ b/test/test_data/log/test_raw_pkt_error_bypass_ok.fs2 @@ -0,0 +1,23 @@ +============================================================Fri Apr 7 09:41: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 145 1 145 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 1 145 1 145 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 0 0 0 0 0 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 +________________________________________________________________________________________________________________________________________________ diff --git a/test/test_data/log/test_raw_pkt_mirr_block_ok.fs2 b/test/test_data/log/test_raw_pkt_mirr_block_ok.fs2 new file mode 100644 index 0000000..cf27813 --- /dev/null +++ b/test/test_data/log/test_raw_pkt_mirr_block_ok.fs2 @@ -0,0 +1,23 @@ +============================================================Fri Apr 7 08:47:52 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 1 145 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 0 0 +speed/s 0 0 0 0 0 +________________________________________________________________________________________________________________________________________________ diff --git a/test/test_data/log/test_raw_pkt_mirr_bypass_ok.fs2 b/test/test_data/log/test_raw_pkt_mirr_bypass_ok.fs2 new file mode 100644 index 0000000..00fd820 --- /dev/null +++ b/test/test_data/log/test_raw_pkt_mirr_bypass_ok.fs2 @@ -0,0 +1,23 @@ +============================================================Fri Apr 7 09:01:03 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 1 145 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 0 0 +speed/s 0 0 0 0 0 +________________________________________________________________________________________________________________________________________________ diff --git a/test/test_data/log/test_raw_pkt_mirr_forward_ok.fs2 b/test/test_data/log/test_raw_pkt_mirr_forward_ok.fs2 new file mode 100644 index 0000000..1f9b035 --- /dev/null +++ b/test/test_data/log/test_raw_pkt_mirr_forward_ok.fs2 @@ -0,0 +1,23 @@ +============================================================Fri Apr 7 09:26:07 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 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 1 145 +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 +________________________________________________________________________________________________________________________________________________ diff --git a/test/test_data/log/test_raw_pkt_mirr_rx_drop_ok.fs2 b/test/test_data/log/test_raw_pkt_mirr_rx_drop_ok.fs2 new file mode 100644 index 0000000..e3cbc80 --- /dev/null +++ b/test/test_data/log/test_raw_pkt_mirr_rx_drop_ok.fs2 @@ -0,0 +1,23 @@ +============================================================Fri Apr 7 09:56:54 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 1 195 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 1 145 1 145 +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 1 195 1 195 +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 +________________________________________________________________________________________________________________________________________________ diff --git a/test/test_data/log/test_raw_pkt_stee_rx_egress_ok.fs2 b/test/test_data/log/test_raw_pkt_stee_rx_egress_ok.fs2 new file mode 100644 index 0000000..16f4462 --- /dev/null +++ b/test/test_data/log/test_raw_pkt_stee_rx_egress_ok.fs2 @@ -0,0 +1,23 @@ +============================================================Fri Apr 7 10:51:51 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 1 195 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 1 145 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 +________________________________________________________________________________________________________________________________________________ diff --git a/test/test_data/resource/raw_pkt_mirr_block.json b/test/test_data/resource/raw_pkt_mirr_block.json new file mode 100644 index 0000000..30ca9f1 --- /dev/null +++ b/test/test_data/resource/raw_pkt_mirr_block.json @@ -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\t2\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" + ] + } + ] +} \ No newline at end of file diff --git a/test/test_data/resource/raw_pkt_mirr_bypass.json b/test/test_data/resource/raw_pkt_mirr_bypass.json new file mode 100644 index 0000000..78a9226 --- /dev/null +++ b/test/test_data/resource/raw_pkt_mirr_bypass.json @@ -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\t2\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" + ] + } + ] +} \ No newline at end of file diff --git a/test/test_data/resource/raw_pkt_mirr_forward.json b/test/test_data/resource/raw_pkt_mirr_forward.json new file mode 100644 index 0000000..99237fc --- /dev/null +++ b/test/test_data/resource/raw_pkt_mirr_forward.json @@ -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\t2\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" + ] + } + ] +} \ No newline at end of file