Skip to content

Commit

Permalink
bgpd: bgp_best_selection is inherently pi based
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
donaldsharp committed Mar 18, 2024
1 parent 56bcfab commit 6159d5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
14 changes: 8 additions & 6 deletions bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,14 +1438,16 @@ 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;
afi_t afi = AFI_L2VPN;
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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions bgpd/bgp_evpn_mh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion bgpd/bgp_evpn_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6159d5e

Please sign in to comment.