<?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-03"
     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="13" month="October" year="2026"/>

    <area>Routing</area>

    <workgroup>IDR Working Group</workgroup>

    <!---->

    <abstract>
      <t>BGP Flow Specification Version 2 (FSv2) propagates traffic Flow
      Specifications and Traffic Filtering Actions using an extensible
      TLV-based filter family architecture. This document specifies a new FSv2
      component type under the Routing Filter Family 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, originally defined in <xref
      target="RFC8955"/> <xref target="RFC8956"/>, has evolved to Flow
      Specification Version 2 (FSv2) as specified in <xref
      target="I-D.ietf-idr-fsv2-ip-basic"/>. FSv2 introduces an extensible,
      TLV-based filter family architecture with explicit rule ordering and
      modular components.</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 FSv2 component type under the Routing
      Filter Family, Source-IP-Community (SIP COM), 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>

      <t/>
    </section>

    <section title="Definitions and Acronyms">
      <t><list style="symbols">
          <t>FSv2: Flow Specification Version 2</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="Flow Specification Version 2 Encoding for Source-IP-Community Filter">
      <t>This document defines a new FSv2 component encoded within the Routing
      Filter Family (Type 1400). Unlike legacy FSv1 raw byte streams, FSv2
      utilizes explicit TLV formatting.</t>

      <t><list style="symbols">
          <t>Filter Family: 1400 (Routing Filter Family)</t>

          <t>Component Type: 400 (SIP COM)</t>
        </list></t>

      <t>Encoding format for the SIP COM component:</t>

      <t><figure anchor="SIP_COM" title="Source-IP-Community Filter">
          <artwork align="left"><![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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Flags |    Type (400)         |            Length             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             <[numeric_op, Source-IP-Community]+>              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
]]></artwork>
        </figure></t>

      <t>Where:</t>

      <t><list style="symbols">
          <t>Flags (4 bits): Defined in FSv2 specifications.</t>

          <t>Type (12 bits): Set to 400 for SIP COM.</t>

          <t>Length (16 bits): Length of the value field in octets.</t>

          <t>&lt;[numeric_op, Source-IP-Community]+&gt;: Contains a list of
          {numeric_op, Source-IP-Community} pairs that are used to match the
          Source-IP-Community.<list style="symbols">
              <t>numeric_op: This component uses the Numeric Operator
              (numeric_op) described in Section 4.1.1 of <xref
              target="I-D.ietf-idr-fsv2-ip-basic"/>, Type 400 component values
              SHOULD be encoded as 4 octets (numeric_op len=10).</t>

              <t>Source-IP-Community (32 bits): BGP Community value to
              match.</t>
            </list></t>
        </list></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 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 <xref
      target="Redirect_the_traffic_using_Flowspec"/>. 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="left"><![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="left"><![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 make the following allocations under the BGP
      Flow Specification Version 2 (FSv2) registries defined in <xref
      target="I-D.ietf-idr-fsv2-ip-basic"/>:</t>

      <t><figure align="left">
          <artwork><![CDATA[   FSv2 Routing Filter Family Component Types Registry:
   +-------------+-----------------------+-------------------+
   | Type        | Description           | Reference         |
   +-------------+-----------------------+-------------------+
   | 400         | SIP COM               |                   |
   |             | (Source-IP-Community) | This document     |
   +-------------+-----------------------+-------------------+
  
]]></artwork>
        </figure></t>
    </section>

    <section anchor="Security Considerations" title="Security Considerations">
      <t>This proposal extends BGP Flow Specification Version 2 (FSv2)
      matching capabilities. All security considerations defined in <xref
      target="I-D.ietf-idr-fsv2-ip-basic"/> 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>

    <section title="Contributors">
      <t>The following people made significant contributions to this
      document:</t>

      <t>TBA</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-fsv2-ip-basic'?>

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