diff options
| -rw-r--r-- | ospfd/ospf_vty.c | 36 | ||||
| -rw-r--r-- | zebra/rt_netlink.c | 2 | ||||
| -rw-r--r-- | zebra/rt_netlink.h | 3 | ||||
| -rw-r--r-- | zebra/zebra_fpm_netlink.c | 9 |
4 files changed, 34 insertions, 16 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index f22c1e7e4e..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; } @@ -11274,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; } diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 1a090c78e3..79d79d74be 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -223,7 +223,7 @@ static inline bool is_selfroute(int proto) return false; } -static inline int zebra2proto(int proto) +int zebra2proto(int proto) { switch (proto) { case ZEBRA_ROUTE_BABEL: diff --git a/zebra/rt_netlink.h b/zebra/rt_netlink.h index 351f98a2ca..8506367ae4 100644 --- a/zebra/rt_netlink.h +++ b/zebra/rt_netlink.h @@ -150,6 +150,9 @@ const char *ifa_flags2str(uint32_t flags, char *buf, size_t buflen); const char *nh_flags2str(uint32_t flags, char *buf, size_t buflen); void nl_dump(void *msg, size_t msglen); + +extern int zebra2proto(int proto); + #endif /* NETLINK_DEBUG */ #ifdef __cplusplus diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 628d4a2a87..06c45578a6 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -253,14 +253,7 @@ static int netlink_route_info_add_nh(struct netlink_route_info *ri, */ static uint8_t netlink_proto_from_route_type(int type) { - switch (type) { - case ZEBRA_ROUTE_KERNEL: - case ZEBRA_ROUTE_CONNECT: - return RTPROT_KERNEL; - - default: - return RTPROT_ZEBRA; - } + return zebra2proto(type); } /* |
