aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat.h
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2018-05-10 22:48:53 -0700
committerOle Trøan <otroan@employees.org>2018-05-14 07:41:51 +0000
commit17e5cfbe8d9b1f47b18eb1a43976fe322e3987a2 (patch)
tree7e845966df3e1a654e8a303e9645d3fa85b13839 /src/plugins/nat/nat.h
parent2be45813c757137000878dc711dd169fc2d414af (diff)
NAT44: delete closed TCP session (VPP-1274)
Change-Id: Id25b447bddccb7b321123e4abc4134e7261a0807 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat.h')
-rw-r--r--src/plugins/nat/nat.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/nat/nat.h b/src/plugins/nat/nat.h
index 61d26b2076c..78b7962b83e 100644
--- a/src/plugins/nat/nat.h
+++ b/src/plugins/nat/nat.h
@@ -687,6 +687,33 @@ user_session_increment(snat_main_t *sm, snat_user_t *u, u8 is_static)
}
always_inline void
+nat44_delete_session(snat_main_t * sm, snat_session_t * ses, u32 thread_index)
+{
+ snat_main_per_thread_data_t *tsm = vec_elt_at_index (sm->per_thread_data,
+ thread_index);
+ clib_bihash_kv_8_8_t kv, value;
+ snat_user_key_t u_key;
+ snat_user_t *u;
+ u_key.addr = ses->in2out.addr;
+ u_key.fib_index = ses->in2out.fib_index;
+ kv.key = u_key.as_u64;
+ if (!clib_bihash_search_8_8 (&tsm->user_hash, &kv, &value))
+ {
+ u = pool_elt_at_index (tsm->users, value.value);
+ if (snat_is_session_static(ses))
+ u->nstaticsessions--;
+ else
+ u->nsessions--;
+ }
+ clib_dlist_remove (tsm->list_pool, ses->per_user_index);
+ pool_put_index (tsm->list_pool, ses->per_user_index);
+ pool_put (tsm->sessions, ses);
+}
+
+/** \brief Set TCP session stet.
+ @return 1 if session was closed, otherwise 0
+*/
+always_inline int
nat44_set_tcp_session_state(snat_main_t * sm, snat_session_t * ses,
tcp_header_t * tcp, u32 thread_index)
{
@@ -704,7 +731,11 @@ nat44_set_tcp_session_state(snat_main_t * sm, snat_session_t * ses,
{
nat_free_session_data (sm, ses, thread_index);
ses->state = SNAT_SESSION_TCP_CLOSED;
+ nat44_delete_session (sm, ses, thread_index);
+ return 1;
}
+
+ return 0;
}
#endif /* __included_snat_h__ */