aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-12-14 11:28:43 -0800
committerDamjan Marion <dmarion@me.com>2018-12-17 08:47:39 +0000
commit3c7d4f9e1f54ec6627795b64525f182e2cda7490 (patch)
tree8d9ca4efe66a2f8f7cf56a3fe9c9d3b92561b26f /src/vnet/session
parent7bb27caf62f5fa942be68015aeb0543566d22371 (diff)
vcl/session: handle reset/disconnect before app accept
Also further improves reset handling. Change-Id: I6e517632f700f181761726b965134e0c217eb06d Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application_interface.h1
-rw-r--r--src/vnet/session/session.c6
-rw-r--r--src/vnet/session/session_node.c22
3 files changed, 18 insertions, 11 deletions
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h
index dfb45a78fc9..a156c82a745 100644
--- a/src/vnet/session/application_interface.h
+++ b/src/vnet/session/application_interface.h
@@ -297,7 +297,6 @@ typedef struct session_reset_msg_
typedef struct session_reset_reply_msg_
{
- u32 client_index;
u32 context;
i32 retval;
u64 handle;
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 6533303d0c6..7f9a32f46de 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -836,6 +836,9 @@ stream_session_reset_notify (transport_connection_t * tc)
application_t *app;
s = session_get (tc->s_index, tc->thread_index);
svm_fifo_dequeue_drop_all (s->server_tx_fifo);
+ if (s->session_state >= SESSION_STATE_TRANSPORT_CLOSING)
+ return;
+ s->session_state = SESSION_STATE_TRANSPORT_CLOSING;
app_wrk = app_worker_get (s->app_wrk_index);
app = application_get (app_wrk->app_index);
app->cb_fns.session_reset_callback (s);
@@ -1204,11 +1207,10 @@ session_vpp_event_queues_allocate (session_manager_main_t * smm)
for (i = 0; i < vec_len (smm->wrk); i++)
{
svm_msg_q_cfg_t _cfg, *cfg = &_cfg;
- u32 notif_q_size = clib_max (16, evt_q_length >> 4);
svm_msg_q_ring_cfg_t rc[SESSION_MQ_N_RINGS] = {
{evt_q_length, evt_size, 0}
,
- {notif_q_size, 256, 0}
+ {evt_q_length << 1, 256, 0}
};
cfg->consumer_pid = 0;
cfg->n_rings = 2;
diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c
index f4e0eaa993e..eb9026c6457 100644
--- a/src/vnet/session/session_node.c
+++ b/src/vnet/session/session_node.c
@@ -66,7 +66,7 @@ session_mq_accepted_reply_handler (void *data)
s = session_get_from_handle_if_valid (mp->handle);
if (!s)
{
- clib_warning ("session doesn't exist");
+ clib_warning ("session 0x%llx doesn't exist", mp->handle);
return;
}
app_wrk = app_worker_get (s->app_wrk_index);
@@ -92,17 +92,17 @@ session_mq_reset_reply_handler (void *data)
u32 index, thread_index;
mp = (session_reset_reply_msg_t *) data;
- app = application_lookup (mp->client_index);
+ app = application_lookup (mp->context);
if (!app)
return;
session_parse_handle (mp->handle, &index, &thread_index);
s = session_get_if_valid (index, thread_index);
- if (!s)
- {
- SESSION_DBG ("Invalid session!");
- return;
- }
+
+ /* Session was already closed or already cleaned up */
+ if (!s || s->session_state != SESSION_STATE_TRANSPORT_CLOSING)
+ return;
+
app_wrk = app_worker_get (s->app_wrk_index);
if (!app_wrk || app_wrk->app_index != app->app_index)
{
@@ -811,6 +811,9 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
{
vec_add2 (fifo_events, e, 1);
svm_msg_q_sub_w_lock (mq, msg);
+ /* Works because reply messages are smaller than a session evt.
+ * If we ever need to support bigger messages this needs to be
+ * fixed */
clib_memcpy_fast (e, svm_msg_q_msg_data (mq, msg), sizeof (*e));
svm_msg_q_free_msg (mq, msg);
}
@@ -875,7 +878,10 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
case FIFO_EVENT_DISCONNECT:
/* Make sure stream disconnects run after the pending list is
* drained */
- s = session_get_from_handle (e->session_handle);
+ s = session_get_from_handle_if_valid (e->session_handle);
+ if (PREDICT_FALSE (!s))
+ break;
+
if (!e->postponed)
{
e->postponed = 1;