summaryrefslogtreecommitdiffstats
path: root/src/vnet/tcp/tcp.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-02-12 07:42:01 +0000
committerDave Barach <openvpp@barachs.net>2020-02-14 12:53:33 +0000
commit5e6305fb02ccdfd38c8c5e369a960deaa7602eba (patch)
tree87b1f93d572ae3c5b5a57a9382850751e608576a /src/vnet/tcp/tcp.c
parente84e9d708e0a7571bc24ae2f443462ed8cddbb84 (diff)
tcp: minimal set of worker stats
Type: feature Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I9dafe564229095d50285276a654f4983f93faff2
Diffstat (limited to 'src/vnet/tcp/tcp.c')
-rw-r--r--src/vnet/tcp/tcp.c90
1 files changed, 84 insertions, 6 deletions
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index ec24082347f..f83f00aa695 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -368,6 +368,7 @@ tcp_connection_close (tcp_connection_t * tc)
tcp_connection_set_state (tc, TCP_STATE_CLOSED);
tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, tcp_cfg.closewait_time);
session_transport_closed_notify (&tc->connection);
+ tcp_worker_stats_inc (tc->c_thread_index, rst_unread, 1);
break;
}
if (!transport_max_tx_dequeue (&tc->connection))
@@ -1376,6 +1377,7 @@ tcp_timer_waitclose_handler (u32 conn_index, u32 thread_index)
if (!(tc->flags & TCP_CONN_FINPNDG))
{
+ clib_warning ("close-wait with fin sent");
tcp_connection_set_state (tc, TCP_STATE_CLOSED);
tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, tcp_cfg.cleanup_time);
break;
@@ -1391,6 +1393,7 @@ tcp_timer_waitclose_handler (u32 conn_index, u32 thread_index)
/* Make sure we don't wait in LAST ACK forever */
tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, tcp_cfg.lastack_time);
+ tcp_worker_stats_inc (thread_index, to_closewait, 1);
/* Don't delete the connection yet */
break;
@@ -1412,13 +1415,21 @@ tcp_timer_waitclose_handler (u32 conn_index, u32 thread_index)
tcp_connection_set_state (tc, TCP_STATE_CLOSED);
tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, tcp_cfg.cleanup_time);
}
+ tcp_worker_stats_inc (thread_index, to_finwait1, 1);
break;
case TCP_STATE_LAST_ACK:
+ tcp_connection_timers_reset (tc);
+ tcp_connection_set_state (tc, TCP_STATE_CLOSED);
+ tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, tcp_cfg.cleanup_time);
+ session_transport_closed_notify (&tc->connection);
+ tcp_worker_stats_inc (thread_index, to_lastack, 1);
+ break;
case TCP_STATE_CLOSING:
tcp_connection_timers_reset (tc);
tcp_connection_set_state (tc, TCP_STATE_CLOSED);
tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, tcp_cfg.cleanup_time);
session_transport_closed_notify (&tc->connection);
+ tcp_worker_stats_inc (thread_index, to_closing, 1);
break;
default:
tcp_connection_del (tc);
@@ -1441,15 +1452,18 @@ static void
tcp_expired_timers_dispatch (u32 * expired_timers)
{
u32 thread_index = vlib_get_thread_index ();
- u32 connection_index, timer_id;
+ u32 connection_index, timer_id, n_expired;
tcp_connection_t *tc;
int i;
+ n_expired = vec_len (expired_timers);
+ tcp_worker_stats_inc (thread_index, timer_expirations, n_expired);
+
/*
* Invalidate all timer handles before dispatching. This avoids dangling
* index references to timer wheel pool entries that have been freed.
*/
- for (i = 0; i < vec_len (expired_timers); i++)
+ for (i = 0; i < n_expired; i++)
{
connection_index = expired_timers[i] & 0x0FFFFFFF;
timer_id = expired_timers[i] >> 28;
@@ -1467,7 +1481,7 @@ tcp_expired_timers_dispatch (u32 * expired_timers)
/*
* Dispatch expired timers
*/
- for (i = 0; i < vec_len (expired_timers); i++)
+ for (i = 0; i < n_expired; i++)
{
connection_index = expired_timers[i] & 0x0FFFFFFF;
timer_id = expired_timers[i] >> 28;
@@ -1964,8 +1978,8 @@ tcp_configure_v6_source_address_range (vlib_main_t * vm,
}
static clib_error_t *
-tcp_src_address (vlib_main_t * vm,
- unformat_input_t * input, vlib_cli_command_t * cmd_arg)
+tcp_src_address_fn (vlib_main_t * vm,
+ unformat_input_t * input, vlib_cli_command_t * cmd_arg)
{
ip4_address_t v4start, v4end;
ip6_address_t v6start, v6end;
@@ -2047,7 +2061,7 @@ VLIB_CLI_COMMAND (tcp_src_address_command, static) =
{
.path = "tcp src-address",
.short_help = "tcp src-address <ip-addr> [- <ip-addr>] add src address range",
- .function = tcp_src_address,
+ .function = tcp_src_address_fn,
};
/* *INDENT-ON* */
@@ -2261,6 +2275,70 @@ VLIB_CLI_COMMAND (show_tcp_punt_command, static) =
};
/* *INDENT-ON* */
+static clib_error_t *
+show_tcp_stats_fn (vlib_main_t * vm, unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ tcp_main_t *tm = vnet_get_tcp_main ();
+ tcp_worker_ctx_t *wrk;
+ u32 thread;
+
+ if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ return clib_error_return (0, "unknown input `%U'", format_unformat_error,
+ input);
+ for (thread = 0; thread < vec_len (tm->wrk_ctx); thread++)
+ {
+ wrk = tcp_get_worker (thread);
+ vlib_cli_output (vm, "Thread %d:\n", thread);
+
+#define _(name,type,str) \
+ if (wrk->stats.name) \
+ vlib_cli_output (vm, " %ld %s", wrk->stats.name, str);
+ foreach_tcp_wrk_stat
+#undef _
+ }
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (show_tcp_stats_command, static) =
+{
+ .path = "show tcp stats",
+ .short_help = "show tcp stats",
+ .function = show_tcp_stats_fn,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+clear_tcp_stats_fn (vlib_main_t * vm, unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ tcp_main_t *tm = vnet_get_tcp_main ();
+ tcp_worker_ctx_t *wrk;
+ u32 thread;
+
+ if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ return clib_error_return (0, "unknown input `%U'", format_unformat_error,
+ input);
+
+ for (thread = 0; thread < vec_len (tm->wrk_ctx); thread++)
+ {
+ wrk = tcp_get_worker (thread);
+ clib_memset (&wrk->stats, 0, sizeof (wrk->stats));
+ }
+
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (clear_tcp_stats_command, static) =
+{
+ .path = "clear tcp stats",
+ .short_help = "clear tcp stats",
+ .function = clear_tcp_stats_fn,
+};
+/* *INDENT-ON* */
+
/*
* fd.io coding-style-patch-verification: ON
*