Skip to content

Commit

Permalink
Merge pull request FRRouting#17240 from opensourcerouting/fix/backpor…
Browse files Browse the repository at this point in the history
…t_d46511d4456ccaccfdac34b456c1c225a29609c8_10.0

bgpd: compare aigp after local route check in bgp_path_info_cmp()
  • Loading branch information
Jafaral authored Oct 25, 2024
2 parents 4f43c13 + acc673d commit 4287007
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
55 changes: 26 additions & 29 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,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)) {
Expand Down Expand Up @@ -996,34 +1021,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.
*/
Expand Down
8 changes: 4 additions & 4 deletions doc/user/bgp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,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.
Expand Down

0 comments on commit 4287007

Please sign in to comment.