summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat44
diff options
context:
space:
mode:
authorFilip Varga <fivarga@cisco.com>2020-02-06 15:25:27 +0100
committerOle Trøan <otroan@employees.org>2020-02-07 07:37:05 +0000
commitedf777272b211de3d54f5dc7b211ee84cdb31373 (patch)
treeac18fd5190adb5d7090fdae80a9a296f048d8d80 /src/plugins/nat/nat44
parentb71ef86c7429e81921997e54a526bf666a2e4089 (diff)
nat: api & cli command for forcing session cleanup
Ticket: VPP-1836 Type: feature Signed-off-by: Filip Varga <fivarga@cisco.com> Change-Id: I8f7fc011bac435445a8916a4948d130ca9162f67
Diffstat (limited to 'src/plugins/nat/nat44')
-rw-r--r--src/plugins/nat/nat44/inlines.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/plugins/nat/nat44/inlines.h b/src/plugins/nat/nat44/inlines.h
index a7bb469b464..d7c355490cc 100644
--- a/src/plugins/nat/nat44/inlines.h
+++ b/src/plugins/nat/nat44/inlines.h
@@ -108,6 +108,43 @@ nat44_session_try_cleanup (ip4_address_t * addr,
thread_index, now);
}
+static_always_inline void
+nat44_force_session_cleanup (void)
+{
+ snat_user_t *u = 0;
+
+ snat_main_t *sm = &snat_main;
+ snat_main_per_thread_data_t *tsm;
+
+ vlib_main_t *vm = vlib_get_main ();
+ f64 now = vlib_time_now (vm);
+
+ // TODO: consider own timeouts
+
+ if (sm->num_workers > 1)
+ {
+ /* *INDENT-OFF* */
+ vec_foreach (tsm, sm->per_thread_data)
+ {
+ pool_foreach (u, tsm->users,
+ ({
+ nat44_user_try_cleanup (u, tsm->thread_index, now);
+ }));
+ }
+ /* *INDENT-ON* */
+ }
+ else
+ {
+ tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers);
+ /* *INDENT-OFF* */
+ pool_foreach (u, tsm->users,
+ ({
+ nat44_user_try_cleanup (u, tsm->thread_index, now);
+ }));
+ /* *INDENT-ON* */
+ }
+}
+
#endif /* included_nat44_inlines_h__ */
/*