From 010c141f8ac743c71d4913de51f813e041268ad9 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 4 May 2016 13:44:43 +0000 Subject: [PATCH] zebra: fix show ip route vrf to use zvrf_list Iterate over the zvrf_list to allow 'show ip route vrf...' to show vrfs that are inactive -vs- not even configured Ticket: CM-10139 Signed-off-by: Donald Sharp Reviewed-by: Vivek Venkatraman Reviewed-by: Don Slice --- zebra/zebra_vty.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index d0f2700b8b..6da085b28f 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -2055,9 +2055,24 @@ DEFUN (show_ip_route, struct rib *rib; int first = 1; vrf_id_t vrf_id = VRF_DEFAULT; + struct zebra_vrf *zvrf = NULL; if (argc) - VRF_GET_ID (vrf_id, argv[0]); + { + if (!(zvrf = zebra_vrf_list_lookup_by_name (argv[0]))) + { + vty_out (vty, "vrf %s not defined%s", argv[0], VTY_NEWLINE); + return CMD_SUCCESS; + } + + if (zvrf->vrf_id == VRF_UNKNOWN) + { + vty_out (vty, "vrf %s inactive%s", argv[0], VTY_NEWLINE); + return CMD_SUCCESS; + } + else + vrf_id = zvrf->vrf_id; + } table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); if (! table) @@ -4677,9 +4692,24 @@ DEFUN (show_ipv6_route, struct rib *rib; int first = 1; vrf_id_t vrf_id = VRF_DEFAULT; + struct zebra_vrf *zvrf = NULL; if (argc > 0) - VRF_GET_ID (vrf_id, argv[0]); + { + if (!(zvrf = zebra_vrf_list_lookup_by_name (argv[0]))) + { + vty_out (vty, "vrf %s not defined%s", argv[0], VTY_NEWLINE); + return CMD_SUCCESS; + } + + if (zvrf->vrf_id == VRF_UNKNOWN) + { + vty_out (vty, "vrf %s inactive%s", argv[0], VTY_NEWLINE); + return CMD_SUCCESS; + } + else + vrf_id = zvrf->vrf_id; + } table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); if (! table) -- 2.39.5