From 5df26422921a943c056aab282b844b43416ac411 Mon Sep 17 00:00:00 2001 From: Neal Shrader Date: Thu, 6 May 2021 14:51:06 -0400 Subject: [PATCH] bgpd: scope evpn specific path selection to type-2 routes For EVPN routes, there is specific logic in place for path selection surrounding MAC Mobility. For pure type-5 routes, if a route is advertised with a MED, this is ignored since it ultimately falls inside of the EVPN specific path selection logic, and ultimately selects the lower IP address. This change ensures only type-2 routes fall into the EVPN BGP path selection. Signed-off-by: Neal Shrader --- bgpd/bgp_route.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 77a0b5fea7..2c792b7abf 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -550,6 +550,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, char *pfx_buf, afi_t afi, safi_t safi, enum bgp_path_selection_reason *reason) { + const struct prefix *new_p; struct attr *newattr, *existattr; bgp_peer_sort_t new_sort; bgp_peer_sort_t exist_sort; @@ -614,10 +615,13 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, newattr = new->attr; existattr = exist->attr; + new_p = bgp_dest_get_prefix(new->net); + /* For EVPN routes, we cannot just go by local vs remote, we have to * look at the MAC mobility sequence number, if present. */ - if (safi == SAFI_EVPN) { + if ((safi == SAFI_EVPN) + && (new_p->u.prefix_evpn.route_type == BGP_EVPN_MAC_IP_ROUTE)) { /* This is an error condition described in RFC 7432 Section * 15.2. The RFC * states that in this scenario "the PE MUST alert the operator" @@ -630,9 +634,9 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, */ if (newattr->sticky != existattr->sticky) { if (!debug) { - prefix2str( - bgp_dest_get_prefix(new->net), pfx_buf, - sizeof(*pfx_buf) * PREFIX2STR_BUFFER); + prefix2str(new_p, pfx_buf, + sizeof(*pfx_buf) + * PREFIX2STR_BUFFER); bgp_path_info_path_with_addpath_rx_str( new, new_buf, sizeof(new_buf)); bgp_path_info_path_with_addpath_rx_str(