From 8c9769e03be93cfdd460fccaea9b0f2c995f1179 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 14 Feb 2020 15:15:26 -0500 Subject: [PATCH] bgpd: Ensure we don't crash when registering RA's There exists a code path that the ifp can be NULL. Prevent an accident. Signed-off-by: Donald Sharp --- bgpd/bgp_nht.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 3060fe482c..55b44de6fb 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -428,9 +428,11 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id) ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id); - zclient_send_interface_radv_req( - zclient, nexthop->vrf_id, ifp, true, - BGP_UNNUM_DEFAULT_RA_INTERVAL); + if (ifp) + zclient_send_interface_radv_req( + zclient, nexthop->vrf_id, ifp, + true, + BGP_UNNUM_DEFAULT_RA_INTERVAL); } /* There is at least one label-switched path */ if (nexthop->nh_label && @@ -898,8 +900,11 @@ void bgp_nht_register_enhe_capability_interfaces(struct peer *peer) return; for (nhop = bnc->nexthop; nhop; nhop = nhop->next) { - ifp = if_lookup_by_index(nhop->ifindex, - nhop->vrf_id); + ifp = if_lookup_by_index(nhop->ifindex, nhop->vrf_id); + + if (!ifp) + continue; + zclient_send_interface_radv_req(zclient, nhop->vrf_id, ifp, true,