<?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="info" docName="draft-zhang-idr-sr-policy-template-01"
     ipr="trust200902">
  <front>
    <title abbrev="BGP SR Policy Extensions for template">BGP SR Policy
    Extensions for template</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="Zhibo Hu" initials="Z. " surname="Hu">
      <organization>Huawei</organization>

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

          <city>Beijing</city>

          <code>100095</code>

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

        <email>huzhibo@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>jie.dong@huawei.com</email>
      </address>
    </author>
    <date day="28" month="April" year="2022"/>

    <abstract>
      <t>Segment Routing(SR) Policies can be advertised using BGP. An SR
      Policy may has lots of constraints, and as the application and features
      evolve, the SR Policy may need have more and more attribute constraints.
      To avoid modifying BGP when constraints are added to an SR Policy, we
      can define a template. The identifier and content of the template are
      defined by the receiver of the SR Policy. The advertiser of an SR policy
      only needs to know the ID of the template. When advertising SR policy,
      the advertiser carries the template ID in the tunnel encapsulation
      information of the SR policy. After receiving the SR Policy information,
      the receiver obtains the corresponding template and content according to
      the template ID, thereby obtaining abundant constraint configuration
      information.</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 some
      attributes encoding of the SR Policy path. However, in actual
      applications, there are many other constraints of SR Policy path. These
      constraints are valid only on the device where the SR Policy path is
      installed. Such constraints may include backup protection, Bidirectional
      Forwarding Detection information, traffic statistics collection, or
      in-situ Flow Information Telemetry detection information, etc. If these
      constraints are directly delivered through BGP, the BGP SR Policy
      protocol may change frequently. This document defines a general method
      to carry the path constraints of SR Policies.</t>
    </section>

    <section title="Terminology">
      <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 extensions like Path Computation Element (PCE)
      Communication Protocol (PCEP) <xref target="RFC8664"/> <xref
      target="I-D.ietf-pce-segment-routing-policy-cp"/> or BGP SR Policy <xref
      target="I-D.ietf-idr-segment-routing-te-policy"/>.</t>

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

      <t>Template: A collection of constraints sets.</t>

      <t>Template ID: The identifier of a template.</t>
    </section>

    <section title="Template ID defination">
      <t>To support the constraints extension of SR Policies, this document
      defines a constraint template identifier. The constraint template ID is
      valid only for the recipient. The SR policy publisher only needs to
      carry the template ID when publishing the SR policy. The receiver of the
      SR Policy may create a template corresponding to the template identifier
      in advance before receiving the SR Policy, or may define a corresponding
      template after receiving the template definition of the SR Policy. The
      template can contain any constraints on the SR Policy path, including
      but not limited to backup protection, Bidirectional Forwarding Detection
      information, traffic statistics collection, or in-situ Flow Information
      Telemetry detection information, etc. After receiving the SR Policy
      information, the receiver matches the template information based on the
      template ID and adds constraints to the SR Policy based on the
      constraints defined in the template.</t>
    </section>

    <section title="SR Policy and Tunnel Encapsulation Attribute Update">
      <t>As the template ID 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)
        Tempate ID 
        Segment List
           Weight
           Segment
           Segment
           ....
        ....		
</artwork>
          </figure>
	  
      <t>Where Tempate ID indicates the template ID for the SR Policy
      candidate path.</t>

      <section title="Template ID sub-TLV">
        <t>A new sub-TLV called Template ID sub-TLV is defined. Template ID
        sub-TLV specifies the template ID of an SR policy candidate path. Each
        sub-TLV is encoded as shown in Figure 1.</t>

        <t><figure suppress-title="false"
            title="Figure 1: Template ID 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     |     Flags     |   RESERVED   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|                   Template ID(4 octets)                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
</artwork>
          </figure></t>

        <t>Type: Template ID, 1 octet, TBD.</t>

        <t>Length: 6.</t>

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

        <t>RESERVED: 1 octet of reserved bits. SHOULD be set to zero on
        transmission and MUST be ignored on receipt.</t>

        <t>Template ID: a 4-octet value.</t>
      </section>
    </section>

    <section title="SR Policy Operations">
      <section title="Advertisement of SR Policies">
        <t>When BGP advertises an SR Policy, different candidate paths of the
        same SR Policy may have different template IDs or the same template
        ID, depending on the constraints required by the candidate paths of
        the SR Policy.</t>
      </section>

      <section title="Reception of an SR Policy">
        <t>When a BGP speaker receives an SR Policy NLRI from a neighbor, BGP
        Speaker determines determine if it's acceptable as described in <xref
        target="I-D.ietf-idr-segment-routing-te-policy"/>. Once BGP on the
        receiving node has determined that the SR Policy NLRI is usable, it
        passes the SR Policy candidate path to the SRPM. The SRPM then
        determine how to use the template ID in SR Policy.</t>

        <t>The SRPM should find the template by template ID, and determines
        the constraints to use when install the candidate path. If there is no
        template find, the SRPM should ignore the template ID and use the
        candidate path as there is no template ID.</t>
      </section>
    </section>

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

    <section anchor="IANA" title="IANA Considerations">
      <t>This document requests that IANA allocates a new sub-TLV type as
      defined in Section 4.1 from the "Sub-TLVs for SR Policy" registry as
      specified.</t>

      <t><figure align="center" title="Figure 2: Template ID sub-TLV">
          <artwork>Value                  Description                  Reference
---------------------- ---------------------------- --------------
TBD                    SR Policy Template ID        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.RFC.8664'?>

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

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