<?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-template-07"
     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>
	    <author fullname="Qiangzhou Gao" initials="Q. " surname="Gao">
      <organization>Huawei</organization>

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

          <city>Beijing</city>

          <code>100095</code>

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

        <email>gaoqiangzhou@huawei.com</email>
      </address>
    </author>	
    <date day="5" month="February" year="2026"/>

    <abstract>
      <t>Segment Routing(SR) Policies can be advertised using BGP. An SR
      Policy may has lots of attributes, and as the application and features
      evolve, the SR Policy may need have more and more attribute attributes.
      To avoid modifying BGP when attributes 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 attributes of SR Policy path. These
      attributes are valid only on the device where the SR Policy path is
      installed. Such attributes may include backup protection, Bidirectional
      Forwarding Detection information, traffic statistics collection, or
      in-situ Flow Information Telemetry detection information, etc. If these
      attributes are directly delivered through BGP, the BGP SR Policy
      protocol may change frequently. This document defines a general method
      to carry the path attributes 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 attributes sets.</t>

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

    <section title="Template ID defination">
      <t>To support the attributes 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 attributes 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 attributes to the SR Policy based on the
      attributes defined in the template.</t>
	  
	  <t>Template ID is an local identifier, just to use on the headend of the SR Policy.
	  And it is a local configured identifier, need to be unique only on the headend device.
	  We need no further process to coordinate the template ID between multiple routers.	  
	  </t>
	  
	  <t>A template represents a configuration plan intent. In a network managed by a
	  controller, the template can be configured by controller and template ID is specified
	  during the configuration. Therefore, the template ID is planned on the entire
	  network. All policies can use the same template as long as they require the same
	  configuration attributes, regardless of whether they are on the same device.</t>
	  
	  <t>For example, a policy has two candidate paths with preference 200 and 100. The path 
	  with preference 200 has a higher preference and is used as the primary path. The BFD 
	  detection time is 10 ms x 3. The candidate path with preference 100 is used as the
	  backup path, uses BFD detection, and the BFD detection time is 50 ms x 3. Then 
	  we can define two templates:</t>	   
	  
<figure suppress-title="false">
            <artwork align="left"> 	  
    Template 1:
        Hotstandby backup Enable
        BFD Seamless Enable
        BFD min-tx-interval 10
        BFD detect-multiplier 3

    Template 2:
        BFD Seamless Enable
        BFD min-tx-interval 50
        BFD detect-multiplier 3

    CP1&lt;E1, C1&gt;:
        &lt;preference = 200,
         SL(Weight=W1): &lt;S1, S2, S3&gt;,
         SL(Weight=W2): &lt;S4, S5, S6&gt;,
         TemplateID = 1&gt;

    CP2&lt;E1, C1&gt;:
        &lt;preference = 100,
        SL(Weight=W1): &lt;S7, S8, S9&gt;,
        SL(Weight=W2): &lt;S10, S11, S12&gt;,
        TemplateID = 2&gt;
</artwork>
          </figure> 
     <t>We can see that the template defines some common attributes and can be 
	 used by different SR Policies.</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)
        Template 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   |N|   RESERVED   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|                   Template ID(4 octets)                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
//                  Template Name (optional)                  //
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
</artwork>
          </figure></t>

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

        <t>Length: 6.</t>

        <t>Flags: 1 octet of flags.</t>

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

        N-Flag: This flag, when set, indicates the presence of the Template 
        Name encoding.
</artwork>
          </figure>

        <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>
		
        <t>Template Name: Template MAY also be assigned with a template name,
		such template name MUST NOT be considered as identifiers for a template.
		The size of the tempalte name for the template is limited to 255 bytes. </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 attributes required by the candidate paths of
        the SR Policy.</t>
        <t>Reflectors just need to advertise the route of SR, no need to process it. 
		</t>		
      </section>

      <section title="Reception of an SR Policy">
        <t>SR Policy is only to be processed on the SR Policy headend,
		reflectors just need to reflect the route of SR Policy, no need to process it. 
		To make this possible, an attribute needs to be attached to the advertisement 
		that enables a BGP speaker to determine whether it is intended to be a headend 
		for the advertised policy. This is done by attaching one or more Route Target 
		Extended Communities to the advertisement <xref target="RFC4360"/>. This process
		is defined in <xref target="I-D.ietf-idr-segment-routing-te-policy"/>. 
		This draft does not add any extra process in this process.</t>
		
		<t>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. The SRPM find the local configured 
		template by template ID, and get all the attributes that is configured in the template, 
		and then process the candidate path with these attributes. For example, if the template
		configure seamless bfd, then the SRPM can create sbfd sessions for each Segment List 
		in 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.4360"?>
	  
      <?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>
