diff options
author | Nathan Van Gheem <vangheem@gmail.com> | 2018-07-27 16:09:38 +0200 |
---|---|---|
committer | Nathan Van Gheem <vangheem@gmail.com> | 2018-07-27 16:17:03 +0200 |
commit | ec1db5882dae354efa5d8af8ce99edfcabd22186 (patch) | |
tree | e8d12514365cacad3d4d37456dc6e156566bbb11 /lib/vrf.h | |
parent | Merge pull request #2708 from ton31337/feature/default-originate_apply_route-... (diff) | |
download | frr-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.h | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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; \ |