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
This commit is contained in:

committed by
Andrew Yourtchenko

parent
b339233494
commit
6595ff7f88
@ -1377,10 +1377,10 @@ If not set, API server doesn't run.
|
||||
* **socket-name <filename>**
|
||||
Configure API socket filename.
|
||||
|
||||
**Example:** socket-name /run/vpp/vpp-api.sock
|
||||
**Example:** socket-name /run/vpp/api.sock
|
||||
|
||||
* **default**
|
||||
Use the default API socket (/run/vpp-api.sock).
|
||||
Use the default API socket (/run/api.sock).
|
||||
|
||||
**Example:** default
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,10 @@
|
||||
#include <svm/ssvm.h>
|
||||
#include <vppinfra/file.h>
|
||||
|
||||
#define API_SOCKET_FILE "/run/vpp-api.sock"
|
||||
/* Deprecated */
|
||||
#define API_SOCKET_FILE "/run/vpp/api.sock"
|
||||
|
||||
#define API_SOCKET_FILENAME "api.sock"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -191,7 +191,7 @@ class VPPApiClient(object):
|
||||
def __init__(self, apifiles=None, testmode=False, async_thread=True,
|
||||
logger=None, loglevel=None,
|
||||
read_timeout=5, use_socket=False,
|
||||
server_address='/run/vpp-api.sock'):
|
||||
server_address='/run/vpp/api.sock'):
|
||||
"""Create a VPP API object.
|
||||
|
||||
apifiles is a list of files containing API
|
||||
|
Reference in New Issue
Block a user