diff options
author | Srikanth Akula <srakula@cisco.com> | 2019-11-18 11:49:58 -0800 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2020-02-06 12:19:50 +0000 |
commit | 4b50a8f025053732bc6ad44394f3b83bc854e304 (patch) | |
tree | bd4830b662342f9f313390be48f1f49ce70439ce /src/vnet/session/session.c | |
parent | 2e05c214a50dcb38e9c5f79f80a2102b847cbafc (diff) |
session: extra checks in session validation
Type: fix
Adding few extra checks while doign session validationwq!
Signed-off-by: Srikanth Akula <srakula@cisco.com>
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I4d18b5ad97d1802ce38a07aeb56b5f35939c1187
(cherry picked from commit e140d5d0255b80f8dda945daf7202b5698d81d9b)
Diffstat (limited to 'src/vnet/session/session.c')
-rw-r--r-- | src/vnet/session/session.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c index 47a9ed6480c..16863f03dc4 100644 --- a/src/vnet/session/session.c +++ b/src/vnet/session/session.c @@ -205,6 +205,32 @@ session_free (session_t * s) pool_put (session_main.wrk[s->thread_index].sessions, s); } +u8 +session_is_valid (u32 si, u8 thread_index) +{ + session_t *s; + transport_connection_t *tc; + + s = pool_elt_at_index (session_main.wrk[thread_index].sessions, si); + + if (!s) + return 1; + + if (s->thread_index != thread_index || s->session_index != si) + return 0; + + if (s->session_state == SESSION_STATE_TRANSPORT_DELETED + || s->session_state <= SESSION_STATE_LISTENING) + return 1; + + tc = session_get_transport (s); + if (s->connection_index != tc->c_index + || s->thread_index != tc->thread_index || tc->s_index != si) + return 0; + + return 1; +} + static void session_cleanup_notify (session_t * s, session_cleanup_ntf_t ntf) { |