Commit 6ef67bad12 for frr

commit 6ef67bad125c9d472b4b5a9368e96a288781e176
Author: Philippe Guibert <philippe.guibert@6wind.com>
Date:   Mon Oct 12 11:01:57 2026 +0200

    bgpd: fix aigp documentation

    Update the documentation of AIGP in multiple points:
    - clarify when AIGP is really used
    - update the sequence number ordering with AIGP.

    Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>

diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index c8f2d9b057..5c3ead7989 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -1416,7 +1416,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 		return 0;
 	}

-	/* 3.5. Tie-breaker - AIGP (Metric TLV) attribute */
+	/* 4. Tie-breaker - AIGP (Metric TLV) attribute */
 	if (bgp_attr_exists(newattr, BGP_ATTR_AIGP) && bgp_attr_exists(existattr, BGP_ATTR_AIGP) &&
 	    CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP)) {
 		uint64_t new_aigp = bgp_aigp_metric_total(new);
@@ -1470,7 +1470,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 	new = bgp_get_imported_bpi_ultimate(new);
 	exist = bgp_get_imported_bpi_ultimate(exist);

-	/* 4. AS path length check. */
+	/* 5. AS path length check. */
 	if (!CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) {
 		int exist_hops = aspath_count_hops(exist_path_for_modifiable_attr->attr->aspath);
 		int exist_confeds =
@@ -1529,7 +1529,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 		}
 	}

-	/* 5. Origin check. */
+	/* 6. Origin check. */
 	if (new_path_for_modifiable_attr->attr->origin <
 	    exist_path_for_modifiable_attr->attr->origin) {
 		*reason = bgp_path_selection_origin;
@@ -1552,7 +1552,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 		return 0;
 	}

-	/* 6. MED check. */
+	/* 7. MED check. */
 	internal_as_route = (aspath_count_hops(new_path_for_modifiable_attr->attr->aspath) == 0 &&
 			     aspath_count_hops(exist_path_for_modifiable_attr->attr->aspath) == 0);
 	confed_as_route = (aspath_count_confeds(new_path_for_modifiable_attr->attr->aspath) > 0 &&
@@ -1603,7 +1603,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 	} else
 		peer_new = new->peer;

-	/* 7. Peer type check. */
+	/* 8. Peer type check. */
 	new_sort = peer_new->sort;
 	exist_sort = peer_exist->sort;
 	new_sub_sort = peer_new->sub_sort;
@@ -1637,7 +1637,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 		peer_sort_ret = 0;
 	}

-	/* 8. IGP metric check. */
+	/* 9. IGP metric check. */
 	newm = existm = 0;

 	if (new->extra)
@@ -1661,7 +1661,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 		igp_metric_ret = 0;
 	}

-	/* 9. Same IGP metric. Compare the cluster list length as
+	/* 10. Same IGP metric. Compare the cluster list length as
 	   representative of IGP hops metric. Rewrite the metric value
 	   pair (newm, existm) with the cluster list length. Prefer the
 	   path with smaller cluster list length.                       */
@@ -1692,7 +1692,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 		}
 	}

-	/* 10. confed-external vs. confed-internal */
+	/* 11. confed-external vs. confed-internal */
 	if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) {
 		if (new_sort == BGP_PEER_CONFED
 		    && exist_sort == BGP_PEER_IBGP) {
@@ -1721,7 +1721,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 		}
 	}

-	/* 11. Maximum path check. */
+	/* 12. Maximum path check. */
 	if (newm == existm) {
 		/* If one path has a label but the other does not, do not treat
 		 * them as equals for multipath
@@ -1814,7 +1814,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 	if (peer_sort_ret >= 0)
 		return peer_sort_ret;

-	/* 12. If both paths are external, prefer the path that was received
+	/* 13. If both paths are external, prefer the path that was received
 	   first (the oldest one).  This step minimizes route-flap, since a
 	   newer path won't displace an older one, even if it was the
 	   preferred route based on the additional decision criteria below.  */
@@ -1839,7 +1839,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 		}
 	}

-	/* 13. Router-ID comparison. */
+	/* 14. Router-ID comparison. */
 	/* If one of the paths is "stale", the corresponding peer router-id will
 	 * be 0 and would always win over the other path. If originator id is
 	 * used for the comparison, it will decide which path is better.
@@ -1871,7 +1871,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 		return 0;
 	}

-	/* 14. Cluster length comparison. */
+	/* 15. Cluster length comparison. */
 	new_cluster = BGP_CLUSTER_LIST_LENGTH(new->attr);
 	exist_cluster = BGP_CLUSTER_LIST_LENGTH(exist->attr);

@@ -1895,7 +1895,7 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 		return 0;
 	}

-	/* 15. Neighbor address comparison. */
+	/* 16. Neighbor address comparison. */
 	/* Do this only if neither path is "stale" as stale paths do not have
 	 * valid peer information (as the connection may or may not be up).
 	 */
diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst
index f38b5ffb56..297b4cb165 100644
--- a/doc/user/bgp.rst
+++ b/doc/user/bgp.rst
@@ -177,36 +177,38 @@ bottom until one of the factors can be used.

    Prefer local routes (statics, aggregates, redistributed) to received routes.

+4. **AIGP**
+
    If ``bgp bestpath aigp`` is enabled, and both paths that are compared have
-   AIGP attribute, BGP uses AIGP tie-breaking unless both of the paths have the
-   AIGP metric attribute. This means that the AIGP attribute is not evaluated
-   during the best path selection process between two paths when one path does
-   not have the AIGP attribute.
+   AIGP attribute, BGP uses AIGP tie-breaking. This means that the AIGP
+   attribute is not evaluated during the best path selection process between
+   two paths when one path does not have the AIGP attribute or AIGP is
+   disabled.

-4. **AS path length check**
+5. **AS path length check**

    Prefer shortest hop-count AS_PATHs.

-5. **Origin check**
+6. **Origin check**

    Prefer the lowest origin type route. That is, prefer IGP origin routes to
    EGP, to Incomplete routes.

-6. **MED check**
+7. **MED check**

    Where routes with a MED were received from the same AS, prefer the route
    with the lowest MED. :ref:`bgp-med`.

-7. **External check**
+8. **External check**

    Prefer the route received from an external, eBGP peer over routes received
    from other types of peers.

-8. **IGP cost check**
+9. **IGP cost check**

    Prefer the route with the lower IGP cost.

-9. **Multi-path check**
+10. **Multi-path check**

    If multi-pathing is enabled, then check whether the routes not yet
    distinguished in preference may be considered equal. If
@@ -215,26 +217,26 @@ bottom until one of the factors can be used.
    AS_PATHs or routes received from eBGP neighbours in the same AS are
    considered equal.

-10. **Already-selected external check**
+11. **Already-selected external check**

     Where both routes were received from eBGP peers, then prefer the route
     which is already selected. Note that this check is not applied if
     :clicmd:`bgp bestpath compare-routerid` is configured. This check can
     prevent some cases of oscillation.

-11. **Router-ID check**
+12. **Router-ID check**

     Prefer the route with the lowest `router-ID`. If the route has an
     `ORIGINATOR_ID` attribute, through iBGP reflection, then that router ID is
     used, otherwise the `router-ID` of the peer the route was received from is
     used.

-12. **Cluster-List length check**
+13. **Cluster-List length check**

     The route with the shortest cluster-list length is used. The cluster-list
     reflects the iBGP reflection path the route has taken.

-13. **Peer address**
+14. **Peer address**

     Prefer the route received from the peer with the higher transport layer
     address, as a last-resort tie-breaker.
@@ -442,8 +444,7 @@ Route Selection
    the best path selection process between two paths that have the AIGP
    attribute.

-   When bgp bestpath aigp is disabled, BGP does not use AIGP tie-breaking
-   rules unless paths have the AIGP attribute.
+   When bgp bestpath aigp is disabled, BGP does not use AIGP tie-breaking.

    Disabled by default.