From 4c66767c1018818b715ad313b51cfb438a9095a5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 27 Mar 2018 14:59:05 -0400 Subject: [PATCH] zebra: Prevent crash in the off-chance we make a mistake Prevent zebra from crashing for when the nexthop vrf has changed in some manner and the lookup fails. Signed-off-by: Donald Sharp --- zebra/zebra_vty.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index c7951b6f0a..a9107dc4a0 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -1108,7 +1108,10 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn, struct vrf *vrf = vrf_lookup_by_id(nexthop->vrf_id); - vty_out(vty, "(vrf %s)", vrf->name); + if (vrf) + vty_out(vty, "(vrf %s)", vrf->name); + else + vty_out(vty, "(vrf UKNOWN)"); } if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE)) @@ -1468,7 +1471,10 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn, if (nexthop->vrf_id != re->vrf_id) { struct vrf *vrf = vrf_lookup_by_id(nexthop->vrf_id); - vty_out(vty, "(vrf %s)", vrf->name); + if (vrf) + vty_out(vty, "(vrf %s)", vrf->name); + else + vty_out(vty, "(vrf UKNOWN)"); } if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE)) -- 2.39.5