aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat44_cli.c
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2020-05-04 09:56:58 +0000
committerOle Trøan <otroan@employees.org>2020-05-13 11:39:30 +0000
commita3a830484fa6b6487f7f3d991a52cb6b090a8be8 (patch)
tree3b833401c46da712228b0c1194b9f6c3b80b0ffa /src/plugins/nat/nat44_cli.c
parentbc752e432ff3e252f6e1a3f0372c9532f14909cd (diff)
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 <ksekera@cisco.com> Change-Id: I5e54b2aab73b23911d6518d42e8c3f166c69a38c
Diffstat (limited to 'src/plugins/nat/nat44_cli.c')
-rw-r--r--src/plugins/nat/nat44_cli.c33
1 files changed, 29 insertions, 4 deletions
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);