<?xml version="1.0" encoding="iso-8859-1"?>
<!--
     vim: set softtabstop=2 shiftwidth=2 expandtab
     version=20150108
-->
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc strict="no" ?>
<?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"?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC4271 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4271.xml">
<!ENTITY RFC4364 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4364.xml">
<!ENTITY RFC4760 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4760.xml">
<!ENTITY RFC5226 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5226.xml">
<!ENTITY RFC6790 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6790.xml">
<!ENTITY RFC7498 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7498.xml">
<!ENTITY RFC7510 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7510.xml">
<!ENTITY RFC7665 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7665.xml">
]>

<rfc category="std" docName="draft-mackie-bess-nsh-bgp-control-plane-01" ipr="trust200902">
  <front>
    <title abbrev="BGP for NSH SFC">BGP Control Plane for NSH SFC</title>

    <author fullname="Adrian Farrel" initials="A." surname="Farrel">
      <organization>Juniper Networks</organization>
      <address>
        <email>adrian@olddog.co.uk</email>
      </address>
    </author>

    <author fullname="John Drake" initials="J." surname="Drake">
      <organization>Juniper Networks</organization>
      <address>
        <email>jdrake@juniper.net</email>
      </address>
    </author>

    <author fullname="Eric Rosen" initials="E." surname="Rosen">
      <organization>Juniper Networks</organization>
      <address>
        <email>erosen@juniper.net</email>
      </address>
    </author>

    <author fullname="Jim Uttaro" initials="J." surname="Uttaro">
      <organization>AT&amp;T</organization>
      <address>
        <email>ju1738@att.com</email>
      </address>
    </author>

    <author fullname="Luay Jalil" initials="L" surname="Jalil">
      <organization>Verizon</organization>
      <address>
        <email>luay.jalil@verizon.com</email>
      </address>
    </author>

    <date year="2016" />
    <area>Routing</area>
    <workgroup>BESS Working Group</workgroup>
    <keyword>Service Function Chaining</keyword>
    <keyword>Service Function Chain</keyword>
    <keyword>Network Service Header</keyword>
    <keyword>Service Function</keyword>
    <keyword>Service Function Forwarder</keyword>
    <keyword>Service Function Path</keyword>
    <keyword>Service Function Path Route</keyword>
    <keyword>Service Function Instance</keyword>
    <keyword>Service Function Instance Route</keyword>
    <keyword>Service Function Type</keyword>
    <keyword>Control Plane</keyword>

    <abstract>

      <t>This document describes the use of BGP as a control plane for networks that support
         Service Function Chaining (SFC).  The document introduces a new BGP address family
         called the SFC AFI/SAFI with two route types.  One route type is originated by a
         node to advertise that it hosts a particular instance of a specified service function.
         This route type also provides "instructions" on how to send a packet to the hosting
         node in a way that indicates that the service function has to be applied to the packet.
         The other route type is used by a Controller to advertise the paths of "chains" of
         service functions, and to give a unique designator to each such path so that they can
         be used in conjunction with the Network Service Header.</t>

      <t>This document adopts the SFC architecture described in RFC 7665.</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"/>.</t>
    </note>
</front>

<middle>

  <!-- === Introduction === -->
  <section anchor="introduction" title="Introduction">

    <t>As described in <xref target="RFC7498" />, the delivery of end-to-end services can
       require a packet to pass through a series of Service Functions (SFs) (e.g., classifiers,
       firewalls, TCP accelerators, and server load balancers) in a specified order: this is
       termed "Service Function Chaining" (SFC).  There are a number of issues associated with
       deploying and maintaining service function chaining in production networks, which are
       described below.</t>

    <t>Conventionally, if a packet needs to travel through a particular service chain, the
       nodes hosting the service functions of that chain are placed in the network topology
       in such a way that the packet cannot reach its ultimate destination without first
       passing through all the service functions in the proper order.  This need to place the
       service functions at particular topological locations limits the ability to adapt a
       service function chain to changes in network topology (e.g., link or node failures),
       network utilization, or offered service load.  These topological restrictions on where
       the service functions can be placed raise the following issues:

       <list style="numbers">
         <t>The process of configuring or modifying a service function chain is operationally
            complex and may require changes to the network topology.</t>

         <t>Alternate or redundant service functions may need to be co-located with the
            primary service functions.</t>

         <t>When there is more than one path between source and destination, forwarding may be
            asymmetric and it may be difficult to support bidirectional service function chains
            using simple routing methodologies and protocols without adding mechanisms for traffic
            steering or traffic engineering.</t>
       </list></t>

    <t>In order to address these issues, the SFC architecture includes Service Function Chains
       that are built in their own overlay network (the service function overlay network),
       coexisting with other overlay networks, over a common underlay network
       <xref target="RFC7665" />.  A Service Function Chain is a sequence of Service Functions
       through which packet flows satisfying specified criteria will pass.</t>

    <t>This document describes the use of BGP as a control plane for networks that support
       Service Function Chaining (SFC).  The document introduces a new BGP address family
       called the SFC AFI/SAFI with two route types.  One route type is originated by a
       node to advertise that it hosts a particular instance of a specified service function.
       This route type also provides "instructions" on how to send a packet to the hosting
       node in a way that indicates that the service function has to be applied to the packet.
       The other route type is used by a Controller to advertise the paths of "chains" of
       service functions, and to give a unique designator to each such path so that they can
       be used in conjunction with the Network Service Header.</t>

    <t>This document adopts the SFC architecture described in <xref target="RFC7665"/>.</t>

    <section anchor="terms" title="Terminology">
       <t>This document uses the following terms from <xref target="RFC7665"/>:
          <list style="symbols">
             <t>Bidirectional Service Function Chain</t>
             <t>Classifier</t>
             <t>Service Function (SF)</t>
             <t>Service Function Chain (SFC)</t>
             <t>Service Function Forwarder (SFF)</t>
             <t>Service Function Instance (SFI)</t>
             <t>Service Function Path (SFP)</t>
             <t>SFC branching</t>
          </list></t>

       <t>Additionally, this document uses the following terms from <xref target="I-D.ietf-sfc-nsh"/>:
          <list style="symbols">
             <t>Network Service Header (NSH)</t>
             <t>Service Index (SI)</t>
             <t>Service Path Identifier (SPI)</t>
          </list></t>

       <t>This document introduces the following terms:
          <list style="symbols">
             <t>Service Function Instance Route (SFIR)</t>
             <t>Service Function Overlay Network</t>
             <t>Service Function Path Route (SFPR)</t>
             <t>Service Function Type (SFT)</t>
          </list></t>

    </section>

  </section>

  <section anchor="overview" title="Overview">

    <section anchor="funcover" title="Functional Overview">

      <t>In <xref target="I-D.ietf-sfc-nsh"/> a Service Function Chain (SFC) is an ordered list of
         Service Functions (SFs).  A Service Function Path (SFP) is an indication of which instances
         of SFs are acceptable to be traversed in an instantiation of an SFC in a service function
         overlay network.  The Service Path Identifier (SPI) is a 24-bit number that identifies
         a specific SFP, and a Service Index (SI) is an 8-bit number that identifies a specific point
         in that path.  In the context of a particular SFP (identified by an SPI), an SI represents a
         particular Service Function, and indicates the order of that SF in the SFP.</t>

      <t>In fact, each SI is mapped to one or more SFs that are implemented by one or more Service
         Function Instances (SFIs) that support those specified SFs.  Thus an SI may represent a choice
         of SFIs of one or more Service Function Types.  By deploying multiple SFIs for a single SF, one
         can provide load balancing and redundancy.</t>

      <t>A special Service Function, called a Classifier, is located at each ingress point to a service
         function overlay network.  It assigns the packets of a given packet flow to a specific Service
         Function Path.  This may be done by comparing specific fields in a packet&apos;s header with
         local policy, which may be customer/network/service specific.  The classifier picks an SFP and
         sets the SPI accordingly it then sets the SI to the value of the SI for the first hop in the
         SFP and then prepending a Network Services Header (NSH) <xref target="I-D.ietf-sfc-nsh" />,
         to that packet containing the assigned SPI/SI.  Note that the Classifier and the node that
         hosts the first Service Function in a Service Function Path need not be located at the same
         point in the service function overlay network.</t>

      <t>Note that the presence of the NSH can make it difficult for nodes in the underlay network
         to locate the fields in the original packet that would normally be used to constrain equal
         cost multipath (ECMP) forwarding.  Therefore, it is recommended, as described in
         <xref target="entropy" />, that the node prepending the NSH also provide some form of entropy
         indicator that can be used in the underlay network.</t>

      <t>The Service Function Forwarder (SFF) receives a packet from the previous node in a Service
         Function Path, removes the packet&apos;s link layer or tunnel encapsulation and hands the
         packet and the NSH to the Service Function Instance for processing.</t>

      <t>When the SFF receives the packet and the NSH back from the SFI it must select the next SFI
         along the path using the SPI and SI in the NSH and potentially choosing between multiple SFIs
         (possibly of different Service Function Types) as described in <xref target="selection" />.  In
         the normal case the SPI remains unchanged and the SI will have been decremented to indicate the
         next SF along the path.  But other possibilities exist if the SF makes other changes to the NSH
         through a process of re-classification:
         <list style="symbols">
            <t>The SI in the NSH may indicate:
               <list style="symbols">
                  <t>A previous SF in the path: known as "looping" (see <xref target="looping"/>).</t>
                  <t>An SF further down the path: known as "jumping" (see also <xref target="looping"/>).</t>
               </list></t>
            <t>The SPI and the SI may point to an SF on a different SFP: known as "branching" (see also
               <xref target="looping"/>).</t>
         </list></t>

      <t>Such modifications are limited to within the same service function overlay network.  That is, an
         SPI is known within the scope of service function overlay network.  Furthermore, the new SI value
         is interpreted in the context of the SFP identified by the SPI, and SI values that do not form part
         of the definition of the path are invalid.</t>

      <t>An unknown or invalid SPI/SI combination SHALL be treated as an error and the SFF MUST drop the
         packet.  Such errors SHOULD be logged, and such logs MUST be subject to rate limits.  See
         <xref target="I-D.ietf-sfc-nsh"/> for more details of handling this situation in received NSH
         packets.</t>

      <t>The SFF then selects an SFI that provides the SF denoted by the SPI/SI, and forwards the packet
         to the SFF that supports that SFI.</t>

    </section>

    <section anchor="ctrlover" title="Control Plane Overview">

      <t>To accomplish the function described in <xref target="funcover" />, this document introduces a new
         BGP AFI/SAFI [values to be assigned by IANA] for "SFC Routes".  Two SFC Route Types are defined by
         this document: the Service Function Instance Route (SFIR), and the Service Function Path Route
         (SFPR).  As detailed in <xref target="sfcBGPRoutes" />, the route type is indicated by a sub-field
         in the NLRI.

         <list style="symbols">

            <t>The SFIR is advertised by the node hosting the service function instance.  The SFIR describes
               a particular instance of a particular Service Function and the way to forward a packet to it
               through the underlay network, i.e., IP address and encapsulation information.</t>

            <t>The SFPRs are originated by Controllers.  One SFPR is originated for each Service
               Function Path.  The SFPR specifies:
               <list style="letters">
                  <t>the SPI of the path</t>
                  <t>the sequence of SFTs and/or SFIs of which the path consists</t>
                  <t>for each such SFT or SFI, the SI that represents it in the identified path.</t>
               </list></t>

         </list></t>

      <t>This approach assumes that there is an underlay network that provides connectivity between
         SFFs and Controllers, and that the SFFs are grouped to form one or more service function
         overlay networks through which SFPs are built.  We assume BGP connectivity between the
         Controllers and all SFFs within each service function overlay network.</t>

      <t>In addition, we also introduce the Service Function Type (SFT) that is the category of SF
         that is supported by an SFF (such as "firewall").  An IANA registry of Service Function Types
         is introduced in <xref target="iana" />.  An SFF may support SFs of multiple different SFTs,
         and may support multiple SFIs of each SF.</t>

      <t>When choosing the next SFI in a path, the SFF uses the SPI and SI as well as the SFT to choose
         among the SFIs, applying, for example, a load balancing algorithm or direct knowledge of the
         underlay network topology as described in <xref target="mode" />.</t>

      <t>The SFF then encapsulates the packet using the encapsulation specified by the SFIR of the
         selected SFI and forwards the packet.  See <xref target="SFCarch" />.</t>

      <t>Thus the SFF can be seen as a portal in the underlay network through which a particular SFI
         is reached.</t>

      <figure anchor="SFCarch" title="The SFC Architecture Reference Model">
        <artwork>
          <![CDATA[
   Packets
    | | |
    | | |
    | | |
 ------------
|            |
| Classifier |
|            |
 ------------
       |
       |
    -------               -------
   |       |    Tunnel   |       |
   |  SFF  |=============|  SFF  |===========     .........
   |       |             |       |           #   : SFT     :
   |       |              -+---+-            #   :  -----  :
   |       |              /     \            #   : | SFI | :
   |       |       ....../.......\......     #   :  --+--  :
   |       |      :     /         \     :    #    ....|....
   |       |      :   -+---     ---+-   :    #        |
   |       |      :  | SFI |   | SFI |  :    #     ---+---
   |       |      :   -----     -----   :     ====|       |---
   |       |      :                     :         |  SFF  |--- Dests
   |       |      :        -----        :     ====|       |---
   |       |      :       | SFI |       :    #     -------
   |       |      :        --+--        :    #
   |       |      : SFT      |          :    #
   |       |       ..........|..........     #
   |       |                 |               #
   |       |                 |               #
   |       |              ---+---            #
   |       |             |       |           #
   |       |=============|  SFF  |===========
    -------              |       |
                          -------
          ]]>
        </artwork>
      </figure>
    </section>

  </section>

  <section anchor="sfcBGPRoutes" title="BGP SFC Routes">

    <t>This document defines a new AFI/SAFI for BGP, known as "SFC", with an NLRI that is described
       in this section.</t>

    <t>The format of the SFC NLRI is shown in <xref target="SFCnlriFig" />.</t>

    <figure anchor="SFCnlriFig" title="The Format of the SFC NLRI">
      <artwork>
        <![CDATA[
                 +---------------------------------------+
                 |  Route Type (2 octets)                |
                 +---------------------------------------+
                 |  Length (2 octets)                    |
                 +---------------------------------------+
                 |  Route Type specific (variable)       |
                 +---------------------------------------+
        ]]>
      </artwork>
    </figure>

    <t>The Route Type field determines the encoding of the rest of the route type specific SFC NLRI.</t>

    <t>The Length field indicates the length in octets of the route type specific field of the SFC
       NLRI.</t>

    <t>This document defines the following Route Types:
       <list style="numbers">
         <t>Service Function Instance Route (SFIR)</t>
         <t>Service Function Path Route (SFPR)</t>
       </list></t>

    <t>A Service Function Instance Route (SFIR) is used to identify an SFI.  A Service Function Path Route
       (SFPR) defines a sequence of Service Functions (each of which has at least one instance advertised in
       an SFIR) that form an SFP.</t>

    <t>The detailed encoding and procedures for these Route Types are described in subsequent sections.</t>

    <t>The SFC NLRI is carried in BGP <xref target="RFC4271" /> using BGP Multiprotocol Extensions
       <xref target="RFC4760" /> with an Address Family Identifier (AFI) of TBD1 and a Subsequent Address
       Family Identifier (SAFI) of TBD2.  The NLRI field in the MP_REACH_NLRI/MP_UNREACH_NLRI attribute
       contains the SFC NLRI, encoded as specified above.</t>

    <t>In order for two BGP speakers to exchange SFC NLRIs, they must use BGP Capabilities Advertisements
       to ensure that they both are capable of properly processing such NLRIs.  This is done as specified
       in <xref target="RFC4760" />, by using capability code 1 (Multiprotocol BGP) with an AFI of TBD1 and
       a SAFI of TBD2.</t>

    <section anchor="sfiRoutes" title="Service Function Instance Route (SFIR)">

       <t><xref target="sfiRouteFig" /> shows the Route Type specific NLRI of the SFIR.</t>

       <figure anchor="sfiRouteFig" title="SFIR Route Type specific NLRI">
         <artwork>
           <![CDATA[
                 +--------------------------------------------+
                 |  Route Distinguisher (RD) (8 octets)       |
                 +--------------------------------------------+
                 |  Service Function Type (2 octets)          |
                 +--------------------------------------------+
           ]]>
         </artwork>
       </figure>

       <t>Per <xref target="RFC4364" /> the RD field comprises a two byte Type field and a six byte
          Value field.  Two SFIs of the same SFT must be associated with different RDs, where the
          association of an SFI with an RD is determined by provisioning.  If two SFIRs are originated
          from different administrative domains, they must have different RDs.  In particular, SFIRs from
          different VPNs (for different service function overlay networks) must have different RDs, and
          those RDs must be different from any non-VPN SFIRs.</t>

       <t>The Service Function Type identifies a service function, e.g., classifier, firewall, load
          balancer, etc.  There may be several SFIs that can perform a given Service Function.  Each node
          hosting an SFI must originate an SFIR for each SFI that it hosts.  The SFIR representing a given
          SFI will contain an NLRI with RD field set to an RD as specified above, and with SFT field set to
          identify that SFI&apos;s Service Function Type.  The values for the SFT field are taken from a
          registry administered by IANA (see <xref target="iana" />).  A BGP Update containing one or more
          SFIRs will also include a Tunnel Encapsulation attribute <xref target="I-D.ietf-idr-tunnel-encaps" />.
          If a data packet needs to be sent to an SFI identified in one of the SFIRs, it will be encapsulated
          as specified by the Tunnel Encapsulation attribute, and then transmitted through the underlay
          network.</t>

    </section>

    <section anchor="sfpRoutes" title="Service Function Path Route (SFPR)">

       <t><xref target="sfpRouteFig" /> shows the Route Type specific NLRI of the SFPR.</t>

       <figure anchor="sfpRouteFig" title="SFPR Route Type Specific NLRI">
         <artwork>
           <![CDATA[
             +-----------------------------------------------+
             |  Route Distinguisher (RD) (8 octets)          |
             +-----------------------------------------------+
             |  Service Path Identifier (SPI) (3 octets)     |
             +-----------------------------------------------+
           ]]>
         </artwork>
       </figure>

       <t>Per <xref target="RFC4364" /> the RD field comprises a two byte Type field and a six byte
          Value field.  All SFPs must be associated with different RDs.  The association of an SFP with
          an RD is determined by provisioning.  If two SFPRs are originated from different Controllers they
          must have different RDs.  Additionally, SFPRs from different VPNs (i.e., in different service
          function overlay networks) must have different RDs, and those RDs must be different from any
          non-VPN SFPRs.</t>

       <t>The Service Path Identifier is defined in <xref target="I-D.ietf-sfc-nsh" /> and is the value
          to be placed in the Service Path Identifier field of the NSH header of any packet sent on this
          Service Function Path.  It is expected that one or more Controllers will originate
          these routes in order to configure a service function overlay network.</t>

       <t>The SFP is described in a new BGP Path attribute, the SFP attribute.  <xref target="sfpatt" />
          shows the format of that attribute.</t>

       <section anchor="sfpatt" title="The SFP Attribute">

          <t><xref target="RFC4271" /> defines the BGP Path attribute.  This document introduces a new
             Path attribute called the SFP attribute with value TBD3 to be assigned by IANA.  The
             first SFP attribute MUST be processed and subsequent instances MUST be ignored.</t>

          <t>The common fields of the SFP attribute are set as follows:
             <list style="symbols">
               <t>Optional bit is set to 1 to indicate that this is an optional attribute.</t>
               <t>The Transitive bit is set to 1 to indicate that this is a transitive attribute.</t>
               <t>The Extended Length bit is set according to the length of the SFP attribute as
                  defined in <xref target="RFC4271" />.</t>
               <t>The Attribute Type Code is set to TBD3.</t>
             </list></t>

          <t>The content of the SFP attribute is a series of Type-Length-Variable (TLV) constructs.
             Each TLV may include sub-TLVs.  All TLVs and sub-TLVs have a common format that is:
             <list style="symbols">
               <t>Type: A single octet indicating the type of the SFP attribute TLV.  Values are
                  taken from the registry described in <xref target="ianasftlv" />.</t>
               <t>Length: A two octet field indicating the length of the data following the Length
                  field counted in octets.</t>
               <t>Value: The contents of the TLV.</t>
             </list></t>

          <t>The formats of the TLVs defined in this document are shown in the following sections.
             The presence rules and meanings are as follows.
             <list style="symbols">
               <t>The SFP attribute contains a sequence of zero or more Association TLVs.  That is, the
                  Association TLV is optional.  Each Association TLV provides an association between this
                  SFPR and another SFPR.  Each associated SFPR is indicated using the RD with which it is
                  advertised (we say the SFPR-RD to avoid ambiguity).</t>

               <t>The SFP attribute contains a sequence of one or more Hop TLVs.  Each Hop TLV contains
                  all of the information about a single hop in the SFP.</t>

               <t>Each Hop TLV contains an SI value and a sequence of one or more SFT TLVs.  Each SFT
                  TLV contains an SFI reference for each instance of an SF that is allowed at this hop
                  of the SFP for the specific SFT.  Each SFI is indicated using the RD with which
                  it is advertised (we say the SFIR-RD to avoid ambiguity).</t>
             </list></t>

          <section anchor="assoctlv" title="The Association TLV">
             <t>The Association TLV is an optional TLV in the SFP attribute.  It may be present
                multiple times.  Each occurrence provides an association with another SFP as
                advertised in another SFPR.  The format of the Association TLV is shown in
                <xref target="assoctlvfig" /></t>

             <figure anchor="assoctlvfig" title="The Format of the Association TLV">
               <artwork>
                 <![CDATA[
             +--------------------------------------------+
             |  Type = 1 (1 octet)                        |
             +--------------------------------------------|
             |  Length (2 octets)                         |
             +--------------------------------------------|
             |  Association Type (1 octet)                |
             +--------------------------------------------|
             |  Associated SFPR-RD (8 octets)             |
             +--------------------------------------------|
             |  Associated SPI (3 octets)                 |
             +--------------------------------------------+
                 ]]>
               </artwork>
             </figure>

             <t>The fields are as follows:
                <list style="emtpy" >
                  <t>Type is set to 1 to indicate an Association TLV.</t>
                  <t>Length indicates the length in octets of the Association Type and Associated
                     SFPR-RD fields.  The value of the Length field is 12.</t>
                  <t>The Association Type field indicate the type of association.  The values are
                     tracked in an IANA registry (see <xref target="ianaassoc" />).  Only one value
                     is defined in this document: type 1 indicates association of two unidirectional
                     SFPs to form a bidirectional SFP.  An SFP attribute SHOULD NOT contain more than
                     one Association TLV with Association Type 1: if more than one is present, the
                     first one MUST be processed and subsequent instances MUST be ignored.  Note that
                     documents that define new Association Types must also define the presence rules
                     for Association TLVs of the new type.</t>
                  <t>The Associated SFPR-RD contains the RD of some other SFPR advertisement that
                     contains the SFP with which this SFP is associated.</t>
                  <t>The Associated SPI contains the SPI of the associated SFP as advertised in the
                     SFPR indicated by the Associated SFPR-RD field.</t>
                </list></t>

             <t>Association TLVs with unknown Association Type values SHOULD be ignored.  Association TLVs
                that contain an Associated SFPR-RD value equal to the RD of the SFPR in which they are
                contained SHOULD be ignored.  If the Associated SPI is not equal to the SPI advertised in
                the SFPR indicated by the Associated SFPR-RD then the Association TLV SHOULD be ignored.</t>

             <t>Note that when two SFPRs reference each other using the Association TLV, one SFPR advertisement
                will be received before the other.  Therefore, processing of an association MUST NOT be
                rejected simply because the Associated SFPR-RD is unknown.</t>

             <t>Further discussion of correlation of SFPRs is provided in <xref target="correlation" />.</t>

          </section>

          <section anchor="hoptlv" title="The Hop TLV">
             <t>There is one Hop TLV in the SFP attribute for each hop in the SFP.  The format of
                the Hop TLV is shown in <xref target="hoptlvfig" />.  At least one Hop TLV must be
                present in an SFP attribute.</t>

             <figure anchor="hoptlvfig" title="The Format of the Hop TLV">
               <artwork>
                 <![CDATA[
             +--------------------------------------------+
             |  Type = 2 (1 octet)                        |
             +--------------------------------------------|
             |  Length (2 octets)                         |
             +--------------------------------------------|
             |  Service Index (1 octet)                   |
             +--------------------------------------------|
             |  Hop Details (variable)                    |
             +--------------------------------------------+
                 ]]>
               </artwork>
             </figure>

             <t>The fields are as follows:
                <list style="emtpy" >
                  <t>Type is set to 2 to indicate a Hop TLV.</t>
                  <t>Length indicates the length in octets of the Service Index and Hop
                     Details fields.</t>
                  <t>The Service Index is defined in [I-D.ietf-sfc-nsh] and is the value found in the
                     Service Index field of the NSH header that an SFF will use to lookup to which next
                     SFI a packet should be sent.</t>
                  <t>The Hop Details consist of a sequence of one or more SFT TLVs.</t>
                </list></t>
          </section>

          <section anchor="sfttlv" title="The SFT TLV">

             <t>There is one or more SFT TLV in each Hop TLV.  There is one SFT TLV for each SFT supported
                in the specific hop of the SFP.  The format of the SFT TLV is shown in <xref target="sfttlvfig" />.</t>

             <figure anchor="sfttlvfig" title="The Format of the SFT TLV">
               <artwork>
                 <![CDATA[
             +--------------------------------------------+
             |  Type = 3 (1 octet)                        |
             +--------------------------------------------|
             |  Length (2 octets)                         |
             +--------------------------------------------|
             |  Service Function Type (2 octets)          |
             +--------------------------------------------|
             |  SFIR-RD List (variable)                   |
             +--------------------------------------------+
                 ]]>
               </artwork>
             </figure>

             <t>The fields are as follows:
                <list style="emtpy" >
                  <t>Type is set to 3 to indicate an SFT TLV.</t>
                  <t>Length indicates the length in octets of the Service Function Type and SFIR-RD List fields.</t>
                  <t>The Service Function Type is used to identify a Service Function Instance Route in the
                     service function overlay network which, in turn, will allow lookup of routes to SFIs
                     implementing the SF.  SFT values in the range 1-31 are Special Purpose SFT values and
                     have meanings defined by the documents that describe them - the value 'Change Sequence'
                     is defined in <xref target="changeseq" /> of this document.</t>
                  <t>The SFIR-RD List is made up of one or more SFIR-RD values from the advertisements of SFIs
                     in SFIRs.  An SFIR-RD of value zero has special meaning as described in <xref target="selection" />.
                     Each entry in the list is 8 octets long, and the number of entries in the list can be deduced
                     from the value of the Length field.</t>
                </list></t>

          </section>

       </section>

       <section anchor="sfparules" title="General Rules For The SFP Attribute">

          <t>It is possible for the same SFI, as described by an SFIR, to be used in multiple SFPRs.</t>

          <t>When two SFPRs have the same SPI but different SFPR-RDs there can be three cases:
             <list style="symbols">
                <t>Two or more Controllers are originating SFPRs for the same SFP.  In this case the
                   content of the SFPRs is identical and the duplication is to ensure receipt and
                   to provide Controller redundancy.</t>
                <t>There is a transition in content of the advertised SFP and the advertisements may
                   originate from one or more Controllers.  In this case the content of the SFPRs will be
                   different.</t>
                <t>The reuse of an SPI may result from a configuration error.</t>
             </list></t>

           <t>In all cases, there is no way for the receiving SFF to know which SFPR to process, and the
              SFPRs could be received in any order.  At any point in time, when multiple SFPRs have the
              same SPI but different SFPR-RDs, the SFF MUST use the SFPR with the numerically lowest
              SFPR-RD.  The SFF SHOULD log this occurrence to assist with debugging.</t>

           <t>Furthermore, a Controller that wants to change the content of an SFP is RECOMMENDED to use a
              new SPI and so create a new SFP onto which the Classifiers can transition packet flows before
              the SFPR for the old SFP is withdrawn.  This avoids any race conditions with SFPR advertisements.</t>

           <t>Additionally, a Controller SHOULD NOT re-use an SPI after it has withdrawn the SFPR that used it
              until at least a configurable amount of time has passed.  This timer SHOULD have a default of one
              hour.</t>

       </section>

    </section>

  </section>

  <section anchor="mode" title="Mode of Operation">

    <t>This document describes the use of BGP as a control plane to create and manage a service
       function overlay network.</t>

    <section anchor="rt" title="Route Targets">

       <t>The main feature introduced by this document is the ability to create multiple service
          function overlay networks through the use of Route Targets (RTs) <xref target="RFC4364" />.</t>

       <t>Every BGP UPDATE containing an SFIR or SFPR carries one or more RTs.  The RT carried by a particular
          SFIR or SFPR is determined by the provisioning of the route&apos;s originator.</t>

       <t>Every node in a service function overlay network is configured with one or more import RTs.
          Thus, each SFF will import only the SFPRs with matching RTs allowing the construction of
          multiple service function overlay networks or the instantiation of Service Function Chains
          within an L3VPN or EVPN instance (see <xref target="private" />).  An SFF that has a presence
          in multiple service function overlay networks (i.e., imports more than one RT) may find it
          helpful to maintain separate forwarding state for each overlay network.</t>

    </section>

    <section anchor="SFIR" title="Service Function Instance Routes">

       <t>The SFIR (see <xref target="sfiRoutes" />) is used to advertise the existence and location
          of a specific Service Function Instance and consists of:

          <list style="symbols">

             <t>The RT as just described.</t>

             <t>A Service Function Type (SFT) that is the category of Service Function that is
                provided (such as "firewall").</t>

             <t>A Route Distinguisher (RD) that is unique to a specific instance of a service
                function.</t>

          </list></t>

    </section>

    <section anchor="SFPR" title="Service Function Path Routes">

       <t>The SFPR (see <xref target="sfpRoutes" />) describes a specific path of a Service Function Chain.
          The SFPR contains the Service Path Identifier (SPI) used to identify the SFP in the NSH
          in the data plane.  It also contains a sequence of Service Indexes (SIs).  Each SI
          identifies a hop in the SFP, and each hop is a choice between one of more SFIs.</t>

       <t>As described in this document, each Service Function Path Route is identified in the
          service function overlay network by an RD and an SPI.  The SPI is unique across all service
          function overlay networks supported by the underlay network.</t>

       <t>The SFPR advertisement comprises:
          <list style="symbols">
            <t>An RT as described in <xref target="rt" />.</t>

            <t>A tuple that identifies the SFPR
               <list style="symbols">
                  <t>An RD that identifies an advertisement of an SFPR.</t>
                  <t>The SPI that uniquely identifies this path within all service function overlay
                     networks supported by the underlay network.  This SPI also appears in the NSH.</t>
               </list></t>

            <t>A series of Service Indexes.  Each SI is used in the context of a particular SPI and
               identifies one or more SFs (distinguished by their SFTs) and for each SF a set of
               SFIs that instantiate the SF.  The values of the SI indicate the order in which the
               SFs are to be executed in the SFP that is represented by the SPI.</t>

            <t>The SI is used in the NSH to identify the entries in the SFP.  Note that the SI values
               have meaning only relative to a specific path.  They have no semantic other than to indicate
               the order of Service Functions within the path and are assumed to be monotonically
               decreasing from the start to the end of the path <xref target="I-D.ietf-sfc-nsh" />.</t>

            <t>Each Service Index is associated with a set of one or more Service Function Instances
               that can be used to provide the indexed Service Function within the path.  Each member of
               the set comprises:
               <list style="symbols">
                  <t>The RD used in an SFIR advertisement of the SFI.</t>
                  <t>The SFT that indicates the type of function as used in the same SFIR advertisement
                     of the SFI.</t>
               </list></t>
          </list></t>

       <t>This may be summarized as follows where the notations "SFPR-RD" and "SFIR-RD" are used
          to distinguish the two different RDs:
          <list style="empty">
            <t>RT, {SFPR-RD, SPI}, m * {SI, {n * {SFT, p * SFIR-RD} } }</t>
          </list></t>
       <t>Where:
          <list style="empty">
             <t>RT: Route Target</t>
             <t>SFPR-RD: The Route Descriptor of the Service Function Path Route advertisement</t>
             <t>SPI: Service Path Identifier used in the NSH</t>
             <t>m: The number of hops in the Service Function Path</t>
             <t>n: The number of choices of Service Function Type for a specific hop</t>
             <t>p: The number of choices of Service Function Instance for given Service Function Type in a specific hop</t>
             <t>SI: Service Index used in the NSH to indicate a specific hop</t>
             <t>SFT: The Service Function Type used in the same advertisement of the Service
                Function Instance Route</t>
             <t>SFIR-RD: The Route Descriptor used in an advertisement of the Service Function
                Instance Route</t>
          </list></t>

       <t>Note that the values of SI are from the set {255, ..., 1} and are monotonically decreasing
          within the SFP.  SIs MUST appear in order within the SFPR (i.e., monotonically decreasing)
          and MUST NOT appear more than once.  Malformed SFPRs MUST be discarded and MUST cause any
          previous instance of the SFPR (same SFPR-RD and SPI) to be discarded.</t>

       <t>The choice of SFI is explained further in <xref target="selection" />.  Note that an SFIR-RD
          value of zero has special meaning as described in that Section.</t>

    </section>

    <section anchor="classy" title="Classifier Operation">

        <t>As shown in <xref target="SFCarch" />, the Classifier is a special Service Function that
           is used to assign packets to an SFP.</t>

        <t>The Classifier is responsible for determining to which packet flow a packet belongs
           (usually by inspecting the packet header), imposing an NSH, and initializing the NSH to
           include the SPI of the selected SFPR and to include the SI from first hop of the selected
           SFP.</t>

        <t>The Classifier may also provide an entropy indicator as described in
           <xref target="entropy" />.</t>

    </section>

    <section anchor="SFF" title="Service Function Forwarder Operation">

       <t>Each packet sent to an SFF is transmitted encapsulated in an NSH.  The NSH includes an SPI
          and SI: the SPI indicates the SFPR advertisement that announced the Service Function Path;
          the tuple SPI/SI indicates a specific hop in a specific path and maps to the RD/SFT of a
          particular SFIR advertisement.</t>

       <t>When an SFF gets an SFPR advertisement it will first determine whether to import the route
          by examining the RT.  If the SFPR is imported the SFF then determines whether it is on the
          SFP by looking for its own SFIR-RDs in the SFPR.  For each occurrence in the SFP, the SFF
          creates forwarding state for incoming packets and forwarding state for outgoing packets that
          have been processed by the specified SFI.</t>

       <t>The SFF creates local forwarding state for packets that it receives from other SFFs.  This
          state makes the association between the SPI/SI in the NSH of the received packet and one or
          more specific local SFIs as identified by the SFIR-RD/SFT.  If there are multiple local SFIs
          that match this is because a single advertisement was made for a set of equivalent SFIs and
          the SFF may use local policy (such as load balancing) to determine to which SFI to forward a
          received packet.</t>

       <t>The SFF also creates next hop forwarding state for packets received back from the local SFI
          that need to be forwarded to the next hop in the SFP.  There may be a choice of next hops
          as described in <xref target="SFPR" />.  The SFF could install forwarding state for all
          potential next hops, or it could choose to only install forwarding state to a subset of the
          potential next hops.  If a choice is made then it will be as described in
          <xref target="selection" />.</t>

       <t>The installed forwarding state may change over time reacting to changes in the underlay network
          and the availability of particular SFIs.</t>

       <t>Note that SFFs only create and store forwarding state for the SFPs on which they are included.
          They do not retain state for all SFPs advertised.</t>

       <t>An SFF may also install forwarding state to support looping, jumping, and branching.
          The protocol mechanism for explicit control of looping, jumping, and
          branching is described in <xref target="changeseq" /> using a special value of the SFT within
          an entry in an SFPR.</t>

    </section>

  </section>

  <section anchor="selection" title="Selection in Service Function Paths">

    <t>As described in <xref target="overview" /> the SPI/SI in the NSH passed back from an SFI to
       the SFF may leave the SFF with a choice of next hop SFTs, and a choice of SFIs for each SFT.
       That is, the SPI indicates an SFPR, and the SI indicates an entry in that SFPR.  Each entry in
       an SFPR is a set of one or more SFT/SFIR-RD pairs.  The SFF must choose one of these, identify
       the SFF that supports the chosen SFI, and send the packet to that next hop SFF.</t>

    <t>In the typical case, the SFF chooses a next hop SFF by looking at the set of all SFFs that
       support the SFs identified by the SI (that set having been advertised in individual SFIR
       advertisements), finding the one or more that are "nearest" in the underlay network, and
       choosing between next hop SFFs using its own load-balancing algorithm.</t>

    <t>An SFI may influence this choice process by passing additional information back along
       with the packet and NSH.  This information may influence local policy at the SFF to cause
       it to favor a next hop SFF (perhaps selecting one that is not nearest in the underlay), or
       to influence the load-balancing algorithm.</t>

    <t>This selection applies to the normal case, but also applies in the case of looping,
       jumping, and branching (see <xref target="looping" />).</t>

    <t>Suppose an SFF in a particular service overlay network (identified by a particular import
       RT, RT-z) needs to forward an NSH-encapsulated packet whose SPI is SPI-x and whose SI is SI-y.
       It does the following:

       <list style="numbers">

          <t>It looks for an installed SFPR that carries RT-z and that has SPI-x in its NLRI.
             If there is none, then such packets cannot be forwarded.</t>

          <t>From the SFP attribute of that SFPR, it finds the Hop TLV with SI value set to SI-y.
             If there is no such Hop TLV, then such packets cannot be forwarded.</t>

          <t>It then finds the "relevant" set of SFIRs by going through the list of of SFT TLVs
             contained in the Hop TLV as follows:
             <list style="letters">
                <t>An SFIR is relevant if it carries RT-z, the SFT in its NLRI matches
                   the SFT value in one of the SFT TLVs, and the RD value in its NLRI matches
                   an entry in the list of SFIR-RDs in that SFT TLV.</t>
                <t>If an entry in the SFIR-RD list of an SFT TLV contains the value zero, then
                    an SFIR is relevant if it carries RT-z and the SFT in its NLRI matches
                    the SFT value in that SFT TLV.  I.e., any SFIR in the service function
                    overlay network defined by RT-z and with the correct SFT is relevant.</t>
             </list></t>

       </list></t>

    <t>Each of the relevant SFIRs identifies a single SFI, and contains a Tunnel Encapsulation
       attribute that specifies how to send a packet to that SFI.  For a particular packet, the
       SFF chooses a particular SFI from the set of relevant SFIRs.  This choice is made according
       to local policy.</t>

    <t>A typical policy might be to figure out the set of SFIs that are closest, and to load balance
       among them.  But this is not the only possible policy.</t>

  </section>

  <section anchor="looping" title="Looping, Jumping, and Branching">

    <t>As described in <xref target="overview" /> an SFI or an SFF may cause a packets to
       "loop back" to a previous SF on a path in order that a sequence of functions may be
       re-executed.  This is simply achieved by replacing the SI in the NSH with a higher value
       instead of decreasing it as would normally be the case to determine the next hop in the
       path.</t>

    <t><xref target="overview" /> also describes how an SFI or an SFF may cause a packets to
       "jump forward" to an SF on a path that is not the immediate next SF in the SFP.  This
       is simply achieved by replacing the SI in the NSH with a lower value than would be
       achieved by decreasing it by the normal amount.</t>

    <t>A more complex option to move packets from one SFP to another is described in
       <xref target="I-D.ietf-sfc-nsh" /> and <xref target="overview" /> where it is termed
       "branching".  This mechanism allows an SFI or SFF to make a choice of downstream
       treatments for packets based on local policy and output of the local SF.  Branching is
       achieved by changing the SPI in the NSH to indicate the new path and setting the SI to
       indicate the point in the path at which the packets should enter.</t>

    <t>Note that the NSH does not include a marker to indicate whether a specific packet has
       been around a loop before.  Therefore, the use of NSH metadata may be required in order
       to prevent infinite loops.</t>

    <section anchor="changeseq" title="Protocol Control of Looping, Jumping, and Branching">

       <t>If the SFT value in an SFT TLV in an SFPR has the Special Purpose SFT value "Change
          Sequence" (see <xref target="iana" />) then this is an indication that the SFF may
          make a loop, jump, or branch according to local policy and information returned by
          the local SFI.</t>

       <t>In this case, the SPI and SI of the next hop is encoded in the eight bytes of an entry
          in the SFIR-RD list as follows:
          <list style="empty">
            <t>3 bytes SPI</t>
            <t>2 bytes SI</t>
            <t>3 bytes Reserved (SHOULD be set to zero and ignored)</t>
          </list></t>

       <t>If the SI in this encoding is not part of the SFPR indicated by the SPI in this
          encoding, then this is an explicit error that SHOULD be detected by the SFF when it
          parses the SFPR.  The SFPR SHOULD NOT cause any forwarding state to be installed in
          the SFF and packets received with the SPI that indicates this SFPR SHOULD be silently
          discarded.</t>

       <t>If the SPI in this encoding is unknown, the SFF SHOULD NOT install any forwarding state
          for this SFPR, but MAY hold the SFPR pending receipt of another SFPR that does use the
          encoded SPI.</t>

       <t>If the SPI matches the current SPI for the path, this is a loop or jump.  In this case,
          if the SI is greater than to the current SI it is a loop.  If the SPI matches and the SI
          is less than the next SI, it is a jump.</t>

       <t>If the SPI indicates anther path, this is a branch and the SI indicates the point at
          which to enter that path.</t>

       <t>The Change Sequence SFT is just another SFT that may appear in a set of SFI/SFT tuples
          within an SI and is selected as described in <xref target="selection" />.</t>

       <t>Note that Special Purpose SFTs MUST NOT be advertised in SFIRs.</t>

    </section>

    <section anchor="implications" title="Implications for Forwarding State">

       <t>Support for looping and jumping requires that the SFF has forwarding state established
          to an SFF that provides access to an instance of the appropriate SF.  This means
          that the SFF must have seen the relevant SFIR advertisements and known that it needed to
          create the forwarding state.  This is a matter of local configuration and implementation:
          for example, an implementation could be configured to install forwarding state for specific
          looping/jumping.</t>

       <t>Support for branching requires that the SFF has forwarding state established to an SFF that
          provides access to an instance of the appropriate entry SF on the other SFP.  This means
          that the SFF must have seen the relevant SFIR and SFPR advertisements and known that it
          needed to create the forwarding state.  This is a matter of local configuration and
          implementation: for example, an implementation could be configured to install forwarding
          state for specific branching (identified by SPI and SI).</t>

    </section>

  </section>

  <section anchor="advanced" title="Advanced Topics">

    <t>This section highlights several advanced topics introduced elsewhere in this document.</t>

    <section anchor="entropy" title="Preserving Entropy">

      <t>Forwarding decisions in the underlay network in the presence of equal cost multipath (ECMP)
         are usually made by inspecting key invariant fields in a packet header so that all packets
         from the same packet flow receive the same forwarding treatment.  However, when an NSH is
         included in a packet, those key fields may be inaccessible.  For example, the fields may be
         too far inside the packet for a forwarding engine to quickly find them and extract their
         values, or the node performing the examination may be unaware of the format and meaning of
         the NSH and so unable to parse far enough into the packet.</t>

      <t>Various mechanisms exist within forwarding technologies to include an "entropy indicator"
         within a forwarded packet.  For example, in MPLS there is the entropy label
         <xref target="RFC6790" />, while for encapsulations in UDP the source port field is often
         used to carry an entropy indicator (such as for MPLS in UDP <xref target="RFC7510" />).</t>

      <t>Implementations of this specification are RECOMMENDED to include an entropy indicator within
         the packet&apos;s underlay network header, and SHOULD preserve any entropy indicator from a
         received packet for use on the same packet when it is forwarded along the path but MAY
         choose to generate a new entropy indicator so long as the method used is constant for all
         packets.  Note that preserving per packet entropy may require that the entropy indicator is
         passed to and returned by the SFI to prevent the SFF from having to maintain per-packet
         state.</t>

    </section>

    <section anchor="correlation" title="Correlating Service Function Path Instances">

      <t>It is often useful to create bidirectional SFPs to enable packet flows to traverse the same
         set of SFs, but in the reverse order.  However, packets on SFPs in the data plane (per
         <xref target="I-D.ietf-sfc-nsh" />) do not contain a direction indicator, so each direction
         must use a different SPI.</t>

      <t>As described in <xref target="assoctlv" /> an SFPR can contain one or more correlators
         encoded in Association TLVs.  If the Association Type indicates "Bidirectional SFP" then
         the SFP advertised in the SFPR is one direction of a bidirectional pair of SFPs where the
         other in the pair is advertised in the SFPR with RD as carried in the Associated SFPR-RD
         field of the Association TLV.  The SPI carried in the Associated SPI field of the
         Association TLV provides a cross-check and should match the SPI advertised in the SFPR with
         RD as carried in the Associated SFPR-RD field of the Association TLV.</t>

      <t>As noted in <xref target="assoctlv" /> SFPRs reference each other one SFPR advertisement
         will be received before the other.  Therefore processing of an association will require
         that the first SFPR is not rejected simply because the Associated SFPR-RD it carries is
         unknown.  However, the SFP defined by the first SFPR is valid and SHOULD be available for
         use as a unidirectional SFP even in the absence of an advertisement of its partner.</t>

      <t>Furthermore, in error cases where SFPR-a associates with SFPR-b, but SFPR-b associates
         with SFPR-c such that a bidirectional pair of SFPs cannot be formed, the individual SFPs
         are still valid and SHOULD be available for use as unidirectional SFPs.  An implementation
         SHOULD log this situation because it represents a Controller error.</t>

      <t>Usage of a bidirectional SFP may be programmed into the Classifiers by the Controller.
         Alternatively, a Classifier may look at incoming packets on a bidirectional packet flow,
         extract the SPI from the received NSH, and look up the SFPR to find the reverse direction
         SFP to use when it sends packets.</t>

      <t>See <xref target="example" /> for an example of how this works.</t>

    </section>

    <section anchor="private" title="VPN Considerations and Private Service Functions">

      <t>Likely deployments include reserving specific instances of Service Functions for specific
         customers or allowing customers to deploy their own Service Functions within the network.
         Building Service Functions in such environments requires that suitable identifiers are used
         to ensure that SFFs distinguish which SFIs can be used and which cannot.</t>

      <t>This problem is similar to how VPNs are supported and is solved in a similar way.  The RT
         field is used to indicate a set of Service Functions from which all choices must be made.</t>

    </section>

  </section>

  <section anchor="example" title="Examples">

    <t>Assume we have a service function overlay network with four SFFs (SFF1, SFF3, SFF3, and SFF4).
       The SFFs have addresses in the underlay network as follows:</t>
       <figure>
         <artwork>
           <![CDATA[
   SFF1 192.0.2.1
   SFF2 192.0.2.2
   SFF3 192.0.2.3
   SFF4 192.0.2.4
           ]]>
         </artwork>
       </figure>

    <t>Each SFF provides access to some SFIs from the four Service Function Types SFT=41, SFT=42,
       SFT=43, and SFT=44 as follows:</t>
       <figure>
         <artwork>
           <![CDATA[
   SFF1 SFT=41 and SFT=42
   SFF2 SFT=41 and SFT=43
   SFF3 SFT=42 and SFT=44
   SFF4 SFT=43 and SFT=44
           ]]>
         </artwork>
       </figure>

    <t>The service function network also contains a Controller with address 198.51.100.1.</t>

    <t>This example service function overlay network is shown in <xref target="examplefig" />.</t>

       <figure anchor="examplefig" title="Example Service Function Overlay Network">
         <artwork>
           <![CDATA[
       --------------
      |  Controller  |
      | 198.51.100.1 |   ------     ------    ------     ------
       --------------   | SFI  |   | SFI  |  | SFI  |   | SFI  |
                        |SFT=41|   |SFT=42|  |SFT=41|   |SFT=43|
                         ------     ------    ------     ------
                              \     /              \     /
                             ---------            ---------
               ----------   |   SFF1  |          |   SFF2  |
   Packet --> |          |  |192.0.2.1|          |192.0.2.2|
   Flows  --> |Classifier|   ---------            ---------  -->Dest
              |          |                                   -->
               ----------    ---------            ---------
                            |   SFF3  |          |   SFF4  |
                            |192.0.2.3|          |192.0.2.4|
                             ---------            ---------
                              /     \              /     \
                         ------     ------    ------     ------
                        | SFI  |   | SFI  |  | SFI  |   | SFI  |
                        |SFT=42|   |SFT=44|  |SFT=43|   |SFT=44|
                         ------     ------    ------     ------
           ]]>
         </artwork>
       </figure>

    <t>The SFFs advertise routes to the SFIs they support.  So we see the following
       SFIRs:</t>

       <figure>
         <artwork>
           <![CDATA[
   RD = 192.0.2.1,1, SFT = 41
   RD = 192.0.2.1,2, SFT = 42
   RD = 192.0.2.2,1, SFT = 41
   RD = 192.0.2.2,2, SFT = 43
   RD = 192.0.2.3,7, SFT = 42
   RD = 192.0.2.3,8, SFT = 44
   RD = 192.0.2.4,5, SFT = 43
   RD = 192.0.2.4,6, SFT = 44
           ]]>
         </artwork>
       </figure>

    <t>Note that the addressing used for communicating between SFFs is taken
       from the Tunnel Encapsulation attribute of the SFIR and not from the SFIR-RD.</t>

    <section anchor="exampleexplicit" title="Example Explicit SFP With No Choices" >

       <t>Consider the following SFPR.</t>

       <figure>
         <artwork>
           <![CDATA[
   SFP1:  RD = 198.51.100.1,101, SPI = 15,
          [SI = 255, SFT = 41, RD = 192.0.2.1,1],
          [SI = 250, SFT = 43, RD = 192.0.2.2,2]
           ]]>
         </artwork>
       </figure>

       <t>The Service Function Path consists of an SF of type 41 located at SFF1 followed by an SF
          of type 43 located at SFF2.  This path is fully explicit and each SFF is
          offered no choice in forwarding packet along the path.</t>

       <t>SFF1 will receive packets on the path from the Classifier and will identify the path
          from the SPI (15).  The initial SI will be 255 and so SFF1 will deliver the packets to the
          SFI for SFT 41.</t>

        <t>When the packets are returned to SFF1 by the SFI the SI will be decreased to 250 for the next hop.
           SFF1 has no flexibility in the choice of SFF to support the next hop SFI and will forward
           the packet to SFF2 which will send the packets to the SFI that supports SFT 43 before
           forwarding the packets to their destinations.</t>

    </section>

    <section anchor="examplechoice" title="Example SFP With Choice of SFIs" >
       <figure>
         <artwork>
           <![CDATA[
   SFP2:  RD = 198.51.100.1,102, SPI = 16,
          [SI = 255, SFT = 41, RD = 192.0.2.1,],
          [SI = 250, SFT = 43, {RD = 192.0.2.2,2,
                                RD = 192.0.2.4,5 } ]
           ]]>
         </artwork>
       </figure>

       <t>In this example the path also consists of an SF of type 41 located at SFF1 and this is
          followed by an SF of type 43, but in this case the SI = 250 contains a choice between the
          SFI located at SFF2 and the SFI located at SFF4.</t>

       <t>SFF1 will receive packets on the path from the Classifier and will identify the path
          from the SPI (16).  The initial SI will be 255 and so SFF1 will deliver the packets to the
          SFI for SFT 41.</t>

        <t>When the packets are returned to SFF1 by the SFI the SI will be decreased to 250 for
           the next hop.  SFF1 now has a choice of next hop SFF to execute the next hop in the path.
           It can either forward packets to SFF2 or SFF4 to execute a function of type 43.  It uses
           its local load balancing algorithm to make this choice.  The chosen SFF will send the
           packets to the SFI that supports SFT 43 before forwarding the packets to their
           destinations.</t>

    </section>

    <section anchor="exampleopen" title="Example SFP With Open Choice of SFIs" >

       <figure>
         <artwork>
           <![CDATA[
   SFP3:  RD = 198.51.100.1,103, SPI = 17,
          [SI = 255, SFT = 41, RD = 192.0.2.1,1],
          [SI = 250, SFT = 44, RD = 0]
           ]]>
         </artwork>
       </figure>

       <t>In this example the path also consists of an SF of type 41 located at SFF1 and this is
          followed by an SI with an RD of zero and SF of type 44.  This means that a choice can be
          made between any SFF that supports an SFI of type 44.</t>

       <t>SFF1 will receive packets on the path from the Classifier and will identify the path
          from the SPI (17).  The initial SI will be 255 and so SFF1 will deliver the packets to the
          SFI for SFT 41.</t>

        <t>When the packets are returned to SFF1 by the SFI the SI will be decreased to 250 for
           the next hop.  SFF1 now has a free choice of next hop SFF to execute the next hop in the
           path selecting between all SFFs that support SFs of type 44.  Looking at the SFIRs it
           has received, SFF1 knows that SF type 44 is supported by SFF3 and SFF4.  SFF1 uses its
           local load balancing algorithm to make this choice.  The chosen SFF will send the packets
           to the SFI that supports SFT 44 before forwarding the packets to their destinations.</t>

    </section>

    <section anchor="examplesft" title="Example SFP With Choice of SFTs" >

       <figure>
         <artwork>
           <![CDATA[
   SFP4:  RD = 198.51.100.1,104, SPI = 18,
          [SI = 255, SFT = 41, RD = 192.0.2.1,1],
          [SI = 250, {SFT = 43, RD = 192.0.2.2,2,
                      SFT = 44, RD = 192.0.2.3,8 } ]
           ]]>
         </artwork>
       </figure>

       <t>This example provides a choice of SF type in the second hop in the path.  The SI of 250
          indicates a choice between SF type 43 located through SF2 and SF type 44 located at SF3.</t>

       <t>SFF1 will receive packets on the path from the Classifier and will identify the path
          from the SPI (18).  The initial SI will be 255 and so SFF1 will deliver the packets to the
          SFI for SFT 41.</t>

       <t>When the packets are returned to SFF1 by the SFI the SI will be decreased to 250 for
          the next hop.  SFF1 now has a free choice of next hop SFF to execute the next hop in the
          path selecting between all SFF2 that support an SF of type 43 and SFF3 that supports an
          SF of type 44.  These may be completely different functions that are to be executed dependent
          on specific conditions, or may be similar functions identified with different type
          identifiers (such as firewalls from different vendors).  SFF1 uses its local policy and load
          balancing algorithm to make this choice, and may use additional information passed back from
          the local SFI to help inform its selection.  The chosen SFF will send the packets to the SFI
          that supports the chose SFT before forwarding the packets to their destinations.</t>

    </section>

    <section anchor="exampleco" title="Example Correlated Bidirectional SFPs" >
       <figure>
         <artwork>
           <![CDATA[
  SFP5:  RD = 198.51.100.1,105, SPI = 19,
         Assoc-Type = 1, Assoc-RD = 198.51.100.1,106, Assoc-SPI = 20,
         [SI = 255, SFT = 41, RD = 192.0.2.1,1],
         [SI = 250, SFT = 43, RD = 192.0.2.2,2]

  SFP6:  RD = 198.51.100.1,106, SPI = 20,
         Assoc-Type = 1, Assoc-RD = 198.51.100.1,105, Assoc-SPI = 19,
         [SI = 254, SFT = 43, RD = 192.0.2.2,2],
         [SI = 249, SFT = 41, RD = 192.0.2.1,1]
           ]]>
         </artwork>
       </figure>

       <t>This example demonstrates correlation of two SFPs to form a bidirectional SFP as
          described in <xref target="correlation" />.</t>

       <t>Two SFPRs are advertised by the Controller.  They have different SPIs (19 and 20)
          so they are known to be separate SFPs, but they both have Association TLVs with Association Type
          set to 1 indicating bidirectional SFPs.  Each has an Associated SFPR-RD fields containing the value
          of the other SFPR-RD to correlated the two SFPs as a bidirectional pair.</t>

       <t>As can be seen from the SFPRs in this example, the paths are symmetric: the hops in
          SFP5 appear in the reverse order in SFP6.</t>

    </section>

    <section anchor="exampleass" title="Example Correlated Asymmetrical Bidirectional SFPs" >
       <figure>
         <artwork>
           <![CDATA[
  SFP7:  RD = 198.51.100.1,107, SPI = 21,
         Assoc-Type = 1, Assoc-RD = 198.51.100.1,108, Assoc-SPI = 22,
         [SI = 255, SFT = 41, RD = 192.0.2.1,1],
         [SI = 250, SFT = 43, RD = 192.0.2.2,2]

  SFP8:  RD = 198.51.100.1,108, SPI = 22,
         Assoc-Type = 1, Assoc-RD = 198.51.100.1,107, Assoc-SPI = 21,
         [SI = 254, SFT = 44, RD = 192.0.2.4,6],
         [SI = 249, SFT = 41, RD = 192.0.2.1,1]
          ]]>
         </artwork>
       </figure>

       <t>Asymmetric bidirectional SFPs can also be created.  This example shows a pair of SFPs
          with distinct SPIs (21 and 22) that are correlated in the same way as in the example in
          <xref target="exampleco" />.</t>

       <t>However, unlike in that example, the SFPs are different in each direction.  Both paths
          include a hop of SF type 41, but SFP7 includes a hop of SF type 43 supported at SFF2 while
          SFP8 includes a hop of SF type 44 supported at SFF4.</t>

    </section>

    <section anchor="exampleloop" title="Example Looping in an SFP" >
       <figure>
         <artwork>
           <![CDATA[
   SFP9:  RD = 198.51.100.1,109, SPI = 23,
          [SI = 255, SFT = 41, RD = 192.0.2.1,1],
          [SI = 250, SFT = 44, RD = 192.0.2.4,5],
          [SI = 245, SFT = 1, RD = {SPI=23, SI=255, Rsv=0}],
          [SI = 245, SFT = 42, RD = 192.0.2.3,7]
           ]]>
         </artwork>
       </figure>

       <t>Looping and jumping are described in <xref target="looping" />.  This example shows
          an SFP that contains an explicit loop-back instruction that is presented as a choice
          within an SFP hop.</t>

       <t>The first two hops in the path (SI = 255 and SI = 250) are normal.  That is, the packets
          will be delivered to SFF1 and SFF4 in turn for execution of SFs of type 41 and 44
          respectively.</t>

       <t>The third hop (SI = 245) presents SFF4 with a choice of next hop.  It can either forward
          the packets to SFF3 for an SF of type 42 (the second choice), or it can loop back.</t>

       <t>The loop-back entry in the SFPR for SI = 245 is indicated by the special purpose SFT value
          1 ("Change Sequence").  Within this hop, the RD is interpreted as encoding the SPI and SI
          of the next hop (see <xref target="changeseq" />.  In this case the SPI is 23 which
          indicates that this is  loop or branch: i.e., the next hop is on the same SFP.  The SI is
          set to 255: this is a higher number than the current SI (245) indicating a loop.</t>

       <t>SFF4 must make a choice between these two next hops.  Either the packets will be forwarded
          to SFF3 with the NSH SI decreased to 245 or looped back to SFF1 with the NSH SI reset to 255.
          This choice will be made according to local policy, information passed back by the local SFI,
          and details in the packets&apos; metadata that are used to prevent infinite looping.</t>

    </section>


    <section anchor="examplebranch" title="Example Branching in an SFP" >
       <figure>
         <artwork>
           <![CDATA[
   SFP10:  RD = 198.51.100.1,110, SPI = 24,
          [SI = 254, SFT = 42, RD = 192.0.2.3,7],
          [SI = 249, SFT = 43, RD = 192.0.2.2,2]

   SFP11:  RD = 198.51.100.1,111, SPI = 25,
          [SI = 255, SFT = 41, RD = 192.0.2.1,1],
          [SI = 250, SFT = 1, RD = {SPI=24, SI=254, Rsv=0}]
           ]]>
         </artwork>
       </figure>

       <t>Branching follows a similar procedure to that for looping (and jumping) as shown in
          <xref target="exampleloop" /> however there are two SFPs involved.</t>

       <t>SFP10 shows a normal path with packets forwarded to SFF3 and SFF2 for execution of
          service functions of type 42 and 43 respectively.</t>

       <t>SFP11 starts as normal (SFF1 for an SF of type 41), but then SFF1 processes the
          next hop in the path and finds a "Change Sequence" Special Purpose SFT.  The SFIR-RD
          field includes an SPI of 24 which indicates SFP10, not the current SFP.  The SI in the
          SFIR-RD is 254, so SFF1 knows that it must set the SPI/SI in the NSH to 24/254 and
          send the packets to the appropriate SFF as advertised in the SFPR for SFP10 (that is,
          SFF3).</t>

    </section>

  </section>

  <section anchor="security" title="Security Considerations">

    <t>This document inherits all the security considerations discussed in the documents that
       specify BGP, the documents that specify BGP Multiprotocol Extensions, and the documents
       that define the attributes that are carried by BGP UPDATEs of the SFC AFI/SAFI.  For more
       information look in <xref target="RFC4271" />, <xref target="RFC4760" />, and
       <xref target="I-D.ietf-idr-tunnel-encaps" />.</t>

    <t>Service Function Chaining provides a significant attack opportunity: packets can be diverted
       from their normal paths through the network, can be made to execute unexpected functions, and
       the functions that are instantiated in software can be subverted.  However, this specification
       does not change the existence of Service Function Chaining and security issues specific to
       Service Function Chaining are covered in <xref target="RFC7665" /> and
       <xref target="I-D.ietf-sfc-nsh" />.</t>

    <t>This document defines a control plane for Service Function Chaining.  Clearly, this provides
       an attack vector for a Service Function Chaining system as an attack on this control plane
       could be used to make the system misbehave.  Thus, the security of the BGP system is critically
       important to the security of the whole Service Function Chaining system.</t>

  </section>

  <section anchor="iana" title="IANA Considerations">

    <section anchor="afisafi" title="New BGP AF/SAFI">

       <t>IANA maintains a registry of "Address Family Numbers".  IANA is requested to assign a new
          Address Family Number from the "Standards Action" range called "BGP SFC" (TBD1 in this
          document) with this document as a reference.</t>

       <t>IANA maintains a registry of "Subsequent Address Family Identifiers (SAFI) Parameters".  IANA
          is requested to assign a new SAFI value from the "Standards Action" range called "BGP SFC"
          (TBD2 in this document) with this document as a reference.</t>

    </section>

    <section anchor="ianasfpatt" title="New BGP Path Attribute">

       <t>IANA maintains a registry of "Border Gateway Protocol (BGP) Parameters" with a subregistry of
          "BGP Path Attributes".  IANA is requested to assign a new Path attribute called "SFP attribute"
          (TBD3 in this document) with this document as a reference.</t>

    </section>

    <section anchor="ianasftlv" title="New SFP Attribute TLVs Type Registry">

       <t>IANA maintains a registry of "Border Gateway Protocol (BGP) Parameters".  IANA is request to
          create a new subregistry called the "SFP Attribute TLVs" registry.</t>

       <t>Valid values are in the range 0 to 65535.
          <list style="symbols">
            <t>Values 0 and 65535 are to be marked "Reserved, not to be allocated".</t>
            <t>Values 1 through 65524 are to be assigned according to the "First Come
               First Served" policy <xref target="RFC5226" />.</t>
          </list></t>

       <t>This document should be given as a reference for this registry.</t>

       <t>The new registry should track:
          <list style="symbols">
             <t>Type</t>
             <t>Name</t>
             <t>Reference Document or Contact</t>
             <t>Registration Date</t>
          </list></t>

       <t>The registry should initially be populated as follows:</t>

       <figure>
         <artwork>
           <![CDATA[
    Type  | Name                  | Reference     | Date
    ------+-----------------------+---------------+---------------
    1     | Association TLV       | [This.I-D]    | Date-to-be-set
    2     | Hop TLV               | [This.I-D]    | Date-to-be-set
    3     | SFT TLV               | [This.I-D]    | Date-to-be-set
           ]]>
         </artwork>
       </figure>
    </section>

    <section anchor="ianaassoc" title="New SFP Association Type Registry">

       <t>IANA maintains a registry of "Border Gateway Protocol (BGP) Parameters".  IANA is request to
          create a new subregistry called the "SFP Association Type" registry.</t>

       <t>Valid values are in the range 0 to 65535.
          <list style="symbols">
            <t>Values 0 and 65535 are to be marked "Reserved, not to be allocated".</t>
            <t>Values 1 through 65524 are to be assigned according to the "First Come
               First Served" policy <xref target="RFC5226" />.</t>
          </list></t>

       <t>This document should be given as a reference for this registry.</t>

       <t>The new registry should track:
          <list style="symbols">
             <t>Association Type</t>
             <t>Name</t>
             <t>Reference Document or Contact</t>
             <t>Registration Date</t>
          </list></t>

       <t>The registry should initially be populated as follows:</t>

       <figure>
         <artwork>
           <![CDATA[
 Association Type | Name               | Reference  | Date
 -----------------+--------------------+------------+---------------
 1                | Bidirectional SFP  | [This.I-D] | Date-to-be-set
           ]]>
         </artwork>
       </figure>
    </section>

    <section anchor="SFTreg" title="New Service Function Type Registry">

       <t>IANA is request to create a new top-level registry called "Service Function Chaining Service Function Types".</t>

       <t>Valid values are in the range 0 to 65535.
          <list style="symbols">
            <t>Values 0 and 65535 are to be marked "Reserved, not to be allocated".</t>
            <t>Values 1 through 31 are to be assigned by "Standards Action" [RFC5226] and are referred to
               as the Special Purpose SFT values.</t>
            <t>Other values (32 through 65534) are to be assigned according to the "First Come
               First Served" policy <xref target="RFC5226" />.</t>
          </list></t>

       <t>This document should be given as a reference for this registry.</t>

       <t>The new registry should track:
          <list style="symbols">
             <t>Value</t>
             <t>Name</t>
             <t>Reference Document or Contact</t>
             <t>Registration Date</t>
          </list></t>

       <t>The registry should initially be populated as follows:</t>

       <figure>
         <artwork>
           <![CDATA[
    Value | Name                  | Reference     | Date
    ------+-----------------------+---------------+---------------
    1     | Change Sequence       | [This.I-D]    | Date-to-be-set
           ]]>
         </artwork>
       </figure>

    </section>

  </section>

  <section anchor="contributors" title="Contributors">

    <figure>
      <artwork>
        <![CDATA[
   Stuart Mackie
   Juniper Networks

   Email: wsmackie@juinper.net

   Keyur Patel
   Arrcus, Inc.

   Email: keyur@arrcus.com
        ]]>
      </artwork>
    </figure>

  </section>

  <section anchor="acks" title="Acknowledgements">

    <t>Thanks to Tony Przygienda for helpful comments, and to Joel Halpern for discussions
       that improved this document.</t>

  </section>

</middle>

<back>
  <references title="Normative References">

    &RFC2119;
    &RFC4271;
    &RFC4364;
    &RFC4760;
    &RFC5226;

    <?rfc include="reference.I-D.ietf-idr-tunnel-encaps"?>
    <?rfc include="reference.I-D.ietf-sfc-nsh"?>

  </references>

  <references title="Informative References">

    &RFC6790;
    &RFC7498;
    &RFC7510;
    &RFC7665;

  </references>

</back>
</rfc>
