From 6159d5eebf540a5cea0d568a00ab1c89e46d7422 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 11 Mar 2024 14:05:59 -0400 Subject: [PATCH] bgpd: bgp_best_selection is inherently pi based Currently evpn code calls bgp_best_selection for local decisions for local tables to figure out what to do. This is also pi based so let's note that the pi has been changed before calling bgp_best_selection. Signed-off-by: Donald Sharp --- bgpd/bgp_evpn.c | 14 ++++++++------ bgpd/bgp_evpn_mh.c | 13 ++++++++----- bgpd/bgp_evpn_private.h | 3 ++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index fc077ebd17de..5f3f0f923c41 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -1438,7 +1438,7 @@ static void evpn_delete_old_local_route(struct bgp *bgp, struct bgpevpn *vpn, * Note: vpn is NULL for local EAD-ES routes. */ int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn, - struct bgp_dest *dest) + struct bgp_dest *dest, struct bgp_path_info *pi) { struct bgp_path_info *old_select, *new_select; struct bgp_path_info_pair old_and_new; @@ -1446,6 +1446,8 @@ int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn, safi_t safi = SAFI_EVPN; int ret = 0; + SET_FLAG(pi->flags, BGP_PATH_UNSORTED); + /* Compute the best path. */ bgp_best_selection(bgp, dest, &bgp->maxpaths[afi][safi], &old_and_new, afi, safi); @@ -2225,7 +2227,7 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn, * route would win, and we should evict the defunct local route * and (re)install the remote route into zebra. */ - evpn_route_select_install(bgp, vpn, dest); + evpn_route_select_install(bgp, vpn, dest, pi); /* * If the new local route was not selected evict it and tell zebra * to re-add the best remote dest. BGP doesn't retain non-best local @@ -2383,7 +2385,7 @@ static int delete_evpn_route(struct bgp *bgp, struct bgpevpn *vpn, if (pi) { dest = bgp_path_info_reap(dest, pi); assert(dest); - evpn_route_select_install(bgp, vpn, dest); + evpn_route_select_install(bgp, vpn, dest, pi); } /* dest should still exist due to locking make coverity happy */ @@ -2497,7 +2499,7 @@ void bgp_evpn_update_type2_route_entry(struct bgp *bgp, struct bgpevpn *vpn, * advertised to peers; otherwise, ensure it is evicted and * (re)install the remote route into zebra. */ - evpn_route_select_install(bgp, vpn, dest); + evpn_route_select_install(bgp, vpn, dest, pi); if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) { route_change = 0; @@ -3187,7 +3189,7 @@ static int install_evpn_route_entry_in_vni_common( bgp_evpn_remote_ip_hash_add(vpn, pi); /* Perform route selection and update zebra, if required. */ - ret = evpn_route_select_install(bgp, vpn, dest); + ret = evpn_route_select_install(bgp, vpn, dest, pi); /* if the best path is a local path with a non-zero ES * sync info against the local path may need to be updated @@ -3229,7 +3231,7 @@ static int uninstall_evpn_route_entry_in_vni_common( bgp_path_info_delete(dest, pi); /* Perform route selection and update zebra, if required. */ - ret = evpn_route_select_install(bgp, vpn, dest); + ret = evpn_route_select_install(bgp, vpn, dest, pi); /* if the best path is a local path with a non-zero ES * sync info against the local path may need to be updated diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c index 9347adea767a..2e148c000383 100644 --- a/bgpd/bgp_evpn_mh.c +++ b/bgpd/bgp_evpn_mh.c @@ -91,7 +91,8 @@ static void bgp_evpn_path_nh_unlink(struct bgp_path_evpn_nh_info *nh_info); */ static int bgp_evpn_es_route_select_install(struct bgp *bgp, struct bgp_evpn_es *es, - struct bgp_dest *dest) + struct bgp_dest *dest, + struct bgp_path_info *pi) { int ret = 0; afi_t afi = AFI_L2VPN; @@ -100,6 +101,8 @@ static int bgp_evpn_es_route_select_install(struct bgp *bgp, struct bgp_path_info *new_select; /* new best */ struct bgp_path_info_pair old_and_new; + SET_FLAG(pi->flags, BGP_PATH_UNSORTED); + /* Compute the best path. */ bgp_best_selection(bgp, dest, &bgp->maxpaths[afi][safi], &old_and_new, afi, safi); @@ -231,7 +234,7 @@ static int bgp_evpn_es_route_install(struct bgp *bgp, } /* Perform route selection and update zebra, if required. */ - ret = bgp_evpn_es_route_select_install(bgp, es, dest); + ret = bgp_evpn_es_route_select_install(bgp, es, dest, pi); bgp_dest_unlock_node(dest); @@ -272,7 +275,7 @@ static int bgp_evpn_es_route_uninstall(struct bgp *bgp, struct bgp_evpn_es *es, bgp_path_info_delete(dest, pi); /* Perform route selection and update zebra, if required. */ - ret = bgp_evpn_es_route_select_install(bgp, es, dest); + ret = bgp_evpn_es_route_select_install(bgp, es, dest, pi); /* Unlock route node. */ bgp_dest_unlock_node(dest); @@ -668,7 +671,7 @@ static int bgp_evpn_type4_route_update(struct bgp *bgp, * this is just to set the flags correctly * as local route in the ES always wins. */ - bgp_evpn_es_route_select_install(bgp, es, dest); + bgp_evpn_es_route_select_install(bgp, es, dest, pi); bgp_dest_unlock_node(dest); /* If this is a new route or some attribute has changed, export the @@ -1008,7 +1011,7 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp, struct bgp_evpn_es *es, * this is just to set the flags correctly as local route in * the ES always wins. */ - evpn_route_select_install(bgp, vpn, dest); + evpn_route_select_install(bgp, vpn, dest, pi); bgp_dest_unlock_node(dest); /* If this is a new route or some attribute has changed, export the diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h index 5af99afa346d..07bba9b42684 100644 --- a/bgpd/bgp_evpn_private.h +++ b/bgpd/bgp_evpn_private.h @@ -716,7 +716,8 @@ extern void delete_evpn_route_entry(struct bgp *bgp, afi_t afi, safi_t safi, struct bgp_path_info **pi); int vni_list_cmp(void *p1, void *p2); extern int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn, - struct bgp_dest *dest); + struct bgp_dest *dest, + struct bgp_path_info *pi); extern struct bgp_dest * bgp_evpn_global_node_get(struct bgp_table *table, afi_t afi, safi_t safi, const struct prefix_evpn *evp, struct prefix_rd *prd,