aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session/session_api.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-03-02 10:47:47 -0800
committerFlorin Coras <fcoras@cisco.com>2019-03-02 15:44:50 -0800
commit6442401c21f880dbfd25d36859f79ddf54b49178 (patch)
tree93912b5311f92999e921509af76af8d2ea4fe78c /src/vnet/session/session_api.c
parenta0dbf9e02871a1a4e985f52d23908f9427a2d83a (diff)
session: remove deprecated binary apis
Change-Id: Ia1a628498fa3b639b6b1508f65c6aea1806f73ec Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/session_api.c')
-rwxr-xr-xsrc/vnet/session/session_api.c345
1 files changed, 12 insertions, 333 deletions
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index c4be556f637..8ee25a9a2ce 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -49,8 +49,6 @@ _(UNBIND_URI, unbind_uri) \
_(CONNECT_URI, connect_uri) \
_(DISCONNECT_SESSION, disconnect_session) \
_(DISCONNECT_SESSION_REPLY, disconnect_session_reply) \
-_(ACCEPT_SESSION_REPLY, accept_session_reply) \
-_(RESET_SESSION_REPLY, reset_session_reply) \
_(BIND_SOCK, bind_sock) \
_(UNBIND_SOCK, unbind_sock) \
_(CONNECT_SOCK, connect_sock) \
@@ -200,189 +198,6 @@ send_app_cut_through_registration_add (u32 api_client_index,
}
static int
-send_session_accept_callback (session_t * s)
-{
- app_worker_t *server_wrk = app_worker_get (s->app_wrk_index);
- vl_api_accept_session_t *mp;
- vl_api_registration_t *reg;
- transport_connection_t *tc;
- session_t *listener;
- svm_msg_q_t *vpp_queue;
- application_t *server;
- app_listener_t *al;
-
- server = application_get (server_wrk->app_index);
- reg =
- vl_mem_api_client_index_to_registration (server_wrk->api_client_index);
- if (!reg)
- {
- clib_warning ("no registration: %u", server_wrk->api_client_index);
- return -1;
- }
-
- mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp));
- clib_memset (mp, 0, sizeof (*mp));
-
- mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_ACCEPT_SESSION);
- mp->context = server_wrk->wrk_index;
- mp->server_rx_fifo = pointer_to_uword (s->rx_fifo);
- mp->server_tx_fifo = pointer_to_uword (s->tx_fifo);
-
- if (session_has_transport (s))
- {
- listener = listen_session_get (s->listener_index);
- al = app_listener_get (server, listener->al_index);
- mp->listener_handle = app_listener_handle (al);
- if (application_is_proxy (server))
- {
- listener =
- app_worker_first_listener (server_wrk, session_get_fib_proto (s),
- session_get_transport_proto (s));
- if (listener)
- mp->listener_handle = listen_session_get_handle (listener);
- }
- vpp_queue = session_main_get_vpp_event_queue (s->thread_index);
- mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
- mp->handle = session_handle (s);
- tc = transport_get_connection (session_get_transport_proto (s),
- s->connection_index, s->thread_index);
- mp->port = tc->rmt_port;
- mp->is_ip4 = tc->is_ip4;
- clib_memcpy_fast (&mp->ip, &tc->rmt_ip, sizeof (tc->rmt_ip));
- }
- else
- {
- ct_connection_t *ct;
- ct = (ct_connection_t *) session_get_transport (s);
- listener = listen_session_get (s->listener_index);
- al = app_listener_get (server, listener->al_index);
- mp->listener_handle = app_listener_handle (al);
- mp->is_ip4 = session_type_is_ip4 (listener->session_type);
- mp->handle = session_handle (s);
- mp->port = ct->c_rmt_port;
- mp->vpp_event_queue_address = ct->client_evt_q;
- mp->server_event_queue_address = ct->server_evt_q;
- }
- vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp);
-
- return 0;
-}
-
-static void
-send_session_disconnect_callback (session_t * s)
-{
- app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
- vl_api_disconnect_session_t *mp;
- vl_api_registration_t *reg;
-
- reg = vl_mem_api_client_index_to_registration (app_wrk->api_client_index);
- if (!reg)
- {
- clib_warning ("no registration: %u", app_wrk->api_client_index);
- return;
- }
-
- mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp));
- clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_DISCONNECT_SESSION);
- mp->handle = session_handle (s);
- mp->context = app_wrk->api_client_index;
- vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp);
-}
-
-static void
-send_session_reset_callback (session_t * s)
-{
- app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
- vl_api_registration_t *reg;
- vl_api_reset_session_t *mp;
-
- reg = vl_mem_api_client_index_to_registration (app_wrk->api_client_index);
- if (!reg)
- {
- clib_warning ("no registration: %u", app_wrk->api_client_index);
- return;
- }
-
- mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp));
- clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_RESET_SESSION);
- mp->handle = session_handle (s);
- vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp);
-}
-
-int
-send_session_connected_callback (u32 app_wrk_index, u32 api_context,
- session_t * s, u8 is_fail)
-{
- vl_api_connect_session_reply_t *mp;
- transport_connection_t *tc;
- vl_api_registration_t *reg;
- svm_msg_q_t *vpp_queue;
- app_worker_t *app_wrk;
-
- app_wrk = app_worker_get (app_wrk_index);
- reg = vl_mem_api_client_index_to_registration (app_wrk->api_client_index);
- if (!reg)
- {
- clib_warning ("no registration: %u", app_wrk->api_client_index);
- return -1;
- }
-
- mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp));
- mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_CONNECT_SESSION_REPLY);
- mp->context = api_context;
-
- if (is_fail)
- goto done;
-
- if (session_has_transport (s))
- {
- tc = session_get_transport (s);
- if (!tc)
- {
- is_fail = 1;
- goto done;
- }
-
- vpp_queue = session_main_get_vpp_event_queue (s->thread_index);
- mp->handle = session_handle (s);
- mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
- clib_memcpy_fast (mp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
- mp->is_ip4 = tc->is_ip4;
- mp->lcl_port = tc->lcl_port;
- mp->server_rx_fifo = pointer_to_uword (s->rx_fifo);
- mp->server_tx_fifo = pointer_to_uword (s->tx_fifo);
- }
- else
- {
- ct_connection_t *ct;
- ct = (ct_connection_t *) session_get_transport (s);
- mp->handle = session_handle (s);
- mp->lcl_port = ct->c_lcl_port;
- mp->vpp_event_queue_address = ct->server_evt_q;
- mp->client_event_queue_address = ct->client_evt_q;
- mp->server_rx_fifo = pointer_to_uword (s->tx_fifo);
- mp->server_tx_fifo = pointer_to_uword (s->rx_fifo);
- }
-
-done:
- mp->retval = is_fail ?
- clib_host_to_net_u32 (VNET_API_ERROR_SESSION_CONNECT) : 0;
- vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp);
- return 0;
-}
-
-static session_cb_vft_t session_cb_vft = {
- .session_accept_callback = send_session_accept_callback,
- .session_disconnect_callback = send_session_disconnect_callback,
- .session_connected_callback = send_session_connected_callback,
- .session_reset_callback = send_session_reset_callback,
- .add_segment_callback = send_add_segment_callback,
- .del_segment_callback = send_del_segment_callback,
-};
-
-static int
mq_try_lock_and_alloc_msg (svm_msg_q_t * app_mq, svm_msg_q_msg_t * msg)
{
int rv;
@@ -737,12 +552,7 @@ vl_api_application_attach_t_handler (vl_api_application_attach_t * mp)
clib_memset (a, 0, sizeof (*a));
a->api_client_index = mp->client_index;
a->options = mp->options;
-
- if (a->options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_USE_MQ_FOR_CTRL_MSGS)
- a->session_cb_vft = &session_mq_cb_vft;
- else
- a->session_cb_vft = &session_cb_vft;
-
+ a->session_cb_vft = &session_mq_cb_vft;
if (mp->namespace_id_len > 64)
{
rv = VNET_API_ERROR_INVALID_VALUE;
@@ -841,12 +651,9 @@ done:
static void
vl_api_bind_uri_t_handler (vl_api_bind_uri_t * mp)
{
- transport_connection_t *tc = 0;
- vnet_listen_args_t _a, *a = &_a;
vl_api_bind_uri_reply_t *rmp;
- session_t *s;
+ vnet_listen_args_t _a, *a = &_a;
application_t *app = 0;
- svm_msg_q_t *vpp_evt_q;
app_worker_t *app_wrk;
int rv;
@@ -871,33 +678,9 @@ vl_api_bind_uri_t_handler (vl_api_bind_uri_t * mp)
done:
- /* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_BIND_URI_REPLY, ({
- if (!rv)
- {
- rmp->handle = a->handle;
- if (app && application_has_global_scope (app))
- {
- app_listener_t* al = app_listener_get_w_handle(a->handle);
- s = app_listener_get_session(al);
- tc = listen_session_get_transport (s);
- rmp->lcl_is_ip4 = tc->is_ip4;
- rmp->lcl_port = tc->lcl_port;
- clib_memcpy_fast (rmp->lcl_ip, &tc->lcl_ip, sizeof(tc->lcl_ip));
- if (session_transport_service_type (s) == TRANSPORT_SERVICE_CL)
- {
- rmp->rx_fifo = pointer_to_uword (s->rx_fifo);
- rmp->tx_fifo = pointer_to_uword (s->tx_fifo);
- vpp_evt_q = session_main_get_vpp_event_queue (0);
- rmp->vpp_evt_q = pointer_to_uword (vpp_evt_q);
- }
- }
- }
- }));
- /* *INDENT-ON* */
+ REPLY_MACRO (VL_API_BIND_URI_REPLY);
- /* If app uses mq for control messages, send an mq message as well */
- if (app && application_use_mq_for_ctrl (app))
+ if (app)
{
app_wrk = application_get_worker (app, 0);
mq_send_session_bound_cb (app_wrk->wrk_index, mp->context, a->handle,
@@ -938,7 +721,7 @@ done:
static void
vl_api_connect_uri_t_handler (vl_api_connect_uri_t * mp)
{
- vl_api_connect_session_reply_t *rmp;
+ vl_api_connect_uri_reply_t *rmp;
vnet_connect_args_t _a, *a = &_a;
application_t *app;
int rv = 0;
@@ -973,9 +756,7 @@ vl_api_connect_uri_t_handler (vl_api_connect_uri_t * mp)
return;
done:
- /* *INDENT-OFF* */
- REPLY_MACRO (VL_API_CONNECT_SESSION_REPLY);
- /* *INDENT-ON* */
+ REPLY_MACRO (VL_API_CONNECT_URI_REPLY);
}
static void
@@ -1033,81 +814,6 @@ vl_api_disconnect_session_reply_t_handler (vl_api_disconnect_session_reply_t *
}
static void
-vl_api_reset_session_reply_t_handler (vl_api_reset_session_reply_t * mp)
-{
- vnet_disconnect_args_t _a = { 0 }, *a = &_a;
- app_worker_t *app_wrk;
- application_t *app;
- session_t *s;
- u32 index, thread_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)
- {
- clib_warning ("Invalid session!");
- return;
- }
-
- app_wrk = app_worker_get (s->app_wrk_index);
- if (app_wrk->app_index != app->app_index)
- {
- clib_warning ("app %u does not own handle 0x%lx", app->app_index,
- mp->handle);
- return;
- }
-
- /* Client objected to resetting the session, log and continue */
- if (mp->retval)
- {
- clib_warning ("client retval %d", mp->retval);
- return;
- }
-
- /* This comes as a response to a reset, transport only waiting for
- * confirmation to remove connection state, no need to disconnect */
- a->handle = mp->handle;
- a->app_index = app->app_index;
- vnet_disconnect_session (a);
-}
-
-static void
-vl_api_accept_session_reply_t_handler (vl_api_accept_session_reply_t * mp)
-{
- vnet_disconnect_args_t _a = { 0 }, *a = &_a;
- session_t *s;
-
- /* Server isn't interested, kill the session */
- if (mp->retval)
- {
- a->app_index = mp->context;
- a->handle = mp->handle;
- vnet_disconnect_session (a);
- return;
- }
-
- s = session_get_from_handle_if_valid (mp->handle);
- if (!s)
- {
- clib_warning ("session doesn't exist");
- return;
- }
- if (s->app_wrk_index != mp->context)
- {
- clib_warning ("app doesn't own session");
- return;
- }
- s->session_state = SESSION_STATE_READY;
-
- if (!session_has_transport (s))
- ct_session_connect_notify (s);
-}
-
-static void
vl_api_map_another_segment_reply_t_handler (vl_api_map_another_segment_reply_t
* mp)
{
@@ -1118,14 +824,10 @@ static void
vl_api_bind_sock_t_handler (vl_api_bind_sock_t * mp)
{
vnet_listen_args_t _a, *a = &_a;
- transport_connection_t *tc = 0;
vl_api_bind_sock_reply_t *rmp;
- svm_msg_q_t *vpp_evt_q;
application_t *app = 0;
app_worker_t *app_wrk;
ip46_address_t *ip46;
- app_listener_t *al;
- session_t *s;
int rv = 0;
if (session_main_is_enabled () == 0)
@@ -1156,33 +858,10 @@ vl_api_bind_sock_t_handler (vl_api_bind_sock_t * mp)
clib_warning ("listen returned: %d", rv);
done:
- /* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_BIND_SOCK_REPLY,({
- if (!rv)
- {
- rmp->handle = a->handle;
- rmp->lcl_port = mp->port;
- rmp->lcl_is_ip4 = mp->is_ip4;
- if (app && application_has_global_scope (app))
- {
- al = app_listener_get_w_handle (a->handle);
- s = app_listener_get_session (al);
- tc = listen_session_get_transport (s);
- clib_memcpy_fast (rmp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
- if (session_transport_service_type (s) == TRANSPORT_SERVICE_CL)
- {
- rmp->rx_fifo = pointer_to_uword (s->rx_fifo);
- rmp->tx_fifo = pointer_to_uword (s->tx_fifo);
- vpp_evt_q = session_main_get_vpp_event_queue (0);
- rmp->vpp_evt_q = pointer_to_uword (vpp_evt_q);
- }
- }
- }
- }));
- /* *INDENT-ON* */
+ /* Actual reply sent only over mq */
+ REPLY_MACRO (VL_API_BIND_SOCK_REPLY);
- /* If app uses mq for control messages, send an mq message as well */
- if (app && application_use_mq_for_ctrl (app))
+ if (app)
{
app_wrk = application_get_worker (app, mp->wrk_index);
mq_send_session_bound_cb (app_wrk->wrk_index, mp->context, a->handle,
@@ -1250,7 +929,7 @@ done:
static void
vl_api_connect_sock_t_handler (vl_api_connect_sock_t * mp)
{
- vl_api_connect_session_reply_t *rmp;
+ vl_api_connect_sock_reply_t *rmp;
vnet_connect_args_t _a, *a = &_a;
application_t *app = 0;
int rv = 0;
@@ -1300,9 +979,9 @@ vl_api_connect_sock_t_handler (vl_api_connect_sock_t * mp)
/* Got some error, relay it */
done:
- REPLY_MACRO (VL_API_CONNECT_SESSION_REPLY);
+ REPLY_MACRO (VL_API_CONNECT_SOCK_REPLY);
- if (app && application_use_mq_for_ctrl (app))
+ if (app)
{
app_worker_t *app_wrk = application_get_worker (app, mp->wrk_index);
mq_send_session_connected_cb (app_wrk->wrk_index, mp->context, 0, 1);