summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/if.c4
-rw-r--r--lib/vrf.h13
-rw-r--r--zebra/interface.c6
-rw-r--r--zebra/router-id.c4
-rw-r--r--zebra/zebra_vty.c14
5 files changed, 25 insertions, 16 deletions
diff --git a/lib/if.c b/lib/if.c
index 2320093a1..e31ccd856 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -652,7 +652,7 @@ DEFUN (interface,
/*Pending: need proper vrf name based lookup/(possible creation of VRF)
Imagine forward reference of a vrf by name in this interface config */
if (vrfname)
- VRF_GET_ID(vrf_id, vrfname);
+ VRF_GET_ID(vrf_id, vrfname, false);
#ifdef SUNOS_5
ifp = if_sunwzebra_get(ifname, vrf_id);
@@ -686,7 +686,7 @@ DEFUN_NOSH (no_interface,
vrf_id_t vrf_id = VRF_DEFAULT;
if (argc > 3)
- VRF_GET_ID(vrf_id, vrfname);
+ VRF_GET_ID(vrf_id, vrfname, false);
ifp = if_lookup_by_name(ifname, vrf_id);
diff --git a/lib/vrf.h b/lib/vrf.h
index 8aa0fc221..88536eada 100644
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -111,15 +111,24 @@ extern struct vrf *vrf_get(vrf_id_t, const char *);
extern const char *vrf_id_to_name(vrf_id_t vrf_id);
extern vrf_id_t vrf_name_to_id(const char *);
-#define VRF_GET_ID(V, NAME) \
+#define VRF_GET_ID(V, NAME, USE_JSON) \
do { \
struct vrf *vrf; \
if (!(vrf = vrf_lookup_by_name(NAME))) { \
+ if (USE_JSON) { \
+ vty_out(vty, "{}\n"); \
+ } else { \
+ vty_out(vty, "%% VRF %s not found\n", NAME); \
+ } \
vty_out(vty, "%% VRF %s not found\n", NAME); \
return CMD_WARNING; \
} \
if (vrf->vrf_id == VRF_UNKNOWN) { \
- vty_out(vty, "%% VRF %s not active\n", NAME); \
+ if (USE_JSON) { \
+ vty_out(vty, "{}\n"); \
+ } else { \
+ vty_out(vty, "%% VRF %s not active\n", NAME); \
+ } \
return CMD_WARNING; \
} \
(V) = vrf->vrf_id; \
diff --git a/zebra/interface.c b/zebra/interface.c
index 6125ff9a1..1067f9bdc 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -1417,7 +1417,7 @@ DEFUN (show_interface,
interface_update_stats();
if (argc > 2)
- VRF_GET_ID(vrf_id, argv[3]->arg);
+ VRF_GET_ID(vrf_id, argv[3]->arg, false);
/* All interface print. */
vrf = vrf_lookup_by_id(vrf_id);
@@ -1466,7 +1466,7 @@ DEFUN (show_interface_name_vrf,
interface_update_stats();
- VRF_GET_ID(vrf_id, argv[idx_name]->arg);
+ VRF_GET_ID(vrf_id, argv[idx_name]->arg, false);
/* Specified interface print. */
ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
@@ -1560,7 +1560,7 @@ DEFUN (show_interface_desc,
vrf_id_t vrf_id = VRF_DEFAULT;
if (argc > 3)
- VRF_GET_ID(vrf_id, argv[4]->arg);
+ VRF_GET_ID(vrf_id, argv[4]->arg, false);
if_show_description(vty, vrf_id);
diff --git a/zebra/router-id.c b/zebra/router-id.c
index 252b558a8..3b96b3371 100644
--- a/zebra/router-id.c
+++ b/zebra/router-id.c
@@ -226,7 +226,7 @@ DEFUN (router_id,
rid.family = AF_INET;
if (argc > 2)
- VRF_GET_ID(vrf_id, argv[idx_name]->arg);
+ VRF_GET_ID(vrf_id, argv[idx_name]->arg, false);
router_id_set(&rid, vrf_id);
@@ -251,7 +251,7 @@ DEFUN (no_router_id,
rid.family = AF_INET;
if (argc > 3)
- VRF_GET_ID(vrf_id, argv[idx_name]->arg);
+ VRF_GET_ID(vrf_id, argv[idx_name]->arg, false);
router_id_set(&rid, vrf_id);
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index bed3b7f77..a2daf5939 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -1808,7 +1808,7 @@ DEFPY (show_route_table_vrf,
vrf_id_t vrf_id = VRF_DEFAULT;
if (vrf_name)
- VRF_GET_ID(vrf_id, vrf_name);
+ VRF_GET_ID(vrf_id, vrf_name, !!json);
zvrf = zebra_vrf_lookup_by_id(vrf_id);
t = zebra_ns_find_table(zvrf->zns, table, afi);
@@ -1831,7 +1831,7 @@ DEFUN (show_ip_nht,
vrf_id_t vrf_id = VRF_DEFAULT;
if (argc == 5)
- VRF_GET_ID(vrf_id, argv[idx_vrf]->arg);
+ VRF_GET_ID(vrf_id, argv[idx_vrf]->arg, false);
zebra_print_rnh_table(vrf_id, AF_INET, vty, RNH_NEXTHOP_TYPE);
return CMD_SUCCESS;
@@ -1871,7 +1871,7 @@ DEFUN (show_ipv6_nht,
vrf_id_t vrf_id = VRF_DEFAULT;
if (argc == 5)
- VRF_GET_ID(vrf_id, argv[idx_vrf]->arg);
+ VRF_GET_ID(vrf_id, argv[idx_vrf]->arg, false);
zebra_print_rnh_table(vrf_id, AF_INET6, vty, RNH_NEXTHOP_TYPE);
return CMD_SUCCESS;
@@ -2037,7 +2037,7 @@ DEFPY (show_route,
vrf_id_t vrf_id = VRF_DEFAULT;
if (vrf_name)
- VRF_GET_ID(vrf_id, vrf_name);
+ VRF_GET_ID(vrf_id, vrf_name, !!json);
vrf = vrf_lookup_by_id(vrf_id);
do_show_ip_route(vty, vrf->name, afi, SAFI_UNICAST, !!fib,
!!json, tag, prefix_str ? prefix : NULL,
@@ -2111,7 +2111,7 @@ DEFPY (show_route_detail,
vrf_id_t vrf_id = VRF_DEFAULT;
if (vrf_name)
- VRF_GET_ID(vrf_id, vrf_name);
+ VRF_GET_ID(vrf_id, vrf_name, false);
table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id);
if (!table)
@@ -2178,7 +2178,7 @@ DEFPY (show_route_summary,
vrf_id_t vrf_id = VRF_DEFAULT;
if (vrf_name)
- VRF_GET_ID(vrf_id, vrf_name);
+ VRF_GET_ID(vrf_id, vrf_name, false);
table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id);
if (!table)
@@ -2793,7 +2793,7 @@ DEFUN (show_ipv6_mroute,
vrf_id_t vrf_id = VRF_DEFAULT;
if (argc == 5)
- VRF_GET_ID(vrf_id, argv[4]->arg);
+ VRF_GET_ID(vrf_id, argv[4]->arg, false);
table = zebra_vrf_table(AFI_IP6, SAFI_MULTICAST, vrf_id);
if (!table)