X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvcl%2Fvcl_bapi.c;h=5b9a9d5d3ce85d37a328b17daeb64d82e2ef54b9;hb=30e79c2e388a98160a3660f4f03103890c9b1b7c;hp=c6e7fdf369dbec5c5782ca60eed9be9502e671ca;hpb=d85de68ec3f72888099172fffd45a90a43018155;p=vpp.git diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c index c6e7fdf369d..5b9a9d5d3ce 100644 --- a/src/vcl/vcl_bapi.c +++ b/src/vcl/vcl_bapi.c @@ -75,7 +75,7 @@ vcl_segment_attach (u64 segment_handle, char *name, ssvm_segment_type_t type, if (type == SSVM_SEGMENT_MEMFD) a->memfd_fd = fd; - if ((rv = svm_fifo_segment_attach (a))) + if ((rv = svm_fifo_segment_attach (&vcm->segment_main, a))) { clib_warning ("svm_fifo_segment_attach ('%s') failed", name); return rv; @@ -88,15 +88,17 @@ vcl_segment_attach (u64 segment_handle, char *name, ssvm_segment_type_t type, static void vcl_segment_detach (u64 segment_handle) { + svm_fifo_segment_main_t *sm = &vcm->segment_main; svm_fifo_segment_private_t *segment; u32 segment_index; segment_index = vcl_segment_table_lookup (segment_handle); if (segment_index == (u32) ~ 0) return; - segment = svm_fifo_segment_get_segment (segment_index); - svm_fifo_segment_delete (segment); + segment = svm_fifo_segment_get_segment (sm, segment_index); + svm_fifo_segment_delete (sm, segment); vcl_segment_table_del (segment_handle); + VDBG (0, "detached segment %u handle %u", segment_index, segment_handle); } static u64 @@ -181,13 +183,16 @@ vl_api_app_worker_add_del_reply_t_handler (vl_api_app_worker_add_del_reply_t * format_api_error, ntohl (mp->retval)); goto failed; } - wrk_index = mp->context; - wrk = vcl_worker_get (wrk_index); - wrk->vpp_wrk_index = clib_net_to_host_u32 (mp->wrk_index); if (!mp->is_add) return; + wrk_index = mp->context; + wrk = vcl_worker_get_if_valid (wrk_index); + if (!wrk) + return; + + wrk->vpp_wrk_index = clib_net_to_host_u32 (mp->wrk_index); wrk->app_event_queue = uword_to_pointer (mp->app_event_queue_address, svm_msg_q_t *); @@ -195,7 +200,7 @@ vl_api_app_worker_add_del_reply_t_handler (vl_api_app_worker_add_del_reply_t * if (segment_handle == VCL_INVALID_SEGMENT_HANDLE) { clib_warning ("invalid segment handle"); - return; + goto failed; } if (mp->n_fds) @@ -204,9 +209,9 @@ vl_api_app_worker_add_del_reply_t_handler (vl_api_app_worker_add_del_reply_t * vl_socket_client_recv_fd_msg (fds, mp->n_fds, 5); if (mp->fd_flags & SESSION_FD_F_VPP_MQ_SEGMENT) - if (vcl_segment_attach - (vcl_vpp_worker_segment_handle (wrk->wrk_index), "vpp-worker-seg", - SSVM_SEGMENT_MEMFD, fds[n_fds++])) + if (vcl_segment_attach (vcl_vpp_worker_segment_handle (wrk_index), + "vpp-worker-seg", SSVM_SEGMENT_MEMFD, + fds[n_fds++])) goto failed; if (mp->fd_flags & SESSION_FD_F_MEMFD_SEGMENT) @@ -327,7 +332,7 @@ static void vl_api_bind_sock_reply_t_handler (vl_api_bind_sock_reply_t * mp) { /* Expecting a similar message on mq. So ignore this */ - VDBG (1, "VCL<%d>: bapi msg vpp handle 0x%llx, sid %u: bind retval: %u!", + VDBG (0, "bapi msg vpp handle 0x%llx, sid %u: bind retval: %u!", getpid (), mp->handle, mp->context, mp->retval); } @@ -362,6 +367,31 @@ vl_api_connect_session_reply_t_handler (vl_api_connect_sock_reply_t * mp) ntohl (mp->retval)); } +static void + vl_api_application_tls_cert_add_reply_t_handler + (vl_api_application_tls_cert_add_reply_t * mp) +{ + if (mp->retval) + { + clib_warning ("VCL<%d>: add cert failed: %U", getpid (), + format_api_error, ntohl (mp->retval)); + return; + } +} + +static void + vl_api_application_tls_key_add_reply_t_handler + (vl_api_application_tls_key_add_reply_t * mp) +{ + if (mp->retval) + { + clib_warning ("VCL<%d>: add key failed: %U", getpid (), + format_api_error, ntohl (mp->retval)); + return; + } + +} + #define foreach_sock_msg \ _(SESSION_ENABLE_DISABLE_REPLY, session_enable_disable_reply) \ _(BIND_SOCK_REPLY, bind_sock_reply) \ @@ -370,6 +400,8 @@ _(CONNECT_SESSION_REPLY, connect_session_reply) \ _(DISCONNECT_SESSION_REPLY, disconnect_session_reply) \ _(APPLICATION_ATTACH_REPLY, application_attach_reply) \ _(APPLICATION_DETACH_REPLY, application_detach_reply) \ +_(APPLICATION_TLS_CERT_ADD_REPLY, application_tls_cert_add_reply) \ +_(APPLICATION_TLS_KEY_ADD_REPLY, application_tls_key_add_reply) \ _(MAP_ANOTHER_SEGMENT, map_another_segment) \ _(UNMAP_SEGMENT, unmap_segment) \ _(APP_CUT_THROUGH_REGISTRATION_ADD, app_cut_through_registration_add) \ @@ -439,6 +471,7 @@ vppcom_app_send_attach (void) bmp->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = vcm->cfg.preallocated_fifo_pairs; bmp->options[APP_OPTIONS_EVT_QUEUE_SIZE] = vcm->cfg.event_queue_size; + bmp->options[APP_OPTIONS_TLS_ENGINE] = TLS_ENGINE_OPENSSL; if (nsid_len) { bmp->namespace_id_len = nsid_len; @@ -467,7 +500,6 @@ vcl_send_app_worker_add_del (u8 is_add) { vcl_worker_t *wrk = vcl_worker_get_current (); vl_api_app_worker_add_del_t *mp; - u32 wrk_index = wrk->wrk_index; mp = vl_msg_api_alloc (sizeof (*mp)); memset (mp, 0, sizeof (*mp)); @@ -475,10 +507,29 @@ vcl_send_app_worker_add_del (u8 is_add) mp->_vl_msg_id = ntohs (VL_API_APP_WORKER_ADD_DEL); mp->client_index = wrk->my_client_index; mp->app_index = clib_host_to_net_u32 (vcm->app_index); - mp->context = wrk_index; + mp->context = wrk->wrk_index; mp->is_add = is_add; if (!is_add) - mp->wrk_index = clib_host_to_net_u32 (wrk_index); + mp->wrk_index = clib_host_to_net_u32 (wrk->vpp_wrk_index); + + vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & mp); +} + +void +vcl_send_child_worker_del (vcl_worker_t * child_wrk) +{ + vcl_worker_t *wrk = vcl_worker_get_current (); + vl_api_app_worker_add_del_t *mp; + + mp = vl_msg_api_alloc (sizeof (*mp)); + memset (mp, 0, sizeof (*mp)); + + mp->_vl_msg_id = ntohs (VL_API_APP_WORKER_ADD_DEL); + mp->client_index = wrk->my_client_index; + mp->app_index = clib_host_to_net_u32 (vcm->app_index); + mp->context = wrk->wrk_index; + mp->is_add = 0; + mp->wrk_index = clib_host_to_net_u32 (child_wrk->vpp_wrk_index); vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & mp); } @@ -559,18 +610,39 @@ vppcom_send_unbind_sock (u64 vpp_handle) } void -vppcom_send_accept_session_reply (u64 handle, u32 context, int retval) +vppcom_send_application_tls_cert_add (vcl_session_t * session, char *cert, + u32 cert_len) { vcl_worker_t *wrk = vcl_worker_get_current (); - vl_api_accept_session_reply_t *rmp; - - rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_ACCEPT_SESSION_REPLY); - rmp->retval = htonl (retval); - rmp->context = context; - rmp->handle = handle; - vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & rmp); + vl_api_application_tls_cert_add_t *cert_mp; + + cert_mp = vl_msg_api_alloc (sizeof (*cert_mp) + cert_len); + clib_memset (cert_mp, 0, sizeof (*cert_mp)); + cert_mp->_vl_msg_id = ntohs (VL_API_APPLICATION_TLS_CERT_ADD); + cert_mp->client_index = wrk->my_client_index; + cert_mp->context = session->session_index; + cert_mp->cert_len = clib_host_to_net_u16 (cert_len); + clib_memcpy_fast (cert_mp->cert, cert, cert_len); + vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & cert_mp); + +} + +void +vppcom_send_application_tls_key_add (vcl_session_t * session, char *key, + u32 key_len) +{ + vcl_worker_t *wrk = vcl_worker_get_current (); + vl_api_application_tls_key_add_t *key_mp; + + key_mp = vl_msg_api_alloc (sizeof (*key_mp) + key_len); + clib_memset (key_mp, 0, sizeof (*key_mp)); + key_mp->_vl_msg_id = ntohs (VL_API_APPLICATION_TLS_KEY_ADD); + key_mp->client_index = wrk->my_client_index; + key_mp->context = session->session_index; + key_mp->key_len = clib_host_to_net_u16 (key_len); + clib_memcpy_fast (key_mp->key, key, key_len); + vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & key_mp); + } u32