diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2021-07-23 08:51:10 +0000 |
---|---|---|
committer | Filip Tehlar <ftehlar@cisco.com> | 2021-09-28 16:06:19 +0000 |
commit | 36217e3ca8a1ca2e7a341b6b44ffc25e6497191c (patch) | |
tree | ba45e2b144e0d66a69c0502a7823c28239d0bc66 /src/vlibmemory/socket_api.c | |
parent | 3459ece6da90627b161e2128b5926f1e58e7db65 (diff) |
api: API trace improvements
Type: improvement
* add support for JSON format in API trace
* add ability to replay JSON API trace in both VPP and VAT2
* use CRC for backward compatibility check during JSON API replay
* fix API trace CLI (and remove duplicits)
* remove custom dump
* remove vppapitrace.py
* update docs accordingly
Change-Id: I5294f68bebe6cbe738630f457f3a87720e06486b
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/vlibmemory/socket_api.c')
-rw-r--r-- | src/vlibmemory/socket_api.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index 60ca650d92f..ce834a70aac 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -495,7 +495,13 @@ vl_api_sockclnt_create_t_handler (vl_api_sockclnt_create_t * mp) regp = socket_main.current_rp; - ASSERT (regp->registration_type == REGISTRATION_TYPE_SOCKET_SERVER); + /* client already connected through shared memory? */ + if (!regp || regp->registration_type != REGISTRATION_TYPE_SOCKET_SERVER) + { + clib_warning ( + "unsupported API call: already connected though shared memory?"); + return; + } regp->name = format (0, "%s%c", mp->name, 0); @@ -765,14 +771,15 @@ reply: vl_sock_api_send_fd_msg (cf->file_descriptor, &memfd->fd, 1); } -#define foreach_vlib_api_msg \ - _(SOCKCLNT_CREATE, sockclnt_create, 1) \ - _(SOCKCLNT_DELETE, sockclnt_delete, 1) \ - _(SOCK_INIT_SHM, sock_init_shm, 1) +#define foreach_vlib_api_msg \ + _ (SOCKCLNT_CREATE, sockclnt_create, 0) \ + _ (SOCKCLNT_DELETE, sockclnt_delete, 0) \ + _ (SOCK_INIT_SHM, sock_init_shm, 0) clib_error_t * vl_sock_api_init (vlib_main_t * vm) { + api_main_t *am = vlibapi_get_main (); clib_file_main_t *fm = &file_main; clib_file_t template = { 0 }; vl_api_registration_t *rp; @@ -784,13 +791,13 @@ vl_sock_api_init (vlib_main_t * vm) if (sm->socket_name == 0) return 0; -#define _(N,n,t) \ - vl_msg_api_set_handlers(VL_API_##N, #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), t); +#define _(N, n, t) \ + vl_msg_api_set_handlers (VL_API_##N, #n, vl_api_##n##_t_handler, \ + vl_noop_handler, vl_api_##n##_t_endian, \ + vl_api_##n##_t_print, sizeof (vl_api_##n##_t), t, \ + vl_api_##n##_t_print_json, vl_api_##n##_t_tojson, \ + vl_api_##n##_t_fromjson); \ + am->api_trace_cfg[VL_API_##N].replay_enable = 0; foreach_vlib_api_msg; #undef _ |