summaryrefslogtreecommitdiff
path: root/bfdd/bfdd_cli.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-05-28 15:25:36 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-06-01 18:08:29 +0300
commit874ca769973550d6d9c0ead69b5e2e7472014a36 (patch)
tree9027b42bc1919158830339566b845ddf153b8bd5 /bfdd/bfdd_cli.c
parentedc3622d8283b8d8fb66b08d7b1256b75b1a7617 (diff)
bfdd: forbid setting interface for multihop sessions
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'bfdd/bfdd_cli.c')
-rw-r--r--bfdd/bfdd_cli.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/bfdd/bfdd_cli.c b/bfdd/bfdd_cli.c
index 6ec724d80c..26ff4a758a 100644
--- a/bfdd/bfdd_cli.c
+++ b/bfdd/bfdd_cli.c
@@ -125,7 +125,13 @@ DEFPY_YANG_NOSH(
if (multihop) {
if (!local_address_str) {
- vty_out(vty, "%% local-address is required when using multihop\n");
+ vty_out(vty,
+ "%% local-address is required when using multihop\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ if (ifname) {
+ vty_out(vty,
+ "%% interface is prohibited when using multihop\n");
return CMD_WARNING_CONFIG_FAILED;
}
snprintf(source_str, sizeof(source_str), "[source-addr='%s']",
@@ -140,7 +146,7 @@ DEFPY_YANG_NOSH(
if (ifname)
slen += snprintf(xpath + slen, sizeof(xpath) - slen,
"[interface='%s']", ifname);
- else
+ else if (!multihop)
slen += snprintf(xpath + slen, sizeof(xpath) - slen,
"[interface='*']");
if (vrf)
@@ -185,10 +191,20 @@ DEFPY_YANG(
char xpath[XPATH_MAXLEN];
char source_str[INET6_ADDRSTRLEN + 32];
- if (multihop)
+ if (multihop) {
+ if (!local_address_str) {
+ vty_out(vty,
+ "%% local-address is required when using multihop\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ if (ifname) {
+ vty_out(vty,
+ "%% interface is prohibited when using multihop\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
snprintf(source_str, sizeof(source_str), "[source-addr='%s']",
local_address_str);
- else
+ } else
source_str[0] = 0;
slen = snprintf(xpath, sizeof(xpath),
@@ -198,7 +214,7 @@ DEFPY_YANG(
if (ifname)
slen += snprintf(xpath + slen, sizeof(xpath) - slen,
"[interface='%s']", ifname);
- else
+ else if (!multihop)
slen += snprintf(xpath + slen, sizeof(xpath) - slen,
"[interface='*']");
if (vrf)
@@ -218,7 +234,6 @@ static void _bfd_cli_show_peer(struct vty *vty, struct lyd_node *dnode,
bool mhop)
{
const char *vrf = yang_dnode_get_string(dnode, "./vrf");
- const char *ifname = yang_dnode_get_string(dnode, "./interface");
vty_out(vty, " peer %s",
yang_dnode_get_string(dnode, "./dest-addr"));
@@ -233,8 +248,12 @@ static void _bfd_cli_show_peer(struct vty *vty, struct lyd_node *dnode,
if (strcmp(vrf, VRF_DEFAULT_NAME))
vty_out(vty, " vrf %s", vrf);
- if (strcmp(ifname, "*"))
- vty_out(vty, " interface %s", ifname);
+ if (!mhop) {
+ const char *ifname =
+ yang_dnode_get_string(dnode, "./interface");
+ if (strcmp(ifname, "*"))
+ vty_out(vty, " interface %s", ifname);
+ }
vty_out(vty, "\n");
}