summaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-10-24 22:18:58 -0700
committerMarco Varlese <marco.varlese@suse.de>2018-10-25 11:35:54 +0000
commitde9a849a18514f0b09bb5f57a73f6a57ee425c76 (patch)
tree54e30a9f89dfa3570ec6d4faa8d5d0c485cf81b1 /src/vnet/session
parentfe7740e6613e065658dd43e4b8a81504ee7bb2ea (diff)
session/tcp: improve cli
Change-Id: I91c9d040fc9b9b63f7109eeaac334c47fb1226cf Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session')
-rwxr-xr-xsrc/vnet/session/session_cli.c37
-rw-r--r--src/vnet/session/transport.c57
-rw-r--r--src/vnet/session/transport.h10
-rw-r--r--src/vnet/session/transport_interface.h2
4 files changed, 82 insertions, 24 deletions
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index 57f3d3ad7f1..6ca090a8508 100755
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -16,7 +16,7 @@
#include <vnet/session/session.h>
u8 *
-format_stream_session_fifos (u8 * s, va_list * args)
+format_session_fifos (u8 * s, va_list * args)
{
stream_session_t *ss = va_arg (*args, stream_session_t *);
int verbose = va_arg (*args, int);
@@ -58,36 +58,34 @@ format_stream_session (u8 * s, va_list * args)
{
stream_session_t *ss = va_arg (*args, stream_session_t *);
int verbose = va_arg (*args, int);
- transport_proto_vft_t *tp_vft;
+ u32 tp = session_get_transport_proto (ss);
u8 *str = 0;
- 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",
+ str = format (0, "%-10u%-10u",
svm_fifo_max_dequeue (ss->server_rx_fifo),
- svm_fifo_max_enqueue (ss->server_tx_fifo),
- session_get_index (ss));
+ svm_fifo_max_dequeue (ss->server_tx_fifo));
if (ss->session_state >= SESSION_STATE_ACCEPTING)
{
- s = format (s, "%U", tp_vft->format_connection, ss->connection_index,
- ss->thread_index, verbose);
+ s = format (s, "%U", format_transport_connection, tp,
+ ss->connection_index, ss->thread_index, verbose);
if (verbose == 1)
s = format (s, "%v", str);
if (verbose > 1)
- s = format (s, "%U", format_stream_session_fifos, ss, verbose);
+ s = format (s, "%U", format_session_fifos, ss, verbose);
}
else if (ss->session_state == SESSION_STATE_LISTENING)
{
- s = format (s, "%-40U%v", tp_vft->format_listener, ss->connection_index,
- str);
+ s = format (s, "%-40U%v", format_transport_listen_connection,
+ tp, ss->connection_index, str);
if (verbose > 1)
- s = format (s, "\n%U", format_stream_session_fifos, ss, verbose);
+ s = format (s, "\n%U", format_session_fifos, ss, verbose);
}
else if (ss->session_state == SESSION_STATE_CONNECTING)
{
- s = format (s, "%-40U%v", tp_vft->format_half_open,
- ss->connection_index, str);
+ s = format (s, "%-40U%v", format_transport_half_open_connection,
+ tp, ss->connection_index, str);
}
else
{
@@ -244,15 +242,15 @@ 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, "%-40s%-24s%-10s", "Listener", "App", "S-idx");
+ vlib_cli_output (vm, "%-40s%-24s", "Listener", "App");
/* *INDENT-OFF* */
pool_foreach (s, smm->sessions[0], ({
if (s->session_state != SESSION_STATE_LISTENING
|| s->session_type != sst)
continue;
app_name = application_name_from_index (s->app_wrk_index);
- vlib_cli_output (vm, "%U%-25v%-10u", format_stream_session, s, 1,
- app_name, s->session_index);
+ vlib_cli_output (vm, "%U%-25v%", format_stream_session, s, 1,
+ app_name);
vec_free (app_name);
}));
/* *INDENT-ON* */
@@ -275,9 +273,8 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
{
if (once_per_pool && verbose == 1)
{
- str = format (str, "%-50s%-15s%-10s%-10s%-10s",
- "Connection", "State", "Rx-f", "Tx-f",
- "S-idx");
+ 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;
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index c333c4161d4..8cbad0d397f 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -93,6 +93,63 @@ format_transport_proto_short (u8 * s, va_list * args)
return s;
}
+u8 *
+format_transport_connection (u8 * s, va_list * args)
+{
+ u32 transport_proto = va_arg (*args, u32);
+ u32 conn_index = va_arg (*args, u32);
+ u32 thread_index = va_arg (*args, u32);
+ u32 verbose = va_arg (*args, u32);
+ transport_proto_vft_t *tp_vft;
+ transport_connection_t *tc;
+ u32 indent;
+
+ tp_vft = transport_protocol_get_vft (transport_proto);
+ if (!tp_vft)
+ return s;
+
+ s = format (s, "%U", tp_vft->format_connection, conn_index, thread_index,
+ verbose);
+ tc = tp_vft->get_connection (conn_index, thread_index);
+ if (tc && transport_connection_is_tx_paced (tc) && verbose > 1)
+ {
+ indent = format_get_indent (s) + 1;
+ s = format (s, "%Upacer: %U\n", format_white_space, indent,
+ format_transport_pacer, &tc->pacer);
+ }
+ return s;
+}
+
+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);
+ return s;
+}
+
+u8 *
+format_transport_half_open_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_half_open, listen_index);
+ return s;
+}
+
uword
unformat_transport_proto (unformat_input_t * input, va_list * args)
{
diff --git a/src/vnet/session/transport.h b/src/vnet/session/transport.h
index 07366692c3e..a4f26a45a6a 100644
--- a/src/vnet/session/transport.h
+++ b/src/vnet/session/transport.h
@@ -20,9 +20,6 @@
#include <vnet/ip/ip.h>
#include <vnet/tcp/tcp_debug.h>
-/*
- * Protocol independent transport properties associated to a session
- */
typedef struct _transport_stats
{
u64 tx_bytes;
@@ -36,6 +33,9 @@ typedef struct _spacer
u64 last_update;
} spacer_t;
+/*
+ * Protocol independent transport properties associated to a session
+ */
typedef struct _transport_connection
{
/** Connection ID */
@@ -116,6 +116,10 @@ typedef enum _transport_proto
u8 *format_transport_proto (u8 * s, va_list * args);
u8 *format_transport_proto_short (u8 * s, va_list * args);
+u8 *format_transport_connection (u8 * s, va_list * args);
+u8 *format_transport_listen_connection (u8 * s, va_list * args);
+u8 *format_transport_half_open_connection (u8 * s, va_list * args);
+
uword unformat_transport_proto (unformat_input_t * input, va_list * args);
#define foreach_transport_connection_fields \
diff --git a/src/vnet/session/transport_interface.h b/src/vnet/session/transport_interface.h
index ec9bd43e30f..a96c5e12d7a 100644
--- a/src/vnet/session/transport_interface.h
+++ b/src/vnet/session/transport_interface.h
@@ -89,7 +89,7 @@ extern transport_proto_vft_t *tp_vfts;
#define transport_proto_foreach(VAR, BODY) \
do { \
for (VAR = 0; VAR < vec_len (tp_vfts); VAR++) \
- if (tp_vfts[VAR].push_header != 0) \
+ if (tp_vfts[VAR].push_header != 0) \
do { BODY; } while (0); \
} while (0)