<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC7606 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7606.xml">
<!ENTITY RFC8174 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8174.xml">
<!ENTITY RFC8955 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8955.xml">
<!ENTITY RFC8956 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8956.xml">
<!ENTITY FLOWSPECV2 SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.hares-idr-flowspec-v2.xml">
<!ENTITY FLOWSPEC-BITS SYSTEM "https://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.haas-flowspec-capability-bits.xml">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- used by XSLT processors -->
<!-- OPTIONS, known as processing instructions (PIs) go here. -->
<!-- For a complete list and description of PIs,
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable PIs that most I-Ds might want to use. -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC): -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="3"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references: -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space: 
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of popular PIs -->
<rfc category="std" docName="draft-haas-idr-flowspec-term-order-00" ipr="trust200902">
  <front>
    <title abbrev="flowspec-term-order">BGP Flowspec Explicit Term Ordering</title>
    <author fullname="Jeffrey Haas" initials="J" surname="Haas">
      <organization>Juniper Networks</organization>
      <address>
        <email>jhaas@juniper.net</email>
      </address>
    </author>
    <author fullname="Susan Hares" initials="S" surname="Hares">
      <organization>Hickory Hill Consulting</organization>
      <address>
        <email>shares@ndzh.com</email>
      </address>
    </author>
    <author fullname="Sven Maduschke" initials="S" surname="Maduschke">
      <organization>Verizon</organization>
      <address>
        <email>sven.maduschke@de.verizon.com</email>
      </address>
    </author>
    <date year="2021"/>
    <area/>
    <workgroup>Inter-Domain Routing</workgroup>
    <!-- <keyword/> -->
    <abstract>
      <t>
	BGP Flowspec (RFC 8955) provides a mechanism for matching traffic flows.  The ordering of
	the Flow Specifications defined by that RFC is provided by a sorting function that uses
	the contents of the received BGP NLRI; that NLRI does not contain an explicit ordering
	component.  The RFC's sorting function permits for origination of Flowspec NLRI from
	multiple BGP Speakers and is generally appropriate for mitigating distributed
	denial-of-service (DDoS) attacks.
      </t>
      <t>
        There are circumstances where the implicit RFC 8955 sorting order is not appropriate.  This
	document defines a mechanism that permits individual Flowspec NLRI to influence their sort
	order.
      </t>
    </abstract>
    <note title="Requirements Language">
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
      "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
      document are to be interpreted as described in BCP 14 <xref target="RFC2119"/> 
      <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t>
    </note>
  </front>
  <middle>
    <section title="Introduction">
      <t>
        BGP Flowspec <xref target="RFC8955"/> creates a mechanism for matching traffic flows and
	taking action upon them.  The BGP Flowspec NLRI format defines multiple components that may
	be used to match such traffic.  Traffic may be matched by more than one BGP Flowpec NLRI,
	either before or after the application of Traffic Filtering Actions (Section 7, 
	<xref target="RFC8955"/>).
      </t>
      <t>
        <xref target="RFC8955"/> does not provide for a mechanism where the originator of a BGP
	Flowspec NLRI can influence its processing order.  Section 5.1 of <xref target="RFC8955"/>
	provides for a sorting function on a BGP Speaker defining the processing order of received
	BGP Flowspec NLRI.  That sorting mechanism permits multiple BGP Speakers in a Flowspec
	domain to originate Flowspec NLRI without coordinating the processing order at a given BGP
	Speaker.
      </t>
      <t>
        That sorting order is generally appropriate for mitigating distributed denial-of-service
	attacks (DDoS).  Flow specification rules first match on related destinations, followed by
	sources, and then later a well-defined set of components.  Longer sets of components are
	considered a better match, and thus "more specific" in many cases.
      </t>
      <t>
        While this sort order has generally worked well for DDoS mitigation, sometimes the implicit
	ordering is problematic.  Some of these problems are implementation specific: Long rule sets
	might be better sorted into higher impact filters near the top of the list.  Mixtures of
	rules that are otherwise independent are sorted in such a way that firewall optimizations
	are not efficiently run.
      </t>
      <t>
        Some initial discussion has begun for a version 2 of Flowspec in 
	<xref target="I-D.hares-idr-flowspec-v2"/>.  Part of that proposal is a mechanism to provide
	for explicit rule ordering as part of the Flowspec v2 NLRI.
      </t>
      <t>
	This document proposes an alternative mechanism to provide for such explicit rule ordering
	with a minor extension to Flowspec v1.
      </t>
    </section>
    <section title="Term Order Component Type">
      <section title="Type 0 - Term Order">
        <t>
	  Encoding: &lt;type (1 octet), length (1 octet), term order (variable)&gt;
	</t>
	<t>
	  Defines the relative term order for this BGP Flowspec NLRI.
	</t>
	<t>
	  The value of the length MUST be 1, 2, or 4.  The length SHOULD be chosen to be the
	  smallest possible value to properly encode the term order value.
	</t>
      </section>
      <section title="Discussion">
        <t>
          The choice of Component Type 0, currently RESERVED by <xref target="RFC8955"/>, is intended
	  to be minimally disruptive to the sorting function and deployed code for BGP Flowspec.
	  Consider the following text from Section 5.1 of that RFC:
  
         <list><t>
           "The relative order of two Flow Specifications is determined by
           comparing their respective components.  The algorithm starts by
           comparing the left-most components (lowest component type value) of
           the Flow Specifications.  If the types differ, the Flow Specification
           with lowest numeric type value has higher precedence (and thus will
           match before) than the Flow Specification that doesn't contain that
           component type.  If the component types are the same, then a 
	   type-specific comparison is performed (see below).  If the types are
           equal, the algorithm continues with the next component."
          </t></list>
        </t>
        <t>
	  By using Component Type 0, the ability to bias sort order is provided without a change to
	  the remaining sorting semantics used by <xref target="RFC8955"/> and other proposals.
        </t>
      </section>
    </section>

    <section title="Operation">
      <t>
        The term order value, when present in a BGP Flowspec NLRI, is intended to provide a logical
	order to that NLRI vs. other NLRI with that component.  A lower term order value has a
	higher precedence than a higher term order value.
      </t>
      <t>
        A BGP Flowspec NLRI with no term order component is considered to be lower precedence versus
	a BGP Flowspec NLRI with a term order component.  This is consistent with existing BGP
	Flowspec sorting rules.
      </t>
      <t>
        The same term order value MAY occur more than once in a set of BGP Flowspec NLRI.
      </t>
      <t>
        The term order value is not intended to supplant the ordering mechanism for a firewall
	implementation.  Its only purpose is to provide for biasing the sorting of received BGP
	Flowspec NLRI.
      </t>
      <section title="Incremental Deployment">
        <t>
	  <xref target="I-D.haas-flowspec-capability-bits"/> is required to deploy this feature for
	  Flowspec v1.  When a BGP Speaker wishes to use, originate, or propagate BGP Flowspec NLRI
	  with the term order component, that BGP Speaker MUST advertise the BGP Flowspec Capability
	  Bits with bit 0 set to a value of 1.
	</t>
      </section>
    </section>
    <section title="Error Handling">
      <t>
        A BGP Flowpsec Term Order Component with a length that is not 1, 2, or 4 is considered
	syntactically incorrect per Section 5.3 of <xref target="RFC7606"/>.  Upon receiving such
	syntactically incorrect NLRI, the BGP session SHALL be reset by sending a NOTIFICATION
	message.
      </t>
    </section>
    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>
        TBD.
      </t>
    </section>
    <section title="Security Considerations">
      <t>
        All of the Security Considerations for 
	<xref target="RFC8955"/> and <xref target="RFC8956"/>
	still apply.
      </t>
      <t>
        This feature provides for the ability to bias the installed filter order of BGP Flow
	Specification NLRI.  The default sort order provided by <xref target="RFC8955"/> serves to
	cluster rules targeting traffic for a given destination and/or source.  By providing an
	ability to alternatively order such rules, more general rules impacting more traffic may
	have precedence.  
      </t>
      <t>
	Operators must take sufficient care to ensure that such more general rules
	are considered systematically in the deployment.  This may include the ability to prohibit
	rules with a term order outside of a specific value range from being accepted.
      </t>
      <t>
	Operators may wish to prohibit other ASes from originating or propagating BGP Flowspec NLRI
	with the term order component, even while exercising the Validation Procedures of Section 6
	of <xref target="RFC8955"/>.
      </t>
    </section>
    <section title="IANA Considerations">
      <t>
	Upon approval of this document as an RFC, IANA is requested to assign Type Value 0
	from the 
	<eref target="https://www.iana.org/assignments/flow-spec/flow-spec.xhtml">IANA Flow Spec
	Component Types registry</eref>.  The IPv4 Name and IPv6 name for Type 0 will be "Term
	Order".  The Reference will be this document.
      </t>
    </section>
  </middle>
  <back>
    <references title="Normative References">
      &RFC2119;
      &RFC7606;
      &RFC8174;
      &RFC8955;
      &RFC8956;
      &FLOWSPEC-BITS;
    </references>
    <references title="Informative References">
      &FLOWSPECV2;
    </references>
    <section title="Open Issues">
      <t>
        <list style="symbols">
	<t>
	  After sufficient discussion has been given to this proposal, update the python pseudocode
	  example to include interaction with this feature.
	</t>
	</list>
      </t>
    </section>
  </back>
</rfc>
