From d6b901ac78f164a5239c7694076968456bd163d4 Mon Sep 17 00:00:00 2001 From: anlan_cs Date: Tue, 11 Jan 2022 04:21:05 -0500 Subject: 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 --- ospf6d/ospf6d.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'ospf6d/ospf6d.c') diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index d9f730586b..cc5a0f7870 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -421,6 +421,8 @@ DEFUN(show_ipv6_ospf6_database, show_ipv6_ospf6_database_cmd, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -471,6 +473,8 @@ DEFUN(show_ipv6_ospf6_database_type, show_ipv6_ospf6_database_type_cmd, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -512,6 +516,8 @@ DEFUN(show_ipv6_ospf6_database_id, show_ipv6_ospf6_database_id_cmd, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -557,6 +563,8 @@ DEFUN(show_ipv6_ospf6_database_router, show_ipv6_ospf6_database_router_cmd, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -625,6 +633,8 @@ DEFUN_HIDDEN( } } + OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -681,6 +691,8 @@ DEFUN(show_ipv6_ospf6_database_type_id, show_ipv6_ospf6_database_type_id_cmd, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -740,6 +752,8 @@ DEFUN(show_ipv6_ospf6_database_type_router, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -789,6 +803,8 @@ DEFUN(show_ipv6_ospf6_database_id_router, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -838,6 +854,8 @@ DEFUN(show_ipv6_ospf6_database_adv_router_linkstate_id, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -899,6 +917,8 @@ DEFUN(show_ipv6_ospf6_database_type_id_router, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -967,6 +987,8 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -1008,6 +1030,8 @@ DEFUN(show_ipv6_ospf6_database_self_originated, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -1065,6 +1089,8 @@ DEFUN(show_ipv6_ospf6_database_type_self_originated, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -1127,6 +1153,8 @@ DEFUN(show_ipv6_ospf6_database_type_self_originated_linkstate_id, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -1187,6 +1215,8 @@ DEFUN(show_ipv6_ospf6_database_type_id_self_originated, } } + OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -1263,6 +1293,8 @@ DEFUN(show_ipv6_ospf6_border_routers, show_ipv6_ospf6_border_routers_cmd, } } + OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -1306,6 +1338,8 @@ DEFUN(show_ipv6_ospf6_linkstate, show_ipv6_ospf6_linkstate_cmd, } } + OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6); + return CMD_SUCCESS; } @@ -1346,6 +1380,8 @@ DEFUN(show_ipv6_ospf6_linkstate_detail, show_ipv6_ospf6_linkstate_detail_cmd, } } + OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6); + return CMD_SUCCESS; } -- cgit v1.2.3