aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat.h
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2017-09-22 02:43:05 -0700
committerOle Trøan <otroan@employees.org>2017-09-25 07:01:57 +0000
commit41fef50d5db5e7deb3cfd901c3108abbc4406813 (patch)
tree3618d4a8ce87f9b89cedff3624d28b1118a1c218 /src/plugins/nat/nat.h
parentba3c4e88c102afd601fbac0e02de73a28a279a73 (diff)
NAT: session number limitation to avoid running out of memory crash (VPP-984)
Change-Id: I7f18f8c4ba609d96950dc1f833feb967d4a099b7 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat.h')
-rw-r--r--src/plugins/nat/nat.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/nat/nat.h b/src/plugins/nat/nat.h
index 20e45952d55..d34ff07b7fe 100644
--- a/src/plugins/nat/nat.h
+++ b/src/plugins/nat/nat.h
@@ -345,6 +345,7 @@ typedef struct snat_main_s {
u8 deterministic;
u32 translation_buckets;
u32 translation_memory_size;
+ u32 max_translations;
u32 user_buckets;
u32 user_memory_size;
u32 max_translations_per_user;
@@ -551,4 +552,13 @@ is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0,
return 0;
}
+always_inline u8
+maximum_sessions_exceeded (snat_main_t *sm, u32 thread_index)
+{
+ if (pool_elts (sm->per_thread_data[thread_index].sessions) >= sm->max_translations)
+ return 1;
+
+ return 0;
+}
+
#endif /* __included_nat_h__ */