<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="rfc7991bis.rnc"?>  <!-- Required for schema
      validation and schema-aware editing --> 
<!-- <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?> --> 
<!-- This third-party XSLT can be enabled for direct transformations
in XML processors, including most browsers --> 

<!DOCTYPE rfc [
  <!ENTITY filename "draft-ietf-idr-flowspec-nvo3-20">
  <!ENTITY nbsp   "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<!-- If further character entities are required then they should be
added to the DOCTYPE above. Use of an external entity file is not
recommended. --> 
<?rfc strict="yes" ?>
<?rfc toc="yes"?>

<rfc
  xmlns:xi="http://www.w3.org/2001/XInclude"
  category="std"
  docName="&filename;"
  ipr="trust200902"
  updates=""
  submissionType="IETF"
  xml:lang="en"
  version="3">
<!-- 
    * docName should be the name of your draft * category should be
    one of std, bcp, info, exp, historic * ipr should be one of
    trust200902, noModificationTrust200902, noDerivativesTrust200902,
    pre5378Trust200902 * updates can be an RFC number as NNNN *
    obsoletes can be an RFC number as NNNN
-->


<!-- ____________________FRONT_MATTER____________________ -->
<front>
   <title abbrev="BGP Tunnel Flowspec">BGP Dissemination of Flow
   Specification Rules for Tunneled Traffic</title>
   <!--  The abbreviated title is required if the full title is
        longer than 39 characters --> 

   <seriesInfo name="Internet-Draft"
               value="&filename;"/>

   <author fullname="Donald E. Eastlake 3rd" initials="D."
           surname="Eastlake">
     <organization>Independent</organization>
     <address>
       <postal>
         <street>2386 Panoramic Circle</street>
         <city>Apopka</city>
         <region>Florida</region>
         <code>32703</code>
         <country>USA</country>
       </postal>        
       <phone>+1-508-333-2270</phone>
       <email>d3e3e3@gmail.com</email>
     </address>
   </author>

   <author fullname="Weiguo Hao" initials="W."
           surname="Hao">
     <organization>Huawei Technologies</organization>
     <address>
       <postal>
         <street>101 Software Avenue</street>
         <city>Nanjing</city>
         <region>Jiangsu</region>
         <code>210012</code>
         <country>China</country>
       </postal>        
       <email>haoweiguo@huawei.com</email>
     </address>
   </author>

   <author fullname="Shunwan Zhuang" initials="S."
           surname="Zhuang">
     <organization>Huawei Technologies</organization>
     <address>
       <postal>
         <street>Huawei Building, No.156 Beiqing Road</street>
         <city>Beijing</city>
         <code>100095</code>
         <country>China</country>
       </postal>        
       <email>zhuangshunwan@huawei.com</email>
     </address>
   </author>

   <author fullname="Zhenbin Li" initials="Z."
           surname="Li">
     <organization>Huawei Technologies</organization>
     <address>
       <postal>
         <street>Huawei Building, No.156 Beiqing Road</street>
         <city>Beijing</city>
         <code>100095</code>
         <country>China</country>
       </postal>        
       <email>lizhenbin@huawei.com</email>
     </address>
   </author>

   <author fullname="Rong Gu" initials="R."
           surname="Gu">
     <organization>China Mobile</organization>
     <address>
       <email>gurong_cmcc@outlook.com</email>
     </address>
   </author>

   <date year="2024" month="6" day="16"/>

   <area>Routing</area>
   <workgroup>IDR Working Group</workgroup>
   <!-- "Internet Engineering Task Force" is fine for individual
        submissions.  If this element is not present, the default is
        "Network Working Group", which is used by the RFC Editor as a
        nod to the history of the RFC Series. --> 

   <keyword/>
   <!-- Multiple keywords are allowed.  Keywords are incorporated
        into HTML output files for use by search engines. --> 

<abstract>
<t>This draft specifies a Border Gateway Protocol (BGP) Network Layer
Reachability Information (NLRI) encoding format for flow
specifications (RFC 8955) that can match on a variety of tunneled
traffic. In addition, flow specification components are specified for
certain tunneling header fields.</t>
</abstract>

</front>


<!-- ____________________MIDDLE_MATTER____________________ -->
<middle>
    
<section>  <!-- 1. -->
  <name>Introduction</name>
  
<t>BGP Flow Specification (flowspec <xref target="RFC8955"/>) is an
extension to BGP that supports the dissemination of traffic flow
specification rules and actions to be taken on packets matching such
specifications.  It uses the BGP control plane to simplify the
distribution of Access Control Lists (ACLs) and allows new filter
rules to be injected to all BGP peers simultaneously without changing
router configuration. A typical application of BGP flowspec is to
automate the distribution of traffic filter lists to routers for
Distributed Denial of Service (DDOS) mitigation.</t>

<t>BGP flowspec defines BGP Network Layer Reachability Information
(NLRI) formats used to distribute traffic flow specification rules.
AFI=1/SAFI=133 is for IPv4 unicast filtering. AFI=1/SAFI=134 is for
IPv4 BGP/MPLS VPN filtering <xref target="RFC8955"/>. <xref
target="RFC8956"/> and <xref target="FlowSpecL2"/> extend the flowspec
rules for IPv6 and Layer 2 Ethernet packets respectively.  None of
these previously defined flow specifications are suitable for matching
packets in cases of tunneling or encapsulation where there might be
duplicates of a layer of header such as two IPv6 headers in IP-in-IP
<xref target="RFC2003"/> or a nested header sequence such as the Layer
2 and 3 headers encapsulated in VXLAN <xref target="RFC7348"/>.</t>

<t>In the cloud computing era, multi-tenancy has become a core
requirement for data centers. It is increasingly common to see
tunneled traffic with a field to distinguish tenants. An example is
the Network Virtualization Over Layer 3 (NVO3 <xref target="RFC8014"/>)
overlay technology that can satisfy multi-tenancy key
requirements. VXLAN <xref target="RFC7348"/> and NVGRE <xref
target="RFC7637"/> are two typical NVO3 encapsulations.  Other
encapsulations such as IP-in-IP or GRE may be encountered.  Because
these tunnel / overlay technologies involving an additional level of
encapsulation, flow specification that can match on the inner header
as well as the outer header and fields in any tunneling header are
needed.</t>

<t>In summary, Flow Specifications should be able to include inner
nested header information as well as fields specific to the type of
tunneling in use such as virtual network / tenant ID. This draft
specifies methods for accomplishing this using SAFI=77 and a new NLRI
encoding. In addition, flow specification components are specified for
certain tunneling header fields.</t>

<section>
 <name>Terminology</name>

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

<t>The reader is assumed to be familiar with BGP terminology <xref
target="RFC4271"/> <xref target="RFC4760"/>. The following terms and
acronyms are used in this document with the meaning indicated:</t>

<dl>
<dt>ACL</dt><dd>- Access Control List</dd>

<dt>DDoS</dt><dd>- Distributed Denial of Service (Attack)</dd>

<dt>DSCP</dt><dd>- Differentiated Services Code Point <xref
target="RFC2474"/></dd>

<dt>GRE</dt><dd>- Generic Router Encapsulation <xref
target="RFC2890"/></dd>

<dt>L2TPv3</dt><dd>- Layer Two Tunneling Protocol - Version 3 <xref
target="RFC3931"/></dd>

<dt>NLRI</dt><dd>- Network Layer Reachability Information <xref
target="RFC4271"/> <xref target="RFC4760"/></dd>

<dt>NVGRE</dt><dd>- Network Virtualization Using Generic Routing
Encapsulation <xref target="RFC7637"/></dd>

<dt>NVO3</dt><dd>- Network Virtual Overlay Layer 3 <xref
target="RFC8014"/></dd>

<dt>PE</dt><dd>- Provider Edge</dd>

<dt>VN</dt><dd>- virtual network</dd>

<dt>VXLAN</dt><dd>- Virtual eXtensible Local Area Network <xref
target="RFC7348"/></dd>
</dl>

</section>

</section>

<section>  <!-- 2. -->
  <name>Tunneled Traffic Flow Specification NLRI</name>

<t>The Flowspec rules specified in <xref target="RFC8955"/>, <xref
target="RFC8956"/>, and <xref target="FlowSpecL2"/> cannot match or
filter tunneled traffic based on the tunnel type, tunnel header
fields, or headers past the tunnel header. To enable flow
specification of tunneled traffic, a new SAFI (77) and NLRI encoding
are specified. This encoding, shown in Figure 1, enables flow
specification of more than one layer of header when needed.</t>

<figure>
  <name>Tunneled Traffic Flowspec NLRI</name>
  <artwork type="ascii-art" align="center">
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  | Length                          2 octets      |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  | Tunnel Type                     2 octets      |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Flags:
  +--+--+--+--+--+--+--+--+
  | D| I| Reserved        |         1 octet
  +--+--+--+--+--+--+--+--+
Optional Routing Distinguisher:
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  |                                               |
  +                                               +
  |                                               |
  + Routing Distinguisher           8 octets      +
  |                                               |
  +                                               +
  |                                               |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Outer Flowspec:
  +--+--+--+--+--+--+--+--+
  | Outer Flowspec Length ...       1 or 2 octets
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  | Outer Flowspec                  variable      :
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Tunnel Header Flowspec:
  +--+--+--+--+--+--+--+--+
  | Tunnel Flowspec Length ...      1 or 2 octets
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  | Tunnel Header Flowspec          variable      :
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Optional Inner Flowspec:
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  | Inner AFI                       2 octets      |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  | Inner Flowspec Length ...       1 or 2 octets
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  | Inner Flowspec                  variable      :
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  </artwork>
</figure>

<dl>
<dt>Length</dt><dd>- The NLRI Length encoded as an unsigned integer
including the Tunnel Type.</dd>

<dt>Tunnel Type</dt><dd>- The type of tunnel using a value from the
IANA BGP Tunnel Encapsulation Attribute Tunnel Types registry.</dd>

<dt>Flags: D bit</dt><dd>- Indicates the presence of the Routing
Distinguisher (see below).</dd>

<dt>Flags: I bit</dt><dd>- Indicates the presence of the Inner AFI and
the Inner Flowspec (see below).</dd>

<dt>Flags: Reserved</dt><dd>- Six bits that MUST be sent as zero and
ignored on receipt. </dd>

<dt>Routing Distinguisher</dt><dd>- If the outer Layer 3 address
belongs to a BGP/MPLS VPN, the routing distinguisher is included to
indicate traffic filtering within that VPN. Because NVO3 outer layer
addresses normally belong to a public network, a Route Distinguisher
field is normally not needed for NVO3.</dd>

<dt>Outer Flowspec / Length</dt><dd>- The flow specification for the
outer header. The length is encoded as provided in Section 4.1 of
<xref target="RFC8955"/>. The AFI for the Outer Flowspec is the AFI at
the beginning of the BGP multiprotocol MP_REACH_NLRI or
MP_UNREACH_NLRI containing the tunneled traffic flow specification
NLRI.</dd>

<dt>Tunnel Header Flowspec / Length</dt><dd>- The flow specification
for the tunneling header. The length is encoded as provided in Section
4.1 of <xref target="RFC8955"/>. This specifies matching criterion on
tunnel header fields as well as, implicitly, on the tunnel type which
is indicated by the Tunnel Type field above. For some types of
tunneling, such as IP-in-IP, there may be no tunnel header fields. For
other types of tunneling, there may be several tunnel header fields on
which matching can be specified with this flowspec. If a Tunnel Type
has no tunnel header fields or it is not desired to filter on header
fields, the Tunnel Flowspec length field is present but has value
zero. </dd>

<dt>Inner AFI</dt><dd>- Depending on the Tunnel Type, there may be an
Inner AFI that indicate the type of inner flow specification. The
"Inner SAFI" is implicitly 133 for flowspec.</dd>

<dt>Inner Flowspec / Length</dt><dd>- Depending on the Tunnel Type,
there may be an inner flowspec for the header level encapsulated
within the outer header. The length is encoded as provided in Section
4.1 of <xref target="RFC8955"/>.</dd>
</dl>

<t>A Tunneled Traffic Flowspec matches if the Outer Flowspec, Tunnel
Type, and Tunnel Header Flowspec match and, in addition, each of the
following optional items matches if it is present:</t>

<dl>
<dt>-</dt><dd>Inner Flowspec, and</dd>
<dt>-</dt><dd>Routing Distinguisher.</dd>
</dl>

<t>An omitted (as can be done for the Inner Flowspec) or null flowspec
is considered to always match.</t>

<section>  <!-- 2.1 -->
  <name>The SAFI Code Point</name>

<t>Use of the tunneled traffic flow specification NLRI format is
indicated by SAFI=77. This is used in conjunction with the AFI for
the outer header, that is AFI=1 for IPv4, AFI=2 for IPv6, and AFI=6
for Layer 2.</t>

</section>

<section>  <!-- 2.2 -->
  <name>Tunnel Header Component Code Points</name>

<t>For most cases of tunneled traffic, there are tunnel header fields
that can be tested by components that appear in the Tunnel Header
Flowspec field. The types for these components are specified in a
Tunnel Header Flowspec component registry (see Section 6) and the
initial entries in this registry are specified below.</t>

<t>All Tunnel Header field components defined below and all such
components added in the future have a TLV structure as follows:</t>

<dl>
<dt>-</dt><dd>one octet of type followed by</dd>

<dt>-</dt><dd>one octet giving the length of the value part as an
unsigned integer number of octets followed by</dd>

<dt>-</dt><dd>the specific matching operations/values as determined by
the type.</dd>
</dl>

<dl>
<dt>Type 1 -</dt><dd>VN ID</dd>

<dt>Encoding:</dt><dd><t>&lt;type (1 octet), length (1 octet), [op,
value]+&gt;</t>

<t>Defines a list of {operation, value} pairs used to match the 24-bit VN
ID (Virtual Network Identifier) that is used as the tenant
identification in some tunneling headers. For VXLAN and Geneve
encapsulation, the VN ID field is the VNI. For NVGRE encapsulation,
the VN ID is the VSID. op is encoded as specified in Section 4.2.3 of
<xref target="RFC8955"/>. Values are encoded as a 1, 2, or 4 octet
quantity. If value is 24-bits, it is left-justified in the first 3
octets of the value and the last value octet MUST be sent as zero and
ignored on receipt.</t>
</dd>

<dt>Type 2 -</dt><dd>Flow ID</dd>

<dt>Encoding:</dt><dd><t>&lt;type (1 octet), length (1 octet), [op,
value]+&gt;</t> 

<t>Defines a list of {operation, value} pairs used to match 8-bit Flow
ID fields which are currently only useful for NVGRE encapsulation. op
is encoded as specified in Section 4.2.3 of <xref
target="RFC8955"/>. Values are encoded as a 1-octet quantity.</t>
</dd>

<dt>Type 3 -</dt><dd>Session</dd>

<dt>Encoding:</dt><dd><t>&lt;type (1 octet), length (1 octet), [op,
value]+&gt;</t>

<t>Defines a list of {operation, value} pairs used to match a 32-bit
Session field. This field is called Key in GRE <xref target="RFC2890"/>
encapsulation and Session ID in L2TPv3 encapsulation. op is encoded as
specified in Section 4.2.3 of <xref target="RFC8955"/>. Values are
encoded as a 1, 2, or 4 octet quantity; if 1 or 2 octets are provided,
these are right justified and padded on the left with zeros.</t>
</dd>

<dt>Type 4 -</dt><dd>Cookie</dd>

<dt>Encoding:</dt><dd><t>&lt;type (1 octet), length (1 octet), [op,
value]+&gt;</t>

<t>Defines a list of {operation, value} pairs used to match a variable
length Cookie field. This is only useful in L2TPv3 encapsulation. op
is encoded as specified in Section 4.2.3 of <xref
target="RFC8955"/>. Values are encoded as a 1, 2, 4, or 8 octet
quantity. If the Cookie does not fit exactly into the value length, it
is left justified and padded with following octets that MUST be sent
as zero and ignored on receipt.</t>
</dd>

<dt>Type 5 -</dt><dd>Tunnel Header Flags</dd>

<dt>Encoding:</dt><dd><t>&lt;type (1 octet), length (1 octet), [op,
bitmask]+&gt;</t>

<t>Defines a list of {operation, bitmask} pairs used to match against
the tunnel header flags field. op is encoded as in Section 4.2.9 of
<xref target="RFC8955"/>. bitmask is encoded as 1 octet for VXLAN-GPE
and Geneve and as 2 octets for L2TPv3 control messages. When matching
on L2TPv3 control message flags, the 3-bit Version subfield is treated
as if it was zero.</t>
</dd>

<dt>Type 6 -</dt><dd>L2TP Control Version</dd>

<dt>Encoding:</dt><dd><t>&lt;type
(1 octet), length (1 octet), [op, value]+&gt;</t>

<t>Defines a list of {operation, value} pairs used to match against
the L2TP Control Message Version. op is encoded as in Section 4.2.3 of
<xref target="RFC8955"/>. Value is encoded as 1 octet.</t>
</dd>

<dt>Type 7 -</dt><dd>L2TPv3 Control Connection ID</dd>

<dt>Encoding:</dt><dd><t>&lt;type (1 octet), length (1 octet), [op,
value]+&gt;</t>

<t>Defines a list of {operation, value} pairs used to match against
the L2TPv3 Control Connection ID. op is encoded as in Section 4.2.3 of
<xref target="RFC8955"/>. Value is encoded as 4 octets.</t>
</dd>

<dt>Type 8 -</dt><dd>L2TPv3 Ns</dd>

<dt>Encoding:</dt><dd><t>&lt;type (1 octet), length (1 octet), [op,
value]+&gt;</t>

<t>Defines a list of {operation, value} pairs used to match against
the L2TPv3 control message Ns field. op is encoded as in Section 4.2.3
of <xref target="RFC8955"/>. Value is encoded as 2 octets.</t>
</dd>

<dt>Type 9 -</dt><dd>L2TPv3 Nr</dd>

<dt>Encoding:</dt><dd><t>&lt;type (1 octet), length (1 octet), [op,
value]+&gt;</t>

<t>Defines a list of {operation, value} pairs used to match against
the L2TPv3 control message Nr field. op is encoded as in Section 4.2.3
of <xref target="RFC8955"/>. Values are encoded as 2 octets.</t>
</dd>

<dt>Type 10 -</dt><dd>Protocol Type</dd>

<dt>Encoding:</dt><dd><t>&lt;type (1 octet), length (1 octet), [op,
value]+&gt;</t>

<t>Defines a list of {operation, value} pairs used to match against
the GRE and Geneve Protocol Type fields. op is encoded as in Section
4.2.3 of <xref target="RFC8955"/>. Values are encoded as 2 octets.</t>
</dd>

<dt>Type 11 -</dt><dd>GRE Sequence</dd>

<dt>Encoding:</dt><dd><t>&lt;type (1 octet), length (1 octet), [op,
value]+&gt;</t>

<t>Defines a list of {operation, value} pairs used to match against
the GRE Sequence field. op is encoded as in Section 4.2.3 of <xref
target="RFC8955"/>. Values are encoded as a 1, 2, or 4 octet quantity;
if 1 or 2 octets are provided, these are right justified and padded on
the left with zeros.</t>
</dd>

</dl>

</section>

<section>  <!-- 2.3    -->
  <name>Specific Tunnel Types</name>

<t>The following subsections describe how to handle flow specification
for several specific tunnel types.</t>

<section>  <!-- 2.3.1 -->
		<name>VXLAN</name>

<t>The headers on a VXLAN <xref target="RFC7348"/> data packet are an
outer Ethernet header, an outer IP header, a UDP header, the VXLAN
header, and an inner Ethernet header. This inner Ethernet header is
frequently, but not always, followed by an inner IP header. If the
tunnel type is VXLAN, the I flag MUST be set in the Tunneled Traffic
Flow Specification.</t>

<t>If the outer Ethernet header is not being matched, the version
(IPv4 or IPv6) of the outer IP header is indicated by the AFI at the
beginning of the multiprotocol MP_REACH_NLRI or MP_UNREACH_NLRI
containing the Tunneled Traffic Flow Specification NLRI.  The outer
Flowspec is used to filter the outer headers including, if desired,
the UDP header.</t>

<t>If the outer Ethernet header is being matched, then the initial AFI
is 6 <xref target="FlowSpecL2"/> and the Outer Flowspec can match the
outer Ethernet header, specify the IP version of the outer IP header,
and match that IP header including, if desired, the UDP header.</t>

<t>The Tunnel Header Flowspec can be used to filter on the VXLAN
header VN ID (VNI).</t>

<t>The Inner Flowspec can be used on the Inner Ethernet header <xref
target="FlowSpecL2"/> and any following IP header.  If the inner AFI
is 6, then the inner Flowspec provides filtering of the Layer 2
header, indicates whether filtering on a following IPv4 or IPv6 header
is desired, and if it is desired provides the Flowspec components for
that filtering.  If the Inner AFI is 1 or 2, the Inner Ethernet header
is not matched and to match the Flowspec the Inner Ethernet header
must be followed by an IPv4 or IPv6 header, respectively, and the
inner Flowspec is used to filter that inner IP header.</t>

<t>The inner MAC/IP address is associated with the VN ID. In the NVO3
terminating into a VPN scenario, if multiple access VN IDs map to one
VPN instance, one shared VN ID can be carried in the flowspec rule to
enforce the rule on the entire VPN instance and the shared VN ID and
VPN correspondence should be configured on each VPN PE beforehand. In
this case, the function of the Layer 3 VN ID is the same as a Route
Distinguisher: it acts as the identification of the VPN instance.</t>

</section>

<section>  <!-- 2.3.2 -->
  <name>VXLAN-GPE</name>

<t>VXLAN-GPE <xref target="GPE"/> is similar to VXLAN. The VXLAN-GPE
header is the same size as the VXLAN header but has been extended from
the VXLAN header by specifying a number of bits that are reserved in
the VXLAN header. In particular, a number of additional flag bits are
specified and a Next Protocol field is added that is valid if the P
flag bit is set in the VXLAN-GPE header.  These flags bits can be
tested using the Tunnel Header Flags flowspec component defined
above. VXLAN and VXLAN-GPE are distinguished by the port number in the
UDP header that precedes the VXLAN or VXLAN-GPE headers.</t>

<t>If the VXLAN-GPE header P flag is zero, then that header is
followed by the same sequence as for VXLAN and the same flowspec
choices apply (see Section 2.3.1).</t>

<t>If the VXLAN-GPE header P flag is one and that header's next protocol
field is 1, then the VXLAN-GPE header is followed by an IPv4 header
(there is no Inner Ethernet header).  The Inner Flowspec matches only
if the Inner AFI is 1 and the Inner Flowspec matches.</t>

<t>If the VXLAN-GPE header P flag is one and that header's next protocol
field is 2, then the VXLAN-GPE header is followed by an IPv6 header
(there is no Inner Ethernet header).  The Inner Flowspec match only if
the Inner AFI is 2 and the Inner Flowspec matches.</t>

</section>

<section>  <!-- 2.3.3 -->
  <name>NVGRE</name>

<t>NVGRE <xref target="RFC7637"/> is similar to VXLAN except that the
UDP header and VXLAN header immediately after the outer IP header are
replaced by a GRE (Generic Router Encapsulation) header. The GRE
header as used in NVGRE has no Checksum or Reserved1 field as shown in
<xref target="RFC2890"/> but there are Virtual Subnet ID and Flow ID
fields in place of what is labeled in <xref target="RFC2890"/> as the
Key field. Processing and restrictions for NVGRE are as in Section
2.3.1 eliminating references to a UDP header and replacing references
to the VXLAN header and its VN ID with references to the GRE header
and its VN ID (VSID) and Flow ID.</t>

</section>

<section>  <!-- 2.3.4 -->
  <name>L2TPv3</name>

<t>The headers on an L2TPv3 <xref target="RFC3931"/> packets are an
outer Ethernet header, an outer IP header, the L2TPv3 header, an inner
Ethernet header, and possibly an inner IP header if indicated by the
inner Ethernet header EtherType. The Outer Flowspec operates on the
outer headers that precede the L2TPv3 Session Header. The version of
IP in the outer IP header is specified by either the outer AFI at the
beginning of the MP_REACH_NLRI or MP_UNREACH_NLRI or, if that AFI is 6
(L2), optionally specified by the inner AFI within that L2
flowspec.</t>

<t>L2TPv3 data messages and control messages both start with a Session
ID and are distinguished by whether the Session ID is non-zero or
zero, respectively. Data message filtering is further specified in
Section 2.3.4.1 and control message filtering is further specified in
Section 2.3.4.2.</t>

<section> <!-- 2.3.4.1 -->
  <name>L2TPv3 Data Messages</name>

<t>For data messages, the L2TPv3 Session Header consists of a 32-bit
non-zero Session ID followed by a variable length Cookie (maximum
length 8 octets). A Tunnel Header flowspec is assumed to apply to data
messages unless the first component requires a zero Session ID.</t>

<t>The Session ID and Cookie can be filtered on by using the Session
and Cookie flowspec components in the Tunnel Header Flowspec. To
filter on Cookie or even be able to bypass Cookie and parse the
remainder of the L2TPv3 packet, the node implementing tunneled traffic
flowspec needs to know the length and/or value of the Cookie fields of
interest. This is negotiated at L2TPv3 session establishment and it is
out of scope for this document how the node would learn this
information.  Of course, if flowspec is being used for DDOS mitigation
and the Cookie has a fixed length and/or value in the DDOS traffic,
this could be learned by inspecting that traffic.</t>

<t>If the I flag bit is zero, then no filtering is done on data beyond
the L2TPv3 header. If the I flag is one, indicating the presence of an
Inner Flowspec, and the node implementing flowspec does not know the
length of the L2TPv3 header Cookie, the match fails. If that node does
know the length of that Cookie, the Inner Flowspec if matched against
the headers at the beginning of that data using the Inner AFI. If that
Inner AFI is 1 or 2, then an inner IP header is required and filtering
can be done on that IPv4 or IPv6 header respectively. If the Inner AFI
is 6, filtering is done on the inner Ethernet header and, if an IPv4
or IPv6 inner AFI is specified within the inner L2 flowspec, done on
the following IP header <xref target="FlowSpecL2"/>.</t>

</section>

<section>  <!-- 2.3.4.2 -->
  <name>L2TPv3 Control Messages</name>

<t>Control messages are distinguished by starting with a zero value
32-bit Session ID. L2TPv3 control message flowspecs MUST start with a
Session component that requires Session to be zero.  For L2TPv3
control messages, there is no Cookie but there are L2TPv3 flags, a
3-bit Version field, a 32-bit Control Connection ID, and 16-bit Ns and
Nr sequence numbers. These can be tested using the Tunnel Header
Flags, L2TP Control Version, L2TPv3 Control Connection ID, L2TPv3 Ns,
and L2TPv3 Nr flowspec components in the Tunnel Header Flowspec.</t>

</section>
</section>

<section>  <!-- 2.3.5 -->
  <name>GRE</name>

<t>Generic Router Encapsulation (GRE <xref target="RFC2890"/>) is
another type of encapsulation. The Outer Flowspec operates on the
outer headers that precede the GRE header. The version of IP is
specified by the outer AFI at the beginning of the MP_REACH_NLRI or
MP_UNREACH_NLRI.</t>

<t>The Tunnel Header Flags component can be used to match the first
two octets of the GRE header. The Protocol Type component can be used
to match the corresponding GRE header field. The Session and GRE
Sequence components can be used to match on the GRE Key and GRE
Sequence fields if those fields are present respectively. If either of
those fields is not present, a component to match on that field
fails.</t>

<t>If the I flag bit is zero, no filtering is done on data after the
GRE header. If the I flag bit is one in the tunnel flowspec, then
there is an inner AFI and inner flowspec and the Protocol Type field
of the GRE header must correspond to the Inner AFI as follows for the
tunnel Flowspec to match. Otherwise, the match fails.</t>

<table>
  <thead>
<tr><th>GRE Protocol Type</th><th>Inner AFI</th></tr>
  </thead>
  <tbody>
<tr><td>0x0800  (IPv4)</td><td align="center">1</td></tr>
<tr><td>0x86DD  (IPv6)</td><td align="center">2</td></tr>
<tr><td>0x6558</td><td align="center">6</td></tr>
  </tbody>
</table>

<t>With the I flag a one and the Inner AFI and GRE Protocol Type fields
correspond, the Inner Flowspec is used to filter the inner IP headers
(Inner AFI=1 or 2) or the inner Ethernet header and optionally a
following IP header (Inner AFI=6).</t>

</section>

<section>  <!-- 2.3.6 -->
  <name>IP-in-IP</name>

<t>IP-in-IP encapsulation <xref target="RFC2003"/> is indicated when an
outer IP header indicates an inner IP IPv4 or IPv6 header by the value
of the outer IP header's Protocol (IPv4) or Next Protocol (IPv6)
field.</t>

<t>The IP version of the outer IP header (IPv4 or IPv6) matched is
indicated by an AFI of 1 or 2 at the beginning of the MP_REACH_NLRI or
MP_UNREACH_NLRI while if that AFI is 6, it indicates a match on the
outer Ethernet header and, optionally, the following IP Header <xref
target="FlowSpecL2"/>.  The IP version of the inner IP header is
indicated by the Inner AFI and the Inner Flowspec applies to the inner
IP header.</t>

<t>There is no tunnel header so there are no fields that can be
matched by the Tunnel Header Flowspec in the case of IP-in-IP.</t>

</section>

<section>  <!-- 2.3.7 -->
  <name>Geneve</name>

<t>The headers on a Geneve <xref target="RFC8926"/> encapsulated packet
are an outer Ethernet header, an outer IP header, a UDP header, the
Geneve header, and subsequent headers depending on the Geneve header
Protocol Type field.</t>

<t>If the outer Ethernet header is not being matched, the version (IPv4
or IPv6) of the outer IP header is indicated by the AFI at the
beginning of the multiprotocol MP_REACH_NLRI or MP_UNREACH_NLRI
containing the Tunneled Traffic Flow Specification NLRI.  The outer
Flowspec is used to filter the outer headers including, if desired,
the UDP header.</t>

<t>If the outer Ethernet header is being matched, then the initial AFI
is 6 <xref target="FlowSpecL2"/> and the Outer Flowspec can match the
outer Ethernet header, specify the IP version of the outer IP header,
and match that IP header including, if desired, the UDP header.</t>

<t>The Tunnel Header Flowspec can be used to filter on the Protocol Type
field and/or the VNI field in the Geneve header. The flags octet of
the Geneve header, the second octet of that header, can be filtered
using the Tunnel Header Flags component.</t>

<t>If an Inner Flowspec is present, it is used to match the header(s)
after the Geneve header. The Protocol Type field in the Geneve header
must correspond to the Inner AFI as shown in the table in Section
2.3.5 above or the match fails. If the Inner AFI and GRE Protocol Type
fields correspond, the Inner Flowspec is used to filter the inner IP
headers (Inner AFI=1 or 2) or the inner Ethernet header and optionally
a following IP header (Inner AFI=6).</t>

</section>
</section>

<section>  <!-- 2.4 -->
  <name>Tunneled Traffic Actions</name>

<t>The traffic filtering actions previously specified in <xref
target="RFC8955"/> and <xref target="FlowSpecL2"/> are used for
tunneled traffic. For Traffic Marking in NVO3, only the DSCP in the
outer header can be modified.</t>

</section>
</section>

<section>  <!-- 3 -->
  <name>Order of Traffic Filtering Rules</name>

<t>The following rules determine which flowspec takes precedence where
one or more are applicable and at least one of the applicable
flowspecs is a tunneled traffic flowspec:</t>

<ul>
<li>In comparing an applicable tunneled traffic flow specification with
an applicable non-tunneled flow specification, the tunneled
specification has precedence.</li>

<li> If comparing tunneled traffic flow specifications, if all are
applicable, the tunnel types will be the same. Any that have a Routing
Distinguisher will take precedence over those without a Routing
Distinguisher. Of those with a Routing Distinguisher, all applicable
flowspecs will have the same Routing Distinguisher.</li>

<li> At this point in the process, all remaining contenders for the
highest precedence will either not have a Routing Distinguisher or
have equal Routing Distinguishers. If more than one contender remain,
those with an L2 Outer Flowspec take precedence over those with an L3
Outer Flowspec.  If the Outer Flowspec AFI is the same, their order of
precedence is determined by comparing the Outer Flowspecs as described
in <xref target="RFC8955"/> and <xref target="RFC8956"/> for AFI for 1
or 2 respectively or <xref target="FlowSpecL2"/> for AFI=6.</li>

<li> If the Outer Flowspecs are equal, then the Tunnel Header Flowspecs
are compared using the usual sequential component comparison process
<xref target="RFC8955"/>.</li>

<li> If the Tunnel Header Flowspecs are equal then compare the "I" flag.
Those with an Inner Flowspec take precedence over those without an
Inner Flowspec.  If you get to this stage in the ordering process,
those without an Inner Flowspec are equal. For those with an Inner
Flowspec, check the Inner AFI. An L2 Inner AFI (AFI=6) takes
precedence over an L3 Inner AFI.</li>

<li> If the Inner AFIs are equal, precedence is determined by
comparing the Inner Flowspecs as described in <xref
target="FlowSpecL2"/> for L2 or <xref target="RFC8955"/> for L3.</li>
</ul>

</section>

<section>  <!-- 4 -->
  <name>Flow Spec Validation</name>

<t>Flowspecs received over AFI=1/SAFI=77 or AFI=2/SAFI=77 are
validated, using only the Outer Flowspec, against routing reachability
received over AFI=1/SAFI=133 and AFI=2/SAFI=133 respectively, as
modified by <xref target="RFC9117"/>.</t>

</section>

<section>  <!-- 5 -->
  <name>Security Considerations</name>

<t>No new security issues are introduced to the BGP protocol by this
specification.</t>

<t>For general Flowspec security considerations, see <xref
target="RFC8955"/>.</t>

</section>

<section>  <!-- 6 -->
  <name>IANA Considerations</name>

<t>IANA has assigned the following SAFI:</t>

<table>
  <thead>
<tr><th>Value</th><th>Description</th><th>Reference</th></tr>
  </thead>
  <tbody>
<tr><td>77</td><td>Tunneled Traffic Flowspec</td><td>[This
document]</td></tr>
  </tbody>
</table>

<t>IANA is requested to create a "Tunnel Header Flow Spec Component
Type" registry on the Flow Spec Component Types registries web page as
follows:</t>

<dl>
  <dt>Name:</dt><dd>Tunnel Flow Spec Component Types</dd>
  <dt>Reference:</dt><dd>[this document]</dd>
  <dt>Registration Procedures:</dt><dd>
  <table>
    <tbody>
<tr><td align="right">0</td><td>Reserved</td></tr>
<tr><td align="right">1-127</td><td>Specification
Required</td></tr>
<tr><td align="right">128-254</td><td>First Come First
Served</td></tr>
<tr><td align="right">255</td><td>Reserved</td></tr>
    </tbody>
  </table>
</dd>
</dl>

<t>Initial contents:</t>

<table>
  <thead>
<tr><th>Type</th><th>Name</th><th>Reference</th></tr>
  </thead>
  <tbody>
<tr><td align="right">0</td><td>reserved</td><td>[this
document]</td></tr>
<tr><td align="right">1</td><td>VN ID</td><td>[this
document]</td></tr>
<tr><td align="right">4</td><td>Cookie</td><td>[this
document]</td></tr>
<tr><td align="right">5</td><td>Tunnel Header Flags</td><td>[this
document]</td></tr>
<tr><td align="right">6</td><td>L2TP Control Version</td><td>[this
document]</td></tr>
<tr><td align="right">7</td><td>L2TPv3 Control Connection
ID</td><td>[this document]</td></tr>
<tr><td align="right">8</td><td>L2TPv3 Ns</td><td>[this
document]</td></tr>
<tr><td align="right">9</td><td>L2TPv3 Nr</td><td>[this
document]</td></tr>
<tr><td align="right">10</td><td>Protocol Type</td><td>[this
document]</td></tr>
<tr><td align="right">11</td><td>GRE Sequence</td><td>[this
document]</td></tr>
<tr><td align="right">12-254</td><td>unassigned</td><td>[this
document]</td></tr>
<tr><td align="right">255</td><td>reserved</td><td>[this
document]</td></tr>
  </tbody>
</table>

</section>

</middle>

<!-- ____________________BACK_MATTER____________________ -->
<back>

<references>
  <name>Normative References</name>

  <reference anchor="FlowSpecL2"
	     target="https://datatracker.ietf.org/doc/draft-ietf-idr-flowspec-l2vpn/">
    <front>
      <title>Dissemination of Flow Specification Rules for L2
      VPN</title>
   <author fullname="Weiguo Hao" initials="W."
           surname="Hao">
     <organization>Huawei Technologies</organization>
     <address>
       <postal>
         <street>101 Software Avenue</street>
         <city>Nanjing</city>
         <region>Jiangsu</region>
         <code>210012</code>
         <country>China</country>
       </postal>        
       <email>haoweiguo@huawei.com</email>
     </address>
   </author>
   <author fullname="Donald E. Eastlake, 3rd" initials="D."
           surname="Eastlake">
     <organization>Futurewei Technologies</organization>
     <address>
       <postal>
         <street>2386 Panoramic Circle</street>
         <city>Apopka</city>
         <region>Florida</region>
         <code>32703</code>
         <country>USA</country>
       </postal>        
       <phone>+1-508-333-2270</phone>
       <email>d3e3e3@gmail.com</email>
     </address>
   </author>
   <author fullname="Stephane Litkowski" initials="S."
           surname="Litkowski">
     <organization>Cisco Systems, Inc.</organization>
     <address>
        <email>slitkows.ietf@gmail.com</email>
     </address>
   </author>
   <author fullname="Shunwan Zhuang" initials="S."
           surname="Zhuang">
     <organization>Huawei Technologies</organization>
     <address>
       <postal>
         <street>Huawei Building, No.156 Beiqing Road</street>
         <city>Beijing</city>
         <code>100095</code>
         <country>China</country>
       </postal>        
       <email>zhuangshunwan@huawei.com</email>
     </address>
   </author>
    </front>
    <seriesInfo name="Work in" value="progress"/>
</reference>

<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.2003.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.2119.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.2474.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.2890.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.3931.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.4271.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.4760.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.7348.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.7637.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.8174.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.8926.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.8955.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.8956.xml"/>
<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.9117.xml"/>

</references>

<references>
  <name>Informative References</name>

<reference anchor="GPE"
	   target="https://datatracker.ietf.org/doc/html/draft-ietf-nvo3-vxlan-gpe-12">
  <front>
    <title>Generic Protocol Extension for VXLAN</title>
    <author fullname="Fabio Maino" initials="F."
	    surname="Maino">
      <organization>Cisco Systems</organization>
      <address><email>fmaino@cisco.com</email></address>
    </author>
    <author fullname="Larry Kreeger" initials="L."
	    surname="Kreeger">
      <organization>Arrcus</organization>
      <address><email>lkreeger@gmail.com</email></address>
    </author>
    <author fullname="Uri Elzur" initials="U."
	    surname="Elzur">
      <organization>Intel</organization>
      <address><email>uri.elzur@intel.com</email></address>
    </author>
    <date year="2021" month="March" day="26"/>
  </front>
  <seriesInfo name="Work in" value="progress"/>
</reference>

<xi:include
    href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.8014.xml"/>

</references>

<section anchor="Acknowledgements" numbered="false">
  <name>Acknowledgments</name>

<t>The authors wish to acknowledge the important contributions of the
following listed in alphabetic order:</t>

<t>
Jeff Haas, Susan Hares, Yizhou Li, Qiandeng Liang, Greg Mirsky,
Nan Wu, Robert Raszuk, and Lucy Yong
</t>

</section>

</back>

</rfc>
