44 #include <sys/ucontext.h> 46 #include <sys/types.h> 50 #include <sys/resource.h> 53 #define UNIX_CLI_DEFAULT_PAGER_LIMIT 100000 56 #define UNIX_CLI_DEFAULT_HISTORY 50 77 msg =
format (msg,
"received signal %U, PC %U",
80 if (signum == SIGSEGV)
81 msg =
format (msg,
", faulting address %p", si->si_addr);
89 syslog (LOG_ERR | LOG_DAEMON,
"received SIGTERM, exiting...");
116 syslog (LOG_ERR | LOG_DAEMON,
"%s", msg);
131 for (i = 1; i < 32; i++)
133 memset (&sa, 0,
sizeof (sa));
135 sa.sa_flags = SA_SIGINFO;
150 sa.sa_sigaction = (
void *) SIG_IGN;
158 if (sigaction (i, &sa, 0) < 0)
177 char save = msg[msg_len - 1];
180 msg[msg_len - 1] = 0;
182 syslog (LOG_ERR | LOG_DAEMON,
"%s", msg);
184 msg[msg_len - 1] = save;
205 save = msg[msg_len - 1];
206 msg[msg_len - 1] = 0;
208 syslog (LOG_ERR | LOG_DAEMON,
"%s", msg);
210 msg[msg_len - 1] = save;
234 fd = open (fn, O_RDONLY);
241 if (fstat (fd, &s) < 0)
249 if (!(S_ISREG (s.st_mode) || S_ISLNK (s.st_mode)))
259 n = read (fd, buf + l, 4096);
262 _vec_len (buf) = l + n;
272 lv =
format (lv,
"%U: ***** Startup Config *****\n%v",
277 int rv __attribute__ ((unused)) =
281 lv =
format (lv,
"%U: ***** End Startup Config *****\n",
285 int rv __attribute__ ((unused)) =
307 .name =
"startup-config-process",
324 if (
unformat (input,
"interactive"))
326 else if (
unformat (input,
"nodaemon"))
328 else if (
unformat (input,
"cli-prompt %s", &cli_prompt))
333 else if (
unformat (input,
"cli-line-mode"))
335 else if (
unformat (input,
"cli-no-banner"))
337 else if (
unformat (input,
"cli-no-pager"))
339 else if (
unformat (input,
"cli-pager-buffer-limit %d",
345 else if (
unformat (input,
"coredump-size"))
347 uword coredump_size = 0;
350 coredump_size = RLIM_INFINITY;
356 "invalid coredump-size parameter `%U'",
359 const struct rlimit new_limit = { coredump_size, coredump_size };
360 if (0 != setrlimit (RLIMIT_CORE, &new_limit))
365 else if (
unformat (input,
"full-coredump"))
369 fd = open (
"/proc/self/coredump_filter", O_WRONLY);
372 if (write (fd,
"0x6f\n", 5) != 5)
379 else if (
unformat (input,
"startup-config %s",
387 O_CREAT | O_WRONLY | O_APPEND, 0644);
396 lv =
format (0,
"%U: ***** Start: PID %d *****\n",
401 int rv __attribute__ ((unused)) =
418 openlog (vm->
name, LOG_CONS | LOG_PERROR | LOG_PID, LOG_DAEMON);
558 VLIB_THREAD_STACK_SIZE);
577 VLIB_THREAD_STACK_SIZE));
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static clib_error_t * unix_main_init(vlib_main_t *vm)
sll srl srl sll sra u16x4 i
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
volatile int unix_config_complete
static uword startup_config_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
u32 cli_pager_buffer_limit
void vlib_unix_cli_set_prompt(char *prompt)
Set the CLI prompt.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
clib_error_t * vlib_plugin_config(vlib_main_t *vm, unformat_input_t *input)
#define VLIB_MAIN_LOOP_EXIT_CLI
void clib_longjmp(clib_longjmp_t *save, uword return_value)
void clib_error_register_handler(clib_error_handler_func_t func, void *arg)
clib_socket_t cli_listen_socket
#define UNIX_FLAG_NODAEMON
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
static vlib_node_registration_t startup_config_node
(constructor) VLIB_REGISTER_NODE (startup_config_node)
#define VLIB_INIT_FUNCTION(x)
#define clib_error_return(e, args...)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
#define vlib_call_init_function(vm, x)
int vlib_plugin_early_init(vlib_main_t *vm)
#define UNIX_CLI_DEFAULT_PAGER_LIMIT
Default CLI pager limit is not configured in startup.conf.
vlib_main_t vlib_global_main
static clib_error_t * unix_config(vlib_main_t *vm, unformat_input_t *input)
#define clib_error_return_unix(e, args...)
static void unix_signal_handler(int signum, siginfo_t *si, ucontext_t *uc)
u8 * startup_config_filename
#define VLIB_CONFIG_FUNCTION(x, n,...)
static clib_error_t * setup_signal_handlers(unix_main_t *um)
uword * init_functions_called
vlib_thread_main_t vlib_thread_main
static clib_error_t * unix_exit(vlib_main_t *vm)
#define vec_free(V)
Free vector's memory (no header).
#define VLIB_MAIN_LOOP_EXIT_FUNCTION(x)
#define clib_warning(format, args...)
static void * clib_mem_get_heap(void)
#define hash_create(elts, value_bytes)
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
#define UNIX_CLI_DEFAULT_HISTORY
Default CLI history depth if not configured in startup.conf.
#define UNIX_FLAG_INTERACTIVE
#define clib_error_report(e)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * vlib_call_all_config_functions(vlib_main_t *vm, unformat_input_t *input, int is_early)
void vlib_unix_error_report(vlib_main_t *vm, clib_error_t *error)
#define clib_unix_warning(format, args...)
#define VLIB_THREAD_STACK_SIZE
static void * clib_mem_alloc_aligned(uword size, uword align)
uword clib_calljmp(uword(*func)(uword func_arg), uword func_arg, void *stack)
#define VLIB_REGISTER_NODE(x,...)
static void unix_error_handler(void *arg, u8 *msg, int msg_len)
clib_longjmp_t main_loop_exit
uword clib_mem_get_page_size(void)
static uword thread0(uword arg)
int vlib_unix_main(int argc, char *argv[])