Skip to content

Commit aafcfaf

Browse files
committed
bgpd: Fix evpn bestpath calculation when path is not established
If you have a bestpath list that looks something like this: <local evpn mac route> <learned from peer out swp60> <learned from peer out swp57> And a network event happens that causes the peer out swp60 to not be in an established state, yet we still have the path_info for the destination for swp60, bestpath will currently end up with this order: <learned from peer out swp60> <local evpn mac route> <learned from peer out swp57> This causes the local evpn mac route to be deleted in zebra( Wrong! ). This is happening because swp60 is skipped in bestpath calculation and not considered to be a path yet it stays at the front of the list. Modify bestpath calculation such that when pulling the unsorted_list together to pull path info's into that list when they are also not in a established state. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
1 parent 6103bf8 commit aafcfaf

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

bgpd/bgp_route.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2988,7 +2988,10 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
29882988

29892989
old_select = NULL;
29902990
pi = bgp_dest_get_bgp_path_info(dest);
2991-
while (pi && CHECK_FLAG(pi->flags, BGP_PATH_UNSORTED)) {
2991+
while (pi && (CHECK_FLAG(pi->flags, BGP_PATH_UNSORTED) ||
2992+
(pi->peer != bgp->peer_self &&
2993+
!CHECK_FLAG(pi->peer->sflags, PEER_STATUS_NSF_WAIT) &&
2994+
!peer_established(pi->peer->connection)))) {
29922995
struct bgp_path_info *next = pi->next;
29932996

29942997
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
@@ -3082,6 +3085,30 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
30823085
continue;
30833086
}
30843087

3088+
if (first->peer && first->peer != bgp->peer_self &&
3089+
!CHECK_FLAG(first->peer->sflags, PEER_STATUS_NSF_WAIT) &&
3090+
!peer_established(first->peer->connection)) {
3091+
if (debug)
3092+
zlog_debug("%s: %pBD(%s) pi %p from %s is not in established state",
3093+
__func__, dest, bgp->name_pretty, first,
3094+
first->peer->host);
3095+
3096+
/*
3097+
* Peer is not in established state we cannot sort this
3098+
* item yet. Let's wait, so hold this one to the side
3099+
*/
3100+
if (unsorted_holddown) {
3101+
first->next = unsorted_holddown;
3102+
unsorted_holddown->prev = first;
3103+
unsorted_holddown = first;
3104+
} else
3105+
unsorted_holddown = first;
3106+
3107+
UNSET_FLAG(first->flags, BGP_PATH_UNSORTED);
3108+
3109+
continue;
3110+
}
3111+
30853112
bgp_path_info_unset_flag(dest, first, BGP_PATH_DMED_CHECK);
30863113

30873114
worse = NULL;

0 commit comments

Comments
 (0)