diff options
author | Florin Coras <fcoras@cisco.com> | 2019-02-01 18:00:05 -0800 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2019-02-02 08:51:12 +0000 |
commit | 3389dd2aaa3a5e68f808cece114ae8fe05edb3cc (patch) | |
tree | f3cb72c8b2950cf315c579d6ffdddfe7eaf8d5c5 /src/vnet | |
parent | 7e0c48e3a941ce874361b442a02624e586db810b (diff) |
session: improve show session cli
Change-Id: If30cea80058752cedcc6ecc38e90bef8732c83d3
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet')
-rwxr-xr-x | src/vnet/session/session_cli.c | 98 | ||||
-rw-r--r-- | src/vnet/session/transport.c | 3 | ||||
-rw-r--r-- | src/vnet/tcp/tcp.c | 6 |
3 files changed, 64 insertions, 43 deletions
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c index 9da7f5b46b8..99baf4431ac 100755 --- a/src/vnet/session/session_cli.c +++ b/src/vnet/session/session_cli.c @@ -61,10 +61,22 @@ format_stream_session (u8 * s, va_list * args) u32 tp = session_get_transport_proto (ss); u8 *str = 0; - if (verbose == 1 && ss->session_state >= SESSION_STATE_ACCEPTING) - str = format (0, "%-10u%-10u", - svm_fifo_max_dequeue (ss->server_rx_fifo), - svm_fifo_max_dequeue (ss->server_tx_fifo)); + if (ss->session_state >= SESSION_STATE_TRANSPORT_CLOSED) + { + s = format (s, "[%u:%u] CLOSED", ss->thread_index, ss->session_index); + return s; + } + + if (verbose == 1) + { + u8 post_accept = ss->session_state >= SESSION_STATE_ACCEPTING; + u8 hasf = post_accept | session_tx_is_dgram (ss); + u32 rxf, txf; + + rxf = hasf ? svm_fifo_max_dequeue (ss->server_rx_fifo) : 0; + txf = hasf ? svm_fifo_max_dequeue (ss->server_tx_fifo) : 0; + str = format (0, "%-10u%-10u", rxf, txf); + } if (ss->session_state >= SESSION_STATE_ACCEPTING) { @@ -77,8 +89,8 @@ format_stream_session (u8 * s, va_list * args) } else if (ss->session_state == SESSION_STATE_LISTENING) { - s = format (s, "%-40U%v", format_transport_listen_connection, - tp, ss->connection_index, str); + s = format (s, "%U%v", format_transport_listen_connection, + tp, ss->connection_index, verbose, str); if (verbose > 1) s = format (s, "\n%U", format_session_fifos, ss, verbose); } @@ -219,7 +231,7 @@ static clib_error_t * show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { - u8 *str = 0, one_session = 0, do_listeners = 0, sst, do_elog = 0; + u8 one_session = 0, do_listeners = 0, sst, do_elog = 0; session_manager_main_t *smm = &session_manager_main; u32 transport_proto = ~0, track_index; stream_session_t *pool, *s; @@ -255,7 +267,7 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, if (one_session) { - str = format (0, "%U", format_stream_session, s, 3); + u8 *str = format (0, "%U", format_stream_session, s, 3); if (do_elog && s->session_state != SESSION_STATE_LISTENING) { elog_main_t *em = &vm->elog_main; @@ -270,13 +282,14 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, dt, track_index); } vlib_cli_output (vm, "%v", str); + vec_free (str); return 0; } if (do_listeners) { sst = session_type_from_proto_and_ip (transport_proto, 1); - vlib_cli_output (vm, "%-40s%-24s", "Listener", "App"); + vlib_cli_output (vm, "%-50s%-24s", "Listener", "App"); /* *INDENT-OFF* */ pool_foreach (s, smm->wrk[0].sessions, ({ if (s->session_state != SESSION_STATE_LISTENING @@ -284,7 +297,7 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, continue; app_wrk = app_worker_get (s->app_wrk_index); app_name = application_name_from_index (app_wrk->app_index); - vlib_cli_output (vm, "%U%-25v%", format_stream_session, s, 1, + vlib_cli_output (vm, "%U%-25v%", format_stream_session, s, 0, app_name); })); /* *INDENT-ON* */ @@ -293,42 +306,46 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, for (i = 0; i < vec_len (smm->wrk); i++) { - u32 once_per_pool; - pool = smm->wrk[i].sessions; + u32 once_per_pool = 1, n_closed = 0; - once_per_pool = 1; + pool = smm->wrk[i].sessions; + if (!pool_elts (pool)) + { + vlib_cli_output (vm, "Thread %d: no sessions", i); + continue; + } - if (pool_elts (pool)) + if (!verbose) { + vlib_cli_output (vm, "Thread %d: %d sessions", i, pool_elts (pool)); + continue; + } - vlib_cli_output (vm, "Thread %d: %d active sessions", - i, pool_elts (pool)); - if (verbose) - { - if (once_per_pool && verbose == 1) - { - str = format (str, "%-50s%-15s%-10s%-10s", - "Connection", "State", "Rx-f", "Tx-f"); - vlib_cli_output (vm, "%v", str); - vec_reset_length (str); - once_per_pool = 0; - } - - /* *INDENT-OFF* */ - pool_foreach (s, pool, - ({ - vec_reset_length (str); - str = format (str, "%U", format_stream_session, s, verbose); - vlib_cli_output (vm, "%v", str); - })); - /* *INDENT-ON* */ - } + if (once_per_pool && verbose == 1) + { + vlib_cli_output (vm, "%s%-50s%-15s%-10s%-10s", i ? "\n" : "", + "Connection", "State", "Rx-f", "Tx-f"); + once_per_pool = 0; } + + /* *INDENT-OFF* */ + pool_foreach (s, pool, ({ + if (s->session_state >= SESSION_STATE_TRANSPORT_CLOSED) + { + n_closed += 1; + continue; + } + vlib_cli_output (vm, "%U", format_stream_session, s, verbose); + })); + /* *INDENT-ON* */ + + if (!n_closed) + vlib_cli_output (vm, "Thread %d: active sessions %u", i, + pool_elts (pool) - n_closed); else - vlib_cli_output (vm, "Thread %d: no active sessions", i); - vec_reset_length (str); + vlib_cli_output (vm, "Thread %d: active sessions %u closed %u", i, + pool_elts (pool) - n_closed, n_closed); } - vec_free (str); return 0; } @@ -337,7 +354,8 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, VLIB_CLI_COMMAND (vlib_cli_show_session_command) = { .path = "show session", - .short_help = "show session [verbose [nnn]]", + .short_help = "show session [verbose [n]] [listeners <proto>] " + "[<session-id> [elog]]", .function = show_session_command_fn, }; /* *INDENT-ON* */ diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c index c2d21bf28f9..0d4ccb549b7 100644 --- a/src/vnet/session/transport.c +++ b/src/vnet/session/transport.c @@ -125,14 +125,13 @@ u8 * format_transport_listen_connection (u8 * s, va_list * args) { u32 transport_proto = va_arg (*args, u32); - u32 listen_index = va_arg (*args, u32); transport_proto_vft_t *tp_vft; tp_vft = transport_protocol_get_vft (transport_proto); if (!tp_vft) return s; - s = format (s, "%U", tp_vft->format_listener, listen_index); + s = (tp_vft->format_listener) (s, args); return s; } diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c index 037abdc652d..99b015ba3d8 100644 --- a/src/vnet/tcp/tcp.c +++ b/src/vnet/tcp/tcp.c @@ -920,8 +920,12 @@ static u8 * format_tcp_listener_session (u8 * s, va_list * args) { u32 tci = va_arg (*args, u32); + u32 verbose = va_arg (*args, u32); tcp_connection_t *tc = tcp_listener_get (tci); - return format (s, "%U", format_tcp_connection_id, tc); + s = format (s, "%-50U", format_tcp_connection_id, tc); + if (verbose) + s = format (s, "%-15U", format_tcp_state, tc->state); + return s; } static u8 * |