Ensure that routes from a peer are not considered for best path

comparison if the peer is not in an Established state. There can
be a window between a peer being deleted and the background
thread that actually clears the routes (marks them as "removed")
runs during which best path may run. If this path selection
compared two prefixes all the way down to peer IP addresses and
one of these two peers had just been deleted, that peer would
not have its sockunion structures, especially su_remote, resulting
in a BGPD exception.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2015-05-19 18:03:51 -07:00
parent b2f4a39527
commit 2fed88876a

View File

@ -1991,6 +1991,9 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
continue;
if (BGP_INFO_HOLDDOWN (ri1))
continue;
if (ri1->peer && ri1->peer != bgp->peer_self)
if (ri1->peer->status != Established)
continue;
new_select = ri1;
if (do_mpath)
@ -2003,6 +2006,11 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
continue;
if (BGP_INFO_HOLDDOWN (ri2))
continue;
if (ri2->peer &&
ri2->peer != bgp->peer_self &&
!CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT))
if (ri2->peer->status != Established)
continue;
if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
|| aspath_cmp_left_confed (ri1->attr->aspath,
@ -2055,6 +2063,12 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
continue;
}
if (ri->peer &&
ri->peer != bgp->peer_self &&
!CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
if (ri->peer->status != Established)
continue;
if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
&& (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
{