summaryrefslogtreecommitdiffstats
path: root/lib/vrf.h
diff options
context:
space:
mode:
authorNathan Van Gheem <vangheem@gmail.com>2018-07-27 16:09:38 +0200
committerNathan Van Gheem <vangheem@gmail.com>2018-07-27 16:17:03 +0200
commitec1db5882dae354efa5d8af8ce99edfcabd22186 (patch)
treee8d12514365cacad3d4d37456dc6e156566bbb11 /lib/vrf.h
parentMerge pull request #2708 from ton31337/feature/default-originate_apply_route-... (diff)
downloadfrr-ec1db5882dae354efa5d8af8ce99edfcabd22186.tar.xz
frr-ec1db5882dae354efa5d8af8ce99edfcabd22186.zip
lib,zebra: fix json output when vrf1 when not active
When I did a show ip route with `json` on a vrf when it didn't exist, frr would output invalid json. Signed-off-by: Nathan Van Gheem <nathan@cumulusnetworks.com>
Diffstat (limited to 'lib/vrf.h')
-rw-r--r--lib/vrf.h13
1 files changed, 11 insertions, 2 deletions
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; \