diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index 41bc0dbb86..ca08380ad0 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -2920,6 +2920,15 @@ module frr-zebra { description "Enable PTM globally."; } + leaf route-map-delay { + type uint32 { + range "0..600"; + } + units "seconds"; + default "5"; + description + "Time to wait before route-map updates are processed."; + } /* * Debug options */ diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index 19b0ae11ed..42d7562f8b 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -103,6 +103,12 @@ const struct frr_yang_module_info frr_zebra_info = { } }, #endif + { + .xpath = "/frr-zebra:zebra/route-map-delay", + .cbs = { + .modify = zebra_route_map_delay_modify, + } + }, { .xpath = "/frr-zebra:zebra/debugs/debug-events", .cbs = { diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index 8d6fe64646..edf2ecb845 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -49,6 +49,7 @@ int zebra_ptm_enable_modify(struct nb_cb_modify_args *args); void zebra_ptm_enable_cli_write(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); #endif +int zebra_route_map_delay_modify(struct nb_cb_modify_args *args); int zebra_debugs_debug_events_modify(struct nb_cb_modify_args *args); int zebra_debugs_debug_events_destroy(struct nb_cb_destroy_args *args); int zebra_debugs_debug_zapi_send_modify(struct nb_cb_modify_args *args); diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index 3ae8ab683c..0216d39170 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -290,6 +290,21 @@ int zebra_ptm_enable_modify(struct nb_cb_modify_args *args) } #endif +/* + * XPath: /frr-zebra:zebra/route-map-delay + */ +int zebra_route_map_delay_modify(struct nb_cb_modify_args *args) +{ + uint32_t delay = yang_dnode_get_uint32(args->dnode, NULL); + + if (args->event != NB_EV_APPLY) + return NB_OK; + + zebra_route_map_set_delay_timer(delay); + + return NB_OK; +} + /* * XPath: /frr-zebra:zebra/debugs/debug-events */ diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index cfa0a4af86..30359d1b90 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -36,8 +36,6 @@ struct zebra_rmap_obj { struct route_entry *re; }; -static void zebra_route_map_set_delay_timer(uint32_t value); - /* 'match tag TAG' * Match function return 1 if match is success else return 0 */ @@ -634,24 +632,20 @@ DEFPY_YANG( return nb_cli_apply_changes(vty, NULL); } -DEFUN_YANG (zebra_route_map_timer, +DEFPY_YANG (zebra_route_map_timer, zebra_route_map_timer_cmd, - "zebra route-map delay-timer (0-600)", + "zebra route-map delay-timer (0-600)$delay", ZEBRA_STR "Set route-map parameters\n" "Time to wait before route-map updates are processed\n" "0 means route-map changes are run immediately instead of delaying\n") { - int idx_number = 3; - uint32_t rmap_delay_timer; - - rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); - zebra_route_map_set_delay_timer(rmap_delay_timer); - - return (CMD_SUCCESS); + nb_cli_enqueue_change(vty, "/frr-zebra:zebra/route-map-delay", + NB_OP_MODIFY, delay_str); + return nb_cli_apply_changes(vty, NULL); } -DEFUN_YANG (no_zebra_route_map_timer, +DEFPY_YANG (no_zebra_route_map_timer, no_zebra_route_map_timer_cmd, "no zebra route-map delay-timer [(0-600)]", NO_STR @@ -660,9 +654,9 @@ DEFUN_YANG (no_zebra_route_map_timer, "Reset delay-timer to default value, 30 secs\n" "0 means route-map changes are run immediately instead of delaying\n") { - zebra_route_map_set_delay_timer(ZEBRA_RMAP_DEFAULT_UPDATE_TIMER); - - return (CMD_SUCCESS); + nb_cli_enqueue_change(vty, "/frr-zebra:zebra/route-map-delay", + NB_OP_DESTROY, NULL); + return nb_cli_apply_changes(vty, NULL); } DEFPY_YANG (ip_protocol, @@ -1677,7 +1671,7 @@ static void zebra_route_map_update_timer(struct event *thread) */ } -static void zebra_route_map_set_delay_timer(uint32_t value) +void zebra_route_map_set_delay_timer(uint32_t value) { zebra_rmap_update_timer = value; if (!value && zebra_t_rmap_update) { diff --git a/zebra/zebra_routemap.h b/zebra/zebra_routemap.h index 3b8edf50ea..bc36fd3997 100644 --- a/zebra/zebra_routemap.h +++ b/zebra/zebra_routemap.h @@ -35,6 +35,7 @@ extern route_map_result_t zebra_nht_route_map_check(afi_t afi, int client_proto, struct route_entry *re, struct nexthop *nexthop); +extern void zebra_route_map_set_delay_timer(uint32_t value); extern int ip_protocol_rm_add(struct zebra_vrf *zvrf, const char *rmap, int rtype, afi_t afi, safi_t safi); extern int ip_protocol_rm_del(struct zebra_vrf *zvrf, const char *rmap,