X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlib%2Funix%2Fmain.c;h=db5ddd64d3197ea914e983f441bde401bfde605f;hb=586afd762bfa149f5ca167bd5fd5a0cd59ce94fe;hp=562778e0e5de47f265469f33df996d2546d42438;hpb=7cd468a3d7dee7d6c92f69a0bb7061ae208ec727;p=vpp.git diff --git a/src/vlib/unix/main.c b/src/vlib/unix/main.c index 562778e0e5d..db5ddd64d31 100644 --- a/src/vlib/unix/main.c +++ b/src/vlib/unix/main.c @@ -46,6 +46,8 @@ #include #include #include +#include +#include /** Default CLI pager limit is not configured in startup.conf */ #define UNIX_CLI_DEFAULT_PAGER_LIMIT 100000 @@ -340,6 +342,26 @@ unix_config (vlib_main_t * vm, unformat_input_t * input) else if (unformat (input, "cli-history-limit %d", &um->cli_history_limit)) ; + else if (unformat (input, "coredump-size")) + { + uword coredump_size = 0; + if (unformat (input, "unlimited")) + { + coredump_size = RLIM_INFINITY; + } + else + if (!unformat (input, "%U", unformat_memory_size, &coredump_size)) + { + return clib_error_return (0, + "invalid coredump-size parameter `%U'", + format_unformat_error, input); + } + const struct rlimit new_limit = { coredump_size, coredump_size }; + if (0 != setrlimit (RLIMIT_CORE, &new_limit)) + { + clib_unix_warning ("prlimit() failed"); + } + } else if (unformat (input, "full-coredump")) { int fd; @@ -488,13 +510,28 @@ thread0 (uword arg) return i; } +u8 * +vlib_thread_stack_init (uword thread_index) +{ + vec_validate (vlib_thread_stacks, thread_index); + vlib_thread_stacks[thread_index] = clib_mem_alloc_aligned + (VLIB_THREAD_STACK_SIZE, VLIB_THREAD_STACK_SIZE); + + /* + * Disallow writes to the bottom page of the stack, to + * catch stack overflows. + */ + if (mprotect (vlib_thread_stacks[thread_index], + clib_mem_get_page_size (), PROT_READ) < 0) + clib_unix_warning ("thread stack"); + return vlib_thread_stacks[thread_index]; +} + int vlib_unix_main (int argc, char *argv[]) { vlib_main_t *vm = &vlib_global_main; /* one and only time for this! */ - vlib_thread_main_t *tm = &vlib_thread_main; unformat_input_t input; - u8 *thread_stacks; clib_error_t *e; int i; @@ -503,6 +540,14 @@ vlib_unix_main (int argc, char *argv[]) vm->heap_base = clib_mem_get_heap (); ASSERT (vm->heap_base); + unformat_init_command_line (&input, (char **) vm->argv); + if ((e = vlib_plugin_config (vm, &input))) + { + clib_error_report (e); + return 1; + } + unformat_free (&input); + i = vlib_plugin_early_init (vm); if (i) return i; @@ -518,29 +563,9 @@ vlib_unix_main (int argc, char *argv[]) } unformat_free (&input); - /* - * allocate n x VLIB_THREAD_STACK_SIZE stacks, aligned to a - * VLIB_THREAD_STACK_SIZE boundary - * See also: os_get_cpu_number() in vlib/vlib/threads.c - */ - thread_stacks = clib_mem_alloc_aligned - ((uword) tm->n_thread_stacks * VLIB_THREAD_STACK_SIZE, - VLIB_THREAD_STACK_SIZE); + vlib_thread_stack_init (0); - vec_validate (vlib_thread_stacks, tm->n_thread_stacks - 1); - for (i = 0; i < vec_len (vlib_thread_stacks); i++) - { - vlib_thread_stacks[i] = thread_stacks; - - /* - * Disallow writes to the bottom page of the stack, to - * catch stack overflows. - */ - if (mprotect (thread_stacks, clib_mem_get_page_size (), PROT_READ) < 0) - clib_unix_warning ("thread stack"); - - thread_stacks += VLIB_THREAD_STACK_SIZE; - } + vlib_thread_index = 0; i = clib_calljmp (thread0, (uword) vm, (void *) (vlib_thread_stacks[0] +