<?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-sip-origin-as-filter-01"
     ipr="trust200902">
  <front>
    <title abbrev="Source-IP-Origin-AS Filter">Source-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>

    <author fullname="Tao Qin" initials="T." surname="Qin">
      <organization>Huawei</organization>

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

          <city>Beijing</city>

          <code>100095</code>

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

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

    <date day="20" month="March" 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 (FlowSpec) to enable filtering based on the
      Origin Autonomous System (AS) of the source IP address. This extension
      is particularly useful in mitigating Distributed Denial of Service
      (DDoS) attacks where the source IP addresses are dynamic but belong to a
      specific source AS.</t>

      <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>

      <t/>
    </note>
  </front>

  <middle>
    <section title="Introduction">
      <t>BGP Flow Specification (FlowSpec), defined in <xref
      target="RFC8955"/> and <xref target="RFC8956"/>, allows for the
      dissemination of traffic filtering rules. Current FlowSpec components
      support filtering by destination prefix, source prefix, and various
      Layer 4 parameters.</t>

      <t>In certain DDoS mitigation scenarios, an operator may need to apply
      rate-limiting or filtering to all traffic sourced from a particular
      network (Autonomous System), even when the specific souce IP prefixes
      within that AS are numerous or rapidly changing. Manually updating
      hundreds of prefix-based FlowSpec rules is inefficient. This document
      introduces a new FlowSpec component that allows operators to use the
      Source Origin AS as a matching criterion.</t>

      <t/>
    </section>

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

          <t>Source-IP-Origin-AS: The origin AS number of the source IP
          address</t>
        </list></t>
    </section>

    <section title="The Flow Specification Encoding for Destination-IP-Origin-AS 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>Source-IP-Origin-AS</t>
        </list></t>

      <t>Type TBD1 - Source-IP-Origin-AS</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
      Source-IP-Origin-AS (i.e. the origin AS number of the source IP
      address).</t>

      <t>The operator byte is encoded as:</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/>

      <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 Source-IP-Origin-AS 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
      Source-IP-Origin-AS filter or a range of Source-IP-Origin-AS filter(e.g.
      less than AS1 and greater than AS2).</t>

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

      <t><figure anchor="Source-IP-Origin-AS" title="Source-IP-Origin-AS">
          <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-Origin-AS  (4 octets)                         ~
  +---------------------------------------------------------------+
]]></artwork>
        </figure></t>

      <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>In cases of multi-homed prefixes with multiple Origin ASes, the match
      succeeds if any of the valid Origin ASes match the filter.</t>

      <section title="Operational Procedures">
        <t>When a BGP speaker receives a FlowSpec update containing the
        Source-IP-Origin-AS component:</t>

        <t>It MUST determine the Origin AS of the souce IP of the transit
        packet by performing a lookup in its local BGP RIB.</t>

        <t>If the packet's source IP matches a prefix whose BGP path has an
        AS_PATH where the rightmost AS (the origin) matches the value in the
        FlowSpec rule, the action (e.g., rate-limit, discard) MUST be
        applied.</t>

        <t/>
      </section>
    </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. In AS64597's R2, if the ISP
      AS64597 wants to redirect all packets originating from AS64598 to IP
      Prefix 61:</t>

      <t>"first go to R3, then forward them to IP Prefix 61", the ISP AS64597
      can use the traditional method or the method defining in this draft.</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
                *                \      *  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 the traditional method, the ISP AS64597 needs to setup multiple
      "Source Prefix + Destination Prefix" rules in Router R2 as
      following:</t>

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

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

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

      <t><figure anchor="Using_the_AS-level_filtering_method"
          title="Using the AS-level filtering method to redirect the traffic">
          <artwork align="center"><![CDATA[
  +--------------+--------------+-------------------------+
  | Soure IP     | Destination  | Redirect to IP Nexthop  |
  | Origin AS    | Prefix       |                         |
  +--------------+--------------+-------------------------+
  |  64598       | IP Prefix 61 |       R3                |
  +--------------+--------------+-------------------------+

]]></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 source
      prefixes an AS has, the more obvious the benefit.</t>

      <t/>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>In addition to the security considerations in [RFC8955], operators
      must be aware of:</t>

      <t><list style="symbols">
          <t>Routing Inconsistency: If different routers in the network have
          different views of the BGP table, the "Origin AS" for a given IP may
          differ, leading to inconsistent filter application.</t>

          <t>AS_PATH Manipulation: An attacker could potentially spoof or
          prepend ASes to bypass filters if the local BGP table is
          compromised.</t>

          <t>Validation: Implementations SHOULD ensure that FlowSpec rules are
          validated against the originating peer to prevent unauthorized
          AS-based filtering across administrative boundaries.</t>
        </list></t>
    </section>

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

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

    <section anchor="Contributors" title="Contributors">
      <t>TBD</t>

      <t/>
    </section>

    <section anchor="Acknowledgments" title="Acknowledgments">
      <t>TBD</t>

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

  <back>
    <references title="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-flowspec-l2vpn'?>
    </references>
  </back>
</rfc>
