]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: fix route selection with AIGP
authorEnke Chen <enchen@paloaltonetworks.com>
Tue, 15 Oct 2024 01:42:15 +0000 (18:42 -0700)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Tue, 15 Oct 2024 14:25:06 +0000 (14:25 +0000)
The nexthop metric should be added to AIGP when calculating the
bestpath in bgp_path_info_cmp().

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
(cherry picked from commit 081422e8e71085d3a3d4d2ff0bc1e1abaff0d52e)

bgpd/bgp_attr.c
bgpd/bgp_attr.h
bgpd/bgp_route.c

index e4ee589a3844f0af9eb88e221b7742f62311e387..f4215c43b08e5a3793acde992a54375d53372c0e 100644 (file)
@@ -479,16 +479,6 @@ static bool bgp_attr_aigp_get_tlv_metric(uint8_t *pnt, int length,
        return false;
 }
 
-static 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
-               return aigp;
-}
-
 static void stream_put_bgp_aigp_tlv_metric(struct stream *s,
                                           struct bgp_path_info *bpi)
 {
index f353e76913a7db957e7a14ffff797b83861b2340..17b885b8792ef42e66c1ecd659cd34a7bc52708f 100644 (file)
@@ -600,6 +600,16 @@ static inline void bgp_attr_set_aigp_metric(struct attr *attr, uint64_t aigp)
                SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AIGP));
 }
 
+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
+               return aigp;
+}
+
 static inline struct cluster_list *bgp_attr_get_cluster(const struct attr *attr)
 {
        return attr->cluster1;
index 666adc4728316050c08d3cf3d6ea4cc9b4081604..d7faa7abd6367ee514674d4ac58cefea05b734b7 100644 (file)
@@ -1067,8 +1067,8 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
        if (CHECK_FLAG(newattr->flag, ATTR_FLAG_BIT(BGP_ATTR_AIGP)) &&
            CHECK_FLAG(existattr->flag, ATTR_FLAG_BIT(BGP_ATTR_AIGP)) &&
            CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP)) {
-               uint64_t new_aigp = bgp_attr_get_aigp_metric(newattr);
-               uint64_t exist_aigp = bgp_attr_get_aigp_metric(existattr);
+               uint64_t new_aigp = bgp_aigp_metric_total(new);
+               uint64_t exist_aigp = bgp_aigp_metric_total(exist);
 
                if (new_aigp < exist_aigp) {
                        *reason = bgp_path_selection_aigp;