summaryrefslogtreecommitdiff
path: root/ospfd/ospf_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospf_vty.c')
-rw-r--r--ospfd/ospf_vty.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 12ccc8bcea..0b0b9d81ee 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -7314,16 +7314,26 @@ static int show_ip_ospf_database_type_adv_router_common(struct vty *vty,
type = OSPF_OPAQUE_AREA_LSA;
else if (strncmp(argv[arg_base + idx_type]->text, "opaque-as", 9) == 0)
type = OSPF_OPAQUE_AS_LSA;
- else
+ else {
+ if (uj) {
+ if (use_vrf)
+ json_object_free(json_vrf);
+ }
return CMD_WARNING;
+ }
/* `show ip ospf database LSA adv-router ADV_ROUTER'. */
if (strncmp(argv[arg_base + 5]->text, "s", 1) == 0)
adv_router = ospf->router_id;
else {
ret = inet_aton(argv[arg_base + 6]->arg, &adv_router);
- if (!ret)
+ if (!ret) {
+ if (uj) {
+ if (use_vrf)
+ json_object_free(json_vrf);
+ }
return CMD_WARNING;
+ }
}
show_lsa_detail_adv_router(vty, ospf, type, &adv_router, json_vrf);
@@ -7387,9 +7397,12 @@ DEFUN (show_ip_ospf_database_type_adv_router,
} else {
ospf = ospf_lookup_by_inst_name(inst, vrf_name);
if ((ospf == NULL) || !ospf->oi_running) {
- vty_out(vty,
- "%% OSPF is not enabled in vrf %s\n",
- vrf_name);
+ if (uj)
+ vty_json(vty, json);
+ else
+ vty_out(vty,
+ "%% OSPF is not enabled in vrf %s\n",
+ vrf_name);
return CMD_SUCCESS;
}
@@ -7400,7 +7413,11 @@ DEFUN (show_ip_ospf_database_type_adv_router,
/* Display default ospf (instance 0) info */
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
if (ospf == NULL || !ospf->oi_running) {
- vty_out(vty, "%% OSPF is not enabled on vrf default\n");
+ if (uj)
+ vty_json(vty, json);
+ else
+ vty_out(vty,
+ "%% OSPF is not enabled on vrf default\n");
return CMD_SUCCESS;
}
@@ -11117,7 +11134,8 @@ static int show_ip_ospf_border_routers_common(struct vty *vty,
vty_out(vty, "No OSPF routing information exist\n");
else {
json_object_free(json_router);
- json_object_free(json_vrf);
+ if (use_vrf)
+ json_object_free(json_vrf);
}
return CMD_SUCCESS;
}
@@ -11273,7 +11291,12 @@ static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf,
ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf);
if (ospf->new_table == NULL) {
- vty_out(vty, "No OSPF routing information exist\n");
+ if (json) {
+ if (use_vrf)
+ json_object_free(json_vrf);
+ } else {
+ vty_out(vty, "No OSPF routing information exist\n");
+ }
return CMD_SUCCESS;
}