summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_neighbor.c
diff options
context:
space:
mode:
authoranlan_cs <anlan_cs@tom.com>2022-01-11 04:21:05 -0500
committeranlan_cs <anlan_cs@tom.com>2022-01-11 04:21:05 -0500
commitd6b901ac78f164a5239c7694076968456bd163d4 (patch)
tree0fbaa60bae41c0c4bc9529784bf5ee12b1dfd7fd /ospf6d/ospf6_neighbor.c
parentc274b697ee856a67cd225d5ae05195063a991047 (diff)
ospf6d: give error information for commands with non-exist vrfs
Currently the ospf6d's commands with non-exist vrfs can't give the error informations to users. This commit adds a macro "OSPF6_CMD_CHECK_VRF" to give error information if with non-exist vrfs. As usual, skip the checking process in the case of json. So one command can call this macro to do the checking process in its end. At that time it need know json style or not, so add "json" parameter for several related functions. BTW, suppress the build warning of the macro `OSPF6_FIND_VRF_ARGS`: "Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic defects." Signed-off-by: anlan_cs <anlan_cs@tom.com>
Diffstat (limited to 'ospf6d/ospf6_neighbor.c')
-rw-r--r--ospf6d/ospf6_neighbor.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index 1a8fedea0c..afa504d13c 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -1111,12 +1111,15 @@ DEFUN(show_ipv6_ospf6_neighbor, show_ipv6_ospf6_neighbor_cmd,
}
}
+ OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
+
return CMD_SUCCESS;
}
static int ospf6_neighbor_show_common(struct vty *vty, int argc,
struct cmd_token **argv,
- struct ospf6 *ospf6, int idx_ipv4)
+ struct ospf6 *ospf6, int idx_ipv4,
+ bool uj)
{
struct ospf6_neighbor *on;
struct ospf6_interface *oi;
@@ -1126,7 +1129,6 @@ static int ospf6_neighbor_show_common(struct vty *vty, int argc,
json_object *json, bool use_json);
uint32_t router_id;
json_object *json = NULL;
- bool uj = use_json(argc, argv);
showfunc = ospf6_neighbor_show_detail;
if (uj)
@@ -1164,6 +1166,7 @@ DEFUN(show_ipv6_ospf6_neighbor_one, show_ipv6_ospf6_neighbor_one_cmd,
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
+ bool uj = use_json(argc, argv);
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
@@ -1172,13 +1175,15 @@ DEFUN(show_ipv6_ospf6_neighbor_one, show_ipv6_ospf6_neighbor_one_cmd,
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
ospf6_neighbor_show_common(vty, argc, argv, ospf6,
- idx_ipv4);
+ idx_ipv4, uj);
if (!all_vrf)
break;
}
}
+ OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
+
return CMD_SUCCESS;
}