<?xml version="1.0" encoding="utf-8"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
     which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629-xhtml.ent">
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs), 
     please see http://xml.resource.org/authoring/README.html. -->
<?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 list of popular I-D processing instructions -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" category="std" docName="draft-wu-idr-flowspec-dip-community-filter-00" ipr="trust200902" consensus="true" submissionType="IETF">
  <front>
    <title abbrev="Destination-IP-Community Filter">Destination-IP-Community
    Filter for BGP Flow Specification</title>

    <author fullname="Tianhao Wu" initials="T." surname="Wu">
      <organization>Huawei</organization>
      <address>
        <email>wutianhao10@huawei.com</email>
      </address>
    </author>
    <author fullname="Jun Ge" initials="J." surname="Ge">
      <organization>Huawei</organization>
      <address>
        <email>jack.gejun@huawei.com</email>
      </address>
    </author>
    <author fullname="Xiangfeng Ding" initials="X." surname="Ding">
      <organization>Huawei</organization>
      <address>
        <email>dingxiangfeng@huawei.com</email>
      </address>
    </author>
    <author fullname="Haibo Wang" initials="H." surname="Wang">
      <organization>Huawei</organization>
      <address>
        <email>rainsword.wang@huawei.com</email>
      </address>
    </author>

    <date day="28" month="February" year="2024"/>

    <!---->

    <abstract>
      <t>BGP Flowspec mechanism (BGP-FS) propagates both traffic Flow Specifications and
      Traffic Filtering Actions by making use of the BGP NLRI and the BGP
      Extended Community encoding formats. This document specifies a new
      BGP-FS component type to support community-level filtering. The match 
      field is the community of the destination IP address that is encoded in
      the Flowspec NLRI. This function is applied in a single administrative
      domain.</t>
    </abstract>

    <note title="Requirements Language">
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
      "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
      document are to be interpreted as described in <xref
      target="RFC2119"/>.</t>
    </note>
  </front>

  <middle>
    <section title="Introduction">
      <t>BGP Flow Specification (BGP-FS) <xref target="RFC8955"/> <xref
      target="RFC8956"/> defines a new BGP NLRI to distribute traffic flow
      specification rules via BGP (<xref target="RFC4271"/>). BGP-FS policies
      have a match condition that may be n-tuple match in a policy, and an
      action that modifies the packet and forwards/drops the packet. Via BGP,
      new filter rules can be sent to all BGP peers simultaneously without
      changing router configuration, and the BGP peer can install these routes
      in the forwarding table. BGP-FS defines Network Layer Reachability
      Information (NLRI) format used to distribute traffic flow specification
      rules. NLRI (AFI=1, SAFI=133) is for IPv4 unicast filtering. NLRI
      (AFI=1, SAFI=134) is for BGP/MPLS VPN filtering.<xref
      target="I-D.ietf-idr-flowspec-l2vpn"/> 
      extends the flow-spec rules for layer 2 Ethernet packets.</t>

      <t>This document specifies a new BGP-FS component type to support
      community-level filtering. The match field is the community of the
      destination IP address that is encoded in the Flowspec NLRI. This
      function is applied in a single administrative domain.</t>

      <t/>
    </section>

    <section title="Definitions and Acronyms">
      <t><list style="symbols">
          <t>FS: Flow Specification</t>

          <t>Destination-IP-Community: The community of the destination
          IP address</t>
        </list></t>
    </section>

    <section title="The Flow Specification Encoding for Destination-IP-Community Filter">
      <t>This document proposes a new flow specification component type that
      is encoded in the BGP Flowspec NLRI. The following new component type is
      defined.</t>

      <t><list style="symbols">
          <t>Destination-IP-Community</t>
        </list></t>

      <t>Type TBD1 - Destination-IP-Community</t>

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

      <t>Contains a set of {operator, value} pairs that are used to match the
      Destination-IP-Community (i.e. the community of the destination
      IP address).</t>

      <t>The operator byte is encoded as:</t>

      <t><figure align="center">
          <artwork><![CDATA[    0   1   2   3   4   5   6   7
  +---+---+---+---+---+---+---+---+ 
  | e | a |  len  | 0 |lt |gt |eq | 
  +---+---+---+---+---+---+---+---+

 Figure 1: Numeric Operator (numeric_op)
]]></artwork>
        </figure></t>

      <t>Where:</t>

      <t>e - end-of-list bit. Set in the last {op, value} pair in the
      list.</t>

      <t>a - AND bit. If unset, the previous term is logically ORed with the
      current one. If set, the operation is a logical AND. It MUST be unset in
      the Destination-IP-Community filter.</t>

      <t>len - The length of the value field for this operator given as (1
      &lt;&lt; len). This encodes 1 (len=00), 2 (len=01), 4 (len=10), and 8
      (len=11) octets.</t>

      <t>lt - less than comparison between data and value.</t>

      <t>gt - greater than comparison between data and value.</t>

      <t>eq - equality between data and value.</t>

      <t>The bits lt, gt, and eq can be combined to produce match the
      Destination-IP-Community filter or a range of Destination-IP-Community
      filter(e.g. less than community 1 and greater than community 2).</t>

      <t>The value field is encoded as:</t>

      <t><figure align="center">
          <artwork><![CDATA[   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
  +---------------------------------------------------------------+
  ~          Destination-IP-Community  (4 octets)                 ~
  +---------------------------------------------------------------+

      Figure 2: Destination-IP-Community
]]></artwork>
        </figure></t>

      <t>Per section 10 of <xref target="RFC8955"/> , If a receiving BGP
      speaker cannot support this new Flow Specification component type, it
      MUST discard the NLRI value field that contains such unknown components.
      Since the NLRI field encoding (Section 4 of <xref target="RFC8955"/>) is
      defined in the form of a 2-tuple &lt;length, NLRI value&gt;, message
      decoding can skip over the unknown NLRI value and continue with
      subsequent remaining NLRI.</t>

      <t/>
    </section>

    <section title="Use Cases">
      <t>This section describes how to use this function in a simple scenario.
      Considering the topology shown in Figure 3 ("Comm" is short for "Community").
      In AS64597's R1, if the ISP AS64597 wants to redirect all packets originating
      from IP Prefix 61 to AS64598 and AS64599:</t>

      <t>"first go to R3", the ISP AS64597 can
      use the traditional method or the method defining in this draft.</t>

      <t/>

      <t><figure align="center">
          <artwork><![CDATA[                         +---------+
                         | BGP FS  |
                         | Server  |
                         +----|----+
                              |
                              |
                              /
                             /
                ************/************  
                *          /            *  
  IP Prefix 61  *         / AS64597     *  IP Prefix 81 with Comm 1:1
                *        /              *  IP Prefix 82 with Comm 1:1
   +-------+    *  +---+/        +---+  *   +-------+
   +AS64596+-------+ R1+---------+ R2|------+AS64598+
   +-------+    *  +-+-+\        +---+  */  +-------+
                *        \         |\   /
                *         \        | \ /*  
                *          \       |  /\*  
                *           \      | /  \  IP Prefix 91 with Comm 1:1
                *            \     |/   *\ IP Prefix 92 with Comm 1:1
                *             \  +-+-+  * \ +-------+
                *              \-+ R3+------+AS64599+
                *                +---+  *   +-------+
                *                       *
                *************************
      Figure 3: Redirect the traffic using Flowspec

]]></artwork>
        </figure></t>

      <t>Using the traditional method, the ISP AS64597 needs to setup multiple
      "Destination Prefix + Source Prefix" rules in Router R1 as
      following:</t>

      <t><figure align="center">
          <artwork><![CDATA[    +--------------+--------------+-------------------------+
    | Destination  | Source Prefix| Redirect to IP Nexthop  |
    | Prefix       |              |                         |
    +--------------+--------------+-------------------------+
    | IP Prefix 81 | IP Prefix 61 |           R3            |
    +--------------+--------------+-------------------------+
    | IP Prefix 82 | IP Prefix 61 |           R3            |
    +--------------+--------------+-------------------------+
    | IP Prefix 91 | IP Prefix 61 |           R3            |
    +--------------+--------------+-------------------------+
    | IP Prefix 92 | IP Prefix 61 |           R3            |
    +--------------+--------------+-------------------------+
    |                  More ...                             |
    +--------------+--------------+-------------------------+

  Figure 4: Using the traditional method to redirect the traffic

]]></artwork>
        </figure></t>

      <t>Using the method defining in this draft, the ISP AS64597 needs to
      setup only one "Destination Community + Source Prefix" rule in Router R1
      as following:</t>

      <t><figure align="center">
          <artwork><![CDATA[  +--------------+--------------+-------------------------+
  | Destination  | Source Prefix| Redirect to IP Nexthop  |
  | Community    |              |                         |
  +--------------+--------------+-------------------------+
  |     1::1     | IP Prefix 61 |           R3            |
  +--------------+--------------+-------------------------+

  Figure 5: Using the community-level filtering method to redirect the traffic

]]></artwork>
        </figure></t>

      <t>Obviously, the new method defining in this draft saves a lot of entry
      spaces on the control plane and forwarding plane, and it would greatly
      simplify the operation of the control plane, and the more destination
      prefixes with the same community has, the more obvious the benefit.</t>

      <t/>
    </section>

    <section title="IANA Considerations">
      <t>IANA is requested to a new entry in "Flow Spec component types
      registry" with the following values:</t>

      <t><figure align="center">
          <artwork><![CDATA[   +---------+--------------+---------------------------------+
   |   Type  | RFC or Draft |    Description                  |
   +---------+--------------+---------------------------------+
   |   TBD1  |  This Draft  |    Destination-IP-Community     |
   +---------+--------------+---------------------------------+
  
]]></artwork>
        </figure></t>
    </section>

    <section anchor="Security Considerations" title="Security Considerations">
      <t>No new security issues are introduced to the BGP protocol by this
      specification.</t>

      <t/>
    </section>

  </middle>

  <back>
    <references title="Normative References">
      <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
        <front>
          <title>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author fullname="S. Bradner" initials="S." surname="Bradner"/>
          <date month="March" year="1997"/>
          <abstract>
          <t>In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="2119"/>
        <seriesInfo name="DOI" value="10.17487/RFC2119"/>
      </reference>
    </references>
    <references title="Informative References">
      <reference anchor="RFC4271" target="https://www.rfc-editor.org/info/rfc4271">
        <front>
          <title>A Border Gateway Protocol 4 (BGP-4)</title>
          <author fullname="Y. Rekhter" initials="Y." role="editor" surname="Rekhter"/>
          <author fullname="T. Li" initials="T." role="editor" surname="Li"/>
          <author fullname="S. Hares" initials="S." role="editor" surname="Hares"/>
          <date month="January" year="2006"/>
          <abstract>
          <t>This document discusses the Border Gateway Protocol (BGP), which is an inter-Autonomous System routing protocol.</t>
          <t>The primary function of a BGP speaking system is to exchange network reachability information with other BGP systems. This network reachability information includes information on the list of Autonomous Systems (ASes) that reachability information traverses. This information is sufficient for constructing a graph of AS connectivity for this reachability from which routing loops may be pruned, and, at the AS level, some policy decisions may be enforced.</t>
          <t>BGP-4 provides a set of mechanisms for supporting Classless Inter-Domain Routing (CIDR). These mechanisms include support for advertising a set of destinations as an IP prefix, and eliminating the concept of network "class" within BGP. BGP-4 also introduces mechanisms that allow aggregation of routes, including aggregation of AS paths.</t>
          <t>This document obsoletes RFC 1771. [STANDARDS-TRACK]</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="4271"/>
        <seriesInfo name="DOI" value="10.17487/RFC4271"/>
      </reference>
      <reference anchor="RFC8955" target="https://www.rfc-editor.org/info/rfc8955">
        <front>
          <title>Dissemination of Flow Specification Rules</title>
          <author fullname="C. Loibl" initials="C." surname="Loibl"/>
          <author fullname="S. Hares" initials="S." surname="Hares"/>
          <author fullname="R. Raszuk" initials="R." surname="Raszuk"/>
          <author fullname="D. McPherson" initials="D." surname="McPherson"/>
          <author fullname="M. Bacher" initials="M." surname="Bacher"/>
          <date month="December" year="2020"/>
          <abstract>
          <t>This document defines a Border Gateway Protocol Network Layer Reachability Information (BGP NLRI) encoding format that can be used to distribute (intra-domain and inter-domain) traffic Flow Specifications for IPv4 unicast and IPv4 BGP/MPLS VPN services. This allows the routing system to propagate information regarding more specific components of the traffic aggregate defined by an IP destination prefix.</t>
          <t>It also specifies BGP Extended Community encoding formats, which can be used to propagate Traffic Filtering Actions along with the Flow Specification NLRI. Those Traffic Filtering Actions encode actions a routing system can take if the packet matches the Flow Specification.</t>
          <t>This document obsoletes both RFC 5575 and RFC 7674.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="8955"/>
        <seriesInfo name="DOI" value="10.17487/RFC8955"/>
      </reference>
      <reference anchor="RFC8956" target="https://www.rfc-editor.org/info/rfc8956">
        <front>
          <title>Dissemination of Flow Specification Rules for IPv6</title>
          <author fullname="C. Loibl" initials="C." role="editor" surname="Loibl"/>
          <author fullname="R. Raszuk" initials="R." role="editor" surname="Raszuk"/>
          <author fullname="S. Hares" initials="S." role="editor" surname="Hares"/>
          <date month="December" year="2020"/>
          <abstract>
          <t>"Dissemination of Flow Specification Rules" (RFC 8955) provides a Border Gateway Protocol (BGP) extension for the propagation of traffic flow information for the purpose of rate limiting or filtering IPv4 protocol data packets.</t>
          <t>This document extends RFC 8955 with IPv6 functionality. It also updates RFC 8955 by changing the IANA Flow Spec Component Types registry.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="8956"/>
        <seriesInfo name="DOI" value="10.17487/RFC8956"/>
      </reference>
      <reference anchor="I-D.ietf-idr-flowspec-l2vpn" target="https://datatracker.ietf.org/doc/html/draft-ietf-idr-flowspec-l2vpn-22">
        <front>
          <title>BGP Dissemination of L2 Flow Specification Rules</title>
          <author initials="H." surname="Weiguo" fullname="Hao Weiguo">
          <organization>Huawei Technologies</organization>
          </author>
          <author initials="D. E." surname="Eastlake" fullname="Donald E. Eastlake 3rd">
          <organization>Futurewei Technologies</organization>
          </author>
          <author initials="S." surname="Litkowski" fullname="Stephane Litkowski">
          <organization>Cisco Systems, Inc.</organization>
          </author>
          <author initials="S." surname="Zhuang" fullname="Shunwan Zhuang">
          <organization>Huawei Technologies</organization>
          </author>
          <date month="October" day="16" year="2023"/>
          <abstract>
          <t> This document defines a Border Gateway Protocol (BGP) Flow Specification (flowspec) extension to disseminate Ethernet Layer 2 (L2) and Layer 2 Virtual Private Network (L2VPN) traffic filtering rules either by themselves or in conjunction with L3 flowspecs. AFI/ SAFI 6/133 and 25/134 are used for these purposes. New component types and two extended communities are also defined. </t>
          </abstract>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-ietf-idr-flowspec-l2vpn-22"/>
      </reference>
    </references>
  </back>
</rfc>
