Merge pull request #7640 from opensourcerouting/bfd-echo-minttl-check

bfdd: session specific command type checks
This commit is contained in:
Donald Sharp 2020-12-01 09:31:57 -05:00 committed by GitHub
commit 9171f28204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,6 +51,11 @@
/* /*
* Prototypes. * Prototypes.
*/ */
static bool
bfd_cli_is_single_hop(struct vty *vty)
{
return strstr(VTY_CURR_XPATH, "/single-hop") != NULL;
}
/* /*
* Functions. * Functions.
@ -293,6 +298,11 @@ DEFPY_YANG(
"Expect packets with at least this TTL\n" "Expect packets with at least this TTL\n"
"Minimum TTL expected\n") "Minimum TTL expected\n")
{ {
if (bfd_cli_is_single_hop(vty)) {
vty_out(vty, "%% Minimum TTL is only available for multi hop sessions.\n");
return CMD_WARNING_CONFIG_FAILED;
}
if (no) if (no)
nb_cli_enqueue_change(vty, "./minimum-ttl", NB_OP_DESTROY, nb_cli_enqueue_change(vty, "./minimum-ttl", NB_OP_DESTROY,
NULL); NULL);
@ -408,6 +418,11 @@ DEFPY_YANG(
NO_STR NO_STR
"Configure echo mode\n") "Configure echo mode\n")
{ {
if (!bfd_cli_is_single_hop(vty)) {
vty_out(vty, "%% Echo mode is only available for single hop sessions.\n");
return CMD_WARNING_CONFIG_FAILED;
}
nb_cli_enqueue_change(vty, "./echo-mode", NB_OP_MODIFY, nb_cli_enqueue_change(vty, "./echo-mode", NB_OP_MODIFY,
no ? "false" : "true"); no ? "false" : "true");
return nb_cli_apply_changes(vty, NULL); return nb_cli_apply_changes(vty, NULL);
@ -431,6 +446,11 @@ DEFPY_YANG(
{ {
char value[32]; char value[32];
if (!bfd_cli_is_single_hop(vty)) {
vty_out(vty, "%% Echo mode is only available for single hop sessions.\n");
return CMD_WARNING_CONFIG_FAILED;
}
snprintf(value, sizeof(value), "%ld", interval * 1000); snprintf(value, sizeof(value), "%ld", interval * 1000);
nb_cli_enqueue_change(vty, "./desired-echo-transmission-interval", nb_cli_enqueue_change(vty, "./desired-echo-transmission-interval",
NB_OP_MODIFY, value); NB_OP_MODIFY, value);