<?xml version="1.0" encoding="utf-8"?>

<?xml-model href="rfc7991bis.rnc"?>  <!-- Required for schema validation and schema-aware editing -->

<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>


<rfc
  xmlns:xi="http://www.w3.org/2001/XInclude"
  category="std"
  docName="draft-vroonen-idr-bgp-bestpath-nh-selection-02"
  ipr="trust200902"
  obsoletes=""
  updates="4271"
  submissionType="IETF"
  xml:lang="en"
  version="3">

  <front>
    <title abbrev="BGP nh selection enhancements">BGP best path next-hop selection enhancements</title>

    <seriesInfo name="Internet-Draft" value="draft-vroonen-idr-bgp-bestpath-nh-selection-02"/>

    <author fullname="Olivier Vroonen" initials="O." role="editor" surname="Vroonen">
      <organization>Cisco</organization>
      <address>
        <email>ovroonen@cisco.com</email>
      </address>
    </author>
    <author fullname="Stephane Litkowski" initials="S." surname="Litkowski">
      <organization>Cisco</organization>
      <address>
        <email>slitkows@cisco.com</email>
      </address>
    </author>
    <author fullname="Kandhla Chandi" initials="K." surname="Chandi">
      <organization>Bell Canada</organization>
      <address>
        <email>kandhla.chandi@bell.ca</email>
      </address>
    </author>
    <author fullname="Jie Dong" initials="J." surname="Dong">
      <organization>Huawei</organization>
      <address>
        <email>jie.dong@huawei.com</email>
      </address>
    </author>
    <date year="2026"/>


    <area>Routing</area>
    <workgroup>Interdomain Working Group</workgroup>


    <abstract>
      <t>
      BGP [RFC4271] has originally been designed to carry IPv4 routing information over the Internet. 
      IP routing being "hop-by-hop" in nature, NEXT_HOP which purpose is to carry the address of the next router to send the IP packet to. 
      In BGP, the next-hop may not be a directly connected router, hence, when evaluating paths, a BGP speaker must determine if the next-hop is resolvable and, if so, determine the internal cost to reach it. 
      </t>
      <t>
      The incremental use of tunneling technologies to carry traffic between routers (e.g.: GRE, MPLS, SR-MPLS, SRv6...) may violate the assumption that the address carried in the NEXT_HOP is representative of the actual forwarding next-hop.
      These technologies decouple the BGP control-plane's view of the next-hop from the data-plane's actual forwarding endpoint.
      This document describes the problems that arise from this decoupling.
      These problems include sub-optimal path selection, incorrect resolvability tracking of the forwarding path leading to traffic drop or misrouting, and others.
      This document proposes some modification of BGP path selection procedures to accommodate these use cases.
      </t>
    </abstract>
 
  </front>

  <middle>
    <section anchor="introduction">
        <name>Introduction</name>
        <t>
        BGP <xref target="RFC4271"/> is designed to exchange network reachability information between routing domains. 
        A BGP update typically contains a prefix and a set of path attributes, including NEXT_HOP. 
        The receiving router uses this next-hop address to determine the egress point for traffic destined for the advertised prefix. 
        The underlying assumption is that the next-hop address represents the actual next router in the data plane's forwarding path.
        </t>
        <t>
        <xref target="RFC4271"/> Section 9.1.2.1 defines the route resolvability condition: a BGP route is considered unresolvable if the BGP speaker's routing table has no route matching the BGP route next-hop address.
        As per <xref target="RFC4271"/> Section 9.1.2.2 e), when comparing paths received via internal BGP (IBGP), the metric to reach the BGP route's next-hop address, found in the routing table, is used to determine the best path.
        </t>
        <figure anchor="base-bgp-nh-selection">
        <name></name>
        <artwork><![CDATA[

                    AS 1
      <--------------------------------->

           +------+ 
    P/m  --| RTR1 |----------------+
           +------+ (N1, metric=1) |
                                   |
                              +------+
                              | RTR3 |
                              +------+
                                   |
           +------+ (N2, metric=2) |
    P/m  --| RTR2 |----------------+
           +------+ 
          ]]>
        </artwork>
        </figure>
        <t>
        In <xref target="base-bgp-nh-selection"/>, RTR3 receives prefix P/m from RTR1 and RTR2 (IBGP peers) with NEXT_HOP N1 and N2. RTR3 resolves N1 with a cost of 1 and N2 with a cost of 2.
        Based on <xref target="RFC4271"/> procedures, RTR3 will select the path with the lowest cost to the NEXT_HOP address, so RTR3 will select the path received from RTR1. In this example, the path used to resolve N1 and N2 reflects the actual forwarding path, which makes RTR3's best-path decision accurate.
        </t>
        <t>
        This document describes cases where the NEXT_HOP used in the BGP update is not representative of the actual forwarding path. 
        In these cases, the resolvability condition may fail in its goal and path selection may be done on inaccurate criteria leading to suboptimal routing, network congestion, traffic drop or misrouting...
        </t>
        <t>
        These use cases are not new and may have been partially addressed by IETF standards or drafts, some references are provided below:
        </t>
        <ul>
            <li>
            <xref target="I-D.ietf-idr-bgp-bestpath-selection-criteria"/> addresses the case of MPLS networks and proposes a modification of the route resolvability condition to be performed using forwarding database of a particular data plane protocol. 
            It also proposes an optional data path verification.
            </li>
            <li>
            <xref target="RFC9012"/> Section 7 improves the route resolvability condition by verifying that there is a feasible tunnel. However, it doesn't take into account that the cost associated with the tunnel may be different from the cost associated with the BGP next-hop.
            </li>
            <li>
            <xref target="RFC9252"/> defines SRv6 overlay services signaling using BGP. The procedures involve the advertisement of an SRv6 Service TLV within the BGP Prefix SID attribute to signal the SID to be used for forwarding. RFC9252 highlights that ingress PE must perform a resolvability check for the SRv6 SID in addition to the resolvability check done on the NEXT_HOP. However, it doesn't take into account that the cost associated with the SRv6 SID may be different from the cost associated with the BGP next-hop.
            </li>
        </ul>
        <t>
        This document defines generic modifications to the BGP decision process that can apply to all the use cases.
        </t>
      <section>
        <name>Requirements Language</name>
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
            "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT
            RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
            interpreted as described in BCP 14 <xref target="RFC2119"/>
            <xref target="RFC8174"/> when, and only when, they appear in
            all capitals, as shown here.</t>
      </section>
    </section>

    <section title="Use cases">
      <section anchor="mpls-path-use-case" title="Unicast over a BGP-free core">
        <figure anchor="next-hop-not-used-for-fwding" title="Next hop attribute not used for forwarding">
          <artwork><![CDATA[

                  [D=6]         [D=6]
          +-----+ (M=1) +----+  (M=1)
  P/m  -- | PE1 |-------| P1 |--------+
   (N1)   +-----+       +----+        |
          (M=1)  \     /              |
          [D=14]  \   /               |
                   \ /              +-----+
                    X               | PE3 |
                   / \              +-----+
          (M=5)   /   \                |
          [D=14] /     \               |
   (N2)   +-----+       +----+         |
  P/m  -- | PE2 |-------| P2 |---------+
          +-----+ (M=5) +----+  (M=5)
                  [D=2]         [D=2]
          ]]>
          </artwork>
        </figure>
        <t>
        In <xref target="next-hop-not-used-for-fwding"/>, an IPv4 unicast service is deployed over a BGP-free MPLS core. Let's assume PE3 receives prefix P/m from PE1 and PE2 with NEXT_HOP N1 and N2.
        The existence of a route in PE3's IPv4 routing table to reach N1 or N2 (defined in <xref target="RFC4271"/>) is not sufficient to ensure that traffic can be carried from PE3 to PE1 or PE2.
        PE3 needs to ensure that there is a tunnel available to reach PE1 or PE2 that can carry MPLS traffic (e.g.: an MPLS Label Switched Path (LSP)).
        By checking only for the existence of a route in its routing table, PE3 could create a traffic drop or misrouting if there is no tunnel to carry the IPv4 unicast traffic.
        This use case is also considered in <xref target="I-D.ietf-idr-bgp-bestpath-selection-criteria"/>.
        </t>
      </section>
      <section title="Segment Routing Traffic Engineering Policy">
        <t>
        When using SR Policies <xref target="RFC9256"/>, the BGP NEXT_HOP may not accurately represent the actual forwarding path. When SR Policy candidate paths are distributed via BGP <xref target="RFC9830"/>, the metric of their segment lists can be carried as specified in <xref target="I-D.ietf-idr-sr-policy-metric"/>, allowing the SR Policy metric to be taken into account in the best-path selection.
        </t>
        <t>
        In <xref target="next-hop-not-used-for-fwding"/>, a BGP VPN service (as defined in <xref target="RFC4364"/>) is deployed between the PEs. Let's assume PE3 receives prefix P/m from PE1 and PE2 with NEXT_HOP N1, N2 and color C1.
        On PE3, SR Policies (C1, N1) and (C1, N2) are configured to use the low latency path.
        </t>
        <ul>
            <li>Costs M in parentheses represents cost of IGP.</li>
            <li>Costs D in brackets represents cost of latency-based metric</li>
        </ul>
        <t>
        If PE3 performs next-hop resolution based solely on the BGP NEXT_HOP, it will not verify the existence and state of a corresponding SR Policy (C1, Nx). Consequently, it may select a suboptimal path by considering the cost to the NEXT_HOP address instead of the cost of the SR policy. The best path considering SR-policy (C1, Nx) cost is via PE2, while the best path considering IGP metric is via PE1.
        </t>
        <table>
        <name>IPv4 routing table of PE3</name>
        <thead>
        <tr><th>Prefix</th><th>Next hop</th><th>Cost</th></tr>
        </thead>
        <tbody>
        <tr><td>N1</td><td>P1</td><td>2</td></tr>
        <tr><td>N2</td><td>P1</td><td>6</td></tr>
        </tbody>
        </table>
        <table>
        <name>SR Policies of PE3</name>
        <thead>
        <tr><th>SR Policy</th><th>Next hop</th><th>Cost</th><th>State</th></tr>
        </thead>
        <tbody>
        <tr><td>(C1, N1)</td><td>P1</td><td>12</td><td>Up</td></tr>
        <tr><td>(C1, N2)</td><td>P2</td><td>4</td><td>Up</td></tr>
        </tbody>
        </table>
        <t>
        Considering that PE3 may take into account the cost of the SR policy and then picks up the path from PE2 as best. 
        If the SR Policy (C1, N2) is down or not present, and considering that color C1 is using CO-flag equal to 00 (<xref target="RFC9246"/> Section 8.8.1), path from PE2 is authorized to use IGP path to next-hop N2 (fallback to IGP path via P1 with cost=6) as there is no policy (C1, N2) available.
        This situation has multiple drawbacks:
        </t>
        <ul>
          <li>The costs of the two BGP paths are not directly comparable, which makes the comparison inaccurate: the path via PE1 uses a latency-based cost, while the fallback path via PE2 uses an IGP metric.</li>
          <li>Using a path without an SR-policy may violate the intent of the service, especially if there is an alternate path (from PE1) that fulfills the intent.</li>
        </ul>
        <t>
        It may be desirable for PE3 to prefer the path from PE1 that satisfies color C1 or even exclude any path that does not meet the color C1 requirement.
        </t>
      </section>
      <section title="SRv6 services">
        <t>
        When using SRv6 services as defined in <xref target="RFC9252"/>, the BGP NEXT_HOP may not be representative of the actual forwarding path.
        </t>
        <t>
        Considering <xref target="next-hop-not-used-for-fwding"/>, an SRv6-based BGP VPN is deployed between the PEs. PE1 uses locator L1 for algorithm 0 and L1_FA for flexible algorithm 128 (<xref target="RFC9350"/>) optimized for low-latency. Similarly, PE2 uses locator L2 for algorithm 0 and L2_FA for flexible algorithm 128. 
        Let's assume PE3 receives prefix P/m from PE1 and PE2 with NEXT_HOP N1, N2 and SRv6 SID S1 and S2.
        SID S1 and S2 are allocated respectively from L1_FA and L2_FA.
        </t>
        <ul>
            <li>Costs M in parentheses represents cost of algorithm 0 (as defined in <xref target="RFC8665"/> Section 8.5).</li>
            <li>Costs D in brackets represents cost of flexible algorithm <xref target="RFC9350"/> 129 which is using low-latency metric.</li>
        </ul>
        <t>
        The IPv6 routing table of PE3 contains the following entries:
        </t>
        <table>
        <name>IPv6 routing table of PE3</name>
        <thead>
        <tr><th>Prefix</th><th>Next hop</th><th>Cost</th></tr>
        </thead>
        <tbody>
        <tr><td>N1</td><td>P1</td><td>2</td></tr>
        <tr><td>N2</td><td>P1</td><td>6</td></tr>
        <tr><td>L1</td><td>P1</td><td>2</td></tr>
        <tr><td>L2</td><td>P1</td><td>6</td></tr>
        <tr><td>L1_FA</td><td>P1</td><td>12</td></tr>
        <tr><td>L2_FA</td><td>P2</td><td>4</td></tr>
        </tbody>
        </table>
        <t>
        Based on <xref target="RFC4271"/> procedures, PE3 verifies that NEXT_HOP address of each path is resolvable.
        Based on <xref target="RFC9252"/> procedures, PE3 verifies that S1 and S2 addresses are resolvable.
        PE3 will then select the path with the lowest cost to the NEXT_HOP address according to <xref target="RFC4271"/> .
        Cost to N1 is lower than cost to N2, so PE3 will select the path received from PE1. However, from a latency perspective, path to PE2 is the best one.
        </t>
        <t>
        The problem of path suboptimality may also happen with algorithm 0, if for instance SRv6 traffic for algorithm 0 needs to be offloaded from PE1, operator may increase the metric of the locator (while not changing the metric of the next-hop) on PE1.
        In the example above, if L1 is advertised by PE1 with an offset of 1M, then PE3 will have to cost to L1 of 1000002 but N1 will still be reachable with a cost of 2.
        The cost to reach the SID must also be taken into account in this scenario to ensure that the traffic offload works properly.
        </t>
      </section>
    </section>
    
    <section title="Modification of the BGP route selection process">
        <section title="Forwarding address">
            <t>
            This document defines the forwarding address as the IP address of the next router to which packets are sent. The forwarding address may come from the NEXT_HOP or a different address which has been signaled in a different attribute along with the path.
            </t>
            <t>
            The following data already defined in BGP standards SHOULD be considered as forwarding addresses:
            </t>
            <ul>
                <li>The Tunnel Egress Endpoint Sub-TLV contained in Tunnel Encapsulation attribute defined in <xref target="RFC9012"/></li>
                <li>SRv6 SID Information Sub-TLV contained within L3 or L2 SRv6 SID defined in <xref target="RFC9252"/></li>
            </ul>
            <t>
            Unless a BGP update contains another type of forwarding address, the BGP NEXT_HOP is considered as the forwarding address.
            </t>
            <t>
            The forwarding address MAY be complemented by a forwarding context. The forwarding context characterizes more the forwarding path to be used.
            The following attributes defined in BGP standards are examples of forwarding context:
            </t>
            <ul>
                <li>The Tunnel Encapsulation attribute defined in <xref target="RFC9012"/></li>
                <li>The Color extended community defined in <xref target="RFC9012"/></li>
                <li>The SRv6 Sub-TLV and Sub-sub-TLV contained within L3 or L2 SRv6 SID TLV as defined in <xref target="RFC9252"/> other than the SID itself</li>
            </ul>
            <t>
            Each new BGP extension SHOULD specify if an address carried by the extension must be considered as a forwarding address. The procedures defined in the next section SHOULD apply for any new forwarding address defined without having to redefine them.
            </t>
        </section>

        <section anchor="lookup-in-table" title="Resolution constraints">
        <t>
        When the forwarding address and its context are identified for a BGP route, the implementation may know the required characteristics of the route to be used to resolve the forwarding address.
        Depending on the type of forwarding address and context, the implementation may need to ensure that the forwarding address is resolved through a specific type of route in a specific table.
        This resolution constraint may come from the forwarding context and/or may be configured locally.
        </t>
        <t>
        In some cases, operator may want to enforce that the forwarding address is resolved through a specific type of route.
        This can be achieved by configuring a local resolution constraint.
        Reusing the example defined in <xref target="mpls-path-use-case"/>, if we consider an IPv4 unicast BGP service carried over a BGP free-core, the BGP NEXT_HOP must be reachable through a tunnel to allow the end-to-end packet delivery.
        Such a case cannot be derived from the BGP update context and BGP must be configured to resolve the NEXT_HOP only through tunnels (of any or specific types). 
        Similarly, when aggregate routes are present in the routing table, user may want to prevent the forwarding address (which is a specific route) to be resolved over the aggregate routes. A resolution constraint based on prefix/mask can be done to avoid such resolution to be valid.
        An implementation MAY provide a set of configuration options for resolution constraints.
        </t>
        <t>
        Another example of a resolution constraint is the "Resolution Scheme", defined in BGP Classful Transport <xref target="RFC9832"/>. The "Resolution Scheme" constrains the resolution of the NEXT_HOP to an ordered set of transport classes dictated by the intent (Mapping Community) attached to the route.
        </t>
        </section>
        <section title="Route resolvability condition">
        <t>
            This document updates <xref target="RFC4271"/> Section 9.1.2.1 as follows:
        </t>
        <ul>
            <li>
                The route resolvability check for the BGP NEXT_HOP MUST continue to be done.
            </li>
            <li>
                In addition, the route resolvability criteria SHOULD be performed based on the forwarding address.
            </li>
            <li>
                When resolving the forwarding address, look up SHOULD be performed by applying the resolution constraints defined in <xref target="lookup-in-table"/>.
            </li>
        </ul>
        <t>
        The resolvability check based on the forwarding address MAY be enabled through a configuration knob.
        </t>
        </section>
        <section title="Internal cost determination">
        <t>
        For a prefix P/m, different BGP paths may use different forwarding addresses and contexts of various types.
        </t>
        <figure>
            <artwork><![CDATA[
        P/m
            Path1: NH=10.0.0.1 Color: 200
            Path2: NH=2001::2 SRv6-SID: cafe:0:2:e002::
            Path3: NH=10.0.0.3 Tunnel-encap(L2TPv3, endpoint: 10.0.0.3)
            Path4: NH=2001::4 SRv6-SID: cafe:0:4:e002::
            ]]></artwork>
        </figure>
        <t>
        Costs retrieved from different types of forwarding addresses or contexts may not be comparable because they are based on different sets of rules. For instance, path1 may leverage an SR policy (color 200, endpoint R1) optimizing for latency, so the cost of path1 will reflect the latency to R1. Path2 may use the IGP cost to R2. Path3 may have no cost. These values are not directly comparable.
        </t>
        <t>
        The issue of comparing costs of paths of various types is not new. In a regular IP routed network (without tunnels) that runs BGP, a prefix P/m may have paths with nexthops reachable through different IGPs or IGP route types, where costs computed by each IGP may use a different reference. While the routing table can tie-break across different protocols or route types for a single prefix using an internal preference (administrative distance) mechanism, this does not help when comparing BGP paths whose nexthops are resolved through different IGPs.
        </t>
        <t>
        In order to compare the paths, this document introduces the concept of forwarding address preference. The preference is a local numerical value. An implementation SHOULD pick the lowest value as the most preferred.
        </t>
        <t>
        This document updates <xref target="RFC4271"/> Section 9.1.2.2 e) as follows:
        </t>
        <ul>
            <li>
            Remove from consideration any routes with an highest forwarding address preference value. This preference MAY be retrieved from the resolution lookup of the forwarding address or MAY be configured locally.
            </li>
            <li>
            For remaining paths, the interior cost of a route is determined by the metric of the resolving route to the forwarding address applying the resolution constraints defined in <xref target="lookup-in-table"/>. If the forwarding address for a route is reachable, but no cost can be determined, the cost SHOULD be set by default to the maximum allowed cost.
            </li>
        </ul>
        <t>
        Using forwarding preference and forwarding address-based cost SHOULD be enabled through a configuration knob.
        </t>
        <t>
        With the example above and the internal tables defined below, and considering lowest preference value as the most preferred one, BGP would select Path2 as best. Path2 and Path4 have the lowest preference (10), then Path2 has the lowest internal cost (12).

        </t>
        <figure>
            <artwork><![CDATA[
        P/m
            Path1: NH=10.0.0.1 Color: 200, 
                   preference 100 (from table), cost 1001
            Path2: NH=2001::2 SRv6-SID: cafe:0:2:e002::,  
                   preference 10 (from BGP), cost 12
            Path3: NH=10.0.0.3 
                   Tunnel-encap(L2TPv3, endpoint: 10.0.0.3, sessID: 1),
                   preference 1000 (from BGP), cost max
            Path4: NH=2001::4 SRv6-SID: cafe:0:4:e002::, 
                   preference 10 (from BGP), cost 14
            ]]></artwork>
        </figure>
        <table>
          <name>IPv4 Color routing table</name>
          <thead>
            <tr><th>Prefix, Color</th><th>Preference</th><th>Metric</th><th>Forwarding data</th></tr>
          </thead>
          <tbody>
            <tr><th>10.0.0.1, 200</th><th>10</th><th>1001</th><th>interface IF1, label stack {L1, L2, L3}</th></tr>
            <tr><th>10.0.0.2, 200</th><th>10</th><th>1002</th><th>interface IF2, label stack {L4, L5}</th></tr>
            <tr><th>10.0.0.3, 200</th><th>10</th><th>1003</th><th>interface IF1, label stack {L6, L7, L8, L9}</th></tr>
          </tbody>
        </table>
        <table>
          <name>IPv6 routing table</name>
          <thead>
            <tr><th>Prefix</th><th>Preference</th><th>Metric</th><th>Forwarding data</th></tr>
          </thead>
          <tbody>
            <tr><th>cafe:0:1::/48</th><th>5</th><th>11</th><th>interface IF1, label stack {L1, L2, L3}</th></tr>
            <tr><th>cafe:0:2::/48</th><th>5</th><th>12</th><th>interface IF2, label stack {L4, L5}</th></tr>
            <tr><th>cafe:0:3::/48</th><th>5</th><th>13</th><th>interface IF1, label stack {L6, L7, L8, L9}</th></tr>
            <tr><th>cafe:0:4::/48</th><th>5</th><th>14</th><th>interface IF1, label stack {L10, L11, L12}</th></tr>
          </tbody>
        </table>
        <table>
          <name>L2TP session table</name>
          <thead>
            <tr><th>Destination</th><th>Session ID</th><th>Status</th></tr>
          </thead>
          <tbody>
            <tr><th>10.0.0.3</th><th>1</th><th>up</th></tr>
          </tbody>
        </table>
        <table>
          <name>BGP forwarding address preference configuration</name>
          <thead>
            <tr><th>Type</th><th>Preference</th></tr>
          </thead>
          <tbody>
            <tr><th>MPLS LSP (any signaling)</th><th>100</th></tr>
            <tr><th>MPLS RSVP-TE LSP</th><th>50</th></tr>
            <tr><th>SRv6 SID</th><th>10</th></tr>
            <tr><th>Default</th><th>use value from table lookup, use 1000 if table provided no value</th></tr>
          </tbody>
        </table>
        <t>

        </t>
        </section>
        <section title="Next hop and forwarding address tracking" anchor="address-tracking">
        <t>
        A BGP speaker SHOULD track the resolvability of both the NEXT_HOP and the forwarding address. If either the NEXT_HOP or the forwarding address becomes unresolvable or if the cost to reach either the NEXT_HOP or the forwarding address changes, the BGP speaker MUST re-evaluate the best path selection for all prefixes using the affected NEXT_HOP or forwarding address.
        This tracking MUST be done for all paths, including the best path and non-best paths.
        </t>
        </section>
    </section>

    <section title="Example">
      <t>
      The example below illustrates the logic of forwarding address preference and cost comparison.
      </t>
      <figure anchor="enhanced-bgp-nh-selection">
      <artwork><![CDATA[
                      +-----+     (M=5)
              P/m  -- | PE1 |----------------+
               (N1)   +-----+                |
                                             |
                                             |
                      +-----+     (M=10)   +----+     (M=5)    +-----+
              P/m  -- | PE2 |--------------| P1 |--------------| PE4 |
               (N2)   +-----+              +----+              +-----+
                                             |
                                             |                                             
                      +-----+     (M=15)     |
              P/m  -- | PE3 |----------------+
               (N3)   +-----+          
      ]]></artwork>
      </figure>
      <t>
      In <xref target="enhanced-bgp-nh-selection"/>, a prefix P/m is reachable by PE4 from PE1, PE2, PE3 (with respectively NEXT_HOP N1, N2 and N3). Considering that the network is a BGP free core, traffic must be tunneled between edge devices.
      Traffic destined to P/m is of high bandwidth and requires traffic-engineering to spread the traffic across the available links of the core. RSVP-TE is used to provide traffic-engineering MPLS tunnels.
      SR-MPLS is also used to provide best-effort reachability. BGP is configured to use the route preference (or administrative distance) from table lookup as forwarding address preference. RSVP-TE is given a better route preference than SR-MPLS. 
      RSVP-TE tunnel to PE3 cannot be established.
      </t>
      <table>
        <name>IPv4 routing table of PE4</name>
        <thead>
        <tr><th>Prefix</th><th>Protocol</th><th>Preference</th><th>Cost</th></tr>
        </thead>
        <tbody>
        <tr><td>N1</td><td>IS-IS</td><td>100</td><td>10</td></tr>
        <tr><td>N2</td><td>IS-IS</td><td>100</td><td>15</td></tr>
        <tr><td>N3</td><td>IS-IS</td><td>100</td><td>20</td></tr>
        </tbody>
      </table>
      <table>
        <name>MPLS ingress tunnel table of PE4</name>
        <thead>
        <tr><th>Prefix</th><th>Protocol</th><th>Preference</th><th>Cost</th></tr>
        </thead>
        <tbody>
        <tr><td>N1</td><td>IS-IS SR</td><td>110</td><td>10</td></tr>
        <tr><td>N1</td><td>RSVP-TE</td><td>250</td><td>1000</td></tr>
        <tr><td>N2</td><td>IS-IS SR</td><td>110</td><td>15</td></tr>
        <tr><td>N2</td><td>RSVP-TE</td><td>250</td><td>100</td></tr>
        <tr><td>N3</td><td>IS-IS SR</td><td>110</td><td>20</td></tr>
        </tbody>
      </table>
      <t>
      As mentioned in <xref target="lookup-in-table"/>, the case of BGP free-core requires BGP on PE4 to be configured to allow the resolution the NEXT_HOP address through tunnels (of any type).
      Considering that PE4 maintains a separate table for MPLS ingress tunnels, PE4 will look up for N1, N2, N3 addresses only in this table.
      PE4 will first check the resolvability of N1, N2 and N3. All are resolvable in the MPLS ingress tunnel table. PE4 will end-up with the following information from the MPLS ingress tunnel table to compare the path:
      </t>
      <figure>
      <artwork>

  P/m
    Path1:
      from PE1, NH=N1
      cost 1000, forwarding address preference 250

    Path2:
      from PE2, NH=N2
      cost 100, forwarding address preference 250

    Path3:
      from PE3, NH=NH3
      cost 20, forwarding address preference 110

      </artwork>
      </figure>
      <t>
      PE4 will check the forwarding address preference of the paths. PE4 will not consider the paths received from PE3 because the forwarding address preference is lower than others.
      Finally, PE4 will compare the internal costs between paths from PE1 and PE2 as they have the same preference and path from PE2 will be elected as best because it has the lowest cost.
      </t>
      <t>
      As mentioned in <xref target="address-tracking"/>, if the RSVP-TE tunnel to PE2 goes down, PE4 will re-evaluate the best path selection and will select the path from PE1 as best. This is also true if the cost of RSVP-TE LSP to reach N1 changes and becomes lower than the cost of LSP to reach N2.
      </t>
    </section>

    <section title="Example with Intent-Aware BGP Transport">
      <t>
      This example illustrates the need for forwarding address preference when intent-aware BGP transport technologies are deployed. Both BGP Classful Transport (<xref target="RFC9832"/>) and BGP Color-Aware Routing (<xref target="RFC9871"/>) can lead to situations where two paths for a prefix resolve through different transport mechanisms with incomparable costs.
      </t>
      <figure anchor="intent-transport-example">
      <artwork><![CDATA[
                      +-----+     (M=5)
              P/m  -- | PE1 |----------------+
               (N1)   +-----+                |
                                           +----+     (M=5)    +-----+
                                           | P1 |--------------| PE3 |
                                           +----+              +-----+
                      +-----+     (M=10)    |
              P/m  -- | PE2 |----------------+
               (N2)   +-----+          
      ]]></artwork>
      </figure>
      <t>
      In <xref target="intent-transport-example"/>, PE3 receives a VPN prefix P/m from PE1 and PE2 with NEXT_HOP N1 and N2 respectively. An intent-aware transport technology is deployed, requesting "Gold" SLA transport for this prefix. Gold RSVP-TE tunnels exist from PE3 to PE1 but not from PE3 to PE2. Best-effort SR-MPLS tunnels exist to both PE1 and PE2.
      </t>
      <t>
      In a BGP Classful Transport (<xref target="RFC9832"/>) deployment, the prefix P/m is advertised with Mapping Community color:0:100 indicating the Gold SLA intent. The Resolution Scheme for color:0:100 is configured with the following ordered set of Transport Route Databases (TRDBs): [TRDB-Gold, TRDB-Best-Effort], meaning the NEXT_HOP should be resolved first over Gold transport tunnels, with a fallback to best-effort tunnels. Following <xref target="RFC9832"/> Section 7.8 procedures, the Resolution Scheme resolves the NEXT_HOP of each path independently:
      </t>
      <ul>
        <li>Path1 (NH=N1): N1 is found in TRDB-Gold (RSVP-TE tunnel to PE1). Resolution succeeds in the primary TRDB.</li>
        <li>Path2 (NH=N2): N2 is not found in TRDB-Gold. Fallback occurs: N2 is found in TRDB-Best-Effort (SR-MPLS tunnel to PE2). Resolution succeeds in the backup TRDB.</li>
      </ul>
      <t>
      In a BGP Color-Aware Routing (<xref target="RFC9871"/>) deployment, the prefix P/m is advertised as a service route with BGP Color Extended Community C_Gold. PE3 needs color-aware paths (N1, C_Gold) and (N2, C_Gold) to steer traffic. Following <xref target="RFC9871"/> Section 2.5 procedures:
      </t>
      <ul>
        <li>Path1 (NH=N1): color-aware path (N1, C_Gold) is available via RSVP-TE. Resolution succeeds via the primary mechanism.</li>
        <li>Path2 (NH=N2): color-aware path (N2, C_Gold) is not available. Local policy allows fallback: N2 is resolved via best-effort SR-MPLS. Resolution succeeds via the fallback mechanism.</li>
      </ul>
      <t>
      In both cases, both paths are resolvable, but they resolved through different transport mechanisms with different characteristics. The Gold tunnel to PE1 has a cost of 1000 (RSVP-TE metric), while the best-effort tunnel to PE2 has a cost of 15 (IGP metric). These costs are not comparable.
      </t>
      <table>
        <name>Gold transport tunnels on PE3</name>
        <thead>
        <tr><th>Prefix</th><th>Protocol</th><th>Preference</th><th>Cost</th></tr>
        </thead>
        <tbody>
        <tr><td>N1</td><td>RSVP-TE</td><td>50</td><td>1000</td></tr>
        </tbody>
      </table>
      <table>
        <name>Best-effort transport tunnels on PE3</name>
        <thead>
        <tr><th>Prefix</th><th>Protocol</th><th>Preference</th><th>Cost</th></tr>
        </thead>
        <tbody>
        <tr><td>N1</td><td>IS-IS SR</td><td>110</td><td>10</td></tr>
        <tr><td>N2</td><td>IS-IS SR</td><td>110</td><td>15</td></tr>
        </tbody>
      </table>
      <t>
      Without the forwarding address preference mechanism, PE3 would simply compare the costs: 1000 (path via PE1, Gold) vs 15 (path via PE2, best-effort), and would select the path via PE2. This is problematic because:
      </t>
      <ul>
        <li>The path via PE2 uses best-effort transport, violating the Gold SLA intent.</li>
        <li>The path via PE1, which satisfies the Gold SLA, is discarded solely because the RSVP-TE metric is numerically higher than the IGP metric, even though these values are not comparable.</li>
      </ul>
      <t>
      Using the forwarding address preference, PE3 retrieves the preference value from the transport table lookup. The Gold transport table provides a preference of 50, while the best-effort transport table provides a preference of 110. PE3 will first compare the forwarding address preference values and remove from consideration any path with the highest (least preferred) value. Path2 (preference 110) is removed. PE3 selects path1 via PE1, which satisfies the Gold SLA intent.
      </t>
      <figure>
      <artwork>

  P/m
    Path1:
      from PE1, NH=N1
      resolved via Gold transport (RSVP-TE)
      cost 1000, forwarding address preference 50

    Path2:
      from PE2, NH=N2
      resolved via best-effort transport (SR-MPLS)
      cost 15, forwarding address preference 110

    => PE3 selects Path1 (lower preference value = more preferred)

      </artwork>
      </figure>
    </section>

    <section anchor="Operational">
      <name>Operational Considerations</name>
      <t>
      In most cases, tunnels carry traffic from the ingress to the egress node that advertised the BGP service route, as transit routers are not aware of the BGP service routes. For instance, in SRv6 service cases, the SRv6 encapsulation using the advertised SID as destination carries traffic down to the node that knows about the service route. Determining the internal cost by using the forwarding address (tunnel endpoint, SRv6 SID, ...) makes sense in these cases as it reflects the end-to-end cost.
      </t>
      <t>
      However, there are cases where the tunnel does not terminate on the service egress. One example is a service route advertised with a color allowing for usage of a null endpoint policy. Another example is a service route advertised with a Tunnel Encapsulation attribute using a tunnel endpoint different from the service egress. In such cases, the tail node of the tunnel must have routing entries for the service routes to ensure end-to-end reachability.
      </t>
      <t>
      When determining the internal cost using the forwarding address in these cases, the retrieved cost may not reflect the end-to-end path. However, using the NEXT_HOP address would not necessarily provide a better view: it would still give an inaccurate picture of distances from a traffic forwarding perspective, since the forwarding path does not follow the IGP-routed path. Additionally, operators commonly manipulate the NEXT_HOP through routing policies, so there is no guarantee that the NEXT_HOP address correctly reflects the real egress node. Hence, using the forwarding address in cases where the tunnel tail is not the service egress is not worse compared to using the NEXT_HOP.
      </t>
      <t>
      This document defines mechanisms that modify the BGP best path selection process defined in <xref target="RFC4271"/>. Consequently, the potential impact on routing loops needs to be analyzed.
      </t>
      <t>
      The mechanisms described in this document are typically deployed in environments utilizing tunneling technologies (such as MPLS or SRv6). In these scenarios, the BGP path selection determines the specific Forwarding Address used for encapsulation.
      </t>
      <t>
      When the traffic is encapsulated at the ingress router, intermediate nodes forward packets based solely on the outer transport header rather than the inner destination. Consequently, the specific BGP selection criteria are enforced only at the ingress, preventing forwarding loops that might otherwise arise from inconsistent policy decisions on intermediate nodes.
      </t>
      <t>
      To illustrate this loop prevention, consider the following topology where PE1, PE2, and PE3 provide reachability to Prefix X.
      </t>
      <figure anchor="fig_loop_prevention">
        <name>Loop Prevention via Encapsulation</name>
        <artwork type="ascii-art">
                          +-------+
                        /|  PE2  |--- Prefix X
              (Low Delay) |       |
                        / +-------+
                      /
    +-------+    +-------+
    |  PE1  |----|   P   |
    +-------+    +-------+
    (Ingress)          \
                        \ +-------+
              (Low IGP)   |  PE3  |--- Prefix X
                          |       |
                          +-------+
        </artwork>
      </figure>
      <t>
      Assume PE1 is configured with the mechanisms defined in this document and selects PE2 as the BGP next-hop for Prefix X to optimize for low delay. Router P is a transit node and uses standard BGP procedures, preferring PE3 due to a lower IGP metric. 
      </t>
      <t>
      In a hop-by-hop IP routing paradigm, PE1 would forward a bare IP packet to P. Router P would perform a lookup on the inner destination IP (Prefix X) and deflect the packet toward PE3, directly contradicting PE1's decision and potentially causing a loop if PE3 also had a conflicting policy. 
      </t>
      <t>
      However, in a tunneling paradigm, PE1 encapsulates the packet with an outer header (e.g., an SRv6 SID or MPLS label) targeting PE2's Forwarding Address. When the packet arrives at Router P, P only evaluates the outer header and forwards the packet along the IGP shortest path to PE2. Router P's BGP policy regarding Prefix X is never invoked for in-flight traffic.
      </t>
      <t>
      Nevertheless, to ensure predictable routing behavior and simplify troubleshooting, it is recommended that network operators maintain a consistent configuration of these selection criteria across all BGP speakers within the same administrative domain.
      </t>
    </section>
    
    <section anchor="relationship-criteria">
      <name>Relationship to draft-ietf-idr-bgp-bestpath-selection-criteria</name>
      <t>
      This document and <xref target="I-D.ietf-idr-bgp-bestpath-selection-criteria"/> are complementary. Their relationship can be summarized as follows:
      </t>
      <ul>
        <li>Scope: <xref target="I-D.ietf-idr-bgp-bestpath-selection-criteria"/> performs the resolvability check only; this document also covers internal cost determination and path preference.</li>
        <li>Generality: <xref target="I-D.ietf-idr-bgp-bestpath-selection-criteria"/> is MPLS-centric; this document is generic and applies to MPLS, SR Policy, SRv6 and intent-aware BGP transport.</li>
        <li>This document introduces the forwarding address, decoupling path selection from the NEXT_HOP.</li>
        <li>This document introduces the forwarding address preference to compare paths of non-comparable types.</li>
        <li>This document derives the internal cost from the forwarding address, not from the NEXT_HOP only.</li>
        <li>The MPLS case covered by <xref target="I-D.ietf-idr-bgp-bestpath-selection-criteria"/> is one instance of the generic mechanism defined here.</li>
      </ul>
    </section>

    <section anchor="IANA">
      <name>IANA Considerations</name>
      <t>This document does not require any IANA actions.</t>
    </section>
    
    <section anchor="Security">
      <name>Security Considerations</name>
      <t>
      This document modifies BGP route selection process by using data other than the next-hop address to perform the resolvability check as well as to compute the internal cost. 
      This does not add any security consideration compared to using the existing NEXT_HOP defined in <xref target="RFC4271"/>.
      </t>
    </section>
  </middle>

  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4271.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4364.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8665.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9012.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9246.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9252.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9256.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9350.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9832.xml"/>
      </references>
 
      <references>
        <name>Informative References</name>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-idr-bgp-bestpath-selection-criteria.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-idr-sr-policy-metric.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9830.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9871.xml"/>

      </references>
    </references>

    <section anchor="Acknowledgements" numbered="false">
      <name>Acknowledgements</name>
      <t>
      The authors would like to acknowledge Ketan Talaulikar, Serge Krier and Shyam Sethuram for review and comments.
      </t>
    </section>
    
 </back>
</rfc>