bfdd: fix nb cli show with defaults

The idea of the "with-defaults" flag is to show the default values for
parameters that were not configured by the user. But bfdd incorrectly
shows the default values for all parameters, including the
user-configured ones.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2021-04-12 14:17:30 +03:00
parent 8435eae7bb
commit 613bcbc5d5

View File

@ -273,9 +273,6 @@ DEFPY_YANG(
void bfd_cli_show_shutdown(struct vty *vty, struct lyd_node *dnode, void bfd_cli_show_shutdown(struct vty *vty, struct lyd_node *dnode,
bool show_defaults) bool show_defaults)
{ {
if (show_defaults)
vty_out(vty, " no shutdown\n");
else
vty_out(vty, " %sshutdown\n", vty_out(vty, " %sshutdown\n",
yang_dnode_get_bool(dnode, NULL) ? "" : "no "); yang_dnode_get_bool(dnode, NULL) ? "" : "no ");
} }
@ -294,9 +291,6 @@ DEFPY_YANG(
void bfd_cli_show_passive(struct vty *vty, struct lyd_node *dnode, void bfd_cli_show_passive(struct vty *vty, struct lyd_node *dnode,
bool show_defaults) bool show_defaults)
{ {
if (show_defaults)
vty_out(vty, " no passive-mode\n");
else
vty_out(vty, " %spassive-mode\n", vty_out(vty, " %spassive-mode\n",
yang_dnode_get_bool(dnode, NULL) ? "" : "no "); yang_dnode_get_bool(dnode, NULL) ? "" : "no ");
} }
@ -335,11 +329,7 @@ DEFPY_YANG(
void bfd_cli_show_minimum_ttl(struct vty *vty, struct lyd_node *dnode, void bfd_cli_show_minimum_ttl(struct vty *vty, struct lyd_node *dnode,
bool show_defaults) bool show_defaults)
{ {
if (show_defaults) vty_out(vty, " minimum-ttl %s\n", yang_dnode_get_string(dnode, NULL));
vty_out(vty, " minimum-ttl 254\n");
else
vty_out(vty, " minimum-ttl %s\n",
yang_dnode_get_string(dnode, NULL));
} }
DEFPY_YANG( DEFPY_YANG(
@ -356,10 +346,6 @@ DEFPY_YANG(
void bfd_cli_show_mult(struct vty *vty, struct lyd_node *dnode, void bfd_cli_show_mult(struct vty *vty, struct lyd_node *dnode,
bool show_defaults) bool show_defaults)
{ {
if (show_defaults)
vty_out(vty, " detect-multiplier %d\n",
BFD_DEFDETECTMULT);
else
vty_out(vty, " detect-multiplier %s\n", vty_out(vty, " detect-multiplier %s\n",
yang_dnode_get_string(dnode, NULL)); yang_dnode_get_string(dnode, NULL));
} }
@ -382,16 +368,10 @@ DEFPY_YANG(
void bfd_cli_show_rx(struct vty *vty, struct lyd_node *dnode, void bfd_cli_show_rx(struct vty *vty, struct lyd_node *dnode,
bool show_defaults) bool show_defaults)
{ {
uint32_t value; uint32_t value = yang_dnode_get_uint32(dnode, NULL);
if (show_defaults)
vty_out(vty, " receive-interval %d\n",
BFD_DEFREQUIREDMINRX);
else {
value = yang_dnode_get_uint32(dnode, NULL);
vty_out(vty, " receive-interval %u\n", value / 1000); vty_out(vty, " receive-interval %u\n", value / 1000);
} }
}
DEFPY_YANG( DEFPY_YANG(
bfd_peer_tx, bfd_peer_tx_cmd, bfd_peer_tx, bfd_peer_tx_cmd,
@ -411,16 +391,10 @@ DEFPY_YANG(
void bfd_cli_show_tx(struct vty *vty, struct lyd_node *dnode, void bfd_cli_show_tx(struct vty *vty, struct lyd_node *dnode,
bool show_defaults) bool show_defaults)
{ {
uint32_t value; uint32_t value = yang_dnode_get_uint32(dnode, NULL);
if (show_defaults)
vty_out(vty, " transmit-interval %d\n",
BFD_DEFDESIREDMINTX);
else {
value = yang_dnode_get_uint32(dnode, NULL);
vty_out(vty, " transmit-interval %u\n", value / 1000); vty_out(vty, " transmit-interval %u\n", value / 1000);
} }
}
DEFPY_YANG( DEFPY_YANG(
bfd_peer_echo, bfd_peer_echo_cmd, bfd_peer_echo, bfd_peer_echo_cmd,
@ -445,9 +419,6 @@ DEFPY_YANG(
void bfd_cli_show_echo(struct vty *vty, struct lyd_node *dnode, void bfd_cli_show_echo(struct vty *vty, struct lyd_node *dnode,
bool show_defaults) bool show_defaults)
{ {
if (show_defaults)
vty_out(vty, " no echo-mode\n");
else
vty_out(vty, " %secho-mode\n", vty_out(vty, " %secho-mode\n",
yang_dnode_get_bool(dnode, NULL) ? "" : "no "); yang_dnode_get_bool(dnode, NULL) ? "" : "no ");
} }
@ -498,16 +469,10 @@ DEFPY_YANG(
void bfd_cli_show_desired_echo_transmission_interval(struct vty *vty, void bfd_cli_show_desired_echo_transmission_interval(struct vty *vty,
struct lyd_node *dnode, bool show_defaults) struct lyd_node *dnode, bool show_defaults)
{ {
uint32_t value; uint32_t value = yang_dnode_get_uint32(dnode, NULL);
if (show_defaults)
vty_out(vty, " echo transmit-interval %d\n",
BFD_DEF_DES_MIN_ECHO_TX);
else {
value = yang_dnode_get_uint32(dnode, NULL);
vty_out(vty, " echo transmit-interval %u\n", value / 1000); vty_out(vty, " echo transmit-interval %u\n", value / 1000);
} }
}
DEFPY_YANG( DEFPY_YANG(
bfd_peer_echo_receive_interval, bfd_peer_echo_receive_interval_cmd, bfd_peer_echo_receive_interval, bfd_peer_echo_receive_interval_cmd,
@ -538,20 +503,13 @@ DEFPY_YANG(
void bfd_cli_show_required_echo_receive_interval(struct vty *vty, void bfd_cli_show_required_echo_receive_interval(struct vty *vty,
struct lyd_node *dnode, bool show_defaults) struct lyd_node *dnode, bool show_defaults)
{ {
uint32_t value; uint32_t value = yang_dnode_get_uint32(dnode, NULL);
if (show_defaults)
vty_out(vty, " echo receive-interval %d\n",
BFD_DEF_REQ_MIN_ECHO_RX);
else {
value = yang_dnode_get_uint32(dnode, NULL);
if (value) if (value)
vty_out(vty, " echo receive-interval %u\n", vty_out(vty, " echo receive-interval %u\n", value / 1000);
value / 1000);
else else
vty_out(vty, " echo receive-interval disabled\n"); vty_out(vty, " echo receive-interval disabled\n");
} }
}
/* /*
* Profile commands. * Profile commands.