BGP SR Policy Extensions for template
Ka Zhang
Huawei
Huawei Bld., No.156 Beiqing Rd.
Beijing
100095
China
zhangka@huawei.com
Zhibo Hu
Huawei
Huawei Bld., No.156 Beiqing Rd.
Beijing
100095
China
huzhibo@huawei.com
Jie Dong
Huawei
Huawei Bld., No.156 Beiqing Rd.
Beijing
100095
China
jie.dong@huawei.com
28 April 2022
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.

Requirements Language
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 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

Introduction
[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.

Terminology
SR Policy: An ordered list of segments.
Candidate Path: the unit for signaling of an SR Policy to a headend via protocol extensions like Path Computation Element (PCE) Communication Protocol (PCEP) [RFC8664] [I-D.ietf-pce-segment-routing-policy-cp] or BGP SR Policy [I-D.ietf-idr-segment-routing-te-policy].
SRPM: SR Policy Module.
Template: A collection of constraints sets.
Template ID: The identifier of a template.

Template ID defination
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.

SR Policy and Tunnel Encapsulation Attribute Update
As the template ID is defined, the tunnel attribute encapsulation of the BGP SR Policy needs to be updated.
The SR Policy Encoding structure is as follows:
SR Policy SAFI NLRI: <Distinguisher, Policy-Color, Endpoint>

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
           ....
        ....

Where Tempate ID indicates the template ID for the SR Policy candidate path.

Template ID sub-TLV
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.

Figure 1: Template ID Sub-TLV

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)                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

Type: Template ID, 1 octet, TBD.
Length: 6.
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.
RESERVED: 1 octet of reserved bits. SHOULD be set to zero on transmission and MUST be ignored on receipt.
Template ID: a 4-octet value.

SR Policy Operations

Advertisement of SR Policies
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.

Reception of an SR Policy
When a BGP speaker receives an SR Policy NLRI from a neighbor, BGP Speaker determines determine if it's acceptable as described in [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.
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.

Acknowledgements
TBD.

IANA Considerations
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.

Figure 2: Template ID sub-TLV
Value                  Description                  Reference
---------------------- ---------------------------- --------------
TBD                    SR Policy Template ID        This document

Security Considerations
These extensions to BGP SR Policy do not add any new security issues to the existing protocol.

References
[RFC2119]
[RFC8174]
[I-D.ietf-idr-segment-routing-te-policy]
[RFC8664]
[I-D.ietf-pce-segment-routing-policy-cp]