diff options
author | Ole Troan <ot@cisco.com> | 2019-08-07 13:41:39 +0200 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2019-08-08 11:23:31 +0000 |
commit | 6595ff7f88be45d4c3f4dae09f7253b8b4ed26af (patch) | |
tree | 1e443929216b11edf0252c1079537d295127ea19 /src/vlibmemory/socket_api.c | |
parent | b3392334942ed5459edfa7f11e098f4eab3aa29a (diff) |
api: api socket respect unix runtime directory
socksvr {} should respect the unix runtime directory.
Default is now /run/vpp/api.sock
The 'default' keyword is deprecated.
The user is responsible for creating directories outside of the
unix runtime directory.
Not yet done: Exit VPP when socket cannot be opened.
(currently only process exits).
Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I6dd66ed58a3d7e02674dfa16d72c1d7bba07b79e
Diffstat (limited to 'src/vlibmemory/socket_api.c')
-rw-r--r-- | src/vlibmemory/socket_api.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index d3beafb3345..5aad8a9598f 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -723,22 +723,6 @@ vl_sock_api_init (vlib_main_t * vm) vec_resize (sm->input_buffer, 4096); sock->config = (char *) sm->socket_name; - - /* mkdir of file socket, only under /run */ - if (strncmp (sock->config, "/run", 4) == 0) - { - u8 *tmp = format (0, "%s", sock->config); - int i = vec_len (tmp); - while (i && tmp[--i] != '/') - ; - - tmp[i] = 0; - - if (i) - vlib_unix_recursive_mkdir ((char *) tmp); - vec_free (tmp); - } - sock->flags = CLIB_SOCKET_F_IS_SERVER | CLIB_SOCKET_F_ALLOW_GROUP_WRITE; error = clib_socket_init (sock); if (error) @@ -791,16 +775,21 @@ socksvr_config (vlib_main_t * vm, unformat_input_t * input) { if (unformat (input, "socket-name %s", &sm->socket_name)) ; + /* DEPRECATE: default keyword is ignored */ else if (unformat (input, "default")) - { - sm->socket_name = format (0, "%s%c", API_SOCKET_FILE, 0); - } + ; else { return clib_error_return (0, "unknown input '%U'", format_unformat_error, input); } } + + if (!vec_len (sm->socket_name)) + sm->socket_name = format (0, "%s/%s", vlib_unix_get_runtime_dir (), + API_SOCKET_FILENAME); + vec_terminate_c_string (sm->socket_name); + return 0; } |