From 41e7fb8030d60e8df191bf96bd1eb6c86a56b934 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 25 Oct 2017 10:52:24 -0400 Subject: [PATCH 1/4] lib, ospf6d, ospfd, zebra: Add ZEBRA_STR Allow us to use a ZEBRA_STR for commands Signed-off-by: Donald Sharp --- lib/command.h | 1 + ospf6d/ospf6_zebra.c | 2 +- ospfd/ospf_dump.c | 8 ++++---- zebra/zebra_fpm.c | 4 ++-- zebra/zebra_routemap.c | 4 ++-- zebra/zserv.c | 6 +++--- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/command.h b/lib/command.h index e2d31decd4..9e6c954f15 100644 --- a/lib/command.h +++ b/lib/command.h @@ -358,6 +358,7 @@ struct cmd_node { #define PCE_STR "PCE Router Information specific commands\n" #define MPLS_STR "MPLS information\n" #define WATCHFRR_STR "watchfrr information\n" +#define ZEBRA_STR "Zebra information\n" #define CONF_BACKUP_EXT ".sav" diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index 022b913168..a900648236 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -256,7 +256,7 @@ DEFUN (show_zebra, SHOW_STR IPV6_STR OSPF6_STR - "Zebra information\n") + ZEBRA_STR) { int i; if (zclient == NULL) { diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index 5933f5abfe..6876054a63 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -1182,7 +1182,7 @@ DEFUN (debug_ospf_zebra, "debug ospf zebra []", DEBUG_STR OSPF_STR - "OSPF Zebra information\n" + ZEBRA_STR "Zebra interface\n" "Zebra redistribute\n") { @@ -1195,7 +1195,7 @@ DEFUN (debug_ospf_instance_zebra, DEBUG_STR OSPF_STR "Instance ID\n" - "OSPF Zebra information\n" + ZEBRA_STR "Zebra interface\n" "Zebra redistribute\n") { @@ -1245,7 +1245,7 @@ DEFUN (no_debug_ospf_zebra, NO_STR DEBUG_STR OSPF_STR - "OSPF Zebra information\n" + ZEBRA_STR "Zebra interface\n" "Zebra redistribute\n") { @@ -1259,7 +1259,7 @@ DEFUN (no_debug_ospf_instance_zebra, DEBUG_STR OSPF_STR "Instance ID\n" - "OSPF Zebra information\n" + ZEBRA_STR "Zebra interface\n" "Zebra redistribute\n") { diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index a5d256b7aa..0ffa55f1e4 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -1413,7 +1413,7 @@ DEFUN (show_zebra_fpm_stats, show_zebra_fpm_stats_cmd, "show zebra fpm stats", SHOW_STR - "Zebra information\n" + ZEBRA_STR "Forwarding Path Manager information\n" "Statistics\n") { @@ -1428,7 +1428,7 @@ DEFUN (clear_zebra_fpm_stats, clear_zebra_fpm_stats_cmd, "clear zebra fpm stats", CLEAR_STR - "Zebra information\n" + ZEBRA_STR "Clear Forwarding Path Manager information\n" "Statistics\n") { diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index dd0189666e..7bfaf8e275 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -392,7 +392,7 @@ DEFUN (no_set_src, DEFUN (zebra_route_map_timer, zebra_route_map_timer_cmd, "zebra route-map delay-timer (0-600)", - "Zebra information\n" + ZEBRA_STR "Set route-map parameters\n" "Time to wait before route-map updates are processed\n" "0 means event-driven updates are disabled\n") @@ -410,7 +410,7 @@ DEFUN (no_zebra_route_map_timer, no_zebra_route_map_timer_cmd, "no zebra route-map delay-timer [(0-600)]", NO_STR - "Zebra information\n" + ZEBRA_STR "Set route-map parameters\n" "Reset delay-timer to default value, 30 secs\n" "0 means event-driven updates are disabled\n") diff --git a/zebra/zserv.c b/zebra/zserv.c index 15bfd37da8..fe8213702b 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -2841,7 +2841,7 @@ DEFUN (show_zebra, show_zebra_cmd, "show zebra", SHOW_STR - "Zebra information\n") + ZEBRA_STR) { struct vrf *vrf; @@ -2866,7 +2866,7 @@ DEFUN (show_zebra_client, show_zebra_client_cmd, "show zebra client", SHOW_STR - "Zebra information\n" + ZEBRA_STR "Client information\n") { struct listnode *node; @@ -2883,7 +2883,7 @@ DEFUN (show_zebra_client_summary, show_zebra_client_summary_cmd, "show zebra client summary", SHOW_STR - "Zebra information brief\n" + ZEBRA_STR "Client information brief\n" "Brief Summary\n") { From 3a30f50f3ff40888caddc75b04f915fa0d5456c4 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 25 Oct 2017 10:47:55 -0400 Subject: [PATCH 2/4] zebra: Allow user to specify work-queue processing hold time Allow the user to modify the work-queue processing hold time from 10ms to a value from (0-10000). Make the command hidden as that it's a semi-dangerous command and it could cause issues. Signed-off-by: Donald Sharp --- zebra/zebra_rib.c | 8 +------- zebra/zebra_vty.c | 32 ++++++++++++++++++++++++++++++++ zebra/zserv.h | 1 + 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index d46e0730ee..b5c2bc6dae 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -57,12 +57,6 @@ DEFINE_HOOK(rib_update, (struct route_node * rn, const char *reason), /* Should we allow non Quagga processes to delete our routes */ extern int allow_delete; -/* Hold time for RIB process, should be very minimal. - * it is useful to able to set it otherwise for testing, hence exported - * as global here for test-rig code. - */ -int rib_process_hold_time = 10; - /* Each route type's string and default distance value. */ static const struct { int key; @@ -1899,7 +1893,7 @@ static void rib_queue_init(struct zebra_t *zebra) zebra->ribq->spec.completion_func = &meta_queue_process_complete; /* XXX: TODO: These should be runtime configurable via vty */ zebra->ribq->spec.max_retries = 3; - zebra->ribq->spec.hold = rib_process_hold_time; + zebra->ribq->spec.hold = ZEBRA_RIB_PROCESS_HOLD_TIME; if (!(zebra->mq = meta_queue_new())) { zlog_err("%s: could not initialise meta queue!", __func__); diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index d86cc88b42..21a3331f33 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -44,6 +44,7 @@ #include "lib/json.h" #include "zebra/zebra_vxlan.h" #include "zebra/zebra_vty_clippy.c" +#include "zebra/zserv.h" extern int allow_delete; @@ -2695,6 +2696,32 @@ DEFUN (ip_zebra_import_table_distance, return ret; } +DEFUN_HIDDEN (zebra_workqueue_timer, + zebra_workqueue_timer_cmd, + "zebra work-queue (0-10000)", + ZEBRA_STR + "Work Queue\n" + "Time in milliseconds\n") +{ + uint32_t timer = strtoul(argv[2]->arg, NULL, 10); + zebrad.ribq->spec.hold = timer; + + return CMD_SUCCESS; +} + +DEFUN_HIDDEN (no_zebra_workqueue_timer, + no_zebra_workqueue_timer_cmd, + "no zebra work-queue [(0-10000)]", + NO_STR + ZEBRA_STR + "Work Queue\n" + "Time in milliseconds\n") +{ + zebrad.ribq->spec.hold = ZEBRA_RIB_PROCESS_HOLD_TIME; + + return CMD_SUCCESS; +} + DEFUN (no_ip_zebra_import_table, no_ip_zebra_import_table_cmd, "no ip import-table (1-252) [distance (1-255)] [route-map NAME]", @@ -2740,6 +2767,9 @@ static int config_write_protocol(struct vty *vty) if (zebra_rnh_ipv6_default_route) vty_out(vty, "ipv6 nht resolve-via-default\n"); + if (zebrad.ribq->spec.hold != ZEBRA_RIB_PROCESS_HOLD_TIME) + vty_out(vty, "zebra work-queue %u\n", zebrad.ribq->spec.hold); + enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get(); if (ipv4_multicast_mode != MCAST_NO_CONFIG) @@ -2781,6 +2811,8 @@ void zebra_vty_init(void) install_element(CONFIG_NODE, &ip_route_cmd); install_element(CONFIG_NODE, &ip_zebra_import_table_distance_cmd); install_element(CONFIG_NODE, &no_ip_zebra_import_table_cmd); + install_element(CONFIG_NODE, &zebra_workqueue_timer_cmd); + install_element(CONFIG_NODE, &no_zebra_workqueue_timer_cmd); install_element(VIEW_NODE, &show_vrf_cmd); install_element(VIEW_NODE, &show_ip_route_cmd); diff --git a/zebra/zserv.h b/zebra/zserv.h index f661572d53..d847526f2e 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -132,6 +132,7 @@ struct zebra_t { u_int32_t rtm_table_default; /* rib work queue */ + #define ZEBRA_RIB_PROCESS_HOLD_TIME 10 struct work_queue *ribq; struct meta_queue *mq; From a37ef435e9514a455931ddbac090e9bea0943bb5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 25 Oct 2017 11:03:41 -0400 Subject: [PATCH 3/4] zebra: Store packets to process in `struct zebra_t` Store the number of packets we should process at one time in `struct zebra_t`. A future commit will allow the user to control this via a hidden cli. Signed-off-by: Donald Sharp --- zebra/main.c | 1 + zebra/zserv.c | 2 +- zebra/zserv.h | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/zebra/main.c b/zebra/main.c index 5a2979c866..cf677a7753 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -53,6 +53,7 @@ /* Zebra instance */ struct zebra_t zebrad = { .rtm_table_default = 0, + .packets_to_process = ZEBRA_ZAPI_PACKETS_TO_PROCESS, }; /* process id. */ diff --git a/zebra/zserv.c b/zebra/zserv.c index fe8213702b..cbd532339d 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -2387,7 +2387,7 @@ static int zebra_client_read(struct thread *thread) uint8_t marker, version; vrf_id_t vrf_id; struct zebra_vrf *zvrf; - int packets = 10; + int packets = zebrad.packets_to_process; /* Get thread data. Reset reading thread because I'm running. */ sock = THREAD_FD(thread); diff --git a/zebra/zserv.h b/zebra/zserv.h index d847526f2e..279b56ec3c 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -138,6 +138,9 @@ struct zebra_t { /* LSP work queue */ struct work_queue *lsp_process_q; + + #define ZEBRA_ZAPI_PACKETS_TO_PROCESS 10 + u_int32_t packets_to_process; }; extern struct zebra_t zebrad; extern unsigned int multipath_num; From 62d52dedf08e47fb65674209cf5b7f9d62eb7e4f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 25 Oct 2017 11:13:42 -0400 Subject: [PATCH 4/4] zebra: Add Hidden 'zebra zapi-packets (1-10000)' command Allow the end user to specify how many packets we want to process at one time coming down the zapi, before we yield and let other things process. This is a Hidden command because it is not necessarily something that we want end users to be able to play with Signed-off-by: Donald Sharp --- zebra/zebra_vty.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 21a3331f33..e6563c4f54 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -2696,6 +2696,33 @@ DEFUN (ip_zebra_import_table_distance, return ret; } +DEFUN_HIDDEN (zebra_packet_process, + zebra_packet_process_cmd, + "zebra zapi-packets (1-10000)", + ZEBRA_STR + "Zapi Protocol\n" + "Number of packets to process before relinquishing thread\n") +{ + uint32_t packets = strtoul(argv[2]->arg, NULL, 10); + + zebrad.packets_to_process = packets; + + return CMD_SUCCESS; +} + +DEFUN_HIDDEN (no_zebra_packet_process, + no_zebra_packet_process_cmd, + "no zebra zapi-packets [(1-10000)]", + NO_STR + ZEBRA_STR + "Zapi Protocol\n" + "Number of packets to process before relinquishing thread\n") +{ + zebrad.packets_to_process = ZEBRA_ZAPI_PACKETS_TO_PROCESS; + + return CMD_SUCCESS; +} + DEFUN_HIDDEN (zebra_workqueue_timer, zebra_workqueue_timer_cmd, "zebra work-queue (0-10000)", @@ -2770,6 +2797,10 @@ static int config_write_protocol(struct vty *vty) if (zebrad.ribq->spec.hold != ZEBRA_RIB_PROCESS_HOLD_TIME) vty_out(vty, "zebra work-queue %u\n", zebrad.ribq->spec.hold); + if (zebrad.packets_to_process != ZEBRA_ZAPI_PACKETS_TO_PROCESS) + vty_out(vty, + "zebra zapi-packets %u\n", zebrad.packets_to_process); + enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get(); if (ipv4_multicast_mode != MCAST_NO_CONFIG) @@ -2813,6 +2844,8 @@ void zebra_vty_init(void) install_element(CONFIG_NODE, &no_ip_zebra_import_table_cmd); install_element(CONFIG_NODE, &zebra_workqueue_timer_cmd); install_element(CONFIG_NODE, &no_zebra_workqueue_timer_cmd); + install_element(CONFIG_NODE, &zebra_packet_process_cmd); + install_element(CONFIG_NODE, &no_zebra_packet_process_cmd); install_element(VIEW_NODE, &show_vrf_cmd); install_element(VIEW_NODE, &show_ip_route_cmd);