aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2019-08-19 14:51:45 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2019-08-20 12:31:06 +0000
commitd991a798ff5eb6d151b6641e61fefc6315bab0ac (patch)
treee0468584656a5b0e88ef492e62530cd82e3e9be9 /src
parent4ecbf105a4290de9917b1ded14b0854c68cbd655 (diff)
vlib: create unix runtime directory
Ensure the runtime directory is created at startup. Default /run/vpp Type: fix Fixes: I53d70939c8125d04a365ac51a6cbf8926dc52adf Change-Id: I6d70364ea756b86768c4dd1f6a9383238ed275c8 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/vlib/unix/main.c5
-rw-r--r--src/vpp/stats/stat_segment.c32
2 files changed, 29 insertions, 8 deletions
diff --git a/src/vlib/unix/main.c b/src/vlib/unix/main.c
index 3ec4c342cf1..42c3064bc32 100755
--- a/src/vlib/unix/main.c
+++ b/src/vlib/unix/main.c
@@ -500,6 +500,11 @@ unix_config (vlib_main_t * vm, unformat_input_t * input)
vlib_default_runtime_dir, 0);
}
+ /* Ensure the runtime directory is created */
+ error = vlib_unix_recursive_mkdir ((char *) um->runtime_dir);
+ if (error)
+ return error;
+
error = setup_signal_handlers (um);
if (error)
return error;
diff --git a/src/vpp/stats/stat_segment.c b/src/vpp/stats/stat_segment.c
index 7bb01b30d5b..303d7040c94 100644
--- a/src/vpp/stats/stat_segment.c
+++ b/src/vpp/stats/stat_segment.c
@@ -708,6 +708,26 @@ stat_segment_collector_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
return 0; /* or not */
}
+static clib_error_t *
+statseg_init (vlib_main_t * vm)
+{
+ stat_segment_main_t *sm = &stat_segment_main;
+
+ /* set default socket file name when statseg config stanza is empty. */
+ if (!vec_len (sm->socket_name))
+ sm->socket_name = format (0, "%s/%s", vlib_unix_get_runtime_dir (),
+ STAT_SEGMENT_SOCKET_FILENAME);
+ return stats_segment_socket_init ();
+}
+
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (statseg_init) =
+{
+ .runs_after = VLIB_INITS("unix_input_init"),
+};
+/* *INDENT-ON* */
+
+
clib_error_t *
stat_segment_register_gauge (u8 * name, stat_segment_update_fn update_fn,
u32 caller_index)
@@ -775,18 +795,14 @@ statseg_config (vlib_main_t * vm, unformat_input_t * input)
format_unformat_error, input);
}
- /* set default socket file name when statseg config stanza is empty. */
- if (!vec_len (sm->socket_name))
- sm->socket_name = format (0, "%s/%s", vlib_unix_get_runtime_dir (),
- STAT_SEGMENT_SOCKET_FILENAME);
-
/*
* NULL-terminate socket name string
* clib_socket_init()->socket_config() use C str*
*/
- vec_terminate_c_string (sm->socket_name);
+ if (vec_len (sm->socket_name))
+ vec_terminate_c_string (sm->socket_name);
- return stats_segment_socket_init ();
+ return 0;
}
static clib_error_t *
@@ -857,7 +873,7 @@ statseg_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
return 0;
}
-VLIB_CONFIG_FUNCTION (statseg_config, "statseg");
+VLIB_EARLY_CONFIG_FUNCTION (statseg_config, "statseg");
VNET_SW_INTERFACE_ADD_DEL_FUNCTION (statseg_sw_interface_add_del);
/* *INDENT-OFF* */