diff options
author | Klement Sekera <ksekera@cisco.com> | 2020-04-05 10:22:47 +0200 |
---|---|---|
committer | Klement Sekera <ksekera@cisco.com> | 2020-04-08 11:07:49 +0200 |
commit | ba5f9bc7534bcf58225b0658993728b1f4d47a67 (patch) | |
tree | a3ca0cea8eea85910e050808c8df37bf802cd393 /src/plugins/nat/nat44/inlines.h | |
parent | 248ce43c6d79b79597e28f19615e83d2bb0a9276 (diff) |
nat: ED: global session LRU list
Maintain a global session LRU allowing reuse of expired session instead
of relying on a scavenging mechanism to periodically walk sessions.
Whenever a new session is being allocated in slow path, also attempt to
free an expired session from global LRU list.
Type: improvement
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I9edde9ec138de67c9a4888e915b0490ec16415fa
Diffstat (limited to 'src/plugins/nat/nat44/inlines.h')
-rw-r--r-- | src/plugins/nat/nat44/inlines.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/nat/nat44/inlines.h b/src/plugins/nat/nat44/inlines.h index fcaf57383ef..631c4cd4104 100644 --- a/src/plugins/nat/nat44/inlines.h +++ b/src/plugins/nat/nat44/inlines.h @@ -89,6 +89,14 @@ nat44_session_alloc_new (snat_main_per_thread_data_t * tsm, snat_user_t * u, s->per_user_list_head_index, per_user_translation_list_elt - tsm->list_pool); + dlist_elt_t *lru_list_elt; + pool_get (tsm->global_lru_pool, lru_list_elt); + s->global_lru_index = lru_list_elt - tsm->global_lru_pool; + clib_dlist_addtail (tsm->global_lru_pool, tsm->global_lru_head_index, + s->global_lru_index); + lru_list_elt->value = s - tsm->sessions; + s->last_lru_update = now; + s->ha_last_refreshed = now; return s; } @@ -207,6 +215,8 @@ nat44_user_session_cleanup (snat_user_t * u, u32 thread_index, f64 now) clib_dlist_remove (tsm->list_pool, s->per_user_index); pool_put_index (tsm->list_pool, s->per_user_index); + clib_dlist_remove (tsm->global_lru_pool, s->global_lru_index); + pool_put_index (tsm->global_lru_pool, s->global_lru_index); pool_put (tsm->sessions, s); vlib_set_simple_counter (&sm->total_sessions, thread_index, 0, pool_elts (tsm->sessions)); |