diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 779b6ca5004e..9b4c174b8af2 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -970,6 +970,7 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc) safi_t safi; struct bgp *bgp_path; const struct prefix *p; + bool path_valid_changed, bnc_is_valid_nexthop; if (BGP_DEBUG(nht, NHT)) { char buf[PREFIX2STR_BUFFER]; @@ -1019,8 +1020,7 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc) * do not check for a valid label. */ - bool bnc_is_valid_nexthop = false; - bool path_valid = false; + bnc_is_valid_nexthop = false; if (safi == SAFI_UNICAST && path->sub_type == BGP_ROUTE_IMPORTED && path->extra && path->extra->num_labels @@ -1076,23 +1076,24 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc) || path->attr->srte_color != 0) SET_FLAG(path->flags, BGP_PATH_IGP_CHANGED); - path_valid = CHECK_FLAG(path->flags, BGP_PATH_VALID); - if (path_valid != bnc_is_valid_nexthop) { - if (path_valid) { - /* No longer valid, clear flag */ - bgp_aggregate_decrement(bgp_path, p, path, afi, - safi); - bgp_path_info_unset_flag(dest, path, - BGP_PATH_VALID); - } else { + path_valid_changed = CHECK_FLAG(path->flags, BGP_PATH_VALID) != + bnc_is_valid_nexthop; + if (path_valid_changed) { + if (bnc_is_valid_nexthop) { /* Path becomes valid, set flag */ bgp_path_info_set_flag(dest, path, BGP_PATH_VALID); bgp_aggregate_increment(bgp_path, p, path, afi, safi); + } else { + /* No longer valid, clear flag */ + bgp_aggregate_decrement(bgp_path, p, path, afi, + safi); + bgp_path_info_unset_flag(dest, path, + BGP_PATH_VALID); } } - if ((path_valid != bnc_is_valid_nexthop || + if ((path_valid_changed || CHECK_FLAG(path->flags, BGP_PATH_IGP_CHANGED)) && safi == SAFI_EVPN && bgp_evpn_is_prefix_nht_supported(