<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
     which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?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 category="std" docName="draft-wu-idr-flowspec-sip-community-filter-02"
     ipr="trust200902" submissionType="IETF">
  <front>
    <title abbrev="Source-IP-Community Filter">Source-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="Haibo Wang" initials="H." surname="Wang">
      <organization>Huawei</organization>

      <address>
        <email>rainsword.wang@huawei.com</email>
      </address>
    </author>

    <author fullname="Shunwan Zhuang" initials="S." surname="Zhuang">
      <organization>Huawei</organization>

      <address>
        <email>zhuangshunwan@huawei.com</email>
      </address>
    </author>

    <author fullname="Jie Dong" initials="J." surname="Dong">
      <organization>Huawei</organization>

      <address>
        <postal>
          <street>156 Beiqing Road</street>

          <city>Beijing</city>

          <code>100095</code>

          <country>P.R. China</country>
        </postal>

        <email>jie.dong@huawei.com</email>
      </address>
    </author>

    <author fullname="Yang Huang" initials="Y." surname="Huang">
      <organization>Huawei</organization>

      <address>
        <postal>
          <street>156 Beiqing Road</street>

          <city>Beijing</city>

          <code>100095</code>

          <country>P.R. China</country>
        </postal>

        <email>yang.huang@huawei.com</email>
      </address>
    </author>

    <date day="31" month="August" year="2026"/>

    <area>Routing</area>

    <workgroup>IDR Working Group</workgroup>

    <!---->

    <abstract>
      <t>BGP Flow Specification (BGP-FS) propagates traffic Flow
      Specifications and Traffic Filtering Actions using BGP NLRI and BGP
      Extended Community encodings. This document specifies a new BGP-FS
      component type to support community-level filtering within a single
      administrative domain. The match condition filters traffic based on the
      BGP Community attributes associated with the route matching the packet's
      source IP address.</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 title="Introduction">
      <t>BGP Flow Specification (BGP-FS) <xref target="RFC8955"/> <xref
      target="RFC8956"/> defines a BGP NLRI format to distribute traffic flow
      specification rules. A BGP- FS policy consists of match conditions (an
      n-tuple match) and actions that filter, rate-limit, or redirect packets.
      By leveraging BGP, filter rules can be disseminated to peers
      simultaneously without requiring manual router reconfigurations.</t>

      <t>In large-scale networks, operators frequently group ingress traffic
      by assigning BGP Communities to the advertised source prefixes. When
      implementing edge filtering or traffic redirection based on source
      origins, defining rules using individual Source IP Prefixes leads to
      NLRI bloat and forwarding table scale issues.</t>

      <t>This document specifies a new BGP-FS component type, Source-IP-
      Community, to support community-level traffic filtering. Rather than
      matching a raw field in the IP header, this component matches the BGP
      Community attribute associated with the Locating Route (or RIB/FIB
      entry) corresponding to the packet's Source IP address. This mechanism
      is intended for deployment within a single administrative domain.</t>
    </section>

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

          <t>Source-IP-Community: The BGP Community (Standard, Extended, or
          Large) associated with the BGP route that best matches the source IP
          address of the incoming packet.</t>
        </list></t>
    </section>

    <section title="The Flow Specification Encoding for Source-IP-Community Filter">
      <t>This document defines a new Flow Specification component type encoded
      within the BGP-FS NLRI:</t>

      <t><list style="symbols">
          <t>Type TBD1 - Source-IP-Community</t>
        </list></t>

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

      <t>This component contains a set of {operator, value} pairs used to
      match the Source-IP-Community.</t>

      <t>The operator byte (numeric_op) is encoded as defined in Section 4.2.1
      of <xref target="RFC8955"/>:</t>

      <t><figure anchor="numeric_op" title="Numeric Operator (numeric_op)">
          <artwork align="center"><![CDATA[
    0   1   2   3   4   5   6   7
  +---+---+---+---+---+---+---+---+ 
  | e | a |  len  | 0 |lt |gt |eq | 
  +---+---+---+---+---+---+---+---+
]]></artwork>
        </figure></t>

      <t>Where:</t>

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

      <t>a - AND bit. If unset, the logical operation with the previous term
      is OR. If set, the operation is AND. For the Source-IP-Community filter,
      the 'a' bit MUST be unset (0) unless matching multi-value community
      sets.</t>

      <t>len - Length of the value field encoded as (1 &lt;&lt; len). Valid
      lengths for Standard BGP Communities [RFC1997] are 4 octets (len=10).
      Future extensions MAY support 8 octets (Extended) or 12 octets (Large
      Communities).</t>

      <t>lt, gt, eq - Less than, Greater than, and Equality comparison
      bits.</t>

      <t>The value field contains the BGP Community value to match:</t>

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

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

      <t>If a receiving BGP speaker does not support this component type, it
      MUST handle the unknown component in accordance with Section 10 of <xref
      target="RFC8955"/> (i.e., treating the NLRI as unparseable or handling
      it per the extended error handling rules).</t>

      <t/>

      <section title="Operational and Processing Mechanism">
        <t>The implementation of Source-IP-Community filtering relies on a
        cross-coupling mechanism between the Unicast BGP Forwarding Table
        (FIB) and the Flowspec Packet Inspection Engine. The detailed
        processing workflow is defined in the following three steps:</t>

        <t><list style="numbers">
            <t>Control-Plane Community Dissemination and FIB Tagging: When a
            BGP speaker receives unicast BGP routes carrying BGP Communities
            (e.g., Standard, Extended, or Large Communities), and those routes
            are selected as best paths and installed into the Forwarding
            Information Base (FIB), the local system MUST preserve the
            associated BGP Community attributes (or a local mapped metadata
            tag representing the Community) within the corresponding FIB
            entries. For example:<list style="symbols">
                <t>FIB Entry for Source Prefix A: Tagged with Community
                64597:1</t>

                <t>FIB Entry for Source Prefix B: Tagged with Community
                64597:2</t>
              </list></t>

            <t>Flowspec Rule Installation: When a BGP Flowspec rule containing
            the Source-IP-Community component is received, the system programs
            a filtering rule into the forwarding hardware. The match
            parameters include both standard RFC 8955/8956 n-tuples (e.g.,
            Destination IP, Source IP, Protocol, Port) and the target
            Community value specified in the Source-IP-Community component
            (denoted as COMM_Rule, e.g., 64597:1).</t>

            <t>Datapath Two-Stage Packet Matching:<list style="empty">
                <t>Upon receiving a data packet:<list style="letters">
                    <t>The device evaluates the packet against installed
                    Flowspec rules.</t>

                    <t>If a candidate rule contains a Source-IP-Community
                    match condition, the forwarding engine performs a FIB
                    lookup using the packet's Source IP address to extract the
                    associated FIB entry's Community attribute (denoted as
                    COMM_FIB).</t>

                    <t>Evaluation:<list style="symbols">
                        <t>If COMM_FIB matches COMM_Rule (e.g., both are
                        64597:1), the Source-IP-Community match condition is
                        satisfied, and the configured Flowspec action (e.g.,
                        redirect, drop, rate-limit) is executed.</t>

                        <t>If COMM_FIB does not match COMM_Rule (e.g.,
                        COMM_FIB is 64597:2 while COMM_Rule is 64597:1), the
                        match condition fails, and packet processing continues
                        to subsequent rules or default forwarding.</t>
                      </list></t>
                  </list></t>
              </list></t>
          </list></t>
      </section>
    </section>

    <section title="Use Cases">
      <t>Consider the topology shown in Figure 3. An operator in AS64597 wants
      to redirect all traffic originating from AS64598 (whose source prefixes
      are tagged with BGP Community 64597:1) towards Destination IP Prefix 61,
      forcing the traffic to be routed via Router R3.</t>

      <t>Operational Steps:</t>

      <t><list style="numbers">
          <t>Router R2 receives routes for IP Prefixes 81, 82, 83, and 84 with
          Community 64597:1 from AS64598. When R2 populates its FIB, it stores
          the Community value (64597:1) along with each source prefix
          entry.</t>

          <t>The BGP FS Server issues a single Flowspec rule to Router
          R2:<list style="symbols">
              <t>Match Condition: Destination Prefix = IP Prefix 61,
              Source-IP-Community = 64597:1</t>

              <t>Action: Redirect to R3 (IP Nexthop of R3)</t>
            </list></t>

          <t>When R2 receives a packet with Source IP = Prefix 81 and
          Destination IP = Prefix 61:<list style="symbols">
              <t>R2 checks the Flowspec rule.</t>

              <t>R2 queries its FIB using Source IP (Prefix 81) and retrieves
              the stored Community value (64597:1).</t>

              <t>Since the retrieved Community (64597:1) matches the rule's
              Source-IP-Community parameter (64597:1), the rule is triggered,
              and the packet is redirected to R3.</t>
            </list></t>
        </list></t>

      <t><figure anchor="Redirect_the_traffic_using_Flowspec"
          title="Redirect the traffic using Flowspec">
          <artwork align="center"><![CDATA[
                         +---------+
                         | BGP FS  |
                         | Server  |
                         +----|----+
                              |
                              |
                              +
                               \
                ****************\********  IP Prefix 81 w/ Comm 64597:1
                *                \      *  IP Prefix 82 w/ Comm 64597:1
  IP Prefix 61  *        AS64597  \     *  IP Prefix 83 w/ Comm 64597:1
                *                  \    *  IP Prefix 84 w/ Comm 64597:1
   +-------+    *  +---+         +--\+  *   +-------+
   +AS64596+-------+ R1+---------+ R2|------+AS64598+
   +-------+    *  +-+-+\        +---+  */  +-------+
                *        \         |\   /
                *         \        | \ /*  IP Prefix 91 w/ Comm 64597:2
                *          \       |  /\*  IP Prefix 92 w/ Comm 64597:2
                *           \      | /  \  IP Prefix 93 w/ Comm 64597:2
                *            \     |/   *\ IP Prefix 94 w/ Comm 64597:2
                *             \  +-+-+  * \ +-------+
                *              \-+ R3+------+AS64599+
                *                +---+  *   +-------+
                *                       *
                *************************

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

      <t>Using traditional BGP-FS, AS64597 must inject explicit rules pairing
      each Source Prefix with Destination Prefix 61:</t>

      <t><figure anchor="Using_the_traditional_method"
          title="Using the traditional method to redirect the traffic">
          <artwork align="center"><![CDATA[
    +--------------+--------------+-------------------------+
    | source       | Destination  | Redirect to IP Nexthop  |
    | Prefix       | Prefix       |                         |
    +--------------+--------------+-------------------------+
    | IP Prefix 81 | IP Prefix 61 |           R3            |
    +--------------+--------------+-------------------------+
    | IP Prefix 82 | IP Prefix 61 |           R3            |
    +--------------+--------------+-------------------------+
    | IP Prefix 83 | IP Prefix 61 |           R3            |
    +--------------+--------------+-------------------------+
    | IP Prefix 84 | IP Prefix 61 |           R3            |
    |                  More ...                             |
    +--------------+--------------+-------------------------+

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

      <t>With the Source-IP-Community filter defined in this document, AS64597
      only needs to advertise a single Flowspec rule on Router R2:</t>

      <t><figure anchor="Using_the_Community-level_filtering_method"
          title="Using the community-level filtering method to redirect the traffic">
          <artwork align="center"><![CDATA[
  +--------------+--------------+-------------------------+
  | Source       | Destination  | Redirect to IP Nexthop  |
  | Community    | Prefix       |                         |
  +--------------+--------------+-------------------------+
  | 64597:1      | IP Prefix 61 |           R3            |
  +--------------+--------------+-------------------------+

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

      <t>Compared to traditional methods requiring N rules for N source
      prefixes, this community-based FIB lookup mechanism reduces the required
      Flowspec rules in the control plane and hardware TCAM to a single
      entry.</t>

      <t/>
    </section>

    <section title="IANA Considerations">
      <t>IANA is requested to allocate a new component type in the "Flow Spec
      Component Types" registry:</t>

      <t><figure align="center">
          <artwork><![CDATA[      +---------+-----------------------+------------------+
      |  Type   | Description           | Reference        |
      +---------+-----------------------+------------------+
      |  TBD1   | Source-IP-Community   | This-Document    |
      +---------+-----------------------+------------------+
  
]]></artwork>
        </figure></t>
    </section>

    <section anchor="Security Considerations" title="Security Considerations">
      <t>This proposal extends BGP Flow Specification matching capabilities.
      All security considerations defined in <xref target="RFC8955"/> and
      <xref target="RFC8956"/> apply.</t>

      <t>Because matching relies on the BGP Community attribute of the route
      associated with a packet's source IP address, malicious or inaccurate
      community tagging within the local BGP RIB could result in incorrect
      packet filtering or traffic redirection. Therefore, this mechanism MUST
      be restricted to deployment within a single administrative domain where
      Community management is strictly controlled.</t>

      <t>Additionally, lookups linking dynamic packet source IP addresses to
      BGP route attributes MUST be implemented efficiently to mitigate
      potential Data Plane Resource Exhaustion (DoS) attacks.</t>

      <t/>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include='reference.RFC.2119'?>

      <?rfc include='reference.RFC.8174'?>
    </references>

    <references title="Informative References">
      <?rfc include='reference.RFC.4271'?>

      <?rfc include='reference.RFC.8955'?>

      <?rfc include='reference.RFC.8956'?>

      <?rfc include='reference.I-D.ietf-idr-flowspec-l2vpn'?>
    </references>
  </back>
</rfc>
