aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-02-19 20:57:06 -0800
committerDamjan Marion <dmarion@me.com>2019-02-20 16:26:46 +0000
commit51a423dc2b0d4aad0bbd8f7e757d2ca49221ff83 (patch)
treee29457b7aad9743ae5eaec4c85c199dd86b428ba /src/vnet/session
parent84442eed6d0debaa0597e6e58f21f4b45c40ad7a (diff)
session: fix local sessions disconnects
Change-Id: Ib4ca472aa2413ced7f82d87e4fee65ca86ab1f2b Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application.c19
-rw-r--r--src/vnet/session/application_worker.c24
2 files changed, 21 insertions, 22 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index e79851cab4c..3bf722b81a0 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -1155,7 +1155,9 @@ vnet_disconnect_session (vnet_disconnect_args_t * a)
{
if (session_handle_is_local (a->handle))
{
+ app_worker_t *client_wrk, *server_wrk;
local_session_t *ls;
+ u32 wrk_index = ~0;
/* Disconnect reply came to worker 1 not main thread */
app_interface_check_thread_and_barrier (vnet_disconnect_session, a);
@@ -1163,7 +1165,22 @@ vnet_disconnect_session (vnet_disconnect_args_t * a)
if (!(ls = app_worker_get_local_session_from_handle (a->handle)))
return 0;
- return app_worker_local_session_disconnect (a->app_index, ls);
+ client_wrk = app_worker_get_if_valid (ls->client_wrk_index);
+ server_wrk = app_worker_get (ls->app_wrk_index);
+
+ if (server_wrk->app_index == a->app_index)
+ wrk_index = server_wrk->wrk_index;
+ else if (client_wrk && client_wrk->app_index == a->app_index)
+ wrk_index = client_wrk->wrk_index;
+
+ if (wrk_index == ~0)
+ {
+ clib_warning ("app %u does not own session 0x%lx", a->app_index,
+ application_local_session_handle (ls));
+ return VNET_API_ERROR_INVALID_VALUE;
+ }
+
+ return app_worker_local_session_disconnect (wrk_index, ls);
}
else
{
diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c
index a72856a9407..3bab3564ad9 100644
--- a/src/vnet/session/application_worker.c
+++ b/src/vnet/session/application_worker.c
@@ -362,7 +362,7 @@ app_worker_stop_listen (app_worker_t * app_wrk, app_listener_t * al)
/* *INDENT-OFF* */
pool_foreach (ls, app_wrk->local_sessions, ({
if (ls->listener_index == ll->session_index)
- app_worker_local_session_disconnect (app_wrk->app_index, ls);
+ app_worker_local_session_disconnect (app_wrk->wrk_index, ls);
}));
/* *INDENT-ON* */
}
@@ -966,35 +966,17 @@ app_worker_local_session_connect_notify (local_session_t * ls)
}
int
-app_worker_local_session_disconnect (u32 app_index, local_session_t * ls)
+app_worker_local_session_disconnect (u32 app_wrk_index, local_session_t * ls)
{
app_worker_t *client_wrk, *server_wrk;
- u8 is_server = 0, is_client = 0;
- application_t *app;
-
- app = application_get_if_valid (app_index);
- if (!app)
- return 0;
client_wrk = app_worker_get_if_valid (ls->client_wrk_index);
server_wrk = app_worker_get (ls->app_wrk_index);
- if (server_wrk->app_index == app_index)
- is_server = 1;
- else if (client_wrk && client_wrk->app_index == app_index)
- is_client = 1;
-
- if (!is_server && !is_client)
- {
- clib_warning ("app %u is neither client nor server for session 0x%lx",
- app_index, application_local_session_handle (ls));
- return VNET_API_ERROR_INVALID_VALUE;
- }
-
if (ls->session_state == SESSION_STATE_CLOSED)
return app_worker_local_session_cleanup (client_wrk, server_wrk, ls);
- if (app_index == ls->client_wrk_index)
+ if (app_wrk_index == ls->client_wrk_index)
{
mq_send_local_session_disconnected_cb (ls->app_wrk_index, ls);
}