summaryrefslogtreecommitdiff
path: root/ospfd/ospf_ri.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2016-10-25 20:29:52 +0000
committerQuentin Young <qlyoung@cumulusnetworks.com>2016-10-25 20:29:52 +0000
commitd64ff607e8a5b84cb3226bd38a5af09668a05fd3 (patch)
tree5986c22d3fb8aaf17d64226a7cdd4fcd913fef2f /ospfd/ospf_ri.c
parente9e190f2452653469f652a04ef34294430787497 (diff)
parent284a4a0c81516e3e18cb170272a280ea5121b6d6 (diff)
Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> Conflicts: ospfd/ospf_ri.c zebra/zebra_vty.c
Diffstat (limited to 'ospfd/ospf_ri.c')
-rw-r--r--ospfd/ospf_ri.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c
index b3d20dca75..87d8f596f9 100644
--- a/ospfd/ospf_ri.c
+++ b/ospfd/ospf_ri.c
@@ -1259,6 +1259,18 @@ DEFUN (no_router_info,
return CMD_SUCCESS;
}
+static int
+ospf_ri_enabled (struct vty *vty)
+{
+ if (OspfRI.status == enabled)
+ return 1;
+
+ if (vty)
+ vty_out (vty, "%% OSPF RI is not turned on%s", VTY_NEWLINE);
+
+ return 0;
+}
+
DEFUN (pce_address,
pce_address_cmd,
"pce address A.B.C.D",
@@ -1270,6 +1282,9 @@ DEFUN (pce_address,
struct in_addr value;
struct ospf_pce_info *pi = &OspfRI.pce_info;
+ if (!ospf_ri_enabled (vty))
+ return CMD_WARNING;
+
if (!inet_aton (argv[idx_ipv4]->arg, &value))
{
vty_out (vty, "Please specify PCE Address by A.B.C.D%s", VTY_NEWLINE);
@@ -1283,7 +1298,7 @@ DEFUN (pce_address,
set_pce_address (value, pi);
/* Refresh RI LSA if already engaged */
- if ((OspfRI.status == enabled) && (OspfRI.flags & RIFLG_LSA_ENGAGED))
+ if (OspfRI.flags & RIFLG_LSA_ENGAGED)
ospf_router_info_lsa_schedule (REFRESH_THIS_LSA);
}
@@ -1318,6 +1333,9 @@ DEFUN (pce_path_scope,
uint32_t scope;
struct ospf_pce_info *pi = &OspfRI.pce_info;
+ if (!ospf_ri_enabled (vty))
+ return CMD_WARNING;
+
if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &scope) != 1)
{
vty_out (vty, "pce_path_scope: fscanf: %s%s", safe_strerror (errno),
@@ -1330,7 +1348,7 @@ DEFUN (pce_path_scope,
set_pce_path_scope (scope, pi);
/* Refresh RI LSA if already engaged */
- if ((OspfRI.status == enabled) && (OspfRI.flags & RIFLG_LSA_ENGAGED))
+ if (OspfRI.flags & RIFLG_LSA_ENGAGED)
ospf_router_info_lsa_schedule (REFRESH_THIS_LSA);
}
@@ -1369,6 +1387,9 @@ DEFUN (pce_domain,
struct listnode *node;
struct ri_pce_subtlv_domain *domain;
+ if (!ospf_ri_enabled (vty))
+ return CMD_WARNING;
+
if (sscanf (argv[idx_number]->arg, "%d", &as) != 1)
{
vty_out (vty, "pce_domain: fscanf: %s%s", safe_strerror (errno),
@@ -1380,17 +1401,17 @@ DEFUN (pce_domain,
for (ALL_LIST_ELEMENTS_RO (pce->pce_domain, node, domain))
{
if (ntohl (domain->header.type) == 0 && as == domain->value)
- goto out;
+ return CMD_SUCCESS;
}
/* Create new domain if not found */
set_pce_domain (PCE_DOMAIN_TYPE_AS, as, pce);
/* Refresh RI LSA if already engaged */
- if ((OspfRI.status == enabled) && (OspfRI.flags & RIFLG_LSA_ENGAGED))
+ if (OspfRI.flags & RIFLG_LSA_ENGAGED)
ospf_router_info_lsa_schedule (REFRESH_THIS_LSA);
-out:return CMD_SUCCESS;
+ return CMD_SUCCESS;
}
DEFUN (no_pce_domain,
@@ -1439,6 +1460,9 @@ DEFUN (pce_neigbhor,
struct listnode *node;
struct ri_pce_subtlv_neighbor *neighbor;
+ if (!ospf_ri_enabled (vty))
+ return CMD_WARNING;
+
if (sscanf (argv[idx_number]->arg, "%d", &as) != 1)
{
vty_out (vty, "pce_neighbor: fscanf: %s%s", safe_strerror (errno),
@@ -1450,17 +1474,17 @@ DEFUN (pce_neigbhor,
for (ALL_LIST_ELEMENTS_RO (pce->pce_neighbor, node, neighbor))
{
if (ntohl (neighbor->header.type) == 0 && as == neighbor->value)
- goto out;
+ return CMD_SUCCESS;
}
/* Create new domain if not found */
set_pce_neighbor (PCE_DOMAIN_TYPE_AS, as, pce);
/* Refresh RI LSA if already engaged */
- if ((OspfRI.status == enabled) && (OspfRI.flags & RIFLG_LSA_ENGAGED))
+ if (OspfRI.flags & RIFLG_LSA_ENGAGED)
ospf_router_info_lsa_schedule (REFRESH_THIS_LSA);
-out:return CMD_SUCCESS;
+ return CMD_SUCCESS;
}
DEFUN (no_pce_neighbor,
@@ -1506,6 +1530,9 @@ DEFUN (pce_cap_flag,
uint32_t cap;
struct ospf_pce_info *pce = &OspfRI.pce_info;
+ if (!ospf_ri_enabled (vty))
+ return CMD_WARNING;
+
if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &cap) != 1)
{
vty_out (vty, "pce_cap_flag: fscanf: %s%s", safe_strerror (errno),
@@ -1519,7 +1546,7 @@ DEFUN (pce_cap_flag,
set_pce_cap_flag (cap, pce);
/* Refresh RI LSA if already engaged */
- if ((OspfRI.status == enabled) && (OspfRI.flags & RIFLG_LSA_ENGAGED))
+ if (OspfRI.flags & RIFLG_LSA_ENGAGED)
ospf_router_info_lsa_schedule (REFRESH_THIS_LSA);
}