From 7bf6ed662630a26d164affdf8eb77fd2d72c8973 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Wed, 23 Sep 2020 12:02:08 -0700 Subject: session tcp udp tls quic: improve cli formatting Type: improvement Signed-off-by: Florin Coras Change-Id: Iae5dbb8aaaf82d8e95c2ee8bbbe6844c9dd49f80 --- src/vnet/session/application_local.c | 8 ++++---- src/vnet/session/session_cli.c | 7 +++++-- src/vnet/session/session_types.h | 3 +++ src/vnet/tcp/tcp.c | 5 +++-- src/vnet/tcp/tcp_cli.c | 5 +++-- src/vnet/tls/tls.c | 9 +++++---- src/vnet/udp/udp_cli.c | 5 +++-- 7 files changed, 26 insertions(+), 16 deletions(-) (limited to 'src/vnet') diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c index 814350018bb..beca5dbe689 100644 --- a/src/vnet/session/application_local.c +++ b/src/vnet/session/application_local.c @@ -516,9 +516,9 @@ format_ct_listener (u8 * s, va_list * args) u32 __clib_unused thread_index = va_arg (*args, u32); u32 __clib_unused verbose = va_arg (*args, u32); ct_connection_t *ct = ct_connection_get (tc_index); - s = format (s, "%-50U", format_ct_connection_id, ct); + s = format (s, "%-" SESSION_CLI_ID_LEN "U", format_ct_connection_id, ct); if (verbose) - s = format (s, "%-15s", "LISTEN"); + s = format (s, "%-" SESSION_CLI_STATE_LEN "s", "LISTEN"); return s; } @@ -530,10 +530,10 @@ format_ct_connection (u8 * s, va_list * args) if (!ct) return s; - s = format (s, "%-50U", format_ct_connection_id, ct); + s = format (s, "%-" SESSION_CLI_ID_LEN "U", format_ct_connection_id, ct); if (verbose) { - s = format (s, "%-15s", "ESTABLISHED"); + s = format (s, "%-" SESSION_CLI_STATE_LEN "s", "ESTABLISHED"); if (verbose > 1) { s = format (s, "\n"); diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c index 9f6d74c031d..ade76ef4e60 100644 --- a/src/vnet/session/session_cli.c +++ b/src/vnet/session/session_cli.c @@ -329,7 +329,8 @@ session_cli_show_all_sessions (vlib_main_t * vm, int verbose) } if (verbose == 1) - vlib_cli_output (vm, "%s%-50s%-15s%-10s%-10s", + vlib_cli_output (vm, "%s%-" SESSION_CLI_ID_LEN "s%-" + SESSION_CLI_STATE_LEN "s%-10s%-10s", thread_index ? "\n" : "", "Connection", "State", "Rx-f", "Tx-f"); @@ -617,7 +618,9 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, if (do_listeners) { sst = session_type_from_proto_and_ip (transport_proto, 1); - vlib_cli_output (vm, "%-50s%-24s", "Listener", "App"); + vlib_cli_output (vm, "%-" SESSION_CLI_ID_LEN "s%-24s", "Listener", + "App"); + /* *INDENT-OFF* */ pool_foreach (s, smm->wrk[0].sessions, ({ if (s->session_state != SESSION_STATE_LISTENING diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h index 8cea29a8642..950066a958d 100644 --- a/src/vnet/session/session_types.h +++ b/src/vnet/session/session_types.h @@ -495,6 +495,9 @@ typedef enum session_error_ #undef _ } session_error_t; +#define SESSION_CLI_ID_LEN "60" +#define SESSION_CLI_STATE_LEN "15" + /* Maintained for compatibility. Will be deprecated */ #define SESSION_ERROR_SEG_CREATE SESSION_E_SEG_CREATE #define SESSION_ERROR_NO_SPACE SESSION_E_SEG_NO_SPACE diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c index a4599c2fd98..0b3aeba0334 100644 --- a/src/vnet/tcp/tcp.c +++ b/src/vnet/tcp/tcp.c @@ -841,9 +841,10 @@ format_tcp_listener_session (u8 * s, va_list * args) u32 __clib_unused thread_index = va_arg (*args, u32); u32 verbose = va_arg (*args, u32); tcp_connection_t *tc = tcp_listener_get (tci); - s = format (s, "%-50U", format_tcp_connection_id, tc); + s = format (s, "%-" SESSION_CLI_ID_LEN "U", format_tcp_connection_id, tc); if (verbose) - s = format (s, "%-15U", format_tcp_state, tc->state); + s = format (s, "%-" SESSION_CLI_STATE_LEN "U", format_tcp_state, + tc->state); return s; } diff --git a/src/vnet/tcp/tcp_cli.c b/src/vnet/tcp/tcp_cli.c index 94ee21f91bc..e2c1396b5fb 100644 --- a/src/vnet/tcp/tcp_cli.c +++ b/src/vnet/tcp/tcp_cli.c @@ -258,10 +258,11 @@ format_tcp_connection (u8 * s, va_list * args) if (!tc) return s; - s = format (s, "%-50U", format_tcp_connection_id, tc); + s = format (s, "%-" SESSION_CLI_ID_LEN "U", format_tcp_connection_id, tc); if (verbose) { - s = format (s, "%-15U", format_tcp_state, tc->state); + s = format (s, "%-" SESSION_CLI_STATE_LEN "U", format_tcp_state, + tc->state); if (verbose > 1) s = format (s, "\n%U", format_tcp_vars, tc); } diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c index 9caa5d78d8c..516cfd76445 100644 --- a/src/vnet/tls/tls.c +++ b/src/vnet/tls/tls.c @@ -816,10 +816,11 @@ format_tls_connection (u8 * s, va_list * args) if (!ctx) return s; - s = format (s, "%-50U", format_tls_ctx, ctx); + s = format (s, "%-" SESSION_CLI_ID_LEN "U", format_tls_ctx, ctx); if (verbose) { - s = format (s, "%-15U", format_tls_ctx_state, ctx); + s = format (s, "%-" SESSION_CLI_STATE_LEN "U", format_tls_ctx_state, + ctx); if (verbose > 1) s = format (s, "\n"); } @@ -834,9 +835,9 @@ format_tls_listener (u8 * s, va_list * args) u32 verbose = va_arg (*args, u32); tls_ctx_t *ctx = tls_listener_ctx_get (tc_index); - s = format (s, "%-50U", format_tls_listener_ctx, ctx); + s = format (s, "%-" SESSION_CLI_ID_LEN "U", format_tls_listener_ctx, ctx); if (verbose) - s = format (s, "%-15U", format_tls_ctx_state, ctx); + s = format (s, "%-" SESSION_CLI_STATE_LEN "U", format_tls_ctx_state, ctx); return s; } diff --git a/src/vnet/udp/udp_cli.c b/src/vnet/udp/udp_cli.c index 89cea689251..09e3a8a3d7f 100644 --- a/src/vnet/udp/udp_cli.c +++ b/src/vnet/udp/udp_cli.c @@ -14,6 +14,7 @@ */ #include +#include u8 * format_udp_connection_id (u8 * s, va_list * args) @@ -78,10 +79,10 @@ format_udp_connection (u8 * s, va_list * args) u32 verbose = va_arg (*args, u32); if (!uc) return s; - s = format (s, "%-50U", format_udp_connection_id, uc); + s = format (s, "%-" SESSION_CLI_ID_LEN "U", format_udp_connection_id, uc); if (verbose) { - s = format (s, "%-15s", + s = format (s, "%-" SESSION_CLI_STATE_LEN "s", (uc->flags & UDP_CONN_F_LISTEN) ? "LISTEN" : "OPENED", uc); if (verbose > 1) s = format (s, "\n%U", format_udp_vars, uc); -- cgit 1.2.3-korg