From 950da676e61f42a6d6fa4987b9ac5ce79e003fc8 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Fri, 11 Aug 2023 18:11:03 +0300 Subject: [PATCH 1/2] lib: Allow unsetting walltime-warning and cpu-warning With a negative form we get: ``` Internal CLI error [walltime_warning_str] Internal CLI error [cputime_warning_str] ``` Signed-off-by: Donatas Abraitis --- lib/thread.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/lib/thread.c b/lib/thread.c index 4078634f75..5d9775e647 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -368,7 +368,7 @@ DEFPY (service_cputime_stats, DEFPY (service_cputime_warning, service_cputime_warning_cmd, - "[no] service cputime-warning (1-4294967295)", + "[no] service cputime-warning ![(1-4294967295)]", NO_STR "Set up miscellaneous service\n" "Warn for tasks exceeding CPU usage threshold\n" @@ -381,16 +381,9 @@ DEFPY (service_cputime_warning, return CMD_SUCCESS; } -ALIAS (service_cputime_warning, - no_service_cputime_warning_cmd, - "no service cputime-warning", - NO_STR - "Set up miscellaneous service\n" - "Warn for tasks exceeding CPU usage threshold\n") - DEFPY (service_walltime_warning, service_walltime_warning_cmd, - "[no] service walltime-warning (1-4294967295)", + "[no] service walltime-warning ![(1-4294967295)]", NO_STR "Set up miscellaneous service\n" "Warn for tasks exceeding total wallclock threshold\n" @@ -403,13 +396,6 @@ DEFPY (service_walltime_warning, return CMD_SUCCESS; } -ALIAS (service_walltime_warning, - no_service_walltime_warning_cmd, - "no service walltime-warning", - NO_STR - "Set up miscellaneous service\n" - "Warn for tasks exceeding total wallclock threshold\n") - static void show_thread_poll_helper(struct vty *vty, struct thread_master *m) { const char *name = m->name ? m->name : "main"; @@ -539,9 +525,7 @@ void thread_cmd_init(void) install_element(CONFIG_NODE, &service_cputime_stats_cmd); install_element(CONFIG_NODE, &service_cputime_warning_cmd); - install_element(CONFIG_NODE, &no_service_cputime_warning_cmd); install_element(CONFIG_NODE, &service_walltime_warning_cmd); - install_element(CONFIG_NODE, &no_service_walltime_warning_cmd); install_element(VIEW_NODE, &show_thread_timers_cmd); } From c50380955038a6ce7b40e37d16981d8c7a62b21e Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Fri, 11 Aug 2023 18:21:12 +0300 Subject: [PATCH 2/2] vtysh: Print uniq lines when parsing `no service ...` Before this patch: ``` no service cputime-warning no service cputime-warning no ipv6 forwarding no service cputime-warning no service cputime-warning no service cputime-warning ``` Signed-off-by: Donatas Abraitis --- vtysh/vtysh_config.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index ac32f0a774..1613dacead 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -495,8 +495,7 @@ void vtysh_config_parse_line(void *arg, const char *line) config = config_get(RPKI_NODE, line); else { if (strncmp(line, "log", strlen("log")) == 0 || - strncmp(line, "hostname", strlen("hostname")) == - 0 || + strncmp(line, "hostname", strlen("hostname")) == 0 || strncmp(line, "domainname", strlen("domainname")) == 0 || strncmp(line, "allow-reserved-ranges", @@ -508,12 +507,9 @@ void vtysh_config_parse_line(void *arg, const char *line) strlen("no ip prefix-list")) == 0 || strncmp(line, "no ipv6 prefix-list", strlen("no ipv6 prefix-list")) == 0 || - strncmp(line, "service ", strlen("service ")) == - 0 || - strncmp(line, "no service cputime-stats", - strlen("no service cputime-stats")) == 0 || - strncmp(line, "service cputime-warning", - strlen("service cputime-warning")) == 0) + strncmp(line, "service ", strlen("service ")) == 0 || + strncmp(line, "no service ", + strlen("no service ")) == 0) config_add_line_uniq(config_top, line); else config_add_line(config_top, line);