forked from Mirror/frr
ripd: retrofit the 'timer basic' command to the new northbound model
Trivial conversion. Use the northbound 'apply_finish()' callback so we'll call rip_event() only once even if we change the three RIP timers at the same time. Convert the timers to uint32_t to match their representation in the YANG model. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
4068787842
commit
b745780b5f
|
@ -639,6 +639,79 @@ void cli_show_rip_route(struct vty *vty, struct lyd_node *dnode,
|
||||||
vty_out(vty, " route %s\n", yang_dnode_get_string(dnode, NULL));
|
vty_out(vty, " route %s\n", yang_dnode_get_string(dnode, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XPath: /frr-ripd:ripd/instance/timers
|
||||||
|
*/
|
||||||
|
DEFPY (rip_timers,
|
||||||
|
rip_timers_cmd,
|
||||||
|
"timers basic (5-2147483647)$update (5-2147483647)$timeout (5-2147483647)$garbage",
|
||||||
|
"Adjust routing timers\n"
|
||||||
|
"Basic routing protocol update timers\n"
|
||||||
|
"Routing table update timer value in second. Default is 30.\n"
|
||||||
|
"Routing information timeout timer. Default is 180.\n"
|
||||||
|
"Garbage collection timer. Default is 120.\n")
|
||||||
|
{
|
||||||
|
struct cli_config_change changes[] = {
|
||||||
|
{
|
||||||
|
.xpath = "./timers/update-interval",
|
||||||
|
.operation = NB_OP_MODIFY,
|
||||||
|
.value = update_str,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.xpath = "./timers/holddown-interval",
|
||||||
|
.operation = NB_OP_MODIFY,
|
||||||
|
.value = timeout_str,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.xpath = "./timers/flush-interval",
|
||||||
|
.operation = NB_OP_MODIFY,
|
||||||
|
.value = garbage_str,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFPY (no_rip_timers,
|
||||||
|
no_rip_timers_cmd,
|
||||||
|
"no timers basic [(5-2147483647) (5-2147483647) (5-2147483647)]",
|
||||||
|
NO_STR
|
||||||
|
"Adjust routing timers\n"
|
||||||
|
"Basic routing protocol update timers\n"
|
||||||
|
"Routing table update timer value in second. Default is 30.\n"
|
||||||
|
"Routing information timeout timer. Default is 180.\n"
|
||||||
|
"Garbage collection timer. Default is 120.\n")
|
||||||
|
{
|
||||||
|
struct cli_config_change changes[] = {
|
||||||
|
{
|
||||||
|
.xpath = "./timers/update-interval",
|
||||||
|
.operation = NB_OP_MODIFY,
|
||||||
|
.value = NULL,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.xpath = "./timers/holddown-interval",
|
||||||
|
.operation = NB_OP_MODIFY,
|
||||||
|
.value = NULL,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.xpath = "./timers/flush-interval",
|
||||||
|
.operation = NB_OP_MODIFY,
|
||||||
|
.value = NULL,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
|
||||||
|
}
|
||||||
|
|
||||||
|
void cli_show_rip_timers(struct vty *vty, struct lyd_node *dnode,
|
||||||
|
bool show_defaults)
|
||||||
|
{
|
||||||
|
vty_out(vty, " timers basic %s %s %s\n",
|
||||||
|
yang_dnode_get_string(dnode, "./update-interval"),
|
||||||
|
yang_dnode_get_string(dnode, "./holddown-interval"),
|
||||||
|
yang_dnode_get_string(dnode, "./flush-interval"));
|
||||||
|
}
|
||||||
|
|
||||||
void rip_cli_init(void)
|
void rip_cli_init(void)
|
||||||
{
|
{
|
||||||
install_element(CONFIG_NODE, &router_rip_cmd);
|
install_element(CONFIG_NODE, &router_rip_cmd);
|
||||||
|
@ -662,4 +735,6 @@ void rip_cli_init(void)
|
||||||
install_element(RIP_NODE, &rip_redistribute_cmd);
|
install_element(RIP_NODE, &rip_redistribute_cmd);
|
||||||
install_element(RIP_NODE, &no_rip_redistribute_cmd);
|
install_element(RIP_NODE, &no_rip_redistribute_cmd);
|
||||||
install_element(RIP_NODE, &rip_route_cmd);
|
install_element(RIP_NODE, &rip_route_cmd);
|
||||||
|
install_element(RIP_NODE, &rip_timers_cmd);
|
||||||
|
install_element(RIP_NODE, &no_rip_timers_cmd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,5 +57,7 @@ extern void cli_show_rip_redistribute(struct vty *vty, struct lyd_node *dnode,
|
||||||
bool show_defaults);
|
bool show_defaults);
|
||||||
extern void cli_show_rip_route(struct vty *vty, struct lyd_node *dnode,
|
extern void cli_show_rip_route(struct vty *vty, struct lyd_node *dnode,
|
||||||
bool show_defaults);
|
bool show_defaults);
|
||||||
|
extern void cli_show_rip_timers(struct vty *vty, struct lyd_node *dnode,
|
||||||
|
bool show_defaults);
|
||||||
|
|
||||||
#endif /* _FRR_RIP_CLI_H_ */
|
#endif /* _FRR_RIP_CLI_H_ */
|
||||||
|
|
|
@ -691,6 +691,15 @@ static int ripd_instance_static_route_delete(enum nb_event event,
|
||||||
return NB_OK;
|
return NB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XPath: /frr-ripd:ripd/instance/timers/
|
||||||
|
*/
|
||||||
|
static void ripd_instance_timers_apply_finish(const struct lyd_node *dnode)
|
||||||
|
{
|
||||||
|
/* Reset update timer thread. */
|
||||||
|
rip_event(RIP_UPDATE_EVENT, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XPath: /frr-ripd:ripd/instance/timers/flush-interval
|
* XPath: /frr-ripd:ripd/instance/timers/flush-interval
|
||||||
*/
|
*/
|
||||||
|
@ -699,7 +708,11 @@ ripd_instance_timers_flush_interval_modify(enum nb_event event,
|
||||||
const struct lyd_node *dnode,
|
const struct lyd_node *dnode,
|
||||||
union nb_resource *resource)
|
union nb_resource *resource)
|
||||||
{
|
{
|
||||||
/* TODO: implement me. */
|
if (event != NB_EV_APPLY)
|
||||||
|
return NB_OK;
|
||||||
|
|
||||||
|
rip->garbage_time = yang_dnode_get_uint32(dnode, NULL);
|
||||||
|
|
||||||
return NB_OK;
|
return NB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,7 +724,11 @@ ripd_instance_timers_holddown_interval_modify(enum nb_event event,
|
||||||
const struct lyd_node *dnode,
|
const struct lyd_node *dnode,
|
||||||
union nb_resource *resource)
|
union nb_resource *resource)
|
||||||
{
|
{
|
||||||
/* TODO: implement me. */
|
if (event != NB_EV_APPLY)
|
||||||
|
return NB_OK;
|
||||||
|
|
||||||
|
rip->timeout_time = yang_dnode_get_uint32(dnode, NULL);
|
||||||
|
|
||||||
return NB_OK;
|
return NB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,7 +740,11 @@ ripd_instance_timers_update_interval_modify(enum nb_event event,
|
||||||
const struct lyd_node *dnode,
|
const struct lyd_node *dnode,
|
||||||
union nb_resource *resource)
|
union nb_resource *resource)
|
||||||
{
|
{
|
||||||
/* TODO: implement me. */
|
if (event != NB_EV_APPLY)
|
||||||
|
return NB_OK;
|
||||||
|
|
||||||
|
rip->update_time = yang_dnode_get_uint32(dnode, NULL);
|
||||||
|
|
||||||
return NB_OK;
|
return NB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1128,6 +1149,11 @@ const struct frr_yang_module_info frr_ripd_info = {
|
||||||
.cbs.delete = ripd_instance_static_route_delete,
|
.cbs.delete = ripd_instance_static_route_delete,
|
||||||
.cbs.cli_show = cli_show_rip_route,
|
.cbs.cli_show = cli_show_rip_route,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.xpath = "/frr-ripd:ripd/instance/timers",
|
||||||
|
.cbs.apply_finish = ripd_instance_timers_apply_finish,
|
||||||
|
.cbs.cli_show = cli_show_rip_timers,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.xpath = "/frr-ripd:ripd/instance/timers/flush-interval",
|
.xpath = "/frr-ripd:ripd/instance/timers/flush-interval",
|
||||||
.cbs.modify = ripd_instance_timers_flush_interval_modify,
|
.cbs.modify = ripd_instance_timers_flush_interval_modify,
|
||||||
|
|
89
ripd/ripd.c
89
ripd/ripd.c
|
@ -65,7 +65,6 @@ long rip_global_route_changes = 0;
|
||||||
long rip_global_queries = 0;
|
long rip_global_queries = 0;
|
||||||
|
|
||||||
/* Prototypes. */
|
/* Prototypes. */
|
||||||
static void rip_event(enum rip_event, int);
|
|
||||||
static void rip_output_process(struct connected *, struct sockaddr_in *, int,
|
static void rip_output_process(struct connected *, struct sockaddr_in *, int,
|
||||||
uint8_t);
|
uint8_t);
|
||||||
static int rip_triggered_update(struct thread *);
|
static int rip_triggered_update(struct thread *);
|
||||||
|
@ -2851,78 +2850,6 @@ rip_update_default_metric (void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DEFUN (rip_timers,
|
|
||||||
rip_timers_cmd,
|
|
||||||
"timers basic (5-2147483647) (5-2147483647) (5-2147483647)",
|
|
||||||
"Adjust routing timers\n"
|
|
||||||
"Basic routing protocol update timers\n"
|
|
||||||
"Routing table update timer value in second. Default is 30.\n"
|
|
||||||
"Routing information timeout timer. Default is 180.\n"
|
|
||||||
"Garbage collection timer. Default is 120.\n")
|
|
||||||
{
|
|
||||||
int idx_number = 2;
|
|
||||||
int idx_number_2 = 3;
|
|
||||||
int idx_number_3 = 4;
|
|
||||||
unsigned long update;
|
|
||||||
unsigned long timeout;
|
|
||||||
unsigned long garbage;
|
|
||||||
char *endptr = NULL;
|
|
||||||
unsigned long RIP_TIMER_MAX = 2147483647;
|
|
||||||
unsigned long RIP_TIMER_MIN = 5;
|
|
||||||
|
|
||||||
update = strtoul(argv[idx_number]->arg, &endptr, 10);
|
|
||||||
if (update > RIP_TIMER_MAX || update < RIP_TIMER_MIN
|
|
||||||
|| *endptr != '\0') {
|
|
||||||
vty_out(vty, "update timer value error\n");
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
timeout = strtoul(argv[idx_number_2]->arg, &endptr, 10);
|
|
||||||
if (timeout > RIP_TIMER_MAX || timeout < RIP_TIMER_MIN
|
|
||||||
|| *endptr != '\0') {
|
|
||||||
vty_out(vty, "timeout timer value error\n");
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
garbage = strtoul(argv[idx_number_3]->arg, &endptr, 10);
|
|
||||||
if (garbage > RIP_TIMER_MAX || garbage < RIP_TIMER_MIN
|
|
||||||
|| *endptr != '\0') {
|
|
||||||
vty_out(vty, "garbage timer value error\n");
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set each timer value. */
|
|
||||||
rip->update_time = update;
|
|
||||||
rip->timeout_time = timeout;
|
|
||||||
rip->garbage_time = garbage;
|
|
||||||
|
|
||||||
/* Reset update timer thread. */
|
|
||||||
rip_event(RIP_UPDATE_EVENT, 0);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN (no_rip_timers,
|
|
||||||
no_rip_timers_cmd,
|
|
||||||
"no timers basic [(0-65535) (0-65535) (0-65535)]",
|
|
||||||
NO_STR
|
|
||||||
"Adjust routing timers\n"
|
|
||||||
"Basic routing protocol update timers\n"
|
|
||||||
"Routing table update timer value in second. Default is 30.\n"
|
|
||||||
"Routing information timeout timer. Default is 180.\n"
|
|
||||||
"Garbage collection timer. Default is 120.\n")
|
|
||||||
{
|
|
||||||
/* Set each timer value to the default. */
|
|
||||||
rip->update_time = RIP_UPDATE_TIMER_DEFAULT;
|
|
||||||
rip->timeout_time = RIP_TIMEOUT_TIMER_DEFAULT;
|
|
||||||
rip->garbage_time = RIP_GARBAGE_TIMER_DEFAULT;
|
|
||||||
|
|
||||||
/* Reset update timer thread. */
|
|
||||||
rip_event(RIP_UPDATE_EVENT, 0);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct route_table *rip_distance_table;
|
struct route_table *rip_distance_table;
|
||||||
|
|
||||||
|
@ -3219,12 +3146,12 @@ DEFUN (show_ip_rip_status,
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
vty_out(vty, "Routing Protocol is \"rip\"\n");
|
vty_out(vty, "Routing Protocol is \"rip\"\n");
|
||||||
vty_out(vty, " Sending updates every %ld seconds with +/-50%%,",
|
vty_out(vty, " Sending updates every %u seconds with +/-50%%,",
|
||||||
rip->update_time);
|
rip->update_time);
|
||||||
vty_out(vty, " next due in %lu seconds\n",
|
vty_out(vty, " next due in %lu seconds\n",
|
||||||
thread_timer_remain_second(rip->t_update));
|
thread_timer_remain_second(rip->t_update));
|
||||||
vty_out(vty, " Timeout after %ld seconds,", rip->timeout_time);
|
vty_out(vty, " Timeout after %u seconds,", rip->timeout_time);
|
||||||
vty_out(vty, " garbage collect after %ld seconds\n", rip->garbage_time);
|
vty_out(vty, " garbage collect after %u seconds\n", rip->garbage_time);
|
||||||
|
|
||||||
/* Filtering status show. */
|
/* Filtering status show. */
|
||||||
config_show_distribute(vty);
|
config_show_distribute(vty);
|
||||||
|
@ -3325,14 +3252,6 @@ static int config_write_rip(struct vty *vty)
|
||||||
|| rip->version_recv != RI_RIP_VERSION_1_AND_2)
|
|| rip->version_recv != RI_RIP_VERSION_1_AND_2)
|
||||||
vty_out(vty, " version %d\n", rip->version_send);
|
vty_out(vty, " version %d\n", rip->version_send);
|
||||||
|
|
||||||
/* RIP timer configuration. */
|
|
||||||
if (rip->update_time != RIP_UPDATE_TIMER_DEFAULT
|
|
||||||
|| rip->timeout_time != RIP_TIMEOUT_TIMER_DEFAULT
|
|
||||||
|| rip->garbage_time != RIP_GARBAGE_TIMER_DEFAULT)
|
|
||||||
vty_out(vty, " timers basic %lu %lu %lu\n",
|
|
||||||
rip->update_time, rip->timeout_time,
|
|
||||||
rip->garbage_time);
|
|
||||||
|
|
||||||
/* Distribute configuration. */
|
/* Distribute configuration. */
|
||||||
write += config_write_distribute(vty);
|
write += config_write_distribute(vty);
|
||||||
|
|
||||||
|
@ -3603,8 +3522,6 @@ void rip_init(void)
|
||||||
install_default(RIP_NODE);
|
install_default(RIP_NODE);
|
||||||
install_element(RIP_NODE, &rip_version_cmd);
|
install_element(RIP_NODE, &rip_version_cmd);
|
||||||
install_element(RIP_NODE, &no_rip_version_cmd);
|
install_element(RIP_NODE, &no_rip_version_cmd);
|
||||||
install_element(RIP_NODE, &rip_timers_cmd);
|
|
||||||
install_element(RIP_NODE, &no_rip_timers_cmd);
|
|
||||||
|
|
||||||
/* Debug related init. */
|
/* Debug related init. */
|
||||||
rip_debug_init();
|
rip_debug_init();
|
||||||
|
|
12
ripd/ripd.h
12
ripd/ripd.h
|
@ -60,11 +60,6 @@
|
||||||
#define INADDR_RIP_GROUP 0xe0000009 /* 224.0.0.9 */
|
#define INADDR_RIP_GROUP 0xe0000009 /* 224.0.0.9 */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* RIP timers */
|
|
||||||
#define RIP_UPDATE_TIMER_DEFAULT 30
|
|
||||||
#define RIP_TIMEOUT_TIMER_DEFAULT 180
|
|
||||||
#define RIP_GARBAGE_TIMER_DEFAULT 120
|
|
||||||
|
|
||||||
/* RIP peer timeout value. */
|
/* RIP peer timeout value. */
|
||||||
#define RIP_PEER_TIMER_DEFAULT 180
|
#define RIP_PEER_TIMER_DEFAULT 180
|
||||||
|
|
||||||
|
@ -132,9 +127,9 @@ struct rip {
|
||||||
struct thread *t_triggered_interval;
|
struct thread *t_triggered_interval;
|
||||||
|
|
||||||
/* RIP timer values. */
|
/* RIP timer values. */
|
||||||
unsigned long update_time;
|
uint32_t update_time;
|
||||||
unsigned long timeout_time;
|
uint32_t timeout_time;
|
||||||
unsigned long garbage_time;
|
uint32_t garbage_time;
|
||||||
|
|
||||||
/* RIP default metric. */
|
/* RIP default metric. */
|
||||||
uint8_t default_metric;
|
uint8_t default_metric;
|
||||||
|
@ -412,6 +407,7 @@ extern int rip_enable_network_delete(struct prefix *p);
|
||||||
extern int rip_enable_if_add(const char *ifname);
|
extern int rip_enable_if_add(const char *ifname);
|
||||||
extern int rip_enable_if_delete(const char *ifname);
|
extern int rip_enable_if_delete(const char *ifname);
|
||||||
|
|
||||||
|
extern void rip_event(enum rip_event, int);
|
||||||
extern void rip_ecmp_disable(void);
|
extern void rip_ecmp_disable(void);
|
||||||
|
|
||||||
extern int rip_create_socket(void);
|
extern int rip_create_socket(void);
|
||||||
|
|
Loading…
Reference in a new issue