From 07063b8ea39b05d5d7bb00ad2a2363b11792c571 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Fri, 13 Mar 2020 04:44:51 +0000 Subject: session: api to add new transport types Type: feature Signed-off-by: Florin Coras Change-Id: If4dee6dba1ea942daa921d566b35cdecdda680ee --- src/plugins/hs_apps/sapi/vpp_echo.c | 7 ++++--- src/plugins/hs_apps/sapi/vpp_echo_common.c | 7 ------- src/plugins/hs_apps/sapi/vpp_echo_common.h | 15 ++++++++------- src/plugins/hs_apps/sapi/vpp_echo_proto_tcp.c | 1 - src/plugins/quic/quic.c | 2 ++ 5 files changed, 14 insertions(+), 18 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/hs_apps/sapi/vpp_echo.c b/src/plugins/hs_apps/sapi/vpp_echo.c index 4dd8e0f2d80..d6f0b28cc18 100644 --- a/src/plugins/hs_apps/sapi/vpp_echo.c +++ b/src/plugins/hs_apps/sapi/vpp_echo.c @@ -1052,7 +1052,7 @@ print_usage_and_exit (void) " nthreads N Use N busy loop threads for data [in addition to main & msg queue]\n" " TX=1337[K|M|G]|RX Send 1337 [K|M|G]bytes, use TX=RX to reflect the data\n" " RX=1337[K|M|G] Expect 1337 [K|M|G]bytes\n" "\n"); - for (i = 0; i < TRANSPORT_N_PROTO; i++) + for (i = 0; i < vec_len (em->available_proto_cb_vft); i++) { echo_proto_cb_vft_t *vft = em->available_proto_cb_vft[i]; if (vft && vft->print_usage_cb) @@ -1069,7 +1069,7 @@ echo_process_each_proto_opts (unformat_input_t * a) { echo_main_t *em = &echo_main; int i, rv; - for (i = 0; i < TRANSPORT_N_PROTO; i++) + for (i = 0; i < vec_len (em->available_proto_cb_vft); i++) { echo_proto_cb_vft_t *vft = em->available_proto_cb_vft[i]; if (vft && vft->process_opts_cb) @@ -1083,7 +1083,7 @@ static void echo_set_each_proto_defaults_before_opts (echo_main_t * em) { int i; - for (i = 0; i < TRANSPORT_N_PROTO; i++) + for (i = 0; i < vec_len (em->available_proto_cb_vft); i++) { echo_proto_cb_vft_t *vft = em->available_proto_cb_vft[i]; if (vft && vft->set_defaults_before_opts_cb) @@ -1445,6 +1445,7 @@ exit_on_error: else print_global_stats (em); vec_free (em->fail_descr); + vec_free (em->available_proto_cb_vft); exit (em->has_failed); } diff --git a/src/plugins/hs_apps/sapi/vpp_echo_common.c b/src/plugins/hs_apps/sapi/vpp_echo_common.c index e38b17cc013..60ea5a13214 100644 --- a/src/plugins/hs_apps/sapi/vpp_echo_common.c +++ b/src/plugins/hs_apps/sapi/vpp_echo_common.c @@ -309,10 +309,6 @@ unformat_transport_proto (unformat_input_t * input, va_list * args) *proto = TRANSPORT_PROTO_UDP; else if (unformat (input, "UDP")) *proto = TRANSPORT_PROTO_UDP; - else if (unformat (input, "sctp")) - *proto = TRANSPORT_PROTO_SCTP; - else if (unformat (input, "SCTP")) - *proto = TRANSPORT_PROTO_SCTP; else if (unformat (input, "tls")) *proto = TRANSPORT_PROTO_TLS; else if (unformat (input, "TLS")) @@ -338,9 +334,6 @@ format_transport_proto (u8 * s, va_list * args) case TRANSPORT_PROTO_UDP: s = format (s, "UDP"); break; - case TRANSPORT_PROTO_SCTP: - s = format (s, "SCTP"); - break; case TRANSPORT_PROTO_NONE: s = format (s, "NONE"); break; diff --git a/src/plugins/hs_apps/sapi/vpp_echo_common.h b/src/plugins/hs_apps/sapi/vpp_echo_common.h index 0c85b499e9c..f01bb0390f6 100644 --- a/src/plugins/hs_apps/sapi/vpp_echo_common.h +++ b/src/plugins/hs_apps/sapi/vpp_echo_common.h @@ -146,12 +146,13 @@ do { \ clib_warning (_fmt, ##_args); \ } -#define ECHO_REGISTER_PROTO(proto, vft) \ - static void __clib_constructor \ - vpp_echo_init_##proto () \ - { \ - echo_main_t *em = &echo_main; \ - em->available_proto_cb_vft[proto] = &vft; \ +#define ECHO_REGISTER_PROTO(proto, vft) \ + static void __clib_constructor \ + vpp_echo_init_##proto () \ + { \ + echo_main_t *em = &echo_main; \ + vec_validate (em->available_proto_cb_vft, proto); \ + em->available_proto_cb_vft[proto] = &vft; \ } typedef struct @@ -356,7 +357,7 @@ typedef struct /* VNET_API_ERROR_FOO -> "Foo" hash table */ uword *error_string_by_error_number; - echo_proto_cb_vft_t *available_proto_cb_vft[TRANSPORT_N_PROTO]; + echo_proto_cb_vft_t **available_proto_cb_vft; echo_stats_t stats; echo_stats_t last_stat_sampling; /* copy of stats at last sampling */ diff --git a/src/plugins/hs_apps/sapi/vpp_echo_proto_tcp.c b/src/plugins/hs_apps/sapi/vpp_echo_proto_tcp.c index 0a4a0bdbc1f..94f1d3054ab 100644 --- a/src/plugins/hs_apps/sapi/vpp_echo_proto_tcp.c +++ b/src/plugins/hs_apps/sapi/vpp_echo_proto_tcp.c @@ -142,7 +142,6 @@ echo_proto_cb_vft_t echo_tls_proto_cb_vft = { ECHO_REGISTER_PROTO (TRANSPORT_PROTO_TCP, echo_tcp_proto_cb_vft); ECHO_REGISTER_PROTO (TRANSPORT_PROTO_TLS, echo_tls_proto_cb_vft); -ECHO_REGISTER_PROTO (TRANSPORT_PROTO_SCTP, echo_tcp_proto_cb_vft); /* * fd.io coding-style-patch-verification: ON diff --git a/src/plugins/quic/quic.c b/src/plugins/quic/quic.c index 8b111369fed..03e46c60616 100644 --- a/src/plugins/quic/quic.c +++ b/src/plugins/quic/quic.c @@ -2398,6 +2398,8 @@ static const transport_proto_vft_t quic_proto = { .get_transport_endpoint = quic_get_transport_endpoint, .get_transport_listener_endpoint = quic_get_transport_listener_endpoint, .transport_options = { + .name = "quic", + .short_name = "Q", .tx_type = TRANSPORT_TX_INTERNAL, .service_type = TRANSPORT_SERVICE_APP, }, -- cgit 1.2.3-korg