<?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-02"
     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="21" month="September" 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 or numerous but
      belong to a specific source 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 (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, redirection, or filtering to traffic sourced from a
      particular network (Autonomous System), even when the specific source IP
      prefixes within that AS are numerous or rapidly changing. Manually
      updating hundreds of prefix-based FlowSpec rules is inefficient and
      consumes excessive Hardware Forwarding Information Base (FIB) / TCAM
      resources. 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 associated with the
          source IP address of a transit packet, determined from the rightmost
          AS in the AS_PATH attribute of the active BGP route matching that
          source IP.</t>
        </list></t>
    </section>

    <section title="Flow Specification Encoding for Source-IP-Origin-AS Filter">
      <t>This document proposes a new Flow Specification component type that
      is encoded in the BGP FlowSpec NLRI <xref target="RFC8955"/> <xref
      target="RFC8956"/>.</t>

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

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

      <t>It contains a set of {operator, value} pairs used to match the
      Source-IP-Origin-AS.</t>

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

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

      <t/>

      <t>Where:</t>

      <t><list style="symbols">
          <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 (0) 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. For 4-byte AS numbers, len MUST be set to 10 (4
          octets).</t>

          <t>lt, gt, eq - Less than, Greater than, and Equal comparison
          bits.</t>
        </list>The value field contains a 4-octet Autonomous System Number
      encoded in network byte order:</t>

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

      <t/>

      <section title="Ordering of Components">
        <t>As defined in <xref target="RFC8955"/>, a strict ordering of
        components MUST be followed to ensure a deterministic comparison of
        FlowSpec NLRIs.</t>

        <t>The Source-IP-Origin-AS component (Type TBD1) MUST be ordered after
        Type 2 (Source Prefix) and before Type 3 (IP Protocol).</t>

        <t>[Note to IANA: The exact numeric order will depend on the assigned
        Type value.]</t>
      </section>

      <section title="Operational Procedures and Packet Matching Logic">
        <t>When a BGP speaker receives and installs a FlowSpec route
        containing the Source-IP-Origin-AS component, the matching process for
        a transit data packet MUST proceed as follows:</t>

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

            <t>The router performs a longest-prefix match (LPM) lookup for the
            Source 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
            FlowSpec rule, the packet matches this component.</t>

            <t>In multi-homing or multipath scenarios where a source prefix is
            reachable via paths with different Origin ASes, the match MUST
            succeed if ANY valid active path for the source prefix matches the
            Origin AS defined in the FlowSpec rule.</t>
          </list>If a receiving BGP speaker cannot support this new component
        type, it MUST follow the error handling and component skipping
        procedures defined in Section 10 of <xref target="RFC8955"/> and <xref
        target="RFC8956"/>.</t>
      </section>
    </section>

    <section title="Use Cases">
      <t>This section describes how to use this function in a simple scenario.
      Consider the topology shown in Figure 3. Router R2 in AS64597 receives
      traffic originating from AS64598 destined for IP Prefix 61. The operator
      wants to redirect all traffic originating from AS64598 towards Router R3
      before forwarding it to IP Prefix 61.</t>

      <t><figure anchor="Redirect_the_traffic_using_Flowspec"
          title="Traffic Redirection Using FlowSpec">
          <artwork align="left"><![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, ISP AS64597 must inject multiple
      "Destination Prefix + Source Prefix" FlowSpec rules into Router R2:</t>

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

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

      <t>Using the method defined in this draft, ISP AS64597 needs to inject
      only a single "Destination Prefix + Source IP Origin AS" FlowSpec
      rule:</t>

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

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

      <t>This method saves significant TCAM space on network elements, reduces
      BGP UPDATE messaging load on the control plane, and simplifies
      operational management when a source AS advertises numerous dynamic
      prefixes.</t>

      <t/>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>In addition to the security considerations in <xref
      target="RFC8955"/> and <xref target="RFC8956"/>, operators MUST be aware
      of the following:</t>

      <t><list style="symbols">
          <t>Routing Inconsistency: Packet classification relies on the local
          BGP RIB state of the forwarding router. If different ingress routers
          have different active BGP routes (and thus different Origin AS
          views) for a given source IP, filtering or redirection actions may
          be applied inconsistently.</t>

          <t>BGP Origin Validation: Malicious or misconfigured networks may
          spoof AS_PATH attributes. Operators SHOULD deploy RPKI-based Route
          Origin Validation (ROV) <xref target="RFC6811"/> in their networks
          to ensure that the Source Origin AS matching is performed against
          validated BGP routes.</t>

          <t>Validation of FlowSpec Routes: BGP FlowSpec routes MUST be
          validated against originating BGP peers according to the FlowSpec
          validation rules (Section 6 of <xref target="RFC8955"/>) to prevent
          cross-administrative-domain traffic hijacking.</t>
        </list></t>
    </section>

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

      <t><figure align="center">
          <artwork align="center"><![CDATA[+-------+-------------------------------+---------------+
| Type  | Description                   | Reference     |
+-------+-------------------------------+---------------+
| TBD1  | Source-IP-Origin-AS           | This-Draft    |
+-------+-------------------------------+---------------+
  
]]></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="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'?>
    </references>

    <references title="Informative References">
      <?rfc include='reference.RFC.6811'?>
    </references>
  </back>
</rfc>
