bfdd: use microseconds timers in YANG

Lets allow specification to accept microseconds, but limit the timers
configuration in FRR to milliseconds (minimum is 10 ms and maximum is 60
seconds).

This matches the RFC 5880 and the IETF BFD YANG draft model.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
Rafael Zalamena 2019-06-12 18:05:19 -03:00
parent 020a390649
commit 8a676ce6b1
3 changed files with 48 additions and 36 deletions

View File

@ -269,20 +269,27 @@ DEFPY(
"Configure peer receive interval\n"
"Configure peer receive interval value in milliseconds\n")
{
char value[32];
snprintf(value, sizeof(value), "%ld", interval * 1000);
nb_cli_enqueue_change(vty, "./required-receive-interval", NB_OP_MODIFY,
interval_str);
value);
return nb_cli_apply_changes(vty, NULL);
}
void bfd_cli_show_rx(struct vty *vty, struct lyd_node *dnode,
bool show_defaults)
{
uint32_t value;
if (show_defaults)
vty_out(vty, " receive-interval %d\n",
BFD_DEFREQUIREDMINRX);
else
vty_out(vty, " receive-interval %s\n",
yang_dnode_get_string(dnode, NULL));
else {
value = yang_dnode_get_uint32(dnode, NULL);
vty_out(vty, " receive-interval %" PRIu32 "\n", value / 1000);
}
}
DEFPY(
@ -291,20 +298,27 @@ DEFPY(
"Configure peer transmit interval\n"
"Configure peer transmit interval value in milliseconds\n")
{
char value[32];
snprintf(value, sizeof(value), "%ld", interval * 1000);
nb_cli_enqueue_change(vty, "./desired-transmission-interval",
NB_OP_MODIFY, interval_str);
NB_OP_MODIFY, value);
return nb_cli_apply_changes(vty, NULL);
}
void bfd_cli_show_tx(struct vty *vty, struct lyd_node *dnode,
bool show_defaults)
{
uint32_t value;
if (show_defaults)
vty_out(vty, " transmit-interval %d\n",
BFD_DEFDESIREDMINTX);
else
vty_out(vty, " transmit-interval %s\n",
yang_dnode_get_string(dnode, NULL));
else {
value = yang_dnode_get_uint32(dnode, NULL);
vty_out(vty, " transmit-interval %" PRIu32 "\n", value / 1000);
}
}
DEFPY(
@ -334,20 +348,27 @@ DEFPY(
"Configure peer echo interval\n"
"Configure peer echo interval value in milliseconds\n")
{
char value[32];
snprintf(value, sizeof(value), "%ld", interval * 1000);
nb_cli_enqueue_change(vty, "./desired-echo-transmission-interval",
NB_OP_MODIFY, interval_str);
NB_OP_MODIFY, value);
return nb_cli_apply_changes(vty, NULL);
}
void bfd_cli_show_echo_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults)
{
uint32_t value;
if (show_defaults)
vty_out(vty, " echo-interval %d\n",
BFD_DEF_REQ_MIN_ECHO);
else
vty_out(vty, " echo-interval %s\n",
yang_dnode_get_string(dnode, NULL));
else {
value = yang_dnode_get_uint32(dnode, NULL);
vty_out(vty, " echo-interval %" PRIu32 "\n", value / 1000);
}
}
void

View File

@ -327,7 +327,7 @@ static int bfdd_bfd_sessions_single_hop_desired_transmission_interval_modify(
switch (event) {
case NB_EV_VALIDATE:
if (tx_interval < 10 || tx_interval > 60000)
if (tx_interval < 10000 || tx_interval > 60000000)
return NB_ERR_VALIDATION;
break;
@ -337,8 +337,6 @@ static int bfdd_bfd_sessions_single_hop_desired_transmission_interval_modify(
case NB_EV_APPLY:
bs = nb_running_get_entry(dnode, NULL, true);
tx_interval *= 1000;
if (tx_interval == bs->timers.desired_min_tx)
return NB_OK;
@ -366,7 +364,7 @@ static int bfdd_bfd_sessions_single_hop_required_receive_interval_modify(
switch (event) {
case NB_EV_VALIDATE:
if (rx_interval < 10 || rx_interval > 60000)
if (rx_interval < 10000 || rx_interval > 60000000)
return NB_ERR_VALIDATION;
break;
@ -376,8 +374,6 @@ static int bfdd_bfd_sessions_single_hop_required_receive_interval_modify(
case NB_EV_APPLY:
bs = nb_running_get_entry(dnode, NULL, true);
rx_interval *= 1000;
if (rx_interval == bs->timers.required_min_rx)
return NB_OK;
@ -513,7 +509,7 @@ bfdd_bfd_sessions_single_hop_desired_echo_transmission_interval_modify(
switch (event) {
case NB_EV_VALIDATE:
if (echo_interval < 10 || echo_interval > 60000)
if (echo_interval < 10000 || echo_interval > 60000000)
return NB_ERR_VALIDATION;
break;
@ -523,8 +519,6 @@ bfdd_bfd_sessions_single_hop_desired_echo_transmission_interval_modify(
case NB_EV_APPLY:
bs = nb_running_get_entry(dnode, NULL, true);
echo_interval *= 1000;
if (echo_interval == bs->timers.required_min_echo)
return NB_OK;
@ -648,8 +642,7 @@ bfdd_bfd_sessions_single_hop_stats_negotiated_transmission_interval_get_elem(
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint32(xpath,
bs->remote_timers.desired_min_tx / 1000);
return yang_data_new_uint32(xpath, bs->remote_timers.desired_min_tx);
}
/*
@ -662,8 +655,7 @@ bfdd_bfd_sessions_single_hop_stats_negotiated_receive_interval_get_elem(
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint32(xpath,
bs->remote_timers.required_min_rx / 1000);
return yang_data_new_uint32(xpath, bs->remote_timers.required_min_rx);
}
/*
@ -785,8 +777,7 @@ bfdd_bfd_sessions_single_hop_stats_negotiated_echo_transmission_interval_get_ele
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint32(xpath,
bs->remote_timers.required_min_echo / 1000);
return yang_data_new_uint32(xpath, bs->remote_timers.required_min_echo);
}
/*

View File

@ -128,15 +128,15 @@ module frr-bfdd {
leaf desired-transmission-interval {
type uint32;
units milliseconds;
default 300;
units microseconds;
default 300000;
description "Minimum desired control packet transmission interval";
}
leaf required-receive-interval {
type uint32;
units milliseconds;
default 300;
units microseconds;
default 300000;
description "Minimum required control packet receive interval";
}
@ -158,8 +158,8 @@ module frr-bfdd {
leaf desired-echo-transmission-interval {
type uint32;
units milliseconds;
default 50;
units microseconds;
default 50000;
description "Minimum desired control packet transmission interval";
}
}
@ -217,13 +217,13 @@ module frr-bfdd {
leaf negotiated-transmission-interval {
description "Negotiated transmit interval";
type uint32;
units milliseconds;
units microseconds;
}
leaf negotiated-receive-interval {
description "Negotiated receive interval";
type uint32;
units milliseconds;
units microseconds;
}
leaf detection-mode {
@ -287,7 +287,7 @@ module frr-bfdd {
*/
leaf negotiated-echo-transmission-interval {
type uint32;
units milliseconds;
units microseconds;
description "Negotiated echo transmit interval";
}