X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fsession%2Fsession_cli.c;h=929e604b01ecf9d9fb861833395a301c0f11ad28;hb=561af9b441c7392cf391dd46399b0b16b876a08a;hp=028dc9d8ad0f172b605db0f0013d907928994368;hpb=c87c91d8b0e85997debaf575f2e30cc2702edf25;p=vpp.git diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c index 028dc9d8ad0..929e604b01e 100755 --- a/src/vnet/session/session_cli.c +++ b/src/vnet/session/session_cli.c @@ -55,7 +55,7 @@ format_stream_session (u8 * s, va_list * args) int verbose = va_arg (*args, int); transport_proto_vft_t *tp_vft; u8 *str = 0; - tp_vft = session_get_transport_vft (ss->session_type); + tp_vft = transport_protocol_get_vft (session_get_transport_proto (ss)); if (verbose == 1 && ss->session_state >= SESSION_STATE_ACCEPTING) str = format (0, "%-10u%-10u%-10lld", @@ -63,9 +63,7 @@ format_stream_session (u8 * s, va_list * args) svm_fifo_max_enqueue (ss->server_tx_fifo), stream_session_get_index (ss)); - if (ss->session_state == SESSION_STATE_READY - || ss->session_state == SESSION_STATE_ACCEPTING - || ss->session_state == SESSION_STATE_CLOSED) + if (ss->session_state >= SESSION_STATE_ACCEPTING) { s = format (s, "%U", tp_vft->format_connection, ss->connection_index, ss->thread_index, verbose); @@ -115,8 +113,8 @@ unformat_stream_session_id (unformat_input_t * input, va_list * args) { *proto = TRANSPORT_PROTO_UDP; } - else if (unformat (input, "%U:%d->%U:%d", unformat_ip4_address, &lcl->ip4, - lcl_port, unformat_ip4_address, &rmt->ip4, rmt_port)) + if (unformat (input, "%U:%d->%U:%d", unformat_ip4_address, &lcl->ip4, + lcl_port, unformat_ip4_address, &rmt->ip4, rmt_port)) { *is_ip4 = 1; tuple_is_set = 1; @@ -127,13 +125,8 @@ unformat_stream_session_id (unformat_input_t * input, va_list * args) *is_ip4 = 0; tuple_is_set = 1; } - else - return 0; - if (tuple_is_set) - return 1; - - return 0; + return tuple_is_set; } uword @@ -143,34 +136,25 @@ unformat_stream_session (unformat_input_t * input, va_list * args) stream_session_t *s; u8 proto = ~0; ip46_address_t lcl, rmt; - u32 lcl_port = 0, rmt_port = 0; - u8 is_ip4 = 0, s_type = ~0, id_is_set = 0; + u32 lcl_port = 0, rmt_port = 0, fib_index = 0; + u8 is_ip4 = 0; - if (unformat (input, "%U", unformat_stream_session_id, &proto, &lcl, &rmt, - &lcl_port, &rmt_port, &is_ip4)) - { - id_is_set = 1; - } - else + if (!unformat (input, "%U", unformat_stream_session_id, &proto, &lcl, &rmt, + &lcl_port, &rmt_port, &is_ip4)) return 0; - if (!id_is_set) - { - return 0; - } - - s_type = session_type_from_proto_and_ip (proto, is_ip4); if (is_ip4) - s = stream_session_lookup4 (&lcl.ip4, &rmt.ip4, - clib_host_to_net_u16 (lcl_port), - clib_host_to_net_u16 (rmt_port), s_type); + s = session_lookup_safe4 (fib_index, &lcl.ip4, &rmt.ip4, + clib_host_to_net_u16 (lcl_port), + clib_host_to_net_u16 (rmt_port), proto); else - s = stream_session_lookup6 (&lcl.ip6, &rmt.ip6, - clib_host_to_net_u16 (lcl_port), - clib_host_to_net_u16 (rmt_port), s_type); + s = session_lookup_safe6 (fib_index, &lcl.ip6, &rmt.ip6, + clib_host_to_net_u16 (lcl_port), + clib_host_to_net_u16 (rmt_port), proto); if (s) { *result = s; + session_pool_remove_peeker (s->thread_index); return 1; } return 0; @@ -184,36 +168,24 @@ unformat_transport_connection (unformat_input_t * input, va_list * args) transport_connection_t *tc; u8 proto = ~0; ip46_address_t lcl, rmt; - u32 lcl_port = 0, rmt_port = 0; - u8 is_ip4 = 0, s_type = ~0, id_is_set = 0; + u32 lcl_port = 0, rmt_port = 0, fib_index = 0; + u8 is_ip4 = 0; - if (unformat (input, "%U", unformat_stream_session_id, &proto, &lcl, &rmt, - &lcl_port, &rmt_port, &is_ip4)) - { - id_is_set = 1; - } - else + if (!unformat (input, "%U", unformat_stream_session_id, &proto, &lcl, &rmt, + &lcl_port, &rmt_port, &is_ip4)) return 0; - if (!id_is_set) - { - return 0; - } - proto = (proto == (u8) ~ 0) ? suggested_proto : proto; if (proto == (u8) ~ 0) return 0; - s_type = session_type_from_proto_and_ip (proto, is_ip4); if (is_ip4) - tc = stream_session_lookup_transport4 (&lcl.ip4, &rmt.ip4, - clib_host_to_net_u16 (lcl_port), - clib_host_to_net_u16 (rmt_port), - s_type); + tc = session_lookup_connection4 (fib_index, &lcl.ip4, &rmt.ip4, + clib_host_to_net_u16 (lcl_port), + clib_host_to_net_u16 (rmt_port), proto); else - tc = stream_session_lookup_transport6 (&lcl.ip6, &rmt.ip6, - clib_host_to_net_u16 (lcl_port), - clib_host_to_net_u16 (rmt_port), - s_type); + tc = session_lookup_connection6 (fib_index, &lcl.ip6, &rmt.ip6, + clib_host_to_net_u16 (lcl_port), + clib_host_to_net_u16 (rmt_port), proto); if (tc) { @@ -228,10 +200,10 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { session_manager_main_t *smm = &session_manager_main; + u8 *str = 0, one_session = 0, do_listeners = 0, sst, *app_name; int verbose = 0, i; - stream_session_t *pool; - stream_session_t *s; - u8 *str = 0, one_session = 0; + stream_session_t *pool, *s; + u32 transport_proto = ~0; if (!smm->is_enabled) { @@ -244,6 +216,9 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, ; else if (unformat (input, "verbose")) verbose = 1; + else if (unformat (input, "listeners %U", unformat_transport_proto, + &transport_proto)) + do_listeners = 1; else if (unformat (input, "%U", unformat_stream_session, &s)) { one_session = 1; @@ -259,6 +234,27 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, return 0; } + if (do_listeners) + { + sst = session_type_from_proto_and_ip (transport_proto, 1); + vlib_cli_output (vm, "There are %d active %U listeners", + pool_elts (smm->listen_sessions[sst]), + format_transport_proto, transport_proto); + if (verbose) + { + vlib_cli_output (vm, "%-40s%-24s%-10s", "Listener", "App", "S-idx"); + /* *INDENT-OFF* */ + pool_foreach (s, smm->listen_sessions[sst], ({ + app_name = application_name_from_index (s->app_index); + vlib_cli_output (vm, "%U%-25v%-10u", format_stream_session, s, 1, + app_name, s->session_index); + vec_free (app_name); + })); + /* *INDENT-ON* */ + } + return 0; + } + for (i = 0; i < vec_len (smm->sessions); i++) { u32 once_per_pool; @@ -351,7 +347,7 @@ clear_session_command_fn (vlib_main_t * vm, unformat_input_t * input, if (session_index != ~0) { - session = stream_session_get_if_valid (session_index, thread_index); + session = session_get_if_valid (session_index, thread_index); if (!session) return clib_error_return (0, "no session %d on thread %d", session_index, thread_index); @@ -483,19 +479,29 @@ static clib_error_t * session_enable_disable_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { + unformat_input_t _line_input, *line_input = &_line_input; u8 is_en = 1; + clib_error_t *error; - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + if (!unformat_user (input, unformat_line_input, line_input)) + return clib_error_return (0, "expected enable | disable"); + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - if (unformat (input, "enable")) + if (unformat (line_input, "enable")) is_en = 1; - else if (unformat (input, "disable")) + else if (unformat (line_input, "disable")) is_en = 0; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + unformat_free (line_input); + return error; + } } + unformat_free (line_input); return vnet_session_enable_disable (vm, is_en); }