Merge pull request #5066 from ak503/libfrr_crash

zebra: if_is_loopback_or_vrf crash if if_lookup_by_index return NULL
This commit is contained in:
Donald Sharp 2019-09-26 19:32:41 -04:00 committed by GitHub
commit 5c256b572c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1046,14 +1046,18 @@ static struct route_entry *rib_choose_best(struct route_entry *current,
struct nexthop *nexthop = NULL;
for (ALL_NEXTHOPS(alternate->ng, nexthop)) {
if (if_is_loopback_or_vrf(if_lookup_by_index(
nexthop->ifindex, alternate->vrf_id)))
struct interface *ifp = if_lookup_by_index(
nexthop->ifindex, alternate->vrf_id);
if (ifp && if_is_loopback_or_vrf(ifp))
return alternate;
}
for (ALL_NEXTHOPS(current->ng, nexthop)) {
if (if_is_loopback_or_vrf(if_lookup_by_index(
nexthop->ifindex, current->vrf_id)))
struct interface *ifp = if_lookup_by_index(
nexthop->ifindex, current->vrf_id);
if (ifp && if_is_loopback_or_vrf(ifp))
return current;
}