diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index 10e6b0ffcc3c..74cff5a3a3d9 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -602,10 +602,11 @@ static inline uint64_t bgp_aigp_metric_total(struct bgp_path_info *bpi) { uint64_t aigp = bgp_attr_get_aigp_metric(bpi->attr); - if (bpi->nexthop) - return aigp + bpi->nexthop->metric; - else + /* Don't increment if it's locally sourced */ + if (bpi->peer == bpi->peer->bgp->peer_self) return aigp; + + return bpi->extra ? (aigp + bpi->extra->igpmetric) : aigp; } static inline struct cluster_list *bgp_attr_get_cluster(const struct attr *attr)