<?xml version="1.0" encoding="US-ASCII"?>
<?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-zhang-idr-sr-policy-metric-04"
     ipr="trust200902">
  <front>
    <title abbrev="BGP SR Policy Extensions for metric">BGP SR Policy
    Extensions for metric</title>

    <author fullname="Ka Zhang" initials="K. " surname="Zhang">
      <organization>Huawei</organization>

      <address>
        <postal>
          <street>Huawei Bld., No.156 Beiqing Rd.</street>

          <city>Beijing</city>

          <code>100095</code>

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

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

    <author fullname="Jie Dong" initials="J. " surname="Dong">
      <organization>Huawei</organization>

      <address>
        <postal>
          <street>Huawei Bld., No.156 Beiqing Rd.</street>

          <city>Beijing</city>

          <code>100095</code>

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

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

    <author fullname="Ketan Talaulikar" initials="K. " surname="Talaulikar">
      <organization>Cisco Systems</organization>

      <address>
        <postal>
          <country>India</country>
        </postal>

        <email>ketant.ietf@gmail.com</email>
      </address>
    </author>

    <date day="13" month="March" year="2023"/>

    <abstract>
      <t>SR Policy candidate paths can be represented in BGP UPDATE messages.
      BGP can then be used to propagate the SR Policy candidate paths to the
      headend nodes in the network. After SR Policy is installed on the
      ingress node, the packets can be steered into SR Policy through route
      selection. Therefore, route selection may be performed on the ingress
      node of the SR Policy. If there are multiple routes to the same
      destination, the route selection node can select routes based on the
      local policy. The local policy may use the IGP metric of the selected
      path, which is the IGP Metric of the SR Policy. Thus the BGP UPDATE
      message need carry the metric of each segment list of the SR Policy
      Candidate Path, which can be used in path selection of routing. </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 BCP 14 <xref
      target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they
      appear in all capitals, as shown here.</t>
    </note>
  </front>

  <middle>
    <section title="Introduction">
      <t><xref target="I-D.ietf-idr-segment-routing-te-policy"/>defines SR
      Policy and Tunnel Encapsulation Attributes. It defines the segment list
      of the SR policies. Each segment list of an SR Policy is an segment
      routing path, which may be calculated by path compuation element and
      delivered to the head node of the device by BGP Update Message. On the
      ingress node, when steer traffic to an SR Policy, the ingress node may
      need to select between multiple SR Policy paths. And the selection
      policy may need the path metric information. Therefore, BGP needs to
      carry the metric of each path when delivering the semgnet list of the SR
      Policy through Update messages to facilitate route selection on the
      device.</t>
    </section>

    <section title="Terminology">
      <t>The following terminology is used in this document.</t>

      <t>SR Policy: An ordered list of segments.</t>

      <t>Candidate Path: the unit for signaling of an SR Policy to a headend
      via protocol PCEP or BGP, which is defined in <xref
      target="I-D.ietf-pce-segment-routing-policy-cp"/> and <xref
      target="I-D.ietf-idr-segment-routing-te-policy"/>.</t>

      <t>SRPM: SR Policy Module.</t>
    </section>

    <section title="Motivation">
      <t>In route selection scenarios, the metric of the SR Policy segment
      list may be required.</t>

      <t>The specific scenarios are as follows: </t>

      <figure suppress-title="false">
    <artwork align="left"> 
			
                         +--+         +--+         +---+ 
                _ _ _ _ _|P1|_ _ _ _ _|P2|_ _ _ _ _|PE2|_ _ _ _ 
               |         +--+         +--+         +---+       |        
               |                                               | 
 +---+        +---+                                           +---+ 
 |CE1|_ _ _ _ |PE1|                                           |CE1| 
 +---+        +---+                                           +---+            
               |         +--+         +--+         +---+       | 
               |_ _ _ _ _|P3|_ _ _ _ _|P4|_ _ _ _ _|PE3|_ _ _ _| 	       
                         +--+         +--+         +---+	 
</artwork>
          </figure>

      <t> On PE1, the route prefix to CE1 has two diffierent next hop, PE2 and
      PE3. The next hop to PE1 uses an SR Policy1 on PE1, the endpoint of SR
      Policy1 is PE2. The next hop to PE2 uses an SR Policy2 on PE1, the
      endpoint of SR Policy2 is PE3. The prefix to CE1 want to choose a next
      hop based on the IGP metric of the route PE1 to PE2 and PE1 and PE3,
      which uses SR Policy1 and SR Policy2. Thus need the IGP metric of SR
      Policy semgent list on PE1.</t>
    </section>

    <section title="SR Policy and Tunnel Encapsulation Attribute Update">
      <t>As the metric is defined, the tunnel attribute encapsulation of the
      BGP SR Policy needs to be updated.</t>

      <t>The SR Policy Encoding structure is as follows:</t>

      <t>SR Policy SAFI NLRI: &lt;Distinguisher, Policy-Color,
      Endpoint&gt;</t>

    <figure suppress-title="false">
    <artwork align="left"> 
      Attributes:

      Tunnel Encaps Attribute (23)

              Tunnel Type: SR Policy

                 Binding SID

                 Preference

                 Priority

                 Policy Name

                 Policy Candidate Path Name

                 Explicit NULL Label Policy (ENLP)

                 Segment List

                     Weight
	  
                     Metric  

                     Segment

                     Segment

                     ....

                     ....
</artwork>
          </figure>

      <t>Where metric indicates the metric for the segment list.</t>

      <section title="Metric sub-TLV">
        <t>A new sub-TLV called Metric sub-TLV is defined.  Metric sub-TLV
   specifies the metric of an SR policy Segment List. Each sub-TLV is
        encoded as shown in Figure 1. More than one Metric Sub-TLVs may be
        present in one Segment List to refer to the metric values of different
        metric type.</t>

        <t><figure suppress-title="false"
            title="Metric Sub-TLV">
            <artwork align="center"> 
0               1               2               3
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      Type     |    Length     |   Metric Type    |   Flags   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Metric Value                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
          </figure></t>

        <t>* Type: Metric, 1 octet, TBD.</t>

        <t>* Length: 6 octets.</t>

        <t>* Metric Type: 1-octet field which identifies the type of the
        metric being used. The metric type code points are listed as follows.
        The "Metric Type" code point is the same as the SR Segment List Metric
        Sub-TLV "Metric Type" defined in [I-D.ietf-idr-bgp-ls-sr-policy], and
        can re-use the IANA registry of it. </t>

	  <t><figure suppress-title="false"
            title="Metric Type Code Point">
            <artwork align="center"> 
           +------------+------------------------------------------+
           | Code Point |         Metric Type                      |
           +------------+------------------------------------------+
           |     0      | IGP Metric                               |
           |     1      | Min Unidirectional Link Delay [RFC7471]  |
           |     2      | TE Metric [RFC3630]                      |
           |     3      | Hop Count (refer [RFC5440])              |
           |     4      | SID List Length                          |
           |    5-250   | Unassigned                               |
           |  251-255   | Private Use (not to be assigned by IANA) |	   	   
           +------------+------------------------------------------+
</artwork>
          </figure></t>		   

        <t>* Flags: None are defined at this stage. Flags SHOULD be set to
        zero on transmission and MUST be ignored on receipt.</t>

        <t>* Metric Value: 4-octet value which indicates the metric of the
        computed path. </t>
      </section>
    </section>

    <section title="Metric process of SR Policy segment list">
      <t>When SR Policy headend get the SR Policy segment list with metric,
      how to process the metric is local policy.</t>

      <t>The active candidate path of SR Policy may have several segment
      lists, each segment list may have different metric type and value. 
	  The candidate path can choose one metric type to use. If the
      metric value of the Segment Lists in the candidate path is different,
      the candidate path can use the maximum value as the metric of candidate
      path. And the SR Policy can use the metric type and metric value of the
      active candidate path.</t>
    </section>

    <section title="Acknowledgements">
      <t>TBD.</t>
    </section>

    <section anchor="IANA" title="IANA Considerations">
      <t>This document defines a new Sub-TLV in requests registries "SR Policy
      List Sub- TLVs" [I-D.ietf-idr-segment-routing-te-policy]:</t>

      <t><figure align="center" title="Metric sub-TLV">
          <artwork>
Value                  Description                  Reference
---------------------- ---------------------------- --------------
TBD                    Metric                       This document
</artwork>
        </figure></t>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>These extensions to BGP SR Policy do not add any new security issues
      to the existing protocol.</t>
    </section>
  </middle>

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

      <?rfc include="reference.RFC.8174"?>

      <?rfc include='reference.I-D.ietf-pce-segment-routing-policy-cp'?>

      <?rfc include='reference.I-D.ietf-idr-segment-routing-te-policy'?>
	  
      <?rfc include='reference.I-D.ietf-idr-bgp-ls-sr-policy'?>	  
    </references>
  </back>
</rfc>
