<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="3"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" docName="draft-ietf-6man-segment-routing-header-15"
     ipr="trust200902">
  <front>
    <title abbrev="IPv6 Segment Routing Header (SRH)">IPv6 Segment Routing
    Header (SRH)</title>

    <author fullname="Clarence Filsfils" initials="C." role="editor"
            surname="Filsfils">
      <organization>Cisco Systems, Inc.</organization>

      <address>
        <postal>
          <street/>

          <city>Brussels</city>

          <region/>

          <code/>

          <country>BE</country>
        </postal>

        <email>cfilsfil@cisco.com</email>
      </address>
    </author>

    <author fullname="Stefano Previdi" initials="S." surname="Previdi">
      <organization>Huawei</organization>

      <address>
        <postal>
          <street/>

          <city/>

          <code/>

          <country>Italy</country>
        </postal>

        <email>stefano@previdi.net</email>
      </address>
    </author>

    <author fullname="John Leddy" initials="J." surname="Leddy">
      <organization>Individual</organization>

      <address>
        <postal>
          <street/>

          <city/>

          <region/>

          <code/>

          <country>US</country>
        </postal>

        <email>john@leddy.net</email>
      </address>
    </author>

    <author fullname="Satoru Matsushima" initials="S." surname="Matsushima">
      <organization>Softbank</organization>

      <address>
        <email>satoru.matsushima@g.softbank.co.jp</email>
      </address>
    </author>

    <author fullname="Daniel Voyer" initials="D." role="editor"
            surname="Voyer">
      <organization>Bell Canada</organization>

      <address>
        <email>daniel.voyer@bell.ca</email>
      </address>
    </author>

    <date year="2018"/>

    <workgroup>Network Working Group</workgroup>

    <abstract>
      <t>Segment Routing can be applied to the IPv6 data plane using a new
      type of Routing Extension Header. This document describes the Segment
      Routing Extension Header and how it is used by Segment Routing capable
      nodes.</t>
    </abstract>

    <note title="Requirements Language">
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
      "SHOULD", "SHOULD NOT", "RECOMMENDED", "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 anchor="INTRO" title="Introduction">
      <t>Segment Routing can be applied to the IPv6 data plane using a new
      type of Routing Extension Header (SRH). This document describes the
      Segment Routing Extension Header and how it is used by Segment Routing
      capable nodes.</t>

      <t>The Segment Routing Architecture <xref target="RFC8402"/> describes
      Segment Routing and its instantiation in two data planes MPLS and
      IPv6.</t>

      <t>SR with the MPLS data plane is defined in <xref
      target="I-D.ietf-spring-segment-routing-mpls"/>.</t>

      <t>SR with the IPv6 data plane is defined in <xref
      target="I-D.filsfils-spring-srv6-network-programming"/>.</t>

      <t>The encoding of MPLS labels and label stacking are defined in <xref
      target="RFC3032"/>.</t>

      <t>The encoding of IPv6 segments in the Segment Routing Extension Header
      is defined in this document.</t>

      <t>Terminology used within this document is defined in detail in <xref
      target="RFC8402"/>. Specifically, these terms: Segment Routing, SR
      Domain, SRv6, Segment ID (SID), SRv6 SID, Active Segment, and SR
      Policy.</t>
    </section>

    <section anchor="SRH" title="Segment Routing Extension Header">
      <t>Routing Headers are defined in <xref target="RFC8200"/>. The Segment
      Routing Header has a new Routing Type (suggested value 4) to be assigned
      by IANA.</t>

      <t>The Segment Routing Header (SRH) is defined as follows:<figure
          align="left" anchor="SRHFIG" suppress-title="true">
          <artwork>

  0                   1                   2                   3 
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1    
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | Next Header   |  Hdr Ext Len  | Routing Type  | Segments Left |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |  Last Entry   |     Flags     |              Tag              |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |                                                               |
 |            Segment List[0] (128 bits IPv6 address)            |
 |                                                               |
 |                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |                                                               |
 |                                                               |
                               ...
 |                                                               |
 |                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |                                                               |
 |            Segment List[n] (128 bits IPv6 address)            |
 |                                                               |
 |                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 //                                                             //
 //         Optional Type Length Value objects (variable)       //
 //                                                             //
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

where:</artwork>
        </figure><list style="symbols">
          <t>Next Header: Defined in <xref target="RFC8200"/></t>

          <t>Hdr Ext Len: Defined in <xref target="RFC8200"/></t>

          <t>Routing Type: TBD, to be assigned by IANA (suggested value:
          4).</t>

          <t>Segments Left: Defined in <xref target="RFC8200"/></t>

          <t>Last Entry: contains the index (zero based), in the Segment List,
          of the last element of the Segment List.</t>

          <t>Flags: 8 bits of flags. Following flags are defined:<figure
              align="left" anchor="SRHFLAGS" suppress-title="true">
              <artwork align="left">
                       
       0 1 2 3 4 5 6 7  
      +-+-+-+-+-+-+-+-+
      |U U U U U U U U|
      +-+-+-+-+-+-+-+-+
 </artwork>
            </figure><list style="hanging">
              <t>U: Unused and for future use. MUST be 0 on transmission and
              ignored on receipt.</t>
            </list></t>

          <t>Tag: tag a packet as part of a class or group of packets, e.g.,
          packets sharing the same set of properties. When tag is not used at
          source it MUST be set to zero on transmission. When tag is not used
          during SRH Processing it SHOULD be ignored. The allocation and use
          of tag is outside the scope of this document.</t>

          <t>Segment List[n]: 128 bit IPv6 addresses representing the nth
          segment in the Segment List. The Segment List is encoded starting
          from the last segment of the SR Policy. I.e., the first element of
          the segment list (Segment List [0]) contains the last segment of the
          SR Policy, the second element contains the penultimate segment of
          the SR Policy and so on.</t>

          <t>Type Length Value (TLV) are described in <xref
          target="TLVS"/>.</t>
        </list></t>

      <section anchor="TLVS" title="SRH TLVs">
        <t>This section defines TLVs of the Segment Routing Header.</t>

        <figure>
          <artwork>
 0                   1 
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-----------------------
|     Type      |    Length     | Variable length data  
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-----------------------
</artwork>
        </figure>

        <t>Type: An 8 bit value. Unrecognized Types MUST be ignored on
        receipt.</t>

        <t>Length: The length of the Variable length data. It is RECOMMENDED
        that the total length of new TLVs be multiple of 8 bytes to avoid the
        use of Padding TLVs.</t>

        <t>Variable length data: Length bytes of data that is specific to the
        Type.</t>

        <t>Type Length Value (TLV) contain OPTIONAL information that may be
        used by the node identified in the Destination Address (DA) of the
        packet.</t>

        <t>Each TLV has its own length, format and semantic. The code-point
        allocated (by IANA) to each TLV Type defines both the format and the
        semantic of the information carried in the TLV. Multiple TLVs may be
        encoded in the same SRH.</t>

        <t>TLVs may change en route at each segment. To identify when a TLV
        type may change en route the most significant bit of the Type has the
        following significance: <list>
            <t>0: TLV data does not change en route</t>

            <t>1: TLV data does change en route</t>
          </list>Identifying which TLVs change en route, without having to
        understand the Type, is required for Authentication Header Integrity
        Check Value (ICV) computation. Any TLV that changes en route is
        considered mutable for the purpose of ICV computation, the Type Length
        and Variable Length Data is ignored for the purpose of ICV Computation
        as defined in <xref target="RFC4302"/>.</t>

        <t>The "Length" field of the TLV is used to skip the TLV while
        inspecting the SRH in case the node doesn't support or recognize the
        Type. The "Length" defines the TLV length in octets, not including the
        "Type" and "Length" fields.</t>

        <t>The following TLVs are defined in this document:<list>
            <t>Padding TLV</t>

            <t>HMAC TLV</t>
          </list></t>

        <t>Additional TLVs may be defined in the future.</t>

        <section anchor="PADDINGTLV" title="Padding TLVs">
          <t>There are two types of padding TLVs, pad0 and padN, the following
          applies to both:<list>
              <t>Padding TLVs are used to pad the TLVs to a multiple of 8
              octets.</t>

              <t>More than one Padding TLV MUST NOT appear in the SRH.</t>

              <t>The Padding TLVs are used to align the SRH total length on
              the 8 octet boundary.</t>

              <t>When present, a single Pad0 or PadN TLV MUST appear as the
              last TLV.</t>

              <t>When present, a PadN TLV MUST have a length from 0 to 5 in
              order to align the SRH total length on a 8-octet boundary.</t>

              <t>Padding TLVs are ignored by a node processing the SRH TLV,
              even if more than one is present.</t>

              <t>Padding TLVs are ignored during ICV calculation.</t>
            </list></t>

          <section anchor="PAD0" title="PAD0">
            <figure>
              <artwork>
  0 1 2 3 4 5 6 7 
  +-+-+-+-+-+-+-+-+ 
  |     Type      |
  +-+-+-+-+-+-+-+-+</artwork>
            </figure>

            <t><list>
                <t>Type: to be assigned by IANA (Suggested value 128)</t>
              </list></t>

            <t>A single Pad0 TLV MUST be used when a single byte of padding is
            required. If more than one byte of padding is required a Pad0 TLV
            MUST NOT be used, the PadN TLV MUST be used.</t>
          </section>

          <section anchor="PADN" title="PADN">
            <figure>
              <artwork>
 0                   1                   2                   3   
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1     
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
|     Type      |    Length     |      Padding (variable)       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//                    Padding (variable)                       //
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+</artwork>
            </figure>

            <t><list>
                <t>Type: to be assigned by IANA (suggested value 129).</t>

                <t>Length: 0 to 5</t>

                <t>Padding: Length octets of padding. Padding bits have no
                semantics. They MUST be set to 0 on transmission and ignored
                on receipt.</t>
              </list></t>

            <t>The PadN TLV MUST be used when more than one byte of padding is
            required.</t>
          </section>
        </section>

        <section anchor="HMACTLV" title="HMAC TLV">
          <t>The keyed Hashed Message Authentication Code (HMAC) TLV is
          OPTIONAL and has the following format:<figure>
              <artwork> 0                   1                   2                   3   
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1     
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
|      Type     |     Length    |          RESERVED             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      HMAC Key ID (4 octets)                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                              //
|                      HMAC (32 octets)                        //
|                                                              //
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 

where:</artwork>
            </figure> <list style="symbols">
              <t>Type: to be assigned by IANA (suggested value 5).</t>

              <t>Length: 38.</t>

              <t>RESERVED: 2 octets. MUST be 0 on transmission and ignored on
              receipt.</t>

              <t>HMAC Key ID: A 4 octet opaque number which uniquely
              identifies the pre-shared key and algorithm used to generate the
              HMAC. If 0, the HMAC is not included.</t>

              <t>HMAC: 32 octets of keyed HMAC, not present if Key ID is
              0.</t>
            </list></t>

          <t>The HMAC TLV is used to verify the source of a packet is
          permitted to use the current segment in the destination address of
          the packet, and ensure the segment list is not modified in
          transit.</t>

          <section title="HMAC generation">
            <t>The HMAC field is the output of the HMAC computation as defined
            in <xref target="RFC2104"/>, using:<list style="symbols">
                <t>key: the pre-shared key identified by HMAC Key ID</t>

                <t>HMAC algorithm: identified by the HMAC Key ID</t>

                <t>Text: a concatenation of the following fields from the IPv6
                header and the SRH, as it would be received at the node
                verifying the HMAC:<list style="symbols">
                    <t>IPv6 header: source address (16 octets)</t>

                    <t>IPv6 header: destination address (16 octets)</t>

                    <t>SRH: Segments Left (1 octet)</t>

                    <t>SRH: Last Entry (1 octet)</t>

                    <t>SRH: Flags (1 octet)</t>

                    <t>SRH: HMAC Key-id (4 octets)</t>

                    <t>SRH: all addresses in the Segment List (variable
                    octets)</t>
                  </list></t>
              </list></t>

            <t>The HMAC digest is truncated to 32 octets and placed in the
            HMAC field of the HMAC TLV.</t>

            <t>For HMAC algorithms producing digests less than 32 octets, the
            digest is placed in the lowest order octets of the HMAC field.
            Remaining octets MUST be set to zero.</t>
          </section>

          <section title="HMAC Verification">
            <t>Local policy determines when to check for an HMAC and
            potentially a requirement on where the HMAC TLV must appear (e.g.
            first TLV). This local policy is outside the scope of this
            document. It may be based on the active segment at an SR Segment
            endpoint node, the result of an ACL that considers incoming
            interface, or other packet fields.</t>

            <t>If HMAC verification is successful, the packet is forwarded to
            the next segment.</t>

            <t>If HMAC verification fails, an ICMP error message (parameter
            problem, error code 0, pointing to the HMAC TLV) SHOULD be
            generated (but rate limited) and SHOULD be logged.</t>
          </section>

          <section title="HMAC Pre-Shared Key Algorithm">
            <t>The HMAC Key ID field allows for the simultaneous existence of
            several hash algorithms (SHA-256, SHA3-256 ... or future ones) as
            well as pre-shared keys.</t>

            <t>The HMAC Key ID field is opaque, i.e., it has neither syntax
            nor semantic except as an identifier of the right combination of
            pre-shared key and hash algorithm, and except that a value of 0
            means that there is no HMAC field.</t>

            <t>At the HMAC TLV verification node the Key ID uniquely
            identifies the pre-shared key and HMAC algorithm.</t>

            <t>At the HMAC TLV generating node the Key ID and destination
            address uniquely identify the pre-shared key and HMAC algorithm.
            Utilizing the destination address with the Key ID allows for
            overlapping key IDs amongst different HMAC verification nodes. The
            Text for the HMAC computation is set to the IPv6 header fields and
            SRH fields as they would appear at the verification node, not
            necessarily the same as the source node sending a packet with the
            HMAC TLV.</t>

            <t>Pre-shared key roll-over is supported by having two key IDs in
            use while the HMAC TLV generating node and verifying node converge
            to a new key.</t>

            <t>SRH implementations can support multiple hash functions but
            MUST implement SHA-2 <xref target="FIPS180-4"/> in its SHA-256
            variant.</t>

            <t>The selection of pre-shared key and algorithm, and their
            distribution is outside the scope of this document, some options
            may include: <list style="symbols">
                <t>in the configuration of the HMAC generating or verifying
                nodes, either by static configuration or any SDN oriented
                approach</t>

                <t>dynamically using a trusted key distribution protocol such
                as <xref target="RFC6407"/></t>
              </list></t>
          </section>
        </section>
      </section>
    </section>

    <section anchor="SRNODES" title="SR Nodes">
      <t>There are different types of nodes that may be involved in segment
      routing networks: source SR nodes originate packets with a segment in
      the destination address of the IPv6 header, transit nodes that forward
      packets destined to a remote segment, and SR segment endpoint nodes that
      process a local segment in the destination address of an IPv6
      header.</t>

      <section anchor="SOURCE" title="Source SR Node">
        <t>A Source SR Node is any node that originates an IPv6 packet with a
        segment (i.e. SRv6 SID) in the destination address of the IPv6 header.
        The packet leaving the source SR Node may or may not contain an SRH.
        This includes either: <list style="hanging">
            <t>A host originating an IPv6 packet.</t>

            <t>An SR domain ingress router encapsulating a received packet in
            an outer IPv6 header, followed by an optional SRH.</t>
          </list></t>

        <t>The mechanism through which a segment in the destination address of
        the IPv6 header and the Segment List in the SRH, is derived is outside
        the scope of this document.</t>
      </section>

      <section anchor="TRANSIT" title="Transit Node">
        <t>A transit node is any node forwarding an IPv6 packet where the
        destination address of that packet is not locally configured as a
        segment nor a local interface. A transit node is not required to be
        capable of processing a segment nor SRH.</t>
      </section>

      <section title="SR Segment Endpoint Node">
        <t>A SR segment endpoint node is any node receiving an IPv6 packet
        where the destination address of that packet is locally configured as
        a segment or local interface.</t>
      </section>
    </section>

    <section anchor="PacketProcessing" title="Packet Processing">
      <t>This section describes SRv6 packet processing at the SR source,
      Transit and SR segment endpoint nodes.</t>

      <section anchor="pktSourceNode" title="Source SR Node">
        <t>A Source node steers a packet into an SR Policy. If the SR Policy
        results in a segment list containing a single segment, and there is no
        need to add information to SRH flag or TLV, the DA is set to the
        single segment list entry and the SRH MAY be omitted.</t>

        <t>When needed, the SRH is created as follows:<list style="hanging">
            <t>Next Header and Hdr Ext Len fields are set as specified in
            <xref target="RFC8200"/>.</t>

            <t>Routing Type field is set as TBD (to be allocated by IANA,
            suggested value 4).</t>

            <t>The DA of the packet is set with the value of the first
            segment.</t>

            <t>The first element of the SRH Segment List is the ultimate
            segment. The second element is the penultimate segment and so
            on.</t>

            <t>The Segments Left field is set to n-1 where n is the number of
            elements in the SR Policy.</t>

            <t>The Last Entry field is set to n-1 where n is the number of
            elements in the SR Policy.</t>

            <t>HMAC TLV may be set according to <xref target="Security"/>.</t>

            <t>The packet is forwarded toward the packet's Destination Address
            (the first segment).</t>
          </list></t>

        <section title="Reduced SRH">
          <t>When a source does not require the entire SID list to be
          preserved in the SRH, a reduced SRH may be used.</t>

          <t>A reduced SRH does not contain the first segment of the related
          SR Policy (the first segment is the one already in the DA of the
          IPv6 header), and the Last Entry field is set to n-2 where n is the
          number of elements in the SR Policy.</t>
        </section>
      </section>

      <section title="Transit Node">
        <t>As specified in <xref target="RFC8200"/>, the only node allowed to
        inspect the Routing Extension Header (and therefore the SRH), is the
        node corresponding to the DA of the packet. Any other transit node
        MUST NOT inspect the underneath routing header and MUST forward the
        packet toward the DA according to its IPv6 routing table.</t>

        <t>When a SID is in the destination address of an IPv6 header of a
        packet, it's routed through an IPv6 network as an IPv6 address. SIDs,
        or the prefix(es) covering SIDs, and their reachability may be
        distributed by means outside the scope of this document. For example,
        <xref target="RFC5308"/> or <xref target="RFC5340"/> may be used to
        advertise a prefix covering the SIDs on a node.</t>
      </section>

      <section title="SR Segment Endpoint Node">
        <t>Without constraining the details of an implementation, the SR
        segment endpoint node creates Forwarding Information Base (FIB)
        entries for its local SIDs.</t>

        <t>When an SRv6-capable node receives an IPv6 packet, it performs a
        longest-prefix-match lookup on the packets destination address. This
        lookup can return any of the following:<figure align="left">
            <artwork>
    A FIB entry that represents a locally instantiated SRv6 SID
    A FIB entry that represents a local interface, not locally
                                  instantiated as an SRv6 SID
    A FIB entry that represents a non-local route
    No Match</artwork>
          </figure></t>

        <section anchor="pktENDSID"
                 title="FIB Entry Is Locally Instantiated SRv6 END SID">
          <t>This document, and section, defines a single SRv6 SID called END.
          Future documents may define additional SRv6 SIDs. In which case, the
          entire content of this section will be defined in that document.</t>

          <t>If the FIB entry represents a locally instantiated SRv6 SID,
          process the next header of the IPv6 header as defined in section 4
          of <xref target="RFC8200"/></t>

          <t>The following sections describe the actions to take while
          processing next header fields.</t>

          <section title="SRH Processing">
            <t><figure align="left">
                <artwork>
When an SRH is processed {
  If Segments Left is equal to zero {
    Proceed to process the next header in the packet, whose type
    is identified by the Next Header field in the Routing header.
  }
  Else {
    If local policy requires TLV processing {
      Perform TLV processing (see TLV Processing)
    }
    max_last_entry  =  ( Hdr Ext Len /  2 ) - 1
                    
    If  ((Last Entry &gt; max_last_entry) or 
         (Segments Left is greater than (Last Entry+1)) {
      Send an ICMP Parameter Problem, Code 0, message to the
      Source Address, pointing to the Segments Left field, and
      discard the packet.
    }
    Else {
      Decrement Segments Left by 1.
      Copy Segment List[Segments Left] from the SRH to the
      destination address of the IPv6 header.
      If the IPv6 Hop Limit is less than or equal to 1 {
        Send an ICMP Time Exceeded -- Hop Limit Exceeded in
        Transit message to the Source Address and discard
        the packet.
      }
      Else {
        Decrement the Hop Limit by 1
        Resubmit the packet to the IPv6 module for transmission
        to the new destination.
      }
    }
  }
}
</artwork>
              </figure></t>

            <section title="TLV Processing">
              <t>Local policy determines how TLV's are to be processed when
              the Active Segment is a local END SID. The definition of local
              policy is outside the scope of this document.</t>

              <t>For illustration purpose only, two example local policies
              that may be associated with an END SID are provided below.</t>

              <t><figure align="left">
                  <artwork>
Example 1:
For any packet received from interface I2
  Skip TLV processing

Example 2:
For any packet received from interface I1
  If first TLV is HMAC {
    Process the HMAC TLV
  }
  Else {
    Discard the packet
  }</artwork>
                </figure></t>
            </section>
          </section>

          <section title="Upper-layer Header or No Next Header">
            <t>Send an ICMP parameter problem message to the Source Address
            and discard the packet. Error code (TBD by IANA) "SR Upper-layer
            Header Error", pointer set to the offset of the upper-layer
            header.</t>

            <t>A unique error code allows an SR Source node to recognize an
            error in SID processing at an endpoint.</t>
          </section>
        </section>

        <section title="FIB Entry is a Local Interface">
          <t>If the FIB entry represents a local interface, not locally
          instantiated as an SRv6 SID, the SRH is processed as follows:<list>
              <t>If Segments Left is zero, the node must ignore the Routing
              header and proceed to process the next header in the packet,
              whose type is identified by the Next Header field in the Routing
              Header.</t>

              <t>If Segments Left is non-zero, the node must discard the
              packet and send an ICMP Parameter Problem, Code 0, message to
              the packet's Source Address, pointing to the unrecognized
              Routing Type.</t>
            </list></t>
        </section>

        <section title="FIB Entry Is A Non-Local Route">
          <t>Processing is not changed by this document.</t>
        </section>

        <section title="FIB Entry Is A No Match">
          <t>Processing is not changed by this document.</t>
        </section>

        <section anchor="LBECMP" title="Load Balancing and ECMP">
          <t>Within an SR domain, an SR source node encapsulates a packet in
          an outer IPv6 header for transport to an endpoint. The SR source
          node MUST impose a flow label computed based on the inner packet.
          The computation of the flow label is as recommended in <xref
          target="RFC6438"/> for the sending Tunnel End Point.</t>

          <t>At any transit node within an SR domain, the flow label MUST be
          used as defined in <xref target="RFC6438"/> to calculate the ECMP
          hash toward the destination address. If flow label is not used, the
          transit node may hash all packets between a pair of SR Edge nodes to
          the same link.</t>

          <t>At an SR segment endpoint node, the flow label MUST be used as
          defined in <xref target="RFC6438"/> to calculate any ECMP hash used
          to forward the processed packet to the next segment.</t>
        </section>
      </section>
    </section>

    <section title="Illustrations">
      <t>This section provides illustrations of SRv6 packet processing at SR
      source, transit and SR segment endpoint nodes.</t>

      <section title="Abstract Representation of an SRH">
        <t>For a node k, its IPv6 address is represented as Ak, its SRv6 SID
        is represented as Sk.</t>

        <t>IPv6 headers are represented as the tuple of (source, destination).
        For example, a packet with source address A1 and destination address
        A2 is represented as (A1,A2). The payload of the packet is
        omitted.</t>

        <t>An SR Policy is a list of segments. A list of segments is
        represented as &lt;S1,S2,S3&gt; where S1 is the first SID to visit, S2
        is the second SID to visit and S3 is the last SID to visit.</t>

        <t>(SA,DA) (S3, S2, S1; SL) represents an IPv6 packet with:<list
            style="symbols">
            <t>Source Address is SA, Destination Addresses is DA, and
            next-header is SRH.</t>

            <t>SRH with SID list &lt;S1, S2, S3&gt; with SegmentsLeft =
            SL.</t>

            <t>Note the difference between the &lt;&gt; and () symbols.
            &lt;S1, S2, S3&gt; represents a SID list where the leftmost
            segment is the first segment. Whereas, (S3, S2, S1; SL) represents
            the same SID list but encoded in the SRH Segment List format where
            the leftmost segment is the last segment. When referring to an SR
            policy in a high-level use-case, it is simpler to use the &lt;S1,
            S2, S3&gt; notation. When referring to an illustration of detailed
            behavior, the (S3, S2, S1; SL) notation is more convenient.</t>
          </list></t>

        <t>At its SR Policy headend, the Segment List &lt;S1,S2,S3&gt; results
        in SRH (S3,S2,S1; SL=2) represented fully as: <figure align="left">
            <artwork>
    Segments Left=2
    Last Entry=2
    Flags=0
    Tag=0
    Segment List[0]=S3
    Segment List[1]=S2
    Segment List[2]=S1</artwork>
          </figure></t>
      </section>

      <section title="Example Topology">
        <t>The following topology is used in examples below: <figure
            align="center" anchor="TOPO1">
            <artwork>
        + * * * * * * * * * * * * * * * * * * * * +

        *         [8]                [9]          *
                   |                  |
        *          |                  |           *
[1]----[3]--------[5]----------------[6]---------[4]---[2]
        *          |                  |           *
                   |                  |
        *          |                  |           *
                   +--------[7]-------+
        *                                         *

        + * * * * * * *  SR Domain  * * * * * * * +</artwork>
          </figure><list style="symbols">
            <t>3 and 4 are SR Domain edge routers</t>

            <t>5, 6, and 7 are all SR Domain routers</t>

            <t>8 and 9 are hosts within the SR Domain</t>

            <t>1 and 2 are hosts outside the SR Domain</t>
          </list></t>
      </section>

      <section title="Source SR Node">
        <section title="Intra SR Domain Packet">
          <t>When host 8 sends a packet to host 9 via an SR Policy
          &lt;S7,A9&gt; the packet is</t>

          <t>P1: (A8,S7)(A9,S7; SL=1)</t>

          <section title="Reduced Variant">
            <t>When host 8 sends a packet to host 9 via an SR Policy
            &lt;S7,A9&gt; and it wants to use a reduced SRH, the packet is</t>

            <t>P2: (A8,S7)(A9; SL=1)</t>
          </section>
        </section>

        <section title="Transit Packet Through SR Domain">
          <t>When host 1 sends a packet to host 2, the packet is</t>

          <t>P3: (A1,A2)</t>

          <t>The SR Domain ingress router 3 receives P3 and steers it to SR
          Domain egress router 4 via an SR Policy &lt;S7, S4&gt;. Router 3
          encapsulates the received packet P3 in an outer header with an SRH.
          The packet is</t>

          <t>P4: (A3, S7)(S4, S7; SL=1)(A1, A2)</t>

          <t>If the SR Policy contains only one segment (the egress router 4),
          the ingress Router 3 encapsulates P3 into an outer header (A3, S4).
          The packet is</t>

          <t>P5: (A3, S4)(A1, A2)</t>

          <section title="Reduced Variant">
            <t>The SR Domain ingress router 3 receives P3 and steers it to SR
            Domain egress router 4 via an SR Policy &lt;S7, S4&gt;. If router
            3 wants to use a reduced SRH, Router 3 encapsulates the received
            packet P3 in an outer header with a reduced SRH. The packet is</t>

            <t>P6: (A3, S7)(S4; SL=1)(A1, A2)</t>
          </section>
        </section>
      </section>

      <section title="Transit Node">
        <t>Nodes 5 acts as transit nodes for packet P1, and sends packet</t>

        <t>P1: (A8,S7)(A9,S7;SL=1)</t>

        <t>on the interface toward node 7.</t>
      </section>

      <section title="SR Segment Endpoint Node">
        <t>Node 7 receives packet P1 and, using the logic in section 4.3.1,
        sends packet</t>

        <t>P7: (A8,A9)(A9,S7; SL=0)</t>

        <t>on the interface toward router 6.</t>
      </section>
    </section>

    <section anchor="DEP" title="Deployment Models">
      <section anchor="NODESINSR" title="Nodes Within the SR domain">
        <t>SR Source Nodes within an SR Domain are trusted to generate IPv6
        packets with SRH. SR segment endpoint nodes receiving packets on
        interface that are part of the SR Domain may process any packet
        destined to a local segment, containing an SRH.</t>

        <t>A SR Source Node connected to the SR Domain via a secure tunnel,
        e.g. IPSec tunnel mode <xref target="RFC4303"/> or Ethernet pseudowire
        <xref target="RFC4448"/>, may be considered trusted and directly
        connected. Some types of tunnels may result in additional processing
        overhead that should be considered in a deployment.</t>
      </section>

      <section anchor="NODESOUTSR" title="Nodes Outside the SR Domain">
        <t>Nodes outside the SR Domain cannot be trusted. SR Domain Ingress
        routers SHOULD discard packets destined to SIDs within the SR Domain
        (regardless of the presence of an SRH) to avoid attacks on the SR
        Domain as described and referenced in <xref target="RFC5095"/>. As an
        additional layer of protection, SR Segment Endpoint nodes SHOULD
        discard packets destined to local SIDs from source addresses not part
        of the SR Domain.</t>

        <t>For example, using the example topology from section 5, all SIDs in
        the SR Domain (SIDS S1-S9) are assigned within a single IPv6 prefix,
        Prefix-S. All SIDs assigned to a node k are assigned within a single
        IPv6 prefix Prefix-Sk, all addresses permitted to source packets
        destined to SIDs in the SR Domain are assigned within a single IPv6
        prefix Prefix-A.</t>

        <t>An Infrastructure Access List (IACL), applied to the external
        interfaces of SR Domain ingress nodes 3 and 4, that discards packets
        destined to a SID covered by Prefix-S is used to discard packets
        destined to SIDs within the SR Domain.</t>

        <t>An IACL, applied to each interface of SR Segment Endpoint Nodes k,
        that discards packets destined to a SID covered by Prefix-Sk with a
        source address not covered by Prefix-A.</t>

        <t>Failure to implement a method of ingress filtering, as defined
        above, exposes the SR domain to source routing attacks from nodes
        outside the SR Domain, as described and referenced in <xref
        target="RFC5095"/>.</t>

        <section anchor="DEPNDC"
                 title="SR Source Nodes Not Directly Connected">
          <t>Nodes outside the SR Domain may request, by some trusted means
          outside the scope of this document, a complete SRH including an HMAC
          TLV which is computed correctly for the SRH.</t>

          <t>SR Domain ingress routers permit traffic destined to select SIDs
          with local policy requiring HMAC TLV processing for those select
          SIDs, i.e. those SIDs provide a gateway to the SR Domain for a set
          of segment lists.</t>

          <t>If HMAC verification is successful, the packet is forwarded to
          the next segment. Within the SR Domain no further HMAC check need be
          performed.</t>

          <t>If HMAC verification fails, an ICMP error message (parameter
          problem, error code 0, pointing to the HMAC TLV) SHOULD be generated
          (but rate limited) and SHOULD be logged.</t>

          <t>For example, extending the topology defined in <xref
          target="TOPO1"/>, consider node 3 offering access to a premium SLA
          service to node 20. Node 20 is a trusted SR Source not directly
          connected to the SR Domain. <figure align="center">
              <artwork>
             + * * * * * * * * * * * * * * * * * * * * +

             *         [8]                [9]          *
                        |                  |
             *          |                  |           *
[20]--[11]--[3]--------[5]----------------[6]---------[4]---[2]
             *          |                  |           *
                        |                  |
             *          |                  |           *
                        +--------[7]-------+
             *                                         *

                + * * * * * * *  SR Domain  * * * * * * * +</artwork>
            </figure></t>

          <t>In order to access the SLA service, node 20 must be able to
          access segments within the SR Domain. To provide a secure entry
          point for the SLA service, SIDs with local policy requiring HMAC
          verification at node k are defined as Hk and assigned from a prefix
          Prefix-H. Prefix-H is disjoint with Prefix-S and Prefix-A defined
          earlier.</t>

          <t>Prefix-H is not part of the IACLs applied at the external facing
          interfaces of node 3 and 4, allowing external nodes access to
          it.</t>

          <t>SID H3 is a SID covered by Prefix-H at node 3.</t>

          <t>Node 20 requests the premium SLA service to node 2 and is
          provided a pre-computed SRH and HMAC with destination address
          H3.</t>

          <t>Node 20 sends a packet with destination addresses set to H2, SRH
          and HMAC TLV are as provided for the premium SLA service.</t>

          <t>Node 3 receives the packet and verifies the HMAC as defined in
          section 4.3, forwarding the packet to the next segment in the
          segment list or dropping it based on the HMAC result.</t>

          <t>This use of an HMAC is particularly valuable within an enterprise
          based SR Domain to authenticate a host which is using SRv6 segment
          routing as documented in <xref target="SRN"/>. In that example, the
          HMAC is used to validate a source node is using a permitted segment
          list.</t>
        </section>
      </section>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>This section reviews security considerations related to the SRH,
      given the SRH processing and deployment models discussed in this
      document.</t>

      <t>As describe in <xref target="DEP"/>, it is necessary to filter
      packets ingress to the SR Domain destined to segments within the SR
      Domain. This ingress filtering is via an IACL at SR Domain ingress
      border nodes. Additional protection is applied via an IACL at each SR
      Segment Endpoint node, filtering packets not from within the SR Domain,
      destined to SIDs in the SR Domain. ACLs are easily supported for small
      numbers of prefixes, making summarization important, and when the
      prefixes requiring filtering is kept to a seldom changing set.</t>

      <t>Additionally, ingress filtering of IPv6 source addresses as
      recommended in BCP38 SHOULD be used.</t>

      <t>SR Source Nodes not directly connected to the SR Domain may access
      specific sets of segments within the SR Domain when secured with the SRH
      HMAC TLV. The SRH HMAC TLV provides a means of verifying the validity of
      ingress packets SRH, limiting access to the segments in the SR Domain to
      only those source nodes with permission.</t>

      <section title="Source Routing Attacks">
        <t><xref target="RFC5095"/> deprecates the Type 0 Routing header due
        to a number of significant attacks that are referenced in that
        document. Such attacks include bypassing filtering devices, reaching
        otherwise unreachable Internet systems, network topology discovery,
        bandwidth exhaustion, and defeating anycast.</t>

        <t>Because this document specifies that the SRH is for use within an
        SR domain protected by ingress filtering via IACLs, and by
        cryptographically authenticated SR source nodes not directly connected
        to the SR Domain; such attacks cannot be mounted from outside an SR
        Domain. As specified in this document, SR Domain ingress edge nodes
        drop packets entering the SR Domain destined to segments within the SR
        Domain.</t>

        <t>Aditionally, this document specifies the use of IACL on SR Segment
        Endpoint nodes within the SR Domain to limit the source addresses
        permitted to send packets to a SID in the SR Domain.</t>

        <t>Such attacks may, however, be mounted from within the SR Domain,
        from nodes permitted to source traffic to SIDs in the domain. As such,
        these attacks and other known attacks on an IP network (e.g. DOS/DDOS,
        topology discovery, man-in-the-middle, traffic
        interception/siphoning), can occur from compromised nodes within an SR
        Domain.</t>
      </section>

      <section title="Service Theft">
        <t>Service theft is defined as the use of a service offered by the SR
        Domain by a node not authorized to use the service.</t>

        <t>Service theft is not a concern within the SR Domain as all SR
        Source nodes and SR segment endpoint nodes within the domain are able
        to utilizing the services of the Domain. If a node outside the SR
        Domain learns of segments or a topological service within the SR
        domain, IACL filtering denies access to those segments.</t>

        <t>Nodes outside the SR Domain, capable of intercepting packets from
        SR Source nodes not directly connected to the SR Domain utilizing the
        SRH HMAC, may steel the outer IP header SRH and HMAC TLV. If such an
        attacker is capable of spoofing the source address of the original
        sender it may use the IP header and HMAC to access services of the SR
        Domain intended for the original SR Source node.</t>

        <t>Frequent rekeying of the HMAC TLV helps mitigate against this
        attack but cannot prevent it.</t>

        <t>However, as described in <xref target="DEPNDC"/>, there exist use
        cases where the risk of service threat is of minimum concern and the
        HMAC TLV is used primarily to validate that the source is permitted to
        use the segment list in the SRH.</t>
      </section>

      <section title="Topology Disclosure">
        <t>The SRH may contains SIDs of some intermediate SR-nodes in the path
        towards the destination, this reveals those addresses to attackers if
        they are able to intercept packets containing SRH.</t>

        <t>This is applicable within an SR Domain but the disclosure is less
        relevant as an attacker has other means of learning topology.</t>

        <t>For an SR Source node not directly connected to the SR Domain this
        disclosure is applicable. While the segments within the SR domain
        disclosed in SRH are protected by ingress filtering, they may be
        learned by an attacker external to the SR Domain.</t>

        <t>As described in <xref target="DEPNDC"/>, there exist use cases
        where the risk of topology disclosure is of minimum concern when the
        HMAC TLV is used primarily to validate that the source is permitted to
        use the segment list in the SRH.</t>
      </section>

      <section title="ICMP Generation">
        <t>The generation of ICMPv6 error messages may be used to attempt
        denial-of-service attacks by sending an error-causing destination
        address or SRH in back-to-back packets. An implementation that
        correctly follows Section 2.4 of <xref target="RFC4443"/> would be
        protected by the ICMPv6 rate-limiting mechanism.</t>
      </section>
    </section>

    <section anchor="IANA" title="IANA Considerations">
      <t>This document makes the following registrations in the Internet
      Protocol Version 6 (IPv6) Parameters "Routing Type" registry maintained
      by IANA:<figure align="center">
          <artwork align="left">Suggested            Description             Reference 
  Value
----------------------------------------------------------
   4         Segment Routing Header (SRH)    This document</artwork>
        </figure></t>

      <t>This document request IANA to create and maintain a new Registry:
      "Segment Routing Header TLVs"</t>

      <section anchor="SRHFLAGSREG"
               title="Segment Routing Header Flags Register">
        <t>This document requests the creation of a new IANA managed registry
        to identify SRH Flags Bits. The registration procedure is "Expert
        Review" as defined in <xref target="RFC8126"/>. Suggested registry
        name is "Segment Routing Header Flags". Flags is 8 bits, the following
        bits are defined in this document: <figure align="center">
            <artwork align="left">
Suggested      Description               Reference 
  Bit
-----------------------------------------------------
   4           HMAC                      This document</artwork>
          </figure></t>
      </section>

      <section anchor="SRHTLVREG" title="Segment Routing Header TLVs Register">
        <t>This document requests the creation of a new IANA managed registry
        to identify SRH TLVs. The registration procedure is "Expert Review" as
        defined in <xref target="RFC8126"/>. Suggested registry name is
        "Segment Routing Header TLVs". A TLV is identified through an unsigned
        8 bit codepoint value. The following codepoints are defined in this
        document: <figure align="center">
            <artwork align="left">
Suggested      Description               Reference 
  Value
-----------------------------------------------------
   5           HMAC TLV                  This document
   128         Pad0 TLV                  This document
   129         PadN TLV                  This document</artwork>
          </figure></t>
      </section>
    </section>

    <section anchor="Implementation" title="Implementation Status">
      <t>This section is to be removed prior to publishing as an RFC.</t>

      <section anchor="IMPLINUX" title="Linux">
        <t>Name: Linux Kernel v4.14</t>

        <t>Status: Production</t>

        <t>Implementation: adds SRH, performs END processing, supports HMAC
        TLV</t>

        <t>Details: https://irtf.org/anrw/2017/anrw17-final3.pdf and <xref
        target="I-D.filsfils-spring-srv6-interop"/></t>
      </section>

      <section anchor="IMPCISCO" title="Cisco Systems">
        <t>Name: IOS XR and IOS XE</t>

        <t>Status: Pre-production</t>

        <t>Implementation: adds SRH, performs END processing, no TLV
        processing</t>

        <t>Details: <xref target="I-D.filsfils-spring-srv6-interop"/></t>
      </section>

      <section anchor="IMPFDIO" title="FD.io">
        <t>Name: VPP/Segment Routing for IPv6</t>

        <t>Status: Production</t>

        <t>Implementation: adds SRH, performs END processing, no TLV
        processing</t>

        <t>Details: https://wiki.fd.io/view/VPP/Segment_Routing_for_IPv6 and
        <xref target="I-D.filsfils-spring-srv6-interop"/></t>
      </section>

      <section anchor="IMPBAREFOOT" title="Barefoot">
        <t>Name: Barefoot Networks Tofino NPU</t>

        <t>Status: Prototype</t>

        <t>Implementation: performs END processing, no TLV processing</t>

        <t>Details: <xref target="I-D.filsfils-spring-srv6-interop"/></t>
      </section>

      <section title="Juniper">
        <t>Name: Juniper Networks Trio and vTrio NPU's</t>

        <t>Status: Prototype &amp; Experimental</t>

        <t>Implementation: SRH insertion mode, Process SID where SID is an
        interface address, no TLV processing</t>
      </section>

      <section title="Huawei">
        <t>Name: Huawei Systems VRP Platform</t>

        <t>Status: Production</t>

        <t>Implementation: adds SRH, performs END processing, no TLV
        processing</t>
      </section>
    </section>

    <section anchor="Contributors" title="Contributors">
      <t>Kamran Raza, Darren Dukes, Brian Field, Daniel Bernier, Ida Leung,
      Jen Linkova, Ebben Aries, Tomoya Kosugi, Eric Vyncke, David Lebrun, Dirk
      Steinberg, Robert Raszuk, Dave Barach, John Brzozowski, Pierre Francois,
      Nagendra Kumar, Mark Townsley, Christian Martin, Roberta Maglione, James
      Connolly, Aloys Augustin contributed to the content of this
      document.</t>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>The authors would like to thank Ole Troan, Bob Hinden, Ron Bonica,
      Fred Baker, Brian Carpenter, Alexandru Petrescu, Punit Kumar Jaiswal,
      and David Lebrun for their comments to this document.</t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.8174.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.8200.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.5095.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.6407.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.8402.xml"?>

      <reference anchor="FIPS180-4"
                 target="http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf">
        <front>
          <title>FIPS 180-4 Secure Hash Standard (SHS)</title>

          <author>
            <organization>National Institute of Standards and
            Technology</organization>
          </author>

          <date month="March" year="2012"/>
        </front>
      </reference>
    </references>

    <references title="Informative References">
      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.8126.xml"?>

      <?rfc include="reference.I-D.ietf-spring-segment-routing-mpls.xml"?>

      <?rfc include="reference.I-D.filsfils-spring-srv6-network-programming.xml"?>

      <?rfc include="reference.I-D.filsfils-spring-srv6-interop.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2104.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.3032.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.5340.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.4302.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.5308.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.6438.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.4443.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.4303.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.4448.xml"?>

      <reference anchor="SRN"
                 target="https://inl.info.ucl.ac.be/system/files/sosr18-final15-embedfonts.pdf">
        <front>
          <title>Software Resolved Networks: Rethinking Enterprise Networks
          with IPv6 Segment Routing</title>

          <author fullname="David Lebrun"/>

          <author fullname="Mathieu Jadin"/>

          <author fullname="Francois Clad"/>

          <author fullname="Clarence Filsfils"/>

          <author fullname="Olivier Bonaventure"/>

          <date year="2018"/>
        </front>
      </reference>
    </references>
  </back>
</rfc>
