zebra: convert route-map delay-timer command to NB

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2024-01-27 02:15:56 +02:00
parent cc619176fe
commit 010bd3e570
6 changed files with 42 additions and 16 deletions

View File

@ -2920,6 +2920,15 @@ module frr-zebra {
description description
"Enable PTM globally."; "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 * Debug options
*/ */

View File

@ -103,6 +103,12 @@ const struct frr_yang_module_info frr_zebra_info = {
} }
}, },
#endif #endif
{
.xpath = "/frr-zebra:zebra/route-map-delay",
.cbs = {
.modify = zebra_route_map_delay_modify,
}
},
{ {
.xpath = "/frr-zebra:zebra/debugs/debug-events", .xpath = "/frr-zebra:zebra/debugs/debug-events",
.cbs = { .cbs = {

View File

@ -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, void zebra_ptm_enable_cli_write(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults); bool show_defaults);
#endif #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_modify(struct nb_cb_modify_args *args);
int zebra_debugs_debug_events_destroy(struct nb_cb_destroy_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); int zebra_debugs_debug_zapi_send_modify(struct nb_cb_modify_args *args);

View File

@ -290,6 +290,21 @@ int zebra_ptm_enable_modify(struct nb_cb_modify_args *args)
} }
#endif #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 * XPath: /frr-zebra:zebra/debugs/debug-events
*/ */

View File

@ -36,8 +36,6 @@ struct zebra_rmap_obj {
struct route_entry *re; struct route_entry *re;
}; };
static void zebra_route_map_set_delay_timer(uint32_t value);
/* 'match tag TAG' /* 'match tag TAG'
* Match function return 1 if match is success else return 0 * Match function return 1 if match is success else return 0
*/ */
@ -634,24 +632,20 @@ DEFPY_YANG(
return nb_cli_apply_changes(vty, NULL); 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_timer_cmd,
"zebra route-map delay-timer (0-600)", "zebra route-map delay-timer (0-600)$delay",
ZEBRA_STR ZEBRA_STR
"Set route-map parameters\n" "Set route-map parameters\n"
"Time to wait before route-map updates are processed\n" "Time to wait before route-map updates are processed\n"
"0 means route-map changes are run immediately instead of delaying\n") "0 means route-map changes are run immediately instead of delaying\n")
{ {
int idx_number = 3; nb_cli_enqueue_change(vty, "/frr-zebra:zebra/route-map-delay",
uint32_t rmap_delay_timer; NB_OP_MODIFY, delay_str);
return nb_cli_apply_changes(vty, NULL);
rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10);
zebra_route_map_set_delay_timer(rmap_delay_timer);
return (CMD_SUCCESS);
} }
DEFUN_YANG (no_zebra_route_map_timer, DEFPY_YANG (no_zebra_route_map_timer,
no_zebra_route_map_timer_cmd, no_zebra_route_map_timer_cmd,
"no zebra route-map delay-timer [(0-600)]", "no zebra route-map delay-timer [(0-600)]",
NO_STR NO_STR
@ -660,9 +654,9 @@ DEFUN_YANG (no_zebra_route_map_timer,
"Reset delay-timer to default value, 30 secs\n" "Reset delay-timer to default value, 30 secs\n"
"0 means route-map changes are run immediately instead of delaying\n") "0 means route-map changes are run immediately instead of delaying\n")
{ {
zebra_route_map_set_delay_timer(ZEBRA_RMAP_DEFAULT_UPDATE_TIMER); nb_cli_enqueue_change(vty, "/frr-zebra:zebra/route-map-delay",
NB_OP_DESTROY, NULL);
return (CMD_SUCCESS); return nb_cli_apply_changes(vty, NULL);
} }
DEFPY_YANG (ip_protocol, 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; zebra_rmap_update_timer = value;
if (!value && zebra_t_rmap_update) { if (!value && zebra_t_rmap_update) {

View File

@ -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 route_entry *re,
struct nexthop *nexthop); 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, extern int ip_protocol_rm_add(struct zebra_vrf *zvrf, const char *rmap,
int rtype, afi_t afi, safi_t safi); int rtype, afi_t afi, safi_t safi);
extern int ip_protocol_rm_del(struct zebra_vrf *zvrf, const char *rmap, extern int ip_protocol_rm_del(struct zebra_vrf *zvrf, const char *rmap,