#define LINK_STATE_ELOGS 0
-#define DEFAULT_HUGE_DIR (VPP_RUN_DIR "/hugepages")
-
/* Port configuration, mildly modified Intel app values */
static struct rte_eth_conf port_conf_template = {
u8 huge_dir = 0;
u8 file_prefix = 0;
u8 *socket_mem = 0;
+ u8 *huge_dir_path = 0;
+
+ huge_dir_path =
+ format (0, "%s/hugepages%c", vlib_unix_get_runtime_dir (), 0);
conf->device_config_index_by_pci_addr = hash_create (0, sizeof (uword));
log_level = RTE_LOG_NOTICE;
u8 less_than_1g = 1;
int rv;
- umount (DEFAULT_HUGE_DIR);
+ umount ((char *) huge_dir_path);
/* Process "socket-mem" parameter value */
if (vec_len (socket_mem))
vec_free (mem_by_socket);
- /* Make sure VPP_RUN_DIR exists */
- error = unix_make_vpp_run_dir ();
+ error = vlib_unix_recursive_mkdir ((char *) huge_dir_path);
if (error)
- goto done;
-
- rv = mkdir (DEFAULT_HUGE_DIR, 0755);
- if (rv && errno != EEXIST)
{
- error = clib_error_return (0, "mkdir '%s' failed errno %d",
- DEFAULT_HUGE_DIR, errno);
goto done;
}
if (use_1g && !(less_than_1g && use_2m))
{
- rv =
- mount ("none", DEFAULT_HUGE_DIR, "hugetlbfs", 0, "pagesize=1G");
+ rv = mount ("none", (char *) huge_dir_path, "hugetlbfs", 0,
+ "pagesize=1G");
}
else if (use_2m)
{
- rv = mount ("none", DEFAULT_HUGE_DIR, "hugetlbfs", 0, NULL);
+ rv = mount ("none", (char *) huge_dir_path, "hugetlbfs", 0, NULL);
}
else
{
tmp = format (0, "--huge-dir%c", 0);
vec_add1 (conf->eal_init_args, tmp);
- tmp = format (0, "%s%c", DEFAULT_HUGE_DIR, 0);
+ tmp = format (0, "%s%c", huge_dir_path, 0);
vec_add1 (conf->eal_init_args, tmp);
if (!file_prefix)
{
(char **) conf->eal_init_args);
/* lazy umount hugepages */
- umount2 (DEFAULT_HUGE_DIR, MNT_DETACH);
+ umount2 ((char *) huge_dir_path, MNT_DETACH);
+ rmdir ((char *) huge_dir_path);
+ vec_free (huge_dir_path);
if (ret < 0)
return clib_error_return (0, "rte_eal_init returned %d", ret);
if (args->socket_filename == 0 || args->socket_filename[0] != '/')
{
- rv = mkdir (MEMIF_DEFAULT_SOCKET_DIR, 0755);
- if (rv && errno != EEXIST)
- return VNET_API_ERROR_SYSCALL_ERROR_1;
+ clib_error_t *error;
+ error = vlib_unix_recursive_mkdir (vlib_unix_get_runtime_dir ());
+ if (error)
+ {
+ clib_error_free (error);
+ return VNET_API_ERROR_SYSCALL_ERROR_1;
+ }
if (args->socket_filename == 0)
- socket_filename = format (0, "%s/%s%c", MEMIF_DEFAULT_SOCKET_DIR,
+ socket_filename = format (0, "%s/%s%c", vlib_unix_get_runtime_dir (),
MEMIF_DEFAULT_SOCKET_FILENAME, 0);
else
- socket_filename = format (0, "%s/%s%c", MEMIF_DEFAULT_SOCKET_DIR,
+ socket_filename = format (0, "%s/%s%c", vlib_unix_get_runtime_dir (),
args->socket_filename, 0);
}
#include <vppinfra/lock.h>
-#define MEMIF_DEFAULT_SOCKET_DIR "/run/vpp"
#define MEMIF_DEFAULT_SOCKET_FILENAME "memif.sock"
#define MEMIF_DEFAULT_RING_SIZE 1024
#define MEMIF_DEFAULT_RX_QUEUES 1
/* 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)
+ /* mkdir of file socketu, only under /run */
+ if (strncmp (s->config, "/run", 4) == 0)
{
- error = unix_make_vpp_run_dir ();
- if (error)
- return error;
+ u8 *tmp = format (0, "%s", s->config);
+ int i = vec_len (tmp);
+ while (i && tmp[--i] != '/')
+ ;
+
+ tmp[i] = 0;
+
+ if (i)
+ vlib_unix_recursive_mkdir ((char *) tmp);
+ vec_free (tmp);
}
s->flags = SOCKET_IS_SERVER | /* listen, don't connect */
/** Default CLI history depth if not configured in startup.conf */
#define UNIX_CLI_DEFAULT_HISTORY 50
+char *vlib_default_runtime_dir __attribute__ ((weak));
+char *vlib_default_runtime_dir = "/run/vlib";
unix_main_t unix_main;
else
if (unformat (input, "cli-listen %s", &um->cli_listen_socket.config))
;
+ else if (unformat (input, "runtime-dir %s", &um->runtime_dir))
+ ;
else if (unformat (input, "cli-line-mode"))
um->cli_line_mode = 1;
else if (unformat (input, "cli-no-banner"))
}
um->unix_config_complete = 1;
+ if (um->runtime_dir == 0)
+ um->runtime_dir = format (0, "%s%c", vlib_default_runtime_dir, 0);
+
return 0;
}
* Ask the Linux kernel to dump all memory-mapped address regions, instead
* of just text+data+bss.
*
+ * @cfgcmd{runtime-dir}
+ * Define directory where VPP is going to store all runtime files.
+ * Default is /run/vpp.
+ *
* @cfgcmd{cli-listen, <address:port>}
* Bind the CLI to listen at the address and port given. @clocalhost
* on TCP port @c 5002, given as <tt>cli-listen localhost:5002</tt>,
* Limit pager buffer to @c nn lines of output.
* A value of @c 0 disables the pager. Default value: @c 100000
?*/
-VLIB_CONFIG_FUNCTION (unix_config, "unix");
+VLIB_EARLY_CONFIG_FUNCTION (unix_config, "unix");
static clib_error_t *
unix_exit (vlib_main_t * vm)
#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);
/* startup-config filename */
u8 *startup_config_filename;
+ /* runtime directory path */
+ u8 *runtime_dir;
+
/* unix config complete */
volatile int unix_config_complete;
return &unix_main;
}
+static inline char *
+vlib_unix_get_runtime_dir (void)
+{
+ return (char *) unix_main.runtime_dir;
+}
+
/* thread stack array; vec_len = max number of threads */
extern u8 **vlib_thread_stacks;
u8 * file_name),
void *arg, int scan_dirs);
-clib_error_t *unix_make_vpp_run_dir (void);
+clib_error_t *vlib_unix_recursive_mkdir (char *path);
#endif /* included_unix_unix_h */
}
clib_error_t *
-unix_make_vpp_run_dir (void)
+vlib_unix_recursive_mkdir (char *path)
{
- int rv;
+ clib_error_t *error = 0;
+ char *c = 0;
+ int i = 0;
- rv = mkdir (VPP_RUN_DIR, 0755);
- if (rv && errno != EEXIST)
- return clib_error_return (0, "mkdir '%s' failed errno %d",
- VPP_RUN_DIR, errno);
+ while (path[i] != 0)
+ {
+ if (c && path[i] == '/')
+ {
+ vec_add1 (c, 0);
+ if ((mkdir (c, 0755)) && (errno != EEXIST))
+ {
+ error = clib_error_return_unix (0, "mkdir '%s'", c);
+ goto done;
+ }
+ _vec_len (c)--;
+ }
+ vec_add1 (c, path[i]);
+ i++;
+ }
- return 0;
+ if ((mkdir (path, 0755)) && (errno != EEXIST))
+ {
+ error = clib_error_return_unix (0, "mkdir '%s'", path);
+ goto done;
+ }
+
+done:
+ vec_free (c);
+
+ return error;
}
/*
vat_plugin_hash_create ();
}
+/*
+ * Default path for runtime data
+ */
+char *vlib_default_runtime_dir = "/run/vpp";
+
/*
* Load plugins from /usr/lib/vpp_plugins by default
*/