summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat_affinity.c
diff options
context:
space:
mode:
authorFilip Varga <fivarga@cisco.com>2020-09-30 22:24:47 +0200
committerOle Tr�an <otroan@employees.org>2020-10-23 12:09:07 +0000
commit5f4f2081c47a5d86c9c96b7de23a2b0147c737d8 (patch)
treefd80c764cc3deb527f54d289c12a03d85c563373 /src/plugins/nat/nat_affinity.c
parent498889ae5d36eca5e2c017400b70f71bc5cdaf4a (diff)
nat: nat44 enable/disable dynamic config
This patch changes initialization and configuration of NAT plugin. Instead of allocating data structures at vpp plugin initialization phase allocation and configuration happens after calling enable API or CLI call. This reduces base VPP memory footprint and also enables dynamic reconfiguration of the NAT plugin. Type: improvement Change-Id: I42c069ee19a0311d043ac1f3f230d87bc8d2680f Signed-off-by: Filip Varga <fivarga@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat_affinity.c')
-rw-r--r--src/plugins/nat/nat_affinity.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/plugins/nat/nat_affinity.c b/src/plugins/nat/nat_affinity.c
index 2c22ae0e097..e7a7354c18d 100644
--- a/src/plugins/nat/nat_affinity.c
+++ b/src/plugins/nat/nat_affinity.c
@@ -43,24 +43,37 @@ format_affinity_kvp (u8 * s, va_list * args)
return s;
}
-clib_error_t *
-nat_affinity_init (vlib_main_t * vm)
+void
+nat_affinity_enable ()
{
nat_affinity_main_t *nam = &nat_affinity_main;
vlib_thread_main_t *tm = vlib_get_thread_main ();
- clib_error_t *error = 0;
if (tm->n_vlib_mains > 1)
clib_spinlock_init (&nam->affinity_lock);
-
clib_bihash_init_16_8 (&nam->affinity_hash, "nat-affinity",
AFFINITY_HASH_BUCKETS, AFFINITY_HASH_MEMORY);
clib_bihash_set_kvp_format_fn_16_8 (&nam->affinity_hash,
format_affinity_kvp);
+}
- nam->vlib_main = vm;
+void
+nat_affinity_disable ()
+{
+ nat_affinity_main_t *nam = &nat_affinity_main;
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
- return error;
+ if (tm->n_vlib_mains > 1)
+ clib_spinlock_free (&nam->affinity_lock);
+ clib_bihash_free_16_8 (&nam->affinity_hash);
+}
+
+clib_error_t *
+nat_affinity_init (vlib_main_t * vm)
+{
+ nat_affinity_main_t *nam = &nat_affinity_main;
+ nam->vlib_main = vm;
+ return 0;
}
static_always_inline void