diff options
author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2019-06-12 23:05:19 +0200 |
---|---|---|
committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2019-06-22 15:10:56 +0200 |
commit | 8a676ce6b13eeec581856471d543d92aae2392f6 (patch) | |
tree | f41058a1a34c15d27cf374b4805db153302cdad6 /bfdd | |
parent | lib: fix northbound static analyzer warning (diff) | |
download | frr-8a676ce6b13eeec581856471d543d92aae2392f6.tar.xz frr-8a676ce6b13eeec581856471d543d92aae2392f6.zip |
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>
Diffstat (limited to 'bfdd')
-rw-r--r-- | bfdd/bfdd_cli.c | 45 | ||||
-rw-r--r-- | bfdd/bfdd_northbound.c | 21 |
2 files changed, 39 insertions, 27 deletions
diff --git a/bfdd/bfdd_cli.c b/bfdd/bfdd_cli.c index 64500cef7..29b77a409 100644 --- a/bfdd/bfdd_cli.c +++ b/bfdd/bfdd_cli.c @@ -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 diff --git a/bfdd/bfdd_northbound.c b/bfdd/bfdd_northbound.c index fd007b57b..24fdfa1ea 100644 --- a/bfdd/bfdd_northbound.c +++ b/bfdd/bfdd_northbound.c @@ -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); } /* |