<?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-wang-idr-flowspec-dip-origin-as-filter-18"
     ipr="trust200902">
  <front>
    <title abbrev="Destination-IP-Origin-AS Filter">Destination-IP-Origin-AS
    Filter for BGP Flow Specification</title>

    <author fullname="Haibo Wang" initials="H." surname="Wang">
      <organization>Huawei</organization>

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

          <city>Beijing</city>

          <code>100095</code>

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

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

    <author fullname="Aijun Wang" initials="A." surname="Wang">
      <organization>China Telecom</organization>

      <address>
        <postal>
          <street>Beiqijia Town, Changping District</street>

          <city>Beijing</city>

          <code>102209</code>

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

        <email>wangaj3@chinatelecom.cn</email>
      </address>
    </author>

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

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

          <city>Beijing</city>

          <code>100095</code>

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

        <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>This document defines an extension to the Border Gateway Protocol
      (BGP) Flow Specification Version 2 (FSv2) defined in
      [draft-ietf-idr-fsv2-ip-basic] to enable filtering based on the Origin
      Autonomous System (AS) of the destination IP address. This extension is
      particularly useful in mitigating Distributed Denial of Service (DDoS)
      attacks or optimizing traffic redirection where the target IP addresses
      are numerous or rapidly changing, but belong to a specific destination
      Origin AS.</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 <xref target="RFC4271"/> Flow Specification, originally defined
      in <xref target="RFC8955"/> and <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 certain DDoS mitigation and traffic engineering scenarios, an
      operator may need to apply rate-limiting, redirection, or filtering to
      traffic destined for a particular network (Autonomous System), even when
      the specific target IP prefixes within that AS are numerous or rapidly
      changing. Manually updating hundreds of prefix-based FlowSpec rules is
      inefficient and consumes significant Hardware Forwarding Information
      Base (FIB) / TCAM resources. This document introduces a new FSv2
      component under the Routing Filter Family that allows operators to use
      the Destination Origin AS as a matching criterion.</t>
    </section>

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

          <t>Destination-IP-Origin-AS: The origin AS number of the destination
          IP address, determined from the rightmost AS in the AS_PATH
          attribute of the matching BGP route.</t>
        </list></t>
    </section>

    <section title="Flow Specification Version 2 Encoding for Destination-IP-Origin-AS Filter">
      <t>This document proposes 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: 100 (DIP-AS)</t>
        </list>Encoding format for the DIP-AS component:</t>

      <t><figure anchor="DIP-AS" title="Destination-IP-Origin-AS Filter">
          <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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Flags |    Type (100)         |            Length             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             <[numeric_op, Destination-IP-Origin-AS]+>         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
]]></artwork>
        </figure>Where:</t>

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

          <t>Type (12 bits): Set to 100 for DIP-AS.</t>

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

          <t>&lt;[numeric_op, Destination-IP-Origin-AS]+&gt;: Contains a list
          of {numeric_op, Destination-IP-Origin-AS} pairs that are used to
          match the Destination-IP-Origin-AS.<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 100 component values
              SHOULD be encoded as 4 octets (numeric_op len=10).</t>

              <t>Destination-IP-Origin-AS (32 bits): A 4-octet Autonomous
              System Number encoded in network byte order.</t>
            </list></t>
        </list></t>

      <section title="Ordering of Components within Filter Family 1400">
        <t>As defined in <xref target="I-D.ietf-idr-fsv2-ip-basic"/>, rules
        and components follow strict ordering principles. The DIP-AS component
        (Type 100) within the Routing Filter Family (1400) MUST be evaluated
        deterministically according to FSv2 component sequencing rules.</t>
      </section>

      <section title="Operational Procedures and Packet Matching Logic">
        <t>When a BGP speaker receives and installs an FSv2 route containing
        the Routing Filter Family with the DIP-AS component (Type 100), the
        matching process for a transit data packet MUST proceed as
        follows:</t>

        <t><list style="numbers">
            <t>The router extracts the packet's Destination IP address.</t>

            <t>The router performs a longest-prefix match (LPM) lookup for the
            Destination IP in its local BGP Loc-RIB / FIB to retrieve the
            associated active BGP route.</t>

            <t>The router evaluates the AS_PATH attribute of the retrieved BGP
            route:<list style="symbols">
                <t>The Origin AS is defined as the rightmost AS number in the
                AS_SEQUENCE segment of the AS_PATH.</t>

                <t>If the AS_PATH ends with an AS_SET or AS_CONFED_SEQUENCE,
                the match fails unless all ASes in the set match, or the
                implementation supports evaluating each AS in the AS_SET
                against the filter.</t>
              </list></t>

            <t>If the evaluated Origin AS matches the criterion in the FSv2
            rule, the packet matches this component.</t>

            <t>In multi-homing or multipath scenarios, the match succeeds if
            ANY valid active path to the destination prefix matches the Origin
            AS defined in the rule.</t>
          </list></t>

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

    <section title="Use Cases">
      <t>This section describes a representative use case for traffic
      redirection and rate-limiting using the Destination-IP-Origin-AS filter
      under the FSv2 framework.</t>

      <t>Consider the topology shown in <xref
      target="Redirect_the_traffic_using_Flowspec"/>. ISP AS64597 receives
      traffic from AS64596 (Source IP Prefix 61) destined for AS64598.</t>

      <t><figure anchor="Redirect_the_traffic_using_Flowspec"
          title="Traffic Redirection Using FlowSpec">
          <artwork><![CDATA[
                         +---------+
                         | BGP FS  |
                         | Server  |
                         +----|----+
                              |
                              |
                              /
                             /
                ************/************  IP Prefix 81
                *          /            *  IP Prefix 82
  IP Prefix 61  *         / AS64597     *  IP Prefix 83
                *        /              *  IP Prefix 84
   +-------+    *  +---+/        +---+  *   +-------+
   +AS64596+-------+ R1+---------+ R2|------+AS64598+
   +-------+    *  +-+-+\        +---+  */  +-------+
                *        \         |\   /
                *         \        | \ /*  IP Prefix 91
                *          \       |  /\*  IP Prefix 92
                *           \      | /  \  IP Prefix 93
                *            \     |/   *\ IP Prefix 94
                *             \  +-+-+  * \ +-------+
                *              \-+ R3+------+AS64599+
                *                +---+  *   +-------+
                *                       *
                *************************

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

      <t>Using traditional FlowSpec (RFC 8955), if AS64598 announces dozens or
      hundreds of individual prefixes (Prefix 81, 82, 83, 84...), AS64597 must
      inject separate FlowSpec rules for each destination prefix to redirect
      traffic coming from Source IP Prefix 61 towards Router R3:</t>

      <t><figure anchor="Using_the_traditional_method"
          title="Traditional Destination Prefix Matching">
          <artwork><![CDATA[
+--------------+--------------+-------------------------+
| Destination  | Source Prefix| Action / Next-hop       |
| Prefix       |              |                         |
+--------------+--------------+-------------------------+
| IP Prefix 81 | IP Prefix 61 | Redirect to R3          |
| IP Prefix 82 | IP Prefix 61 | Redirect to R3          |
| IP Prefix 83 | IP Prefix 61 | Redirect to R3          |
| IP Prefix 84 | IP Prefix 61 | Redirect to R3          |
| ...          | ...          | ...                     |
+--------------+--------------+-------------------------+

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

      <t>Using the extension defined in this draft, the BGP FlowSpec Server
      needs to generate only a single FlowSpec rule:</t>

      <t><figure anchor="Using_the_AS-level_filtering_method"
          title="Destination-IP-Origin-AS Matching">
          <artwork><![CDATA[
  +--------------+--------------+--------------------+
  | Destination  | Source Prefix| Action / Next-hop  |
  | IP Origin AS |              |                    |
  +--------------+--------------+--------------------+
  |  64598       | IP Prefix 61 |       R3           |
  +--------------+--------------+--------------------+

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

      <t>This significantly reduces BGP NLRI messaging overhead, control plane
      churn, and hardware FIB/TCAM entry consumption on network elements.</t>

      <t/>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>This document extends BGP FlowSpec Version 2 (FSv2). Security
      considerations discussed in <xref target="I-D.ietf-idr-fsv2-ip-basic"/>
      apply directly.</t>

      <t>In addition, operators MUST consider routing inconsistencies,
      RPKI-based Route Origin Validation (ROV) [RFC6811], and FSv2 route
      validation procedures.</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     |
   +-------------+---------------------------+---------------+
   | 100         | DIP-AS (Destination-IP-AS)| This document |
   +-------------+---------------------------+---------------+
  
]]></artwork>
        </figure></t>
    </section>

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

      <t><figure align="left">
          <artwork align="left"><![CDATA[   Tao Qin
   Huawei
   Email: qintao11@huawei.com
  
]]></artwork>
        </figure></t>
    </section>

    <section anchor="Acknowledgments" title="Acknowledgments">
      <t>The authors would like to acknowledge the review and inputs from Gang
      Yan, Robert Raszuk, Jeffray Haas, Linda Dunbar, Zhenbin Li, Rainbow Wu,
      Jie Dong and Ziqing Cao.</t>

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

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

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

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

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

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

      <?rfc include='reference.I-D.ietf-idr-fsv2-ip-basic'?>
    </references>

    <references title="Informative References"/>
  </back>
</rfc>
