summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJafar Al-Gharaibeh <jafar@atcorp.com>2024-10-25 10:19:08 -0500
committerGitHub <noreply@github.com>2024-10-25 10:19:08 -0500
commit6e9284acc1330de4a6c73fe7d13a092ba288666c (patch)
tree141ad104cbe2d0835085b21d072b7e8a20188702
parentc3d94f021fa942faebcb8a73d556ac684ed843e2 (diff)
parentb0084b9bc25b8b79643a945bac2f5b387b6017da (diff)
Merge pull request #17241 from opensourcerouting/fix/backport_d46511d4456ccaccfdac34b456c1c225a29609c8_9.1
bgpd: compare aigp after local route check in bgp_path_info_cmp()
-rw-r--r--bgpd/bgp_route.c55
-rw-r--r--doc/user/bgp.rst8
2 files changed, 30 insertions, 33 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 6dc19a6256..4f1afac5d5 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -953,7 +953,32 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
}
}
- /* Tie-breaker - AIGP (Metric TLV) attribute */
+ /* 3. Local route check. We prefer:
+ * - BGP_ROUTE_STATIC
+ * - BGP_ROUTE_AGGREGATE
+ * - BGP_ROUTE_REDISTRIBUTE
+ */
+ new_origin = !(new->sub_type == BGP_ROUTE_NORMAL || new->sub_type == BGP_ROUTE_IMPORTED);
+ exist_origin = !(exist->sub_type == BGP_ROUTE_NORMAL ||
+ exist->sub_type == BGP_ROUTE_IMPORTED);
+
+ if (new_origin && !exist_origin) {
+ *reason = bgp_path_selection_local_route;
+ if (debug)
+ zlog_debug("%s: %s wins over %s due to preferred BGP_ROUTE type", pfx_buf,
+ new_buf, exist_buf);
+ return 1;
+ }
+
+ if (!new_origin && exist_origin) {
+ *reason = bgp_path_selection_local_route;
+ if (debug)
+ zlog_debug("%s: %s loses to %s due to preferred BGP_ROUTE type", pfx_buf,
+ new_buf, exist_buf);
+ return 0;
+ }
+
+ /* 3.5. Tie-breaker - AIGP (Metric TLV) attribute */
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)) {
@@ -983,34 +1008,6 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
}
}
- /* 3. Local route check. We prefer:
- * - BGP_ROUTE_STATIC
- * - BGP_ROUTE_AGGREGATE
- * - BGP_ROUTE_REDISTRIBUTE
- */
- new_origin = !(new->sub_type == BGP_ROUTE_NORMAL ||
- new->sub_type == BGP_ROUTE_IMPORTED);
- exist_origin = !(exist->sub_type == BGP_ROUTE_NORMAL ||
- exist->sub_type == BGP_ROUTE_IMPORTED);
-
- if (new_origin && !exist_origin) {
- *reason = bgp_path_selection_local_route;
- if (debug)
- zlog_debug(
- "%s: %s wins over %s due to preferred BGP_ROUTE type",
- pfx_buf, new_buf, exist_buf);
- return 1;
- }
-
- if (!new_origin && exist_origin) {
- *reason = bgp_path_selection_local_route;
- if (debug)
- zlog_debug(
- "%s: %s loses to %s due to preferred BGP_ROUTE type",
- pfx_buf, new_buf, exist_buf);
- return 0;
- }
-
/* Here if these are imported routes then get ultimate pi for
* path compare.
*/
diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst
index 35004db2fb..46653595f4 100644
--- a/doc/user/bgp.rst
+++ b/doc/user/bgp.rst
@@ -157,16 +157,16 @@ bottom until one of the factors can be used.
Prefer higher local preference routes to lower.
+3. **Local route check**
+
+ Prefer local routes (statics, aggregates, redistributed) to received routes.
+
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.
-3. **Local route check**
-
- Prefer local routes (statics, aggregates, redistributed) to received routes.
-
4. **AS path length check**
Prefer shortest hop-count AS_PATHs.