From 2fed88876abb440c9d87d873b60a043c0e14d3b0 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 May 2015 18:03:51 -0700 Subject: [PATCH] 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 --- bgpd/bgp_route.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 7e0c604645..fe39d47596 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -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))) {