summaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/unix/cli.c11
-rw-r--r--src/vlib/unix/unix.h6
-rw-r--r--src/vlib/unix/util.c13
3 files changed, 30 insertions, 0 deletions
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c
index 953d133c69c..1befa25def4 100644
--- a/src/vlib/unix/cli.c
+++ b/src/vlib/unix/cli.c
@@ -2642,6 +2642,17 @@ unix_cli_config (vlib_main_t * vm, unformat_input_t * input)
/* CLI listen. */
unix_file_t template = { 0 };
+ /* If our listen address looks like a path and it starts with
+ * VPP_RUN_DIR, go make sure VPP_RUN_DIR exists before trying to open
+ * a socket in it.
+ */
+ if (strncmp (s->config, VPP_RUN_DIR "/", strlen (VPP_RUN_DIR) + 1) == 0)
+ {
+ error = unix_make_vpp_run_dir ();
+ if (error)
+ return error;
+ }
+
s->flags = SOCKET_IS_SERVER | /* listen, don't connect */
SOCKET_ALLOW_GROUP_WRITE; /* PF_LOCAL socket only */
error = clib_socket_init (s);
diff --git a/src/vlib/unix/unix.h b/src/vlib/unix/unix.h
index de607c0f490..ffa92bba1dc 100644
--- a/src/vlib/unix/unix.h
+++ b/src/vlib/unix/unix.h
@@ -43,6 +43,10 @@
#include <vppinfra/socket.h>
#include <termios.h>
+
+/** VPP runtime ephemeral directory. Typically stored in a tmpfs. */
+#define VPP_RUN_DIR "/run/vpp"
+
struct unix_file;
typedef clib_error_t *(unix_file_function_t) (struct unix_file * f);
@@ -229,6 +233,8 @@ clib_error_t *foreach_directory_file (char *dir_name,
u8 * file_name),
void *arg, int scan_dirs);
+clib_error_t *unix_make_vpp_run_dir (void);
+
#endif /* included_unix_unix_h */
/*
diff --git a/src/vlib/unix/util.c b/src/vlib/unix/util.c
index edc3e591baf..51b4a4ed9b1 100644
--- a/src/vlib/unix/util.c
+++ b/src/vlib/unix/util.c
@@ -222,6 +222,19 @@ done:
return r;
}
+clib_error_t *
+unix_make_vpp_run_dir (void)
+{
+ int rv;
+
+ rv = mkdir (VPP_RUN_DIR, 0755);
+ if (rv && errno != EEXIST)
+ return clib_error_return (0, "mkdir '%s' failed errno %d",
+ VPP_RUN_DIR, errno);
+
+ return 0;
+}
+
/*
* fd.io coding-style-patch-verification: ON
*