From a3a830484fa6b6487f7f3d991a52cb6b090a8be8 Mon Sep 17 00:00:00 2001 From: Klement Sekera Date: Mon, 4 May 2020 09:56:58 +0000 Subject: nat: fix LRU blocked by inactive session This fixes a situation where long-lived inactive session blocks LRU list. Solution is to have multiple LRU lists based on session type. This helps because session timeout is same for all sessions of same type. Type: fix Signed-off-by: Klement Sekera Change-Id: I5e54b2aab73b23911d6518d42e8c3f166c69a38c --- src/plugins/nat/nat44_cli.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'src/plugins/nat/nat44_cli.c') diff --git a/src/plugins/nat/nat44_cli.c b/src/plugins/nat/nat44_cli.c index 8c800d5c373..796e3495594 100644 --- a/src/plugins/nat/nat44_cli.c +++ b/src/plugins/nat/nat44_cli.c @@ -688,9 +688,9 @@ nat44_show_summary_command_fn (vlib_main_t * vm, unformat_input_t * input, tcp_sessions++; if (s->state) { - if (s->tcp_close_timestamp) + if (s->tcp_closed_timestamp) { - if (now >= s->tcp_close_timestamp) + if (now >= s->tcp_closed_timestamp) { ++transitory_closed; } @@ -734,9 +734,9 @@ nat44_show_summary_command_fn (vlib_main_t * vm, unformat_input_t * input, tcp_sessions++; if (s->state) { - if (s->tcp_close_timestamp) + if (s->tcp_closed_timestamp) { - if (now >= s->tcp_close_timestamp) + if (now >= s->tcp_closed_timestamp) { ++transitory_closed; } @@ -758,6 +758,31 @@ nat44_show_summary_command_fn (vlib_main_t * vm, unformat_input_t * input, })); /* *INDENT-ON* */ count = pool_elts (tsm->sessions); + if (sm->endpoint_dependent) + { + dlist_elt_t *oldest_elt; + u32 oldest_index; +#define _(n, d) \ + oldest_index = \ + clib_dlist_remove_head (tsm->lru_pool, tsm->n##_lru_head_index); \ + if (~0 != oldest_index) \ + { \ + oldest_elt = pool_elt_at_index (tsm->lru_pool, oldest_index); \ + s = pool_elt_at_index (tsm->sessions, oldest_elt->value); \ + sess_timeout_time = \ + s->last_heard + (f64)nat44_session_get_timeout (sm, s); \ + vlib_cli_output (vm, d " LRU min session timeout %llu (now %llu)", \ + sess_timeout_time, now); \ + clib_dlist_addhead (tsm->lru_pool, tsm->n##_lru_head_index, \ + oldest_index); \ + } + _(tcp_estab, "established tcp"); + _(tcp_trans, "transitory tcp"); + _(udp, "udp"); + _(unk_proto, "unknown protocol"); + _(icmp, "icmp"); +#undef _ + } } vlib_cli_output (vm, "total timed out sessions: %u", timed_out); -- cgit 1.2.3-korg