BGP4 Best Path Selection Algorithm

The BGP decision process is applied to the routes contained in the Routing Information Base, Incoming (RIB-In) which contains routes learned from inbound update messages. The output of the decision process is the set of routes that will be advertised to BGP speakers in local or remote autonomous systems and are stored in the Adjacency RIB, Outgoing (RIB-Out).

When multiple paths for the same route prefix are known to a BGP4 device, the device uses the following algorithm to weigh the paths and determine the optimal path for the route. The optimal path depends on various parameters, which can be modified.

Refer to the Brocade FastIron Command Reference for more information.

  1. Verify that the next hop can be resolved by means of Interior Gateway Protocol (IGP).
  2. Use the path with the largest weight.
  3. If the weights are the same, prefer the path with the largest local preference.
  4. Prefer the route that was self-originated locally.
  5. If the local preferences are the same, prefer the path with the shortest AS-path. An AS-SET counts as 1. A confederation path length, if present, is not counted as part of the path length.

    The as-path ignore command disables the comparison of the AS path lengths of otherwise equal paths.

    Note: This step can be skipped if the as-path-ignore command is configured.
  6. If the AS-path lengths are the same, prefer the path with the lowest origin type. From low to high, route origin types are valued as follows:
    • IGP is lowest.
    • EGP is higher than IGP but lower than INCOMPLETE.
    • INCOMPLETE is highest.
  7. If the paths have the same origin type, prefer the path with the lowest MED.

    The device compares the MEDs of two otherwise equivalent paths if and only if the routes were learned from the same neighboring AS. This behavior is called deterministic MED. Deterministic MED is always enabled and cannot be disabled.

    To ensure that the MEDs are always compared, regardless of the AS information in the paths, the always-compare-med command can be used. This option is disabled by default.

    The med-missing-as-worst command can be used to make the device regard a BGP4 route with a missing MED attribute as the least-favorable path when the MEDs of the route paths are compared.

    MED comparison is not performed for internal routes that originate within the local AS or confederation, unless the compare-med-empty-aspath command is configured.

  8. Prefer paths in the following order:
    • Routes received through eBGP from a BGP4 neighbor outside of the confederation
    • Routes received through eBGP from a BGP4 device within the confederation or routes received through IBGP.
  9. If all the comparisons are equal, prefer the route with the lowest IGP metric to the BGP4 next hop. This is the closest internal path inside the AS to reach the destination.
  10. If the internal paths also are the same and BGP4 load sharing is enabled, load-share among the paths. Otherwise go to Step 11.
    Note: For eBGP routes, load sharing applies only when the paths are from neighbors within the same remote AS. eBGP paths from neighbors in different ASs are not compared, unless multipath multi-as is enabled.
  11. If compare-routerid is enabled, prefer the path that comes from the BGP4 device with the lowest device ID. If a path contains originator ID attributes, then the originator ID is substituted for the router ID in the decision.
  12. Prefer the path with the minimum cluster-list length.
  13. Prefer the route that comes from the lowest BGP4 neighbor address.