diff options
Diffstat (limited to 'src/vpp-api/vapi')
-rw-r--r-- | src/vpp-api/vapi/vapi_c_test.c | 106 | ||||
-rw-r--r-- | src/vpp-api/vapi/vapi_cpp_test.cpp | 104 |
2 files changed, 117 insertions, 93 deletions
diff --git a/src/vpp-api/vapi/vapi_c_test.c b/src/vpp-api/vapi/vapi_c_test.c index 7a0e462e40a..5bf230f7ed4 100644 --- a/src/vpp-api/vapi/vapi_c_test.c +++ b/src/vpp-api/vapi/vapi_c_test.c @@ -28,7 +28,7 @@ #include <vapi/vlib.api.vapi.h> #include <vapi/vpe.api.vapi.h> #include <vapi/interface.api.vapi.h> -#include <vapi/mss_clamp.api.vapi.h> +#include <vapi/ip.api.vapi.h> #include <vapi/l2.api.vapi.h> #include <fake.api.vapi.h> @@ -37,7 +37,7 @@ DEFINE_VAPI_MSG_IDS_VPE_API_JSON; DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON; -DEFINE_VAPI_MSG_IDS_MSS_CLAMP_API_JSON; +DEFINE_VAPI_MSG_IDS_IP_API_JSON; DEFINE_VAPI_MSG_IDS_L2_API_JSON; DEFINE_VAPI_MSG_IDS_FAKE_API_JSON; @@ -489,9 +489,9 @@ sw_interface_dump_cb (struct vapi_ctx_s *ctx, void *callback_ctx, } vapi_error_e -vapi_mss_clamp_enable_disable_reply_cb ( - struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, - vapi_payload_mss_clamp_enable_disable_reply *reply) +vapi_ip_path_mtu_update_reply_cb (struct vapi_ctx_s *ctx, void *callback_ctx, + vapi_error_e rv, bool is_last, + vapi_payload_ip_path_mtu_update_reply *reply) { bool *x = callback_ctx; *x = true; @@ -499,34 +499,36 @@ vapi_mss_clamp_enable_disable_reply_cb ( } vapi_error_e -vapi_mss_clamp_get_reply_cb (struct vapi_ctx_s *ctx, void *callback_ctx, - vapi_error_e rv, bool is_last, - vapi_payload_mss_clamp_get_reply *reply) +vapi_ip_path_mtu_get_reply_cb (struct vapi_ctx_s *ctx, void *callback_ctx, + vapi_error_e rv, bool is_last, + vapi_payload_ip_path_mtu_get_reply *reply) { int *counter = callback_ctx; ck_assert_int_gt (*counter, 0); // make sure details were called first ++*counter; ck_assert_int_eq (is_last, true); - printf ("Got mss clamp reply error %d\n", rv); + printf ("Got ip path mtu reply error %d\n", rv); ck_assert_int_eq (rv, VAPI_OK); printf ("counter is %d", *counter); return VAPI_OK; } vapi_error_e -vapi_mss_clamp_get_details_cb (struct vapi_ctx_s *ctx, void *callback_ctx, - vapi_error_e rv, bool is_last, - vapi_payload_mss_clamp_details *details) +vapi_ip_path_mtu_details_cb (struct vapi_ctx_s *ctx, void *callback_ctx, + vapi_error_e rv, bool is_last, + vapi_payload_ip_path_mtu_details *details) { int *counter = callback_ctx; ++*counter; if (!is_last) { - printf ("Got ipv4 mss clamp to %u for sw_if_index %u\n", - details->ipv4_mss, details->sw_if_index); - ck_assert_int_eq (details->ipv4_mss, 1000 + details->sw_if_index); + printf ("Got ip path mtu to %u for ip %d.%d.%d.%d\n", + details->pmtu.path_mtu, details->pmtu.nh.un.ip4[0], + details->pmtu.nh.un.ip4[1], details->pmtu.nh.un.ip4[2], + details->pmtu.nh.un.ip4[3]); + ck_assert_int_eq (details->pmtu.path_mtu, 1420); } - printf ("counter is %d", *counter); + printf ("counter is %d\n", *counter); return VAPI_OK; } @@ -571,36 +573,6 @@ START_TEST (test_loopbacks_1) sw_if_indexes[i]); } - { // new context - for (int i = 0; i < num_ifs; ++i) - { - vapi_msg_mss_clamp_enable_disable *mc = - vapi_alloc_mss_clamp_enable_disable (ctx); - mc->payload.sw_if_index = sw_if_indexes[i]; - mc->payload.ipv4_mss = 1000 + sw_if_indexes[i]; - mc->payload.ipv4_direction = MSS_CLAMP_DIR_RX; - bool reply_ctx = false; - printf ("Set ipv4 mss clamp to %u for sw_if_index %u\n", - mc->payload.ipv4_mss, mc->payload.sw_if_index); - vapi_error_e rv = vapi_mss_clamp_enable_disable ( - ctx, mc, vapi_mss_clamp_enable_disable_reply_cb, &reply_ctx); - ck_assert_int_eq (VAPI_OK, rv); - ck_assert_int_eq (reply_ctx, true); - } - } - - { // new context - int counter = 0; - vapi_msg_mss_clamp_get *msg = vapi_alloc_mss_clamp_get (ctx); - msg->payload.sw_if_index = ~0; - vapi_error_e rv = - vapi_mss_clamp_get (ctx, msg, vapi_mss_clamp_get_reply_cb, &counter, - vapi_mss_clamp_get_details_cb, &counter); - printf ("counter is %d", counter); - ck_assert_int_eq (VAPI_OK, rv); - ck_assert_int_eq (counter, num_ifs + 1); - } - bool seen[num_ifs]; sw_interface_dump_ctx dctx = { false, num_ifs, sw_if_indexes, seen, 0 }; vapi_msg_sw_interface_dump *dump; @@ -653,6 +625,47 @@ START_TEST (test_loopbacks_1) END_TEST; +START_TEST (test_pmtu) +{ + printf ("--- Set ip_path_mtu to test stream rpc ---\n"); + const int num_path_mtus = 5; + + { // new context + for (int i = 0; i < num_path_mtus; ++i) + { + vapi_msg_ip_path_mtu_update *mc = vapi_alloc_ip_path_mtu_update (ctx); + mc->payload.pmtu.path_mtu = 1420; + mc->payload.pmtu.nh.af = ADDRESS_IP4; + mc->payload.pmtu.nh.un.ip4[0] = 10; + mc->payload.pmtu.nh.un.ip4[1] = 0; + mc->payload.pmtu.nh.un.ip4[2] = 0; + mc->payload.pmtu.nh.un.ip4[3] = i; + bool reply_ctx = false; + printf ("Set ip path mtu to %u for %d.%d.%d.%d\n", + mc->payload.pmtu.path_mtu, mc->payload.pmtu.nh.un.ip4[0], + mc->payload.pmtu.nh.un.ip4[1], mc->payload.pmtu.nh.un.ip4[2], + mc->payload.pmtu.nh.un.ip4[3]); + vapi_error_e rv = vapi_ip_path_mtu_update ( + ctx, mc, vapi_ip_path_mtu_update_reply_cb, &reply_ctx); + ck_assert_int_eq (VAPI_OK, rv); + ck_assert_int_eq (reply_ctx, true); + } + } + + { // new context + int counter = 0; + vapi_msg_ip_path_mtu_get *msg = vapi_alloc_ip_path_mtu_get (ctx); + vapi_error_e rv = + vapi_ip_path_mtu_get (ctx, msg, vapi_ip_path_mtu_get_reply_cb, &counter, + vapi_ip_path_mtu_details_cb, &counter); + printf ("counter is %d", counter); + ck_assert_int_eq (VAPI_OK, rv); + ck_assert_int_eq (counter, num_path_mtus + 1); + } +} + +END_TEST; + START_TEST (test_show_version_3) { printf ("--- Show version via async callback ---\n"); @@ -1042,6 +1055,7 @@ test_suite (void) tcase_add_test (tc_block, test_show_version_1); tcase_add_test (tc_block, test_show_version_2); tcase_add_test (tc_block, test_loopbacks_1); + tcase_add_test (tc_block, test_pmtu); suite_add_tcase (s, tc_block); TCase *tc_nonblock = tcase_create ("Nonblocking API"); diff --git a/src/vpp-api/vapi/vapi_cpp_test.cpp b/src/vpp-api/vapi/vapi_cpp_test.cpp index 918c7590b60..08bf1b0f570 100644 --- a/src/vpp-api/vapi/vapi_cpp_test.cpp +++ b/src/vpp-api/vapi/vapi_cpp_test.cpp @@ -25,12 +25,12 @@ #include <vapi/vapi.hpp> #include <vapi/vpe.api.vapi.hpp> #include <vapi/interface.api.vapi.hpp> -#include <vapi/mss_clamp.api.vapi.hpp> +#include <vapi/ip.api.vapi.hpp> #include <fake.api.vapi.hpp> DEFINE_VAPI_MSG_IDS_VPE_API_JSON; DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON; -DEFINE_VAPI_MSG_IDS_MSS_CLAMP_API_JSON; +DEFINE_VAPI_MSG_IDS_IP_API_JSON; DEFINE_VAPI_MSG_IDS_FAKE_API_JSON; static char *app_name = nullptr; @@ -149,51 +149,6 @@ START_TEST (test_loopbacks_1) } { // new context - for (int i = 0; i < num_ifs; ++i) - { - Mss_clamp_enable_disable d (con); - auto &req = d.get_request ().get_payload (); - req.sw_if_index = sw_if_indexes[i]; - req.ipv4_mss = 1420; - req.ipv4_direction = vapi_enum_mss_clamp_dir::MSS_CLAMP_DIR_RX; - auto rv = d.execute (); - ck_assert_int_eq (VAPI_OK, rv); - WAIT_FOR_RESPONSE (d, rv); - ck_assert_int_eq (VAPI_OK, rv); - } - } - - { // new context - bool seen[num_ifs] = { 0 }; - Mss_clamp_get d (con); - d.get_request ().get_payload ().sw_if_index = ~0; - auto rv = d.execute (); - ck_assert_int_eq (VAPI_OK, rv); - WAIT_FOR_RESPONSE (d, rv); - ck_assert_int_eq (VAPI_OK, rv); - auto &rs = d.get_result_set (); - for (auto &r : rs) - { - auto &p = r.get_payload (); - ck_assert_int_eq (p.ipv4_mss, 1420); - printf ("tcp-clamp: sw_if_idx %u ip4-mss %d dir %d\n", p.sw_if_index, - p.ipv4_mss, p.ipv4_direction); - for (int i = 0; i < num_ifs; ++i) - { - if (sw_if_indexes[i] == p.sw_if_index) - { - ck_assert_int_eq (0, seen[i]); - seen[i] = true; - } - } - } - for (int i = 0; i < num_ifs; ++i) - { - ck_assert_int_eq (1, seen[i]); - } - } - - { // new context bool seen[num_ifs] = {0}; Sw_interface_dump d (con, 0); auto rv = d.execute (); @@ -435,6 +390,60 @@ START_TEST (test_unsupported) END_TEST; +START_TEST (test_pmtu) +{ + printf ("--- Set ip_path_mtu to test stream rpc ---\n"); + const auto num_path_mtus = 5; + { // new context + for (int i = 0; i < num_path_mtus; ++i) + { + Ip_path_mtu_update d (con); + auto &req = d.get_request ().get_payload (); + req.pmtu.path_mtu = 1420; + req.pmtu.nh.af = vapi_enum_address_family::ADDRESS_IP4; + req.pmtu.nh.un.ip4[0] = 10; + req.pmtu.nh.un.ip4[1] = 0; + req.pmtu.nh.un.ip4[2] = 0; + req.pmtu.nh.un.ip4[3] = i; + auto rv = d.execute (); + WAIT_FOR_RESPONSE (d, rv); + ck_assert_int_eq (VAPI_OK, rv); + } + } + + { // new context + bool seen[num_path_mtus] = { 0 }; + Ip_path_mtu_get d (con); + d.get_request ().get_payload ().cursor = 0; + auto rv = d.execute (); + ck_assert_int_eq (VAPI_OK, rv); + WAIT_FOR_RESPONSE (d, rv); + ck_assert_int_eq (VAPI_OK, rv); + auto &rs = d.get_result_set (); + for (auto &r : rs) + { + auto &p = r.get_payload (); + printf ("ip_path_mtu_get: mtu %hu ip %d.%d.%d.%d\n", p.pmtu.path_mtu, + p.pmtu.nh.un.ip4[0], p.pmtu.nh.un.ip4[1], p.pmtu.nh.un.ip4[2], + p.pmtu.nh.un.ip4[3]); + for (int i = 0; i < num_path_mtus; ++i) + { + if (i == p.pmtu.nh.un.ip4[3]) + { + ck_assert_int_eq (0, seen[i]); + seen[i] = true; + } + } + } + for (int i = 0; i < num_path_mtus; ++i) + { + ck_assert_int_eq (1, seen[i]); + } + } +} + +END_TEST; + Suite *test_suite (void) { Suite *s = suite_create ("VAPI test"); @@ -447,6 +456,7 @@ Suite *test_suite (void) tcase_add_test (tc_cpp_api, test_loopbacks_1); tcase_add_test (tc_cpp_api, test_loopbacks_2); tcase_add_test (tc_cpp_api, test_unsupported); + tcase_add_test (tc_cpp_api, test_pmtu); suite_add_tcase (s, tc_cpp_api); return s; |