summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/application_worker.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-05-07 19:39:43 -0700
committerFlorin Coras <florin.coras@gmail.com>2021-05-10 20:53:32 +0000
commitea72764204dac0a1ab6412bc27b758faead2ca10 (patch)
treed22e849e0e0a84b11c42373c1b97fb6b715d3098 /src/vnet/session/application_worker.c
parente2272ac27c31b8cf7ecf0ff8d4244f90034a09f4 (diff)
session: use half-open sessions for vc establishment
Use half-open sessions to track virtual circuit connection establishment. These sesssions can only be allocated and freed by the thread that allocates half-open connections (main). Consequently, they can only be freed on half-open cleanup notifications from transports. Goal is to simplify state tracking within the session layer but it's also a first step towards allowing builtin apps to track and cleanup outstanding connects. Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I8a535906d13eb7f8966deb82333839de80f8049f
Diffstat (limited to 'src/vnet/session/application_worker.c')
-rw-r--r--src/vnet/session/application_worker.c57
1 files changed, 14 insertions, 43 deletions
diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c
index 7e03171b115..13a3edec486 100644
--- a/src/vnet/session/application_worker.c
+++ b/src/vnet/session/application_worker.c
@@ -58,9 +58,10 @@ app_worker_free (app_worker_t * app_wrk)
vnet_unlisten_args_t _a, *a = &_a;
u64 handle, *handles = 0, *sm_indices = 0;
segment_manager_t *sm;
+ session_handle_t *sh;
session_t *ls;
u32 sm_index;
- int i, j;
+ int i;
/*
* Listener cleanup
@@ -110,26 +111,10 @@ app_worker_free (app_worker_t * app_wrk)
* Half-open cleanup
*/
- for (i = 0; i < vec_len (app_wrk->half_open_table); i++)
- {
- if (!app_wrk->half_open_table[i])
- continue;
-
- /* *INDENT-OFF* */
- hash_foreach (handle, sm_index, app_wrk->half_open_table[i], ({
- vec_add1 (handles, handle);
- }));
- /* *INDENT-ON* */
+ pool_foreach (sh, app_wrk->half_open_table)
+ session_cleanup_half_open (*sh);
- for (j = 0; j < vec_len (handles); j++)
- session_cleanup_half_open (i, handles[j]);
-
- hash_free (app_wrk->half_open_table[i]);
- vec_reset_length (handles);
- }
-
- vec_free (app_wrk->half_open_table);
- vec_free (handles);
+ pool_free (app_wrk->half_open_table);
/*
* Detached listener segment managers cleanup
@@ -396,39 +381,25 @@ app_worker_connect_notify (app_worker_t * app_wrk, session_t * s,
}
int
-app_worker_add_half_open (app_worker_t * app_wrk, transport_proto_t tp,
- session_handle_t ho_handle,
- session_handle_t wrk_handle)
+app_worker_add_half_open (app_worker_t *app_wrk, session_handle_t sh)
{
+ session_handle_t *shp;
+
ASSERT (vlib_get_thread_index () == 0);
- vec_validate (app_wrk->half_open_table, tp);
- hash_set (app_wrk->half_open_table[tp], ho_handle, wrk_handle);
- return 0;
+ pool_get (app_wrk->half_open_table, shp);
+ *shp = sh;
+
+ return (shp - app_wrk->half_open_table);
}
int
-app_worker_del_half_open (app_worker_t * app_wrk, transport_proto_t tp,
- session_handle_t ho_handle)
+app_worker_del_half_open (app_worker_t *app_wrk, u32 ho_index)
{
ASSERT (vlib_get_thread_index () == 0);
- hash_unset (app_wrk->half_open_table[tp], ho_handle);
+ pool_put_index (app_wrk->half_open_table, ho_index);
return 0;
}
-u64
-app_worker_lookup_half_open (app_worker_t * app_wrk, transport_proto_t tp,
- session_handle_t ho_handle)
-{
- u64 *ho_wrk_handlep;
-
- /* No locking because all updates are done from main thread */
- ho_wrk_handlep = hash_get (app_wrk->half_open_table[tp], ho_handle);
- if (!ho_wrk_handlep)
- return SESSION_INVALID_HANDLE;
-
- return *ho_wrk_handlep;
-}
-
int
app_worker_close_notify (app_worker_t * app_wrk, session_t * s)
{