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))
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;
/* 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;
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);
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;
/*
* 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;
}
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;
{
.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* */
};
/* *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
*
u8 next, error;
} tcp_lookup_dispatch_t;
+#define foreach_tcp_wrk_stat \
+ _(timer_expirations, u64, "timer expirations") \
+ _(rxt_segs, u64, "segments retransmitted") \
+ _(tr_events, u32, "timer retransmit events") \
+ _(to_closewait, u32, "timeout close-wait") \
+ _(to_finwait1, u32, "timeout fin-wait-1") \
+ _(to_lastack, u32, "timeout last-ack") \
+ _(to_closing, u32, "timeout closing") \
+ _(tr_abort, u32, "timer retransmit abort") \
+ _(rst_unread, u32, "reset on close due to unread data") \
+
+typedef struct tcp_wrk_stats_
+{
+#define _(name, type, str) type name;
+ foreach_tcp_wrk_stat
+#undef _
+} tcp_wrk_stats_t;
+
typedef struct tcp_worker_ctx_
{
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
/** worker timer wheel */
tw_timer_wheel_16t_2w_512sl_t timer_wheel;
+ CLIB_CACHE_LINE_ALIGN_MARK (cacheline2);
+
+ tcp_wrk_stats_t stats;
} tcp_worker_ctx_t;
+#define tcp_worker_stats_inc(_ti,_stat,_val) \
+ tcp_main.wrk_ctx[_ti].stats._stat += _val
+
+#define tcp_workerp_stats_inc(_wrk,_stat,_val) \
+ _wrk->stats._stat += _val
+
typedef struct tcp_iss_seed_
{
u64 first;