<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="3"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" docName="draft-li-idr-inter-protocol-anti-loop-00"
     ipr="trust200902">
  <front>
    <title abbrev="Abbreviated-Title">Loop prevention for route import between protocols</title>

    <author fullname="Wenyan Li" initials="W" surname="Li">
      <organization>Huawei Technologies</organization>

      <address>
        <postal>
          <street>Huawei Campus, No. 156 Beiqing Road</street>

          <city>Beijing</city>

          <code>100095</code>

          <region/>

          <country>China</country>
        </postal>

        <phone/>

        <facsimile/>

        <email>liwenyan@huawei.com</email>
      </address>
    </author>

    <author fullname="Lili Wang" initials="L" surname="Wang">
      <organization>Huawei Technologies</organization>

      <address>
        <postal>
          <street>Huawei Campus, No. 156 Beiqing Road</street>

          <city>Beijing</city>

          <code>100095</code>

          <region/>

          <country>China</country>
        </postal>

        <phone/>

        <facsimile/>

        <email>lily.wong@huawei.com</email>
      </address>
    </author>
    <date day="3" month="March" year="2023"/>

    <abstract>
      <t>BGP and IGP are commonly used network protocols during network
      construction. At the beginning of BGP protocol design, EBGP and
      IBGP loop prevention are considered. Similarly, the IGP protocol
      has a loop prevention mechanism. In actual deployment, some or even
      all routes of the two protocols are imported to each other. Route
      import causes the loss of the anti-loop attribute of the protocol.
      As a result, the anti-loop fails.</t>
      <t>This document provides a feasible solution to the above problems.
      Attribute information is added when routes are imported between
      protocols. The added attribute information can be advertised to
      neighboring neighbors through BGP peers or IGP peers. How the new
      attributes are advertised using IGP peers is beyond the scope of
      this article.</t>
    </abstract>

    <note title="Requirements Language">
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
      "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
      document are to be interpreted as described in <xref
      target="RFC2119">RFC 2119</xref>.</t>
    </note>
  </front>

  <middle>
    <section title="Introduction">
      <t>During actual network deployment or operation and maintenance,
      it is common to import BGP and IGP routes to each other. In practice,
      engineers must have a good understanding of network planning and
      network status. If they are not careful, routing loops may occur.</t>

      <t>The following figure shows an example:<figure>
          <artwork>
                                 +---+
                                 |RT2|
                                 +---+
                                /   |
                       --IBGP--/    |
                      /             |
                     /              |
                    /               |
+---+            +---+              |
|RT1|----IBGP----|RR |             IGP
+---+            +---+              |
                    \               |
                     \              |
                      \             |
                       --IBGP--\    |
                                \   |
                                 +---+
                                 |RT3|
                                 +---+
          </artwork>
        </figure>
      </t>

      <t>As shown in the figure, RT1 imports routes and advertises the
      routes to the RR. The RR advertises the routes to RT2 through an
      IBGP peer. IGP imports BGP routes on R2 and advertises the routes
      to RT3. In this case, the BGP anti-loop attribute information is
      lost. On RT3, BGP imports IGP routes. RT3 preferentially selects
      the locally imported routes and advertises the routes to the RR
      through IBGP. The RR selects the route from RT3 and advertises
      routing updates to RT2. As a result, a routing loop occurs.</t>

      <t>This document provides a mechanism to prevent loops caused by
      route import between protocols. This mechanism is implemented
      through a new attribute, which we call the route origin site List
      attribute. This attribute is transmitted between protocols when
      routes are imported to each other and can be advertised to neighbors.
      When a neighbor receives a route, it checks whether the local
      protocol route origin site information is contained in the route
      origin site attribute. If yes, a routing loop occurs.</t>

      <t>How IGP advertises and generates protocol site attributes is
      beyond the scope of this document. How to transfer route origin
      site attributes between BGP and IGP is beyond the scope of this
      document.</t>
    </section>

    <section title="Route Origin Site List Attribute">
      <t>The attribute encoding content of the Route Origin Site List is the
      information about the site where the route enters the BGP routing
      table or IGP routing table for the first time.</t>

      <t>The Route Origin Site List attribute is optional and transitive.
      Since the route may pass through multiple sites, the attribute length
      field should be 2 bytes, that is, the extended length flag<xref target="RFC4271"></xref> bit should be set.</t>
      
      <t>The Route Origin Site List attribute contains one or more sub-TLVs.
      The Route Origin Site List attribute are defined as follows:</t>

      <t><figure>
          <artwork><![CDATA[0                   1                   2                   3 
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Attr.Flags  | Attr.Type Code|            Length              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          sub-TLVs                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+]]></artwork>
        </figure><list style="symbols">
          <t>Attr.Flags: Optional-transitive, extended length bit is set, refer to
          <xref target="RFC4271"/>.</t>

          <t>Attr.Type Code: TBD.</t>

          <t>Length: 2 bytes. Indicates the total length of the sub-TLVs.</t>

          <t>sub-TLVs: Variable length, containing one or more sub-TLVs.</t>
        </list>
      </t>

    <section title="Route Origin Site List Attribute sub-TLVs">
    <t>A sub-TLV on the originating node of a route, indicating that the
      route is imported to each other, for example, BGP imports IGP routes.
      The sub-TLVs is optional and may be present multiple times in the
      Route Origin Site List.</t>

    <t>When a route is advertised, the sub-TLV should be added to the
      Route Origin Site List of the route. The receiver should check
      whether a loop occurs on the route according to the Route Origin
      Site List attribute of the route. Similarly, when importing a route,
      the protocol checks whether a loop occurs on the route according to
      the Route Origin Site List.</t>

    <section title="BGP Route Origin Site sub-TLV">
    <t>This type of sub-TLV indicates that the route that carries this
    attribute is imported to BGP from other protocols at the site.</t>
    <t>The sub-TLV codes are as follows:</t>
    <t><figure>
          <artwork><![CDATA[0                   1                   2                   3 
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Type     |   Length      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           VPN ID                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      Protocol Site ID                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+]]></artwork>
        </figure><list style="symbols">
          <t>Type: 1.</t>

          <t>Length: Specifies the length of the value field in terms of
          octets. The value MUST be 8.</t>

          <t>VPN ID: 4 octets of vpn instance ID. Indicates the VPN to
          which the route is imported.</t>

          <t>Protocol Site ID: 4 octets. Identifies the protocol site on
          which the route is imported to BGP. It is recommended that the
          site ID be generated as a random number.</t>
        </list>
      </t>
    </section>
    <section title="OSPF Route Origin Site sub-TLV">
    <t>This type of sub-TLV indicates that the route that carries this attribute
    is imported to OSPF from other protocols at the site.</t>
    <t>The sub-TLV codes are as follows:</t>
    <t><figure>
          <artwork><![CDATA[0                   1                   2                   3 
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Type     |   Length      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Process ID                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      Protocol Site ID                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+]]></artwork>
        </figure><list style="symbols">
          <t>Type: 2.</t>

          <t>Length: Specifies the length of the value field in terms of
          octets. The value MUST be 8.</t>

          <t>Process ID: 4 octets. Indicates the OSPF process to which
          the route is imported.</t>

          <t>Protocol Site ID: 4 octets. Identifies the protocol site on
          which the route is imported to OSPF. It is recommended that the
          site ID be generated using a random number or ospf router-id.</t>
        </list>
      </t>
    </section>
    </section>
    <section title="Route Origin Site List Attribute Advertisement">
      <t>For a route imported from one protocol to another, the local
      Route Origin Site information SHOULD be added to the Route Origin
      Site List attribute when the protocol advertises the route. The
      attribute of a route received from a neighbor SHOULD not be modified
      when the route is forwarded to other neighbors. To prevent inter-AS loops,
      the local Route Origin Site information needs to be added to the
      attribute of the Route Origin Site List for the scenario where
      the route is received from the neighbor and forwarded to the
      EBGP neighbor.</t>
    </section>

    <section title="Usage of Route Origin Site List Attribute">
      <t>When a route is received, the local Route Origin Site information
      SHOULD be compared with the Route Origin Site List attribute of the
      route to determine whether a loop occurs. If a routing loop occurs,
      the protocol SHOULD be handled as follows:
        <list style="symbols">
          <t>For the BGP protocol, the priority of routes with loops SHOULD be
          lower than that of non-loop routes. Therefore, in the BGP route
          selection rules, loop detection SHOULD be one of the route selection
          rules, and this rule SHOULD be placed in a higher priority position.</t>

          <t>For the OSPF protocol, the priority of routes with loops SHOULD
          be lower than that of non-loop routes, and adjust the routing metric
          to a larger value.</t>
        </list>
    </t>
      <t>When routes are imported between protocols, the content of
      Route Origin Site List attribute SHOULD be transferred to the
      peer protocol. Each protocol advertises the attribute content
      to its neighbors. The method used by other routing protocols
      to publish the content of this attribute is not discussed in
      this document.</t>
    </section>
    </section>

    <section title="Error Handling">
      <t>The validation of the TLVs/sub-TLVs introduced in this document
      and defined in their respective sub-sections of Section 2 MUST
      be performed to determine if they are malformed or invalid.</t>

      <t>In case of any error detected, either at the attribute or its
      TLV/sub-TLV level, the "Attribute discard" strategy MUST be applied.
      This is because this attribute is used for loop detection, and
      abnormal attribute mishandling may cause more serious problems
      than attribute discarding.</t>
    </section>

    <section title="Use Cases">
    <t><figure>
          <artwork>
                                 +---+
                                 |RT2| [1,200]
                                 +---+
                                /   |
                       --IBGP--/    |
                      /             |
                     /              |
[0,100]             /               |
 +---+            +---+             |
 |RT1|----IBGP----|RR |            IGP
 +---+            +---+             |
                    \               |
                     \              |
                      \             |
                       --IBGP--\    |
                                \   |
                                 +---+
                                 |RT3| [0,300]
                                 +---+
          </artwork>
        </figure>
      </t>
      <t>As shown in the figure, RT1 imports the route, adds [0, 100] to
      the Route Origin Site List attribute of the route, and advertises
      the route to the RR through the IBGP peer.</t>

      <t>The RR advertises the route to RT2 through the IBGP peer.
      The route contains the Route Origin Site List attribute {[0, 100]}.</t>

      <t>On RT2, OSPF process 1 imports BGP routes and advertises them to
      RT3 through the OSPF neighbor. The routes include {[1, 200], [0, 100]}.
      [1, 200] is added by OSPF process 1.</t>

      <t>On RT3, BGP imports OSPF routes that carry the {[1, 200], [0, 100]}
      attribute. RT3 preferentially selects the locally imported route and
      sends the route to the RR through an IBGP peer. The route carries
      {[0, 300], [1, 200], [0, 100]}, [1, 300] is added by BGP.</t>

      <t>The RR preferentially selects the route from RT3 and advertises a
      route update carrying {[0, 300], [1, 200], [0, 100]} to RT2.</t>

      <t>After RT2 receives the route, OSPF process 1 imports BGP routes.
      BGP sends the route with {[0, 300], [1, 200], [0, 100]} to OSPF. OSPF
      compares [1,200] with {[0, 300], [1, 200], [0, 100]}, and finds that
      a loop occurs in the route. After OSPF adjusts the route priority, it
      advertises a low-priority route to RT3.</t>

      <t>If there are other OSPF routes on RT3, other routes are preferred to
      break the loop. Or, on RT3, when BGP imports OSPF routes containing
      {[0, 300], [1, 200], [0, 100]}, it compares the [0,300] with 
      {[0, 300], [1, 200], [0, 100]} to find routing loops and reduce the Route
      selection priority. Therefore, the route sent by RR to RT3 takes priority,
      and the loop is broken.</t>
    </section>

    <section anchor="IANA" title="IANA Considerations">
      <t>This document requests the creation of a new registry called
      "Route Origin Site List Attribute" under the "BGP Path Attribute"
      registry.</t>

      <t><figure align="center">
          <artwork><![CDATA[Code Point  Description
-------  -------------------------------
  TBD    Route Origin Site List Attribute
]]></artwork>
        </figure></t>
       <t>The following initial Sub-TLV codepoints are assigned by this document:</t>
      <t><figure align="center">
          <artwork><![CDATA[SubType  Description
-------  -------------------------------
   1     BGP Route Origin Site sub-TLV
   2     OSPF Route Origin Site sub-TLV
]]></artwork>
        </figure></t>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>There are no additional security risks introduced by this design.</t>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t/>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119"?>
    </references>

    <references title="References">
      <?rfc include="reference.RFC.4271"?>
    </references>
  </back>
</rfc>
