aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-07-31 16:46:24 -0700
committerFlorin Coras <florin.coras@gmail.com>2019-08-01 22:50:09 +0000
commit49568afd2096600f5d6745385d81d873c8893e29 (patch)
tree7b8a43fbb76c9084986157351972b0f4cb251b17 /src/vnet/session
parent4f9446444d0c718886570626d6e7a25d07610f1b (diff)
session: session pool migration notification
Type: feature Change-Id: Ia9a5b1a6d85c7f3f2e6db583b33b5b20029a1e88 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application.h2
-rw-r--r--src/vnet/session/application_interface.h3
-rw-r--r--src/vnet/session/application_worker.c9
-rw-r--r--src/vnet/session/session.c15
-rwxr-xr-xsrc/vnet/session/session_api.c8
-rw-r--r--src/vnet/session/session_types.h6
6 files changed, 43 insertions, 0 deletions
diff --git a/src/vnet/session/application.h b/src/vnet/session/application.h
index 81be238094e..24c6fc3eeaf 100644
--- a/src/vnet/session/application.h
+++ b/src/vnet/session/application.h
@@ -255,6 +255,8 @@ int app_worker_transport_closed_notify (app_worker_t * app_wrk,
int app_worker_reset_notify (app_worker_t * app_wrk, session_t * s);
int app_worker_cleanup_notify (app_worker_t * app_wrk, session_t * s,
session_cleanup_ntf_t ntf);
+int app_worker_migrate_notify (app_worker_t * app_wrk, session_t * s,
+ session_handle_t new_sh);
int app_worker_builtin_rx (app_worker_t * app_wrk, session_t * s);
int app_worker_builtin_tx (app_worker_t * app_wrk, session_t * s);
segment_manager_t *app_worker_get_listen_segment_manager (app_worker_t *,
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h
index 3a1c9b55738..6cc1af4d78b 100644
--- a/src/vnet/session/application_interface.h
+++ b/src/vnet/session/application_interface.h
@@ -48,6 +48,9 @@ typedef struct _stream_session_cb_vft
/** Notify app that session was reset */
void (*session_reset_callback) (session_t * s);
+ /** Notify app that session pool migration happened */
+ void (*session_migrate_callback) (session_t * s, session_handle_t new_sh);
+
/** Direct RX callback for built-in application */
int (*builtin_app_rx_callback) (session_t * session);
diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c
index 0be1a2e85f7..28793681afb 100644
--- a/src/vnet/session/application_worker.c
+++ b/src/vnet/session/application_worker.c
@@ -373,6 +373,15 @@ app_worker_builtin_tx (app_worker_t * app_wrk, session_t * s)
}
int
+app_worker_migrate_notify (app_worker_t * app_wrk, session_t * s,
+ session_handle_t new_sh)
+{
+ application_t *app = application_get (app_wrk->app_index);
+ app->cb_fns.session_migrate_callback (s, new_sh);
+ return 0;
+}
+
+int
app_worker_own_session (app_worker_t * app_wrk, session_t * s)
{
segment_manager_t *sm;
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 318e01dbf54..3d22cc27ef4 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -715,17 +715,32 @@ typedef struct _session_switch_pool_args
u32 new_session_index;
} session_switch_pool_args_t;
+/**
+ * Notify old thread of the session pool switch
+ */
static void
session_switch_pool (void *cb_args)
{
session_switch_pool_args_t *args = (session_switch_pool_args_t *) cb_args;
+ app_worker_t *app_wrk;
session_t *s;
+
ASSERT (args->thread_index == vlib_get_thread_index ());
s = session_get (args->session_index, args->thread_index);
s->tx_fifo->master_session_index = args->new_session_index;
s->tx_fifo->master_thread_index = args->new_thread_index;
transport_cleanup (session_get_transport_proto (s), s->connection_index,
s->thread_index);
+
+ app_wrk = app_worker_get_if_valid (s->app_wrk_index);
+ if (app_wrk)
+ {
+ session_handle_t new_sh;
+ new_sh = session_make_handle (args->new_session_index,
+ args->new_thread_index);
+ app_worker_migrate_notify (app_wrk, s, new_sh);
+ }
+
session_free (s);
clib_mem_free (cb_args);
}
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index 479c5d1ca83..e3e3bb3c596 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -438,11 +438,19 @@ done:
return 0;
}
+static void
+mq_send_session_migrate_cb (session_t * s, session_handle_t new_sh)
+{
+ clib_warning ("not supported");
+}
+
+
static session_cb_vft_t session_mq_cb_vft = {
.session_accept_callback = mq_send_session_accepted_cb,
.session_disconnect_callback = mq_send_session_disconnected_cb,
.session_connected_callback = mq_send_session_connected_cb,
.session_reset_callback = mq_send_session_reset_cb,
+ .session_migrate_callback = mq_send_session_migrate_cb,
.add_segment_callback = send_add_segment_callback,
.del_segment_callback = send_del_segment_callback,
};
diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h
index 9a5bc768808..f9472ba3828 100644
--- a/src/vnet/session/session_types.h
+++ b/src/vnet/session/session_types.h
@@ -275,6 +275,12 @@ session_parse_handle (session_handle_t handle, u32 * index,
*thread_index = session_thread_from_handle (handle);
}
+static inline session_handle_t
+session_make_handle (u32 session_index, u32 thread_index)
+{
+ return (((u64) thread_index << 32) | (u64) session_index);
+}
+
typedef enum
{
SESSION_IO_EVT_RX,