-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,
-};
-
-static void
-vl_api_session_enable_disable_t_handler (vl_api_session_enable_disable_t * mp)
-{
- vl_api_session_enable_disable_reply_t *rmp;
- vlib_main_t *vm = vlib_get_main ();
- int rv = 0;
-
- vnet_session_enable_disable (vm, mp->is_enable);
- REPLY_MACRO (VL_API_SESSION_ENABLE_DISABLE_REPLY);
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_application_attach_t_handler (vl_api_application_attach_t * mp)
-{
- int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0;
- vl_api_application_attach_reply_t *rmp;
- ssvm_private_t *segp, *evt_q_segment;
- vnet_app_attach_args_t _a, *a = &_a;
- vl_api_registration_t *reg;
- u8 fd_flags = 0;
-
- reg = vl_api_client_index_to_registration (mp->client_index);
- if (!reg)
- return;
-
- if (session_main_is_enabled () == 0)
- {
- rv = VNET_API_ERROR_FEATURE_DISABLED;
- goto done;
- }
-
- STATIC_ASSERT (sizeof (u64) * APP_OPTIONS_N_OPTIONS <=
- sizeof (mp->options),
- "Out of options, fix api message definition");
-
- clib_memset (a, 0, sizeof (*a));
- a->api_client_index = mp->client_index;
- a->options = mp->options;
- a->session_cb_vft = &session_mq_cb_vft;
- if (mp->namespace_id_len > 64)
- {
- rv = VNET_API_ERROR_INVALID_VALUE;
- goto done;
- }
-
- if (mp->namespace_id_len)
- {
- vec_validate (a->namespace_id, mp->namespace_id_len - 1);
- clib_memcpy_fast (a->namespace_id, mp->namespace_id,
- mp->namespace_id_len);
- }
-
- if ((rv = vnet_application_attach (a)))
- {
- clib_warning ("attach returned: %d", rv);
- vec_free (a->namespace_id);
- goto done;
- }
- vec_free (a->namespace_id);
-
- /* Send event queues segment */
- if ((evt_q_segment = session_main_get_evt_q_segment ()))
- {
- fd_flags |= SESSION_FD_F_VPP_MQ_SEGMENT;
- fds[n_fds] = evt_q_segment->fd;
- n_fds += 1;
- }
- /* Send fifo segment fd if needed */
- if (ssvm_type (a->segment) == SSVM_SEGMENT_MEMFD)
- {
- fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
- fds[n_fds] = a->segment->fd;
- n_fds += 1;
- }
- if (a->options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD)
- {
- fd_flags |= SESSION_FD_F_MQ_EVENTFD;
- fds[n_fds] = svm_msg_q_get_producer_eventfd (a->app_evt_q);
- n_fds += 1;
- }
-
-done:
-
- /* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_APPLICATION_ATTACH_REPLY, ({
- if (!rv)
- {
- segp = a->segment;
- rmp->app_index = clib_host_to_net_u32 (a->app_index);
- rmp->segment_name_length = 0;
- rmp->segment_size = segp->ssvm_size;
- if (vec_len (segp->name))
- {
- memcpy (rmp->segment_name, segp->name, vec_len (segp->name));
- rmp->segment_name_length = vec_len (segp->name);
- }
- rmp->app_event_queue_address = pointer_to_uword (a->app_evt_q);
- rmp->n_fds = n_fds;
- rmp->fd_flags = fd_flags;
- rmp->segment_handle = clib_host_to_net_u64 (a->segment_handle);
- }
- }));
- /* *INDENT-ON* */
-
- if (n_fds)
- session_send_fds (reg, fds, n_fds);
-}
-
-static void
-vl_api_app_attach_t_handler (vl_api_app_attach_t * mp)
-{
- int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0;
- vl_api_app_attach_reply_t *rmp;
- ssvm_private_t *segp, *evt_q_segment;
- vnet_app_attach_args_t _a, *a = &_a;
- u8 fd_flags = 0, ctrl_thread;
- vl_api_registration_t *reg;
- svm_msg_q_t *ctrl_mq;
-
- reg = vl_api_client_index_to_registration (mp->client_index);
- if (!reg)
- return;
-
- if (session_main_is_enabled () == 0)
- {
- rv = VNET_API_ERROR_FEATURE_DISABLED;
- goto done;
- }
-
- STATIC_ASSERT (sizeof (u64) * APP_OPTIONS_N_OPTIONS <=
- sizeof (mp->options),
- "Out of options, fix api message definition");
-
- clib_memset (a, 0, sizeof (*a));
- a->api_client_index = mp->client_index;
- a->options = mp->options;
- a->session_cb_vft = &session_mq_cb_vft;
- if (mp->namespace_id_len > 64)
- {
- rv = VNET_API_ERROR_INVALID_VALUE;
- goto done;
- }
-
- if (mp->namespace_id_len)
- {
- vec_validate (a->namespace_id, mp->namespace_id_len - 1);
- clib_memcpy_fast (a->namespace_id, mp->namespace_id,
- mp->namespace_id_len);
- }
-
- if ((rv = vnet_application_attach (a)))
- {
- clib_warning ("attach returned: %d", rv);
- vec_free (a->namespace_id);
- goto done;
- }
- vec_free (a->namespace_id);
-
- /* Send event queues segment */
- if ((evt_q_segment = session_main_get_evt_q_segment ()))
- {
- fd_flags |= SESSION_FD_F_VPP_MQ_SEGMENT;
- fds[n_fds] = evt_q_segment->fd;
- n_fds += 1;
- }
- /* Send fifo segment fd if needed */
- if (ssvm_type (a->segment) == SSVM_SEGMENT_MEMFD)
- {
- fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
- fds[n_fds] = a->segment->fd;
- n_fds += 1;
- }
- if (a->options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD)
- {
- fd_flags |= SESSION_FD_F_MQ_EVENTFD;
- fds[n_fds] = svm_msg_q_get_producer_eventfd (a->app_evt_q);
- n_fds += 1;
- }
-
-done:
- /* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_APP_ATTACH_REPLY, ({
- if (!rv)
- {
- ctrl_thread = vlib_num_workers () ? 1 : 0;
- ctrl_mq = session_main_get_vpp_event_queue (ctrl_thread);
- segp = a->segment;
- rmp->app_index = clib_host_to_net_u32 (a->app_index);
- rmp->app_mq = pointer_to_uword (a->app_evt_q);
- rmp->vpp_ctrl_mq = pointer_to_uword (ctrl_mq);
- rmp->vpp_ctrl_mq_thread = ctrl_thread;
- rmp->n_fds = n_fds;
- rmp->fd_flags = fd_flags;
- if (vec_len (segp->name))
- {
- memcpy (rmp->segment_name, segp->name, vec_len (segp->name));
- rmp->segment_name_length = vec_len (segp->name);
- }
- rmp->segment_size = segp->ssvm_size;
- rmp->segment_handle = clib_host_to_net_u64 (a->segment_handle);
- }
- }));
- /* *INDENT-ON* */
-
- if (n_fds)
- session_send_fds (reg, fds, n_fds);
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_application_detach_t_handler (vl_api_application_detach_t * mp)
-{
- vl_api_application_detach_reply_t *rmp;
- int rv = VNET_API_ERROR_INVALID_VALUE_2;
- vnet_app_detach_args_t _a, *a = &_a;
- application_t *app;
-
- if (session_main_is_enabled () == 0)
- {
- rv = VNET_API_ERROR_FEATURE_DISABLED;
- goto done;
- }
-
- app = application_lookup (mp->client_index);
- if (app)
- {
- a->app_index = app->app_index;
- a->api_client_index = mp->client_index;
- rv = vnet_application_detach (a);
- }
-
-done:
- REPLY_MACRO (VL_API_APPLICATION_DETACH_REPLY);
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_bind_uri_t_handler (vl_api_bind_uri_t * mp)
-{
- vl_api_bind_uri_reply_t *rmp;
- vnet_listen_args_t _a, *a = &_a;
- application_t *app = 0;
- app_worker_t *app_wrk;
- int rv;
-
- if (session_main_is_enabled () == 0)
- {
- rv = VNET_API_ERROR_FEATURE_DISABLED;
- goto done;
- }
-
- app = application_lookup (mp->client_index);
- if (app)
- {
- clib_memset (a, 0, sizeof (*a));
- a->uri = (char *) mp->uri;
- a->app_index = app->app_index;
- rv = vnet_bind_uri (a);
- }
- else
- {
- rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- }
-
-done:
-
- REPLY_MACRO (VL_API_BIND_URI_REPLY);
-
- if (app)
- {
- app_wrk = application_get_worker (app, 0);
- mq_send_session_bound_cb (app_wrk->wrk_index, mp->context, a->handle,
- rv);
- }
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_unbind_uri_t_handler (vl_api_unbind_uri_t * mp)
-{
- vl_api_unbind_uri_reply_t *rmp;
- application_t *app;
- vnet_unlisten_args_t _a, *a = &_a;
- int rv;
-
- if (session_main_is_enabled () == 0)
- {
- rv = VNET_API_ERROR_FEATURE_DISABLED;
- goto done;
- }
-
- app = application_lookup (mp->client_index);
- if (app)
- {
- a->uri = (char *) mp->uri;
- a->app_index = app->app_index;
- a->wrk_map_index = 0;
- rv = vnet_unbind_uri (a);
- }
- else
- {
- rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- }
-
-done:
- REPLY_MACRO (VL_API_UNBIND_URI_REPLY);
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_connect_uri_t_handler (vl_api_connect_uri_t * mp)
-{
- vl_api_connect_uri_reply_t *rmp;
- vnet_connect_args_t _a, *a = &_a;
- application_t *app;
- int rv = 0;
-
- if (session_main_is_enabled () == 0)
- {
- rv = VNET_API_ERROR_FEATURE_DISABLED;
- goto done;
- }
-
- app = application_lookup (mp->client_index);
- if (app)
- {
- clib_memset (a, 0, sizeof (*a));
- a->uri = (char *) mp->uri;
- a->api_context = mp->context;
- a->app_index = app->app_index;
- if ((rv = vnet_connect_uri (a)))
- clib_warning ("connect_uri returned: %d", rv);
- }
- else
- {
- rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- }
-
- /*
- * Don't reply to stream (tcp) connects. The reply will come once
- * the connection is established. In case of the redirects, the reply
- * will come from the server app.
- */
- if (rv == 0)
- return;
-
-done:
- REPLY_MACRO (VL_API_CONNECT_URI_REPLY);
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_disconnect_session_t_handler (vl_api_disconnect_session_t * mp)
-{
- vl_api_disconnect_session_reply_t *rmp;
- vnet_disconnect_args_t _a, *a = &_a;
- application_t *app;
- int rv = 0;
-
- if (session_main_is_enabled () == 0)
- {
- rv = VNET_API_ERROR_FEATURE_DISABLED;
- goto done;
- }
-
- app = application_lookup (mp->client_index);
- if (app)
- {
- a->handle = mp->handle;
- a->app_index = app->app_index;
- rv = vnet_disconnect_session (a);
- }
- else
- {
- rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- }
-
-done:
- REPLY_MACRO2 (VL_API_DISCONNECT_SESSION_REPLY, rmp->handle = mp->handle);
-}
-
-/* ### WILL BE DEPRECATED POST 20.01 ### */
-static void
-vl_api_disconnect_session_reply_t_handler (vl_api_disconnect_session_reply_t *
- mp)
-{
- vnet_disconnect_args_t _a, *a = &_a;
- application_t *app;
-
- /* Client objected to disconnecting the session, log and continue */
- if (mp->retval)
- {
- clib_warning ("client retval %d", mp->retval);
- return;
- }
-
- /* Disconnect has been confirmed. Confirm close to transport */
- app = application_lookup (mp->context);
- if (app)
- {
- a->handle = mp->handle;
- a->app_index = app->app_index;
- vnet_disconnect_session (a);
- }
-}
-
-static void
-vl_api_map_another_segment_reply_t_handler (vl_api_map_another_segment_reply_t
- * mp)