RFC 8955
Dissemination of Flow Specification Rules
RFC 8955: Dissemination of Flow Specification Rules β¨
okay bestie, let's start with the vitals π This is an IETF doc (Request for Comments: 8955) on the Standards Track (ISSN 2070-1721), published December 2020. It obsoletes RFC 5575 and RFC 7674 π The authors are C. Loibl (next layer Telekom GmbH), S. Hares (Huawei), R. Raszuk (NTT Network Innovations), D. McPherson (Verisign), and M. Bacher (T-Mobile Austria). Iconic team π
Abstract
okay so this doc defines a BGP Network Layer Reachability Information (BGP NLRI) encoding format π¦ It's used to pass around traffic Flow Specifications (intra-domain and inter-domain) for IPv4 unicast and IPv4 BGP/MPLS VPN services. The vibe is that the routing system can now share info about more specific pieces of a traffic aggregate, the stuff defined by an IP destination prefix πΈ
It also specifies BGP Extended Community encoding formats π These carry Traffic Filtering Actions along with the Flow Specification NLRI. Those actions are what a routing system can do when a packet matches the Flow Specification. Literally a whole toolkit π§
This document obsoletes both RFC 5575 and RFC 7674. Bye bye, old versions π
Status of This Memo
This is an Internet Standards Track document. Period π
It's a product of the Internet Engineering Task Force (IETF) and it represents the consensus of the IETF community. It went through public review and got approved for publication by the Internet Engineering Steering Group (IESG). If you want more on Internet Standards, check out Section 2 of RFC 7841 π
For the current status, any errata, and how to give feedback, go to https://www.rfc-editor.org/info/rfc8955 β¨
Copyright Notice
Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved. π
This doc is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info), as in effect on the publication date. Please actually read those, bestie, because they spell out your rights and restrictions for this document π Code Components pulled out of this document must include the Simplified BSD License text described in Section 4.e of the Trust Legal Provisions. They come without warranty, as the Simplified BSD License describes.
Table of Contents
1. Introduction
2. Definitions of Terms Used in This Memo
3. Flow Specifications
4. Dissemination of IPv4 Flow Specification Information
4.1. Length Encoding
4.2. NLRI Value Encoding
4.2.1. Operators
4.2.2. Components
4.2.2.1. Type 1 - Destination Prefix
4.2.2.2. Type 2 - Source Prefix
4.2.2.3. Type 3 - IP Protocol
4.2.2.4. Type 4 - Port
4.2.2.5. Type 5 - Destination Port
4.2.2.6. Type 6 - Source Port
4.2.2.7. Type 7 - ICMP Type
4.2.2.8. Type 8 - ICMP Code
4.2.2.9. Type 9 - TCP Flags
4.2.2.10. Type 10 - Packet Length
4.2.2.11. Type 11 - DSCP (Diffserv Code Point)
4.2.2.12. Type 12 - Fragment
4.3. Examples of Encodings
5. Traffic Filtering
5.1. Ordering of Flow Specifications
6. Validation Procedure
7. Traffic Filtering Actions
7.1. Traffic Rate in Bytes (traffic-rate-bytes) Sub-Type 0x06
7.2. Traffic Rate in Packets (traffic-rate-packets) Sub-Type
0x0c
7.3. Traffic-Action (traffic-action) Sub-Type 0x07
7.4. RT Redirect (rt-redirect) Sub-Type 0x08
7.5. Traffic Marking (traffic-marking) Sub-Type 0x09
7.6. Interaction with Other Filtering Mechanisms in Routers
7.7. Considerations on Traffic Filtering Action Interference
8. Dissemination of Traffic Filtering in BGP/MPLS VPN Networks
9. Traffic Monitoring
10. Error Handling
11. IANA Considerations
11.1. AFI/SAFI Definitions
11.2. Flow Component Definitions
11.3. Extended Community Flow Specification Actions
12. Security Considerations
13. References
13.1. Normative References
13.2. Informative References
Appendix A. Example Python code: flow_rule_cmp
Appendix B. Comparison with RFC 5575
Acknowledgments
Contributors
Authors' Addresses
1. Introduction π¦
Okay so this doc obsoletes "Dissemination of Flow Specification Rules" [RFC5575]. The differences are in Appendix B, so go look if you're curious π It also obsoletes "Clarification of the Flowspec Redirect Extended Community" [RFC7674], because it bakes the encoding of the BGP Flow Specification Redirect Extended Community into Section 7.4. Efficient, no notes π
Modern IP routers are seriously powerful. They can forward traffic and also classify, shape, rate limit, filter, or redirect packets based on administratively defined policies π₯ Operators use these policies to define match rules that look at multiple fields in the packet header. And you can attach actions, like the ones I just listed, to each rule.
The n-tuple made of the matching criteria is what defines an aggregate traffic Flow Specification π§ Those criteria can include things like source and destination address prefixes, the IP protocol, and transport protocol port numbers.
Section 4 of this document defines a general procedure for encoding Flow Specifications for aggregated traffic flows, so they can be distributed as a BGP [RFC4271] NLRI. Section 7 defines the required Traffic Filtering Actions BGP Extended Communities. It also covers the mechanisms for using BGP to share traffic filtering rules within a provider and between providers, which helps mitigate DoS and DDoS attacks π‘οΈπ
By adding Flow Specifications to routing info, the routing system can use the ACL (Access Control List) or firewall capabilities in the router's forwarding path. You can think of Flow Specifications as more specific routing entries for a unicast prefix, and they're expected to depend on the existing unicast data information. It's giving layered π°
A Flow Specification received from an external autonomous system has to be validated against unicast routing before it's accepted (Section 6). A Flow Specification received from an internal BGP peer in the same autonomous system [RFC4271] is assumed to have been validated before it was sent around the internal BGP (iBGP) mesh of that autonomous system π«Ά If the aggregate traffic flow defined by the unicast destination prefix is forwarded to a given BGP peer, then the local system can install more specific Flow Specifications. Those can lead to different forwarding behavior, as that system requested.
Operationally, using BGP as the carrier for this info is a big win. A network service provider can reuse its internal route distribution infrastructure (for example, its route reflector or confederation design) and its existing external relationships (for example, inter-domain BGP sessions to a customer network) β¨ Reuse, slay.
Sure, other mechanisms could solve this problem too. But this solution has actually been deployed a lot, because it's an incremental addition to mechanisms that are already deployed π
Possible applications of this extension include automated inter-domain coordination of traffic filtering. That's what you'd need to mitigate DoS and DDoS attacks, or to filter traffic in the context of a BGP/MPLS VPN service πΈ Other applications are possible too, like centralized control of traffic in a Software-Defined Networking (SDN) or Network Function Virtualization (NFV) context.
In current deployments, the info this extension distributes is originated both manually and automatically. The automatic part comes from systems that can detect malicious traffic flows π When you use automated systems, take care to make sure they're correct. You also need to consider the limits of the receiving systems that process these automated Flow Specifications (see also Section 12). Don't skip this, bestie π
This specification defines the protocol extensions that are required to cover the most common uses of IPv4 unicast and VPNv4 unicast filtering π The same mechanism can be reused, and new match criteria can be added, to meet similar filtering needs for other BGP address families, like the IPv6 families [RFC8956] π
2. Definitions of Terms Used in This Memo π
Here's the glossary, babe:
- AFI: Address Family Identifier
- AS: Autonomous System
- Loc-RIB: The Loc-RIB contains the routes that have been selected by the local BGP speaker's Decision Process [RFC4271].
- NLRI: Network Layer Reachability Information
- PE: Provider Edge router
- RIB: Routing Information Base
- SAFI: Subsequent Address Family Identifier
- VRF: Virtual Routing and Forwarding
Quick legal-ish bit π«Ά 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 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
3. Flow Specifications π·
A Flow Specification is an n-tuple made of several matching criteria that can be applied to IP traffic π A given IP packet is said to match the defined Flow Specification if it matches all of the specified criteria. Then this n-tuple gets encoded into a BGP NLRI, which we'll get to below π§
A given Flow Specification may be associated with a set of attributes, depending on the application. Those attributes may or may not include reachability information (i.e., NEXT_HOP) π Well-known or AS-specific community attributes can be used to encode a set of predetermined actions. Very organized.
A particular application is identified by a specific (Address Family Identifier, Subsequent Address Family Identifier (AFI, SAFI)) pair [RFC4760]. Each pair corresponds to a distinct set of RIBs π¦ Those RIBs should be treated independently of each other, so that distinct applications don't interfere with one another π
BGP itself treats the NLRI as a key to an entry in its databases. Entries placed in the Loc-RIB then get associated with a set of semantics, and those semantics depend on the application. This is consistent with existing BGP applications. For example, IP unicast routing (AFI=1, SAFI=1) and IP multicast reverse-path information (AFI=1, SAFI=2) are handled by BGP with no particular semantics attached until they're installed in the Loc-RIB π
Standard BGP policy mechanisms, like UPDATE filtering by NLRI prefix and community matching, must apply to the Flow Specification defined NLRI-type. Network operators can also control the propagation of these routing updates by enabling or disabling the exchange of a particular (AFI, SAFI) pair on a given BGP peering session. You're in charge, queen π
Stay tuned, because more of this RFC is coming up next! π«Ά
4. Dissemination of IPv4 Flow Specification Information β¨
okay so this is where the magic happens πͺ This document defines a Flow Specification NLRI type (Figure 1) that can hold a bunch of components, like destination prefix, source prefix, protocol, ports, and more π (we'll get into those in Section 4.2 below).
This NLRI info gets carried inside MP_REACH_NLRI and MP_UNREACH_NLRI attributes, as defined in [RFC4760] π«Ά When advertising Flow Specifications, the Length of the Next-Hop Network Address MUST be set to 0. The Network Address of the Next-Hop field MUST be ignored. No vibes there, just rules π
The NLRI field of MP_REACH_NLRI and MP_UNREACH_NLRI is encoded as one or more 2-tuples of the form <length, NLRI value>. So it's a 1- or 2-octet length field followed by a variable-length NLRI value, and the length is expressed in octets π
+-------------------------------+
| length (0xnn or 0xfnnn) |
+-------------------------------+
| NLRI value (variable) |
+-------------------------------+
Figure 1: Flow Specification NLRI for IPv4
Implementations that want to exchange Flow Specification MUST use BGP's Capability Advertisement facility to exchange the Multiprotocol Extension Capability Code (Code 1), as defined in [RFC4760]. The (AFI, SAFI) pair carried in the Multiprotocol Extension Capability MUST be (AFI=1, SAFI=133) for IPv4 Flow Specification and (AFI=1, SAFI=134) for VPNv4 Flow Specification π
4.1. Length Encoding
The length field tells you the length in octets of the variable NLRI value, and there are two cases π§
- If the NLRI length is smaller than 240 (
0xf0hex) octets, the length field can be encoded as a single octet. - Otherwise, it is encoded as an extended-length 2-octet value in which the most significant nibble has the hex value
0xf.
In Figure 1 above, values less than 240 are encoded using two hex digits (0xnn). Values above 239 are encoded using 3 hex digits (0xfnnn). The highest value that can be represented with this encoding is 4095. For example, the length value of 239 is encoded as 0xef (single octet), while 240 is encoded as 0xf0f0 (2 octets) π
4.2. NLRI Value Encoding
The Flow Specification NLRI value is a list of optional components, and it's encoded like this π
Encoding: <[component]+>
A specific packet is considered to match the Flow Specification when it matches the intersection (AND) of all the components present in the Flow Specification. So every component has to agree, bestie π
Components MUST follow strict type ordering by increasing numerical order. A given component type MAY (exactly once) be present in the Flow Specification. If present, it MUST precede any component of higher numeric type value. Strict ordering, no exceptions π
All combinations of components within a single Flow Specification are allowed. However, some combinations cannot match any packets (for example, "ICMP Type AND Port" will never match any packets), and thus they SHOULD NOT be propagated by BGP. Not a good look, so don't send them π
An NLRI value that isn't encoded as specified here, including an NLRI that contains an unknown component type, is considered malformed, and error handling according to Section 10 is performed π
4.2.1. Operators
Most of the components described below use comparison operators. Which of the two operators is used is defined by the components in Section 4.2.2. The operators are encoded as a single octet β¨
4.2.1.1. Numeric Operator (numeric_op)
This operator is encoded as shown in Figure 2 π¦
0 1 2 3 4 5 6 7
+---+---+---+---+---+---+---+---+
| e | a | len | 0 |lt |gt |eq |
+---+---+---+---+---+---+---+---+
Figure 2: Numeric Operator (numeric_op)
Here's what each bit does:
- e (end-of-list bit): Set in the last {op, value} pair in the list.
- a (AND bit): If unset, the result of the previous {op, value} pair is logically ORed with the current one. If set, the operation is a logical AND. In the first operator octet of a sequence, it MUST be encoded as unset and MUST be treated as always unset on decoding. The AND operator has higher priority than OR for the purposes of evaluating logical expressions. Big priority energy π
- len (length): The length of the value field for this operator, given as
(1 << len). This encodes 1 (len=00), 2 (len=01), 4 (len=10), and 8 (len=11) octets. - 0: MUST be set to 0 on NLRI encoding and MUST be ignored during decoding.
- lt: less-than comparison between data and value.
- gt: greater-than comparison between data and value.
- eq: equality between data and value.
The bits lt, gt, and eq can be combined to make the common relational operators, like "less or equal", "greater or equal", and "not equal to", as shown in Table 1 πΈ
+====+====+====+==================================+
| lt | gt | eq | Resulting operation |
+====+====+====+==================================+
| 0 | 0 | 0 | false (independent of the value) |
+----+----+----+----------------------------------+
| 0 | 0 | 1 | == (equal) |
+----+----+----+----------------------------------+
| 0 | 1 | 0 | > (greater than) |
+----+----+----+----------------------------------+
| 0 | 1 | 1 | >= (greater than or equal) |
+----+----+----+----------------------------------+
| 1 | 0 | 0 | < (less than) |
+----+----+----+----------------------------------+
| 1 | 0 | 1 | <= (less than or equal) |
+----+----+----+----------------------------------+
| 1 | 1 | 0 | != (not equal value) |
+----+----+----+----------------------------------+
| 1 | 1 | 1 | true (independent of the value) |
+----+----+----+----------------------------------+
Table 1: Comparison Operation Combinations
4.2.1.2. Bitmask Operator (bitmask_op)
This operator is encoded as shown in Figure 3 π
0 1 2 3 4 5 6 7
+---+---+---+---+---+---+---+---+
| e | a | len | 0 | 0 |not| m |
+---+---+---+---+---+---+---+---+
Figure 3: Bitmask Operator (bitmask_op)
- e, a, len (end-of-list bit, AND bit, and length field): Most significant nibble; defined in the Numeric Operator format in Section 4.2.1.1.
- not (NOT bit): If set, logical negation of operation.
- m (Match bit): If set, this is a bitwise match operation defined as "(data AND value) == value". If unset, (data AND value) evaluates to TRUE if any of the bits in the value mask are set in the data.
- 0 (all 0 bits): MUST be set to 0 on NLRI encoding and MUST be ignored during decoding.
4.2.2. Components
Each component's encoding starts with a type field (1 octet), followed by a variable-length parameter. The following sections define component types and parameter encodings for the IPv4 IP layer and transport layer headers. IPv6 NLRI component types are described in [RFC8956] π
4.2.2.1. Type 1 - Destination Prefix
Encoding:
<type (1 octet), length (1 octet), prefix (variable)>
This defines the destination prefix to match. The length and prefix fields are encoded as in BGP UPDATE messages [RFC4271] π―
4.2.2.2. Type 2 - Source Prefix
Encoding:
<type (1 octet), length (1 octet), prefix (variable)>
This defines the source prefix to match. The length and prefix fields are encoded as in BGP UPDATE messages [RFC4271] π¦
4.2.2.3. Type 3 - IP Protocol
Encoding:
<type (1 octet), [numeric_op, value]+>
This contains a list of {numeric_op, value} pairs that are used to match the IP protocol value octet in the IP packet header (see Section 3.1 of [RFC0791]).
This component uses the Numeric Operator (numeric_op) described in Section 4.2.1.1. Type 3 component values SHOULD be encoded as single octet (numeric_op len=00) π
4.2.2.4. Type 4 - Port
Encoding:
<type (1 octet), [numeric_op, value]+>
This defines a list of {numeric_op, value} pairs that match source OR destination TCP/UDP ports (see Section 3.1 of [RFC0793] and the "Format" section of [RFC0768]). This component matches if either the destination port OR the source port of an IP packet matches the value. Either direction counts, babe π
This component uses the Numeric Operator (numeric_op) described in Section 4.2.1.1. Type 4 component values SHOULD be encoded as 1- or 2-octet quantities (numeric_op len=00 or len=01).
When the port component (destination-port (Section 4.2.2.5), source-port (Section 4.2.2.6)) is present, only TCP or UDP packets can match the entire Flow Specification. The port component, if present, never matches when the packet's IP protocol value is not 6 (TCP) or 17 (UDP), if the packet is fragmented and this is not the first fragment, or if the system is unable to locate the transport header. Different implementations may or may not be able to decode the transport header in the presence of IP options or Encapsulating Security Payload (ESP) NULL [RFC4303] encryption. It's a whole thing, but it's the truth π
4.2.2.5. Type 5 - Destination Port
Encoding:
<type (1 octet), [numeric_op, value]+>
This defines a list of {numeric_op, value} pairs used to match the destination port of a TCP or UDP packet (see also Section 3.1 of [RFC0793] and the "Format" section of [RFC0768].
This component uses the Numeric Operator (numeric_op) described in Section 4.2.1.1. Type 5 component values SHOULD be encoded as 1- or 2-octet quantities (numeric_op len=00 or len=01).
The last paragraph of Section 4.2.2.4 also applies to this component π«Ά
4.2.2.6. Type 6 - Source Port
Encoding:
<type (1 octet), [numeric_op, value]+>
This defines a list of {numeric_op, value} pairs used to match the source port of a TCP or UDP packet (see also Section 3.1 of [RFC0793] and the "Format" section of [RFC0768].
This component uses the Numeric Operator (numeric_op) described in Section 4.2.1.1. Type 6 component values SHOULD be encoded as 1- or 2-octet quantities (numeric_op len=00 or len=01).
The last paragraph of Section 4.2.2.4 also applies to this component β¨
4.2.2.7. Type 7 - ICMP Type
Encoding:
<type (1 octet), [numeric_op, value]+>
This defines a list of {numeric_op, value} pairs used to match the type field of an ICMP packet (see also the "Message Formats" section of [RFC0792]).
This component uses the Numeric Operator (numeric_op) described in Section 4.2.1.1. Type 7 component values SHOULD be encoded as single octet (numeric_op len=00).
When the ICMP type component is present, only ICMP packets can match the entire Flow Specification. The ICMP type component, if present, never matches when the packet's IP protocol value is not 1 (ICMP), if the packet is fragmented and this is not the first fragment, or if the system is unable to locate the transport header. Different implementations may or may not be able to decode the transport header in the presence of IP options or Encapsulating Security Payload (ESP) NULL [RFC4303] encryption. Ugh, the transport header stuff again π
4.2.2.8. Type 8 - ICMP Code β¨
Okay bestie, Type 8 is all about the code field of an ICMP packet π¦ (the "Message Formats" section of [RFC0792] has the full ICMP tea). It's a list of {numeric_op, value} pairs, and it uses the Numeric Operator from Section 4.2.1.1.
Encoding: <type (1 octet), [numeric_op, value]+>
Type 8 component values SHOULD be encoded as single octet (numeric_op len=00). π
Here's the drama π: if the ICMP code component is in the Flow Specification, only ICMP packets can match the whole thing. It never matches when the IP protocol value isn't 1 (ICMP), when the packet is fragmented and it's not the first fragment, or when the system can't locate the transport header. Different implementations may or may not be able to decode the transport header when there are IP options or Encapsulating Security Payload (ESP) NULL [RFC4303] encryption, so it's giving "it depends on who's reading" π.
4.2.2.9. Type 9 - TCP Flags π
Encoding time again π§
Encoding: <type (1 octet), [bitmask_op, bitmask]+>
This one defines a list of {bitmask_op, bitmask} pairs for matching TCP control bits (see also Section 3.1 of [RFC0793]). It uses the Bitmask Operator from Section 4.2.1.2. Type 9 component bitmasks MUST be encoded as 1- or 2-octet bitmask (bitmask_op len=00 or len=01). Not optional, bestie π
When you use a single octet (bitmask_op len=00), it matches octet 14 of the TCP header (see also Section 3.1 of [RFC0793]), which holds the TCP control bits. When you use the 2-octet version (bitmask_op len=01), it matches octets 13 and 14 of the TCP header, and the data offset (the leftmost 4 bits) is always treated as 0. β¨
Same vibe as ICMP: if the TCP flags component is present, only TCP packets can match the whole Flow Specification. It never matches when the IP protocol value isn't 6 (TCP), when the packet is a non-first fragment, or when the system can't find the transport header. Implementations might or might not decode the transport header with IP options or ESP NULL [RFC4303] encryption, so again, it's a "depends" situation π
4.2.2.10. Type 10 - Packet Length π¦
Encoding:
Encoding: <type (1 octet), [numeric_op, value]+>
This component defines a list of {numeric_op, value} pairs that match the total IP packet length. Layer 2 is excluded, but the IP header is included π«Ά. It uses the Numeric Operator from Section 4.2.1.1. Type 10 component values SHOULD be encoded as 1- or 2-octet quantities (numeric_op len=00 or len=01). Lowkey the most relatable one π
4.2.2.11. Type 11 - DSCP (Diffserv Code Point) π
Encoding: <type (1 octet), [numeric_op, value]+>
Here we match the 6-bit DSCP field (see also [RFC2474]) with a list of {numeric_op, value} pairs, using the Numeric Operator from Section 4.2.1.1. Type 11 component values MUST be encoded as single octet (numeric_op len=00). No cap, this is a must π₯
The six least significant bits hold the DSCP value. All other bits SHOULD be treated as 0. π
4.2.2.12. Type 12 - Fragment π§
Encoding: <type (1 octet), [bitmask_op, bitmask]+>
This one is for matching specific IP fragments with a list of {bitmask_op, bitmask} pairs. It uses the Bitmask Operator from Section 4.2.1.2. The Type 12 component bitmask MUST be encoded as single octet bitmask (bitmask_op len=00). β¨
0 1 2 3 4 5 6 7
+---+---+---+---+---+---+---+---+
| 0 | 0 | 0 | 0 |LF |FF |IsF|DF |
+---+---+---+---+---+---+---+---+
Figure 4: Fragment Bitmask Operand
Let's decode those bits, bestie π
- DF (Don't Fragment): match if IP Header Flags Bit-1 (DF) [RFC0791] is 1
- IsF (Is a fragment other than the first): match if the [RFC0791] IP Header Fragment Offset is not 0
- FF (First Fragment): match if the [RFC0791] IP Header Fragment Offset is 0 AND Flags Bit-2 (MF) is 1
- LF (Last Fragment): match if the [RFC0791] IP Header Fragment Offset is not 0 AND Flags Bit-2 (MF) is 0
- 0: MUST be set to 0 on NLRI encoding and MUST be ignored during decoding π
4.3. Examples of Encodings πΈ
4.3.1. Example 1 π
Okay, let's see a real one! This is an example of a Flow Specification NLRI encoding for: "all packets to 192.0.2.0/24 and TCP port 25" π¦
+========+================+==========+==========+
| length | destination | protocol | port |
+========+================+==========+==========+
| 0x0b | 01 18 c0 00 02 | 03 81 06 | 04 81 19 |
+--------+----------------+----------+----------+
Table 2
Decoded:
+=======+==============================================+
| Value | |
+=======+============+=================================+
| 0x0b | length | 11 octets (if len<240, 1 octet) |
+-------+------------+---------------------------------+
| 0x01 | type | Type 1 - Destination Prefix |
+-------+------------+---------------------------------+
| 0x18 | length | 24 bit |
+-------+------------+---------------------------------+
| 0xc0 | prefix | 192 |
+-------+------------+---------------------------------+
| 0x00 | prefix | 0 |
+-------+------------+---------------------------------+
| 0x02 | prefix | 2 |
+-------+------------+---------------------------------+
| 0x03 | type | Type 3 - IP Protocol |
+-------+------------+---------------------------------+
| 0x81 | numeric_op | end-of-list, value size=1, == |
+-------+------------+---------------------------------+
| 0x06 | value | 6 (TCP) |
+-------+------------+---------------------------------+
| 0x04 | type | Type 4 - Port |
+-------+------------+---------------------------------+
| 0x81 | numeric_op | end-of-list, value size=1, == |
+-------+------------+---------------------------------+
| 0x19 | value | 25 |
+-------+------------+---------------------------------+
Table 3
This constitutes an NLRI with an NLRI length of 11 octets. Easy win π
4.3.2. Example 2 π
Let's level up! This is an example of a Flow Specification NLRI encoding for: "all packets to 192.0.2.0/24 from 203.0.113.0/24 and port {range [137, 139] or 8080}" π
+========+================+================+=============+
| length | destination | source | port |
+========+================+================+=============+
| 0x12 | 01 18 c0 00 02 | 02 18 cb 00 71 | 04 03 89 45 |
| | | | 8b 91 1f 90 |
+--------+----------------+----------------+-------------+
Table 4
Decoded:
+========+==============================================+
| Value | |
+========+============+=================================+
| 0x12 | length | 18 octets (if len<240, 1 octet) |
+--------+------------+---------------------------------+
| 0x01 | type | Type 1 - Destination Prefix |
+--------+------------+---------------------------------+
| 0x18 | length | 24 bit |
+--------+------------+---------------------------------+
| 0xc0 | prefix | 192 |
+--------+------------+---------------------------------+
| 0x00 | prefix | 0 |
+--------+------------+---------------------------------+
| 0x02 | prefix | 2 |
+--------+------------+---------------------------------+
| 0x02 | type | Type 2 - Source Prefix |
+--------+------------+---------------------------------+
| 0x18 | length | 24 bit |
+--------+------------+---------------------------------+
| 0xcb | prefix | 203 |
+--------+------------+---------------------------------+
| 0x00 | prefix | 0 |
+--------+------------+---------------------------------+
| 0x71 | prefix | 113 |
+--------+------------+---------------------------------+
| 0x04 | type | Type 4 - Port |
+--------+------------+---------------------------------+
| 0x03 | numeric_op | value size=1, >= |
+--------+------------+---------------------------------+
| 0x89 | value | 137 |
+--------+------------+---------------------------------+
| 0x45 | numeric_op | "AND", value size=1, <= |
+--------+------------+---------------------------------+
| 0x8b | value | 139 |
+--------+------------+---------------------------------+
| 0x91 | numeric_op | end-of-list, value size=2, == |
+--------+------------+---------------------------------+
| 0x1f90 | value | 8080 |
+--------+------------+---------------------------------+
Table 5
This constitutes an NLRI with an NLRI length of 18 octets. That's two examples down and we're literally slaying ππ
4.3.3. Example 3 π§
okay bestie, example 3 is the fragment one and it's lowkey my fave π we want an encoding for: "all packets to 192.0.2.1/32 and fragment { DF or FF } (matching packet with DF bit set or First Fragments)" β¨
+========+===================+==========+
| length | destination | fragment |
+========+===================+==========+
| 0x09 | 01 20 c0 00 02 01 | 0c 80 05 |
+--------+-------------------+----------+
Table 6
Now let's decode it, it's giving detective energy ππΈ
+=======+=============================================+
| Value | |
+=======+============+================================+
| 0x09 | length | 9 octets (if len<240, 1 octet) |
+-------+------------+--------------------------------+
| 0x01 | type | Type 1 - Destination Prefix |
+-------+------------+--------------------------------+
| 0x20 | length | 32 bit |
+-------+------------+--------------------------------+
| 0xc0 | prefix | 192 |
+-------+------------+--------------------------------+
| 0x00 | prefix | 0 |
+-------+------------+--------------------------------+
| 0x02 | prefix | 2 |
+-------+------------+--------------------------------+
| 0x01 | prefix | 1 |
+-------+------------+--------------------------------+
| 0x0c | type | Type 12 - Fragment |
+-------+------------+--------------------------------+
| 0x80 | bitmask_op | end-of-list, value size=1 |
+-------+------------+--------------------------------+
| 0x05 | bitmask | DF=1, FF=1 |
+-------+------------+--------------------------------+
Table 7
This constitutes an NLRI with an NLRI length of 9 octets. π
5. Traffic Filtering π¦
Traffic filtering policies have always been kind of static, like a outfit you never change π so the static mechanisms had limits, and that's why this new dynamic mechanism got designed for three new applications of traffic filtering:
- Prevention of traffic-based, denial-of-service (DoS) attacks
- Traffic filtering in the context of BGP/MPLS VPN service
- Centralized traffic control for SDN/NFV networks
These applications require coordination among service providers and/or coordination among the AS within a service provider. π«Ά
The Flow Specification NLRI defined in Section 4 carries information about traffic filtering rules for traffic that should be discarded or handled in a manner specified by a set of predefined actions (which are defined in BGP Extended Communities). This mechanism is mainly built so an upstream autonomous system can do inbound filtering in its ingress routers, for traffic that a given downstream AS wants dropped. Main character energy π
To get there, this document specifies two application-specific NLRI identifiers that provide traffic filters, plus a set of actions encoded in BGP Extended Communities. The two application-specific NLRI identifiers are:
- IPv4 Flow Specification identifier (
AFI=1,SAFI=133) along with specific semantic rules for IPv4 routes - VPNv4 Flow Specification identifier (
AFI=1,SAFI=134) value, which can be used to propagate traffic filtering information in a BGP/MPLS VPN environment
Encoding of the NLRI is described in Section 4 for IPv4 Flow Specification and in Section 8 for VPNv4 Flow Specification. The filtering actions are described in Section 7. π
5.1. Ordering of Flow Specifications
okay so more than one Flow Specification can match the same traffic flow π so we need a clear order for which Flow Specifications get matched first and which actions get applied. The ordering has to not depend on the arrival order of the Flow Specification via BGP, so it stays consistent across the network. iykyk π
The relative order of two Flow Specifications is decided by comparing their components. The algorithm starts with the left-most components (lowest component type value). If the types differ, the Flow Specification with the lowest numeric type value has higher precedence, so it matches first, over the one that doesn't contain that component type. If the component types are the same, a type-specific comparison happens (see below). If the types are equal, the algorithm moves on to the next component. π
For IP prefix values (IP destination or source prefix), if one of the two prefixes is a more specific prefix of the other, the more specific prefix wins. Otherwise, the one with the lowest IP value has higher precedence. β¨
For all other component types, unless otherwise specified, the comparison is done by treating the component data as a binary string using the memcmp() function as defined by [ISO_IEC_9899]. For strings with equal lengths, the lowest string (memcmp) has higher precedence. For strings of different lengths, the common prefix is compared. If the common prefix is not equal, the string with the lowest prefix has higher precedence. If the common prefix is equal, the longest string is considered to have higher precedence than the shorter one. π§
The code in Appendix A shows a Python3 implementation of the comparison algorithm. The full code was tested with Python 3.6.3 and can be found at https://github.com/stoffi92/rfc5575bis/tree/master/flowspec-cmp. π
6. Validation Procedure π₯
Flow Specifications received from a BGP peer that are accepted in the respective Adj-RIB-In are used as input to the route selection process. Even though two routes for the same Flow Specification prefix may have the same forwarding attributes, BGP is still required to run its path selection algorithm, so it can pick the correct set of attributes to advertise. π«Ά
The first step of the BGP Route Selection procedure (Section 9.1.2 of [RFC4271]) is to exclude routes that are considered unfeasible from the selection procedure. For IP routing information, this step checks that the NEXT_HOP attribute of a given route is resolvable. πΈ
The concept can be extended, for the Flow Specification NLRI, to allow other validation procedures. π¦
The validation process below checks Flow Specifications against unicast routes received over the same AFI, but with the associated unicast routing information SAFI:
- Flow Specification received over
SAFI=133will be validated against routes received overSAFI=1. - Flow Specification received over
SAFI=134will be validated against routes received overSAFI=128.
Without explicit configuration, a Flow Specification NLRI MUST be validated such that it is considered feasible if and only if all of the conditions below are true:
a) A destination prefix component is embedded in the Flow Specification.
b) The originator of the Flow Specification matches the originator of the best-match unicast route for the destination prefix embedded in the Flow Specification (this is the unicast route with the longest possible prefix length covering the destination prefix embedded in the Flow Specification).
c) There are no "more-specific" unicast routes, compared with the flow destination prefix, that have been received from a different neighboring AS than the best-match unicast route determined in rule b.
However, rule a MAY be relaxed by explicit configuration, permitting Flow Specifications that include no destination prefix component. If that's the case, rules b and c are moot and MUST be disregarded. π
By "originator" of a BGP route, we mean either the address of the originator in the ORIGINATOR_ID Attribute [RFC4456] or the source IP address of the BGP peer, if this path attribute is not present. π
BGP implementations MUST also enforce that the AS_PATH attribute of a route received via the External Border Gateway Protocol (eBGP) contains the neighboring AS in the left-most position of the AS_PATH attribute. While this rule is optional in the BGP specification, it becomes necessary to enforce it here for security reasons. This one is serious, no cap π
The best-match unicast route can change over time, independently of the Flow Specification NLRI. So a revalidation of the Flow Specification NLRI MUST be performed whenever unicast routes change. Revalidation means retesting rules a to c as described above. π
Explanation:
The underlying concept is that the neighboring AS advertising the best unicast route for a destination is allowed to advertise Flow Specification information that conveys a destination prefix that is more or equally specific. So as long as there are no "more-specific" unicast routes received from a different neighboring AS, which would be affected by that Flow Specification, the Flow Specification is validated successfully. π
The neighboring AS is the immediate destination of the traffic described by the Flow Specification. If it requests these flows to be dropped, that request can be honored without worrying that it's a denial of service in itself. The reasoning is that it's as if the traffic is being dropped by the downstream autonomous system, and there's no added value in carrying the traffic to it. π
7. Traffic Filtering Actions β¨
okay bestie, this is where the rules get actionable π This section defines a minimum set of Traffic Filtering Actions that get standardized as BGP Extended Communities [RFC4360]. It's not a full list of every action you could ever want, just the subset that can be read the same way across the whole network π«Ά Extra actions can be defined later, either through standards or as vendor-specific stuff π
The default action for a matching Flow Specification is to accept the packet, which means it gets treated according to the normal forwarding behavior of the system π¦ so nothing dramatic unless an action says otherwise π
This document defines the Extended Communities values in Table 8 in the form 0xttss, where tt is the type and ss is the sub-type of the Extended Community. The encodings for these are described below πΈ
+==================+======================+=======================+
| community 0xttss | action | encoding |
+==================+======================+=======================+
| 0x8006 | traffic-rate-bytes | 2-octet AS, 4-octet |
| | (Section 7.1) | float |
+------------------+----------------------+-----------------------+
| 0x800c | traffic-rate-packets | 2-octet AS, 4-octet |
| | (Section 7.2) | float |
+------------------+----------------------+-----------------------+
| 0x8007 | traffic-action | bitmask |
| | (Section 7.3) | |
+------------------+----------------------+-----------------------+
| 0x8008 | rt-redirect AS- | 2-octet AS, 4-octet |
| | 2octet (Section 7.4) | value |
+------------------+----------------------+-----------------------+
| 0x8108 | rt-redirect IPv4 | 4-octet IPv4 address, |
| | (Section 7.4) | 2-octet value |
+------------------+----------------------+-----------------------+
| 0x8208 | rt-redirect AS- | 4-octet AS, 2-octet |
| | 4octet (Section 7.4) | value |
+------------------+----------------------+-----------------------+
| 0x8009 | traffic-marking | DSCP value |
| | (Section 7.5) | |
+------------------+----------------------+-----------------------+
Table 8: Traffic Filtering Action Extended Communities
Multiple Traffic Filtering Actions from this document can show up on the same Flow Specification and SHOULD be applied to the traffic flow π₯ For example, traffic-rate-bytes and rt-redirect can both hit the same packets at once π If not all of the Traffic Filtering Actions can be applied to a traffic flow, they should be treated as interfering Traffic Filtering Actions (see below) π
Some Traffic Filtering Actions can interfere with each other or even contradict π Section 7.7 of this document gives general considerations on that kind of drama. Any additional definition of Traffic Filtering Actions SHOULD specify what to do if those actions interfere, including with existing Traffic Filtering Actions π
All Traffic Filtering Actions are specified as transitive BGP Extended Communities β¨
7.1. Traffic Rate in Bytes (traffic-rate-bytes) Sub-Type 0x06
The traffic-rate-bytes Extended Community uses this Extended Community encoding π
The first two octets carry the 2-octet id, which can be assigned from a 2-octet AS number. When a 4-octet AS number is locally present, the 2 least significant octets of that AS number can be used π This value is purely informational and SHOULD NOT be interpreted by the implementation π
The remaining 4 octets carry the maximum rate in IEEE floating point [IEEE.754.1985] format, with units of bytes per second π A traffic-rate of 0 should result in all traffic for the particular flow being discarded π On encoding, the traffic-rate MUST NOT be negative π« On decoding, negative values MUST be treated as zero, which means discard all traffic π
Heads up: negative values are never allowed when encoding, and get treated as zero when decoding. Don't skip this one, it's the whole vibe π«Ά
Interferes with: may interfere with the traffic-rate-packets (see Section 7.2). A policy may allow both filtering by traffic-rate-packets and traffic-rate-bytes. If the policy does not allow this, these two actions will conflict π
7.2. Traffic Rate in Packets (traffic-rate-packets) Sub-Type 0x0c
The traffic-rate-packets Extended Community uses the same encoding as the traffic-rate-bytes Extended Community π¦ The floating point value carries the maximum packet rate in packets per second. A traffic-rate-packets of 0 should result in all traffic for the particular flow being discarded πΈ On encoding, the traffic-rate-packets MUST NOT be negative π« On decoding, negative values MUST be treated as zero, which means discard all traffic π
Interferes with: may interfere with the traffic-rate-bytes (see Section 7.1). A policy may allow both filtering by traffic-rate-packets and traffic-rate-bytes. If the policy does not allow this, these two actions will conflict π
7.3. Traffic-Action (traffic-action) Sub-Type 0x07
The traffic-action Extended Community is 6 octets long, but only the 2 least significant bits of the 6th octet (read from left to right) are defined by this document π§ Figure 5 shows it all π
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Traffic Action Field |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Tr. Action Field (cont.) |S|T|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 5: Traffic-Action Extended Community Encoding
S and T are defined as follows:
Tis the Terminal Action (bit 47). When this bit is set, the traffic filtering engine will evaluate any subsequent Flow Specifications, following the ordering procedure in Section 5.1. If it's not set, the evaluation of the traffic filters stops when this Flow Specification is evaluated πSis the Sample (bit 46). It enables traffic sampling and logging for this Flow Specification, and it only takes effect when set πΈ
Traffic Action Field: the other Traffic Action Field bits (see Section 11) that aren't used in this specification. These bits MUST be set to 0 on encoding and MUST be ignored during decoding π«Ά
The use of the Terminal Action (bit 47) may result in more than one Flow Specification matching a particular traffic flow. All the Traffic Filtering Actions from these Flow Specifications shall be collected and applied. When Traffic Filtering Actions interfere, it's an implementation decision which ones get selected. See also Section 7.7 π
Interferes with: no other BGP Flow Specification Traffic Filtering Action in this document π
7.4. RT Redirect (rt-redirect) Sub-Type 0x08
The redirect Extended Community lets traffic get redirected to a VRF routing instance that lists the specified route-target in its import policy π¦ If several local instances match, the choice between them is a local matter. For example, the instance with the lowest Route Distinguisher value can be picked π
This Extended Community allows 3 different encoding formats for the route-target (type 0x80, 0x81, 0x82) π It uses the same encoding as the Route Target Extended Community in Sections 3.1 (type 0x80: 2-octet AS, 4-octet value), 3.2 (type 0x81: 4-octet IPv4 address, 2-octet value), and 4 of [RFC4360], and Section 2 of [RFC5668] (type 0x82: 4-octet AS, 2-octet value). The high-order octet of the Type field is 0x80, 0x81, or 0x82 respectively, and the low-order octet (Sub-Type) is always 0x08 πΈ
Interferes with: no other BGP Flow Specification Traffic Filtering Action in this document π
7.5. Traffic Marking (traffic-marking) Sub-Type 0x09
The traffic marking Extended Community tells a system to change the DSCP bits in the IP header (Section 3 of [RFC2474]) of a transiting IP packet. The new value is the one encoded in the 6 least significant bits of the Extended Community value, as shown in Figure 6 β¨
The Extended Community is encoded like this π§
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| reserved | reserved | reserved | reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| reserved | r.| DSCP |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 6: Traffic Marking Extended Community Encoding
DSCP: the new DSCP value for the transiting IP packet π
reserved (r): MUST be set to 0 on encoding and MUST be ignored during decoding π«Ά
Interferes with: no other BGP Flow Specification Traffic Filtering Action in this document π
7.6. Interaction with Other Filtering Mechanisms in Routers
Implementations should provide mechanisms that map an arbitrary BGP community value (normal or extended) to Traffic Filtering Actions. Different systems in the network often need different mappings for these π For instance, giving packets a worse-than-best-effort per-hop behavior is something that's likely to be implemented differently across systems, and no standard behavior is currently known for it π Rather than trying to define that here, it can be handled by mapping a user-defined community value to platform- or network-specific behavior through user configuration β
7.7. Considerations on Traffic Filtering Action Interference
Since Traffic Filtering Actions are represented as BGP extended community values, they can interfere with each other. For example, there may be more than one conflicting traffic-rate-bytes Traffic Filtering Action tied to a single Flow Specification π Interference between Traffic Filtering Actions has no impact on BGP propagation of Flow Specifications, since all communities are propagated according to policies π
If a Flow Specification with interfering Traffic Filtering Actions gets selected for packet forwarding, it's an implementation decision which of those interfering actions get selected. Implementors of this specification SHOULD document how their implementation behaves in such cases π
Operators are encouraged to use the BGP policy framework supported by their implementation to get predictable behavior. See also Section 12 π¦
8. Dissemination of Traffic Filtering in BGP/MPLS VPN Networks πΈ
okay so provider-based Layer 3 VPN networks, like the ones running on a BGP/MPLS IP VPN [RFC4364] control plane, can have different traffic filtering requirements than Internet service providers do. but ALSO, ISPs might use those VPNs for stuff like keeping the Internet routing table in a VRF, so they end up with the exact same filtering needs as the global routing table setup in this doc. that's giving full circle πβ¨ This document defines an additional BGP NLRI type (AFI=1, SAFI=134) value, which can be used to propagate Flow Specification in a BGP/MPLS VPN environment.
The NLRI format for this address family is a fixed-length Route Distinguisher field (8 octets) followed by the Flow Specification NLRI value (Section 4.2). The NLRI length field shall include both the 8 octets of the Route Distinguisher and the subsequent Flow Specification NLRI value. The encoding looks like this π
+--------------------------------+
| length (0xnn or 0xfnnn) |
+--------------------------------+
| Route Distinguisher (8 octets) |
+--------------------------------+
| NLRI value (variable) |
+--------------------------------+
Figure 7: Flow Specification NLRI for MPLS
Propagation of this NLRI is controlled by matching Route Target extended communities associated with the BGP path advertisement against the VRF import policy. It uses the same mechanism described in BGP/MPLS IP VPNs [RFC4364], so no new drama there π
Flow Specifications received via this NLRI apply only to traffic that belongs to the VRF(s) where they get imported. By default, traffic received from a remote PE is switched via an MPLS forwarding decision and is not subject to filtering, so it just zooms right past the rules π
Heads up, this one is different from the non-VPN NLRI! Flow Specifications are accepted by default when they're received from remote PE routers. Don't mix up the two, bestie π
The validation procedure (Section 6) and Traffic Filtering Actions (Section 7) are the same as for IPv4. Same vibes, same rules π
9. Traffic Monitoring π
Traffic filtering applications need monitoring and traffic statistics facilities. Honestly this is an implementation-specific choice, but implementations SHOULD provide:
- A mechanism to log the packet header of filtered traffic.
- A mechanism to count the number of matches for a given Flow Specification rule.
10. Error Handling π οΈ
Error handling according to [RFC7606] and [RFC4760] applies to this specification. Literally no skipping it π ββοΈ
This document introduces Traffic Filtering Action Extended Communities. Malformed Traffic Filtering Action Extended Communities, in the sense of Section 7.14 of [RFC7606], are Extended Community values that cannot be decoded according to Section 7 of this document. So if it won't decode, it's officially malformed π
11. IANA Considerations π¦
This section complies with [RFC7153].
11.1. AFI/SAFI Definitions
IANA maintains a registry entitled "SAFI Values". For the purpose of this work, IANA has updated the following SAFIs as shown in the table below. (Note: This document obsoletes both [RFC7674] and [RFC5575], and all references to those documents have been deleted from the registry. Bye bye, old refs π)
+=======+===========================================+===========+
| Value | Name | Reference |
+=======+===========================================+===========+
| 133 | Dissemination of Flow Specification rules | RFC 8955 |
+-------+-------------------------------------------+-----------+
| 134 | L3VPN Dissemination of Flow Specification | RFC 8955 |
| | rules | |
+-------+-------------------------------------------+-----------+
Table 9: Registry: SAFI Values
The above textual changes generalize the definition of the SAFIs rather than change their underlying meaning. So, based on "The YANG 1.1 Data Modeling Language" [RFC7950], the following YANG enums from "Common YANG Data Types for the Routing Area" [RFC8294] have had their names and descriptions at <https://www.iana.org/assignments/iana-routing-types> changed to:
enum flow-spec-safi {
value 133;
description
"Dissemination of Flow Specification rules SAFI.";
}
enum l3vpn-flow-spec-safi {
value 134;
description
"L3VPN Dissemination of Flow Specification rules SAFI.";
}
A new revision statement has been added to the module as follows:
revision 2020-12-31 {
description "Non-backwards-compatible change of SAFI names
(SAFI values 133, 134).";
reference
"RFC 8955: Dissemination of Flow Specification Rules.";
}
11.2. Flow Component Definitions
A Flow Specification consists of a sequence of flow components, which are identified by an 8-bit component type. IANA has created and maintains a registry entitled "Flow Spec Component Types". IANA has updated the reference for this registry to RFC 8955. Furthermore, the references to the values have been updated according to the table below (Note: This document obsoletes both [RFC7674] and [RFC5575], and all references to those documents have been deleted from the registry.)
+=======+====================+===========+
| Value | Name | Reference |
+=======+====================+===========+
| 1 | Destination Prefix | RFC 8955 |
+-------+--------------------+-----------+
| 2 | Source Prefix | RFC 8955 |
+-------+--------------------+-----------+
| 3 | IP Protocol | RFC 8955 |
+-------+--------------------+-----------+
| 4 | Port | RFC 8955 |
+-------+--------------------+-----------+
| 5 | Destination port | RFC 8955 |
+-------+--------------------+-----------+
| 6 | Source port | RFC 8955 |
+-------+--------------------+-----------+
| 7 | ICMP type | RFC 8955 |
+-------+--------------------+-----------+
| 8 | ICMP code | RFC 8955 |
+-------+--------------------+-----------+
| 9 | TCP flags | RFC 8955 |
+-------+--------------------+-----------+
| 10 | Packet length | RFC 8955 |
+-------+--------------------+-----------+
| 11 | DSCP | RFC 8955 |
+-------+--------------------+-----------+
| 12 | Fragment | RFC 8955 |
+-------+--------------------+-----------+
Table 10: Registry: Flow Spec
Component Types
In order to manage the limited number space and accommodate several usages, the following policies defined by [RFC8126] are used:
+==============+========================+
| Type Values | Policy |
+==============+========================+
| 0 | Reserved |
+--------------+------------------------+
| [1 .. 127] | Specification Required |
+--------------+------------------------+
| [128 .. 254] | Expert Review |
+--------------+------------------------+
| 255 | Reserved |
+--------------+------------------------+
Table 11: Flow Spec Component Types
Policies
Guidance for Experts: the registration policy for the range 128-254 is Expert Review. The experts are expected to check the clarity of purpose and use of the requested code points. The experts must also verify that any specification produced in the IETF that requests one of these code points has been made available for review by the IDR Working Group, and that any specification produced outside the IETF does not conflict with work that is active or already published within the IETF. It must be pointed out that introducing new component types may break interoperability with existing implementations of this protocol. Proceed with care, experts π§β οΈ
11.3. Extended Community Flow Specification Actions π
okay so the Extended Community Flow Specification Action types in this doc are made of two parts π
- Type (BGP Transitive Extended Community Type)
- Sub-Type
For the type part, IANA keeps a registry called "BGP Transitive Extended Community Types" π¦. For this work (Section 7), IANA updated the references like the table shows. Heads up: this doc obsoletes both [RFC7674] and [RFC5575], and all the references to those got deleted from the registry π
+=======+=======================================+===========+
| Type | Name | Reference |
| Value | | |
+=======+=======================================+===========+
| 0x81 | Generic Transitive Experimental Use | RFC 8955 |
| | Extended Community Part 2 (Sub-Types | |
| | are defined in the "Generic | |
| | Transitive Experimental Use Extended | |
| | Community Part 2 Sub-Types" Registry) | |
+-------+---------------------------------------+-----------+
| 0x82 | Generic Transitive Experimental Use | RFC 8955 |
| | Extended Community Part 3 (Sub-Types | |
| | are defined in the "Generic | |
| | Transitive Experimental Use Extended | |
| | Community Part 3 Sub-Types" Registry) | |
+-------+---------------------------------------+-----------+
Table 12: Registry: BGP Transitive Extended Community Types
For the sub-type part of the Extended Community Traffic Filtering Actions, IANA has a few registries πΈ. IANA has updated all the names and references according to the tables below and assigns a new value for the "Flow spec traffic-rate-packets" Sub-Type β¨. Note: this doc obsoletes both [RFC7674] and [RFC5575], and all references to those were deleted from the registries below.
+==========+=====================================+===========+
| Sub-Type | Name | Reference |
| Value | | |
+==========+=====================================+===========+
| 0x06 | Flow spec traffic-rate-bytes | RFC 8955 |
+----------+-------------------------------------+-----------+
| 0x0c | Flow spec traffic-rate-packets | RFC 8955 |
+----------+-------------------------------------+-----------+
| 0x07 | Flow spec traffic-action (Use of | RFC 8955 |
| | the "Value" field is defined in the | |
| | "Traffic Action Fields" registry) | |
+----------+-------------------------------------+-----------+
| 0x08 | Flow spec rt-redirect AS-2octet | RFC 8955 |
| | format | |
+----------+-------------------------------------+-----------+
| 0x09 | Flow spec traffic-remarking | RFC 8955 |
+----------+-------------------------------------+-----------+
Table 13: Registry: Generic Transitive Experimental Use
Extended Community Sub- Types
+================+===================================+===========+
| Sub-Type Value | Name | Reference |
+================+===================================+===========+
| 0x08 | Flow spec rt-redirect IPv4 format | RFC 8955 |
+----------------+-----------------------------------+-----------+
Table 14: Registry: Generic Transitive Experimental Use
Extended Community Part 2 Sub-Types
+================+=======================+===========+
| Sub-Type Value | Name | Reference |
+================+=======================+===========+
| 0x08 | Flow spec rt-redirect | RFC 8955 |
| | AS-4octet format | |
+----------------+-----------------------+-----------+
Table 15: Registry: Generic Transitive
Experimental Use Extended Community Part 3 Sub-
Types
Furthermore, IANA has updated the reference for the registries "Generic Transitive Experimental Use Extended Community Part 2 Sub-Types" and "Generic Transitive Experimental Use Extended Community Part 3 Sub-Types" to RFC 8955 π.
The "traffic-action" Extended Community (Section 7.3) defined in this document has 46 unused bits π§, which can be used to convey additional meaning. IANA created and maintains a registry called "Traffic Action Fields" π. IANA has updated the reference for this registry to RFC 8955. IANA has also updated the references according to the table below. These values should be assigned via IETF Review rules only. Note: this doc obsoletes both [RFC7674] and [RFC5575], and all references to those were deleted from the registry.
+=====+=================+===========+
| Bit | Name | Reference |
+=====+=================+===========+
| 47 | Terminal Action | RFC 8955 |
+-----+-----------------+-----------+
| 46 | Sample | RFC 8955 |
+-----+-----------------+-----------+
Table 16: Registry: Traffic
Action Fields
12. Security Considerations π‘οΈ
bestie, this section is SERIOUS π¨ read it like your network depends on it, because it kinda does π
as long as Flow Specifications are restricted to match the matching unicast routing paths for the relevant prefixes (Section 6), the security characteristics of this proposal are equivalent to the existing security properties of BGP unicast routing π. Any relaxation of the validation procedure described in Section 6 may let unwanted Flow Specifications get propagated, and then unwanted Traffic Filtering Actions could be applied to flows π¬.
If the above mechanisms aren't in place, this could open the door to more denial-of-service attacks, like unwanted traffic filtering, remarking, or redirection π.
Deploying specific relaxations of the validation inside an administrative boundary of a network can be useful in some networks for quickly pushing out filters to stop denial-of-service attacks β¨. For a network to use this relaxation, the BGP policies MUST support additional filtering, since the origin AS field is empty. Any specification that relaxes the validation restrictions MUST include security considerations that spell out the required additional filtering π. For example, origin validation can give you extra filtering within an AS confederation π.
Inter-provider routing runs on a web of trust πΈοΈ. Neighboring autonomous systems are trusted to advertise valid reachability information. If that trust model gets violated, a neighboring autonomous system may cause a denial-of-service attack by advertising reachability information for a given prefix that it doesn't actually serve (an unfiltered address space hijack) π±. Since validation of the Flow Specification is tied to the announcement of the best unicast route, a failure in validating the best path route may stop a local router from using the Flow Specification. Possible mitigations are [RFC6811] and [RFC8205] π¦.
On Internet Exchange Points (IXPs), routes are often exchanged through route servers that do not extend the AS_PATH πΈ. In those cases, it's not possible to enforce that the left-most AS in the AS_PATH is the neighbor AS (the AS of the route server). Since validation of the Flow Specification (Section 6) depends on that, extra care is needed. It is advised to use a strict inbound route policy in these scenarios π§±.
Enabling firewall-like capabilities in routers without centralized management could make certain failures harder to diagnose π. For example, it's possible to allow TCP packets to pass between a pair of addresses but not ICMP packets. It's also possible to permit packets smaller than 900 or greater than 1000 octets to pass between a pair of addresses but not packets whose length is in the range 900-1000. That behavior may be confusing, so these capabilities should be used with care, whether they're manually configured or coordinated through the protocol extensions described in this document π«Ά.
Flow Specification BGP speakers (e.g., automated DDoS controllers) that aren't properly programmed, algorithms that aren't performing as expected, or simply rogue systems may announce unintended Flow Specifications, send updates at a high rate, or generate a large number of Flow Specifications π¨. This may stress the receiving systems, exceed their capacity, or lead to unwanted Traffic Filtering Actions being applied to flows π.
Systems may not be able to find all the header values needed to identify a packet π§. This can be especially tricky with fragmented packets that aren't the first fragment, because they lack upper-layer protocol headers or Encapsulating Security Payload (ESP) NULL [RFC4303] encryption π.
While the general verification of the Flow Specification NLRI is specified in this document (Section 6), Traffic Filtering Actions received from a third party may need custom verification or filtering π. In particular, all non-traffic-rate actions may let a third party change packet forwarding properties and potentially gain access to other routing tables/VPNs or undesired queues π. This can be avoided by properly filtering/screening Traffic Filtering Action communities at network borders, and only exposing a predefined subset of Traffic Filtering Actions (see Section 7) to third parties π. One way to do that is to map user-defined communities, which the third party can set, to Traffic Filtering Actions, and to not accept Traffic Filtering Action extended communities from third parties π .
This extension adds more information to Internet routers π₯οΈ. Routers are limited in how many data elements they can hold and how many events they can process in a given unit of time. Service providers need to consider the maximum capacity of their devices and may need to limit the number of Flow Specifications they accept and process β.
13. References π
13.1. Normative References β¨
Okay bestie, these are the must-read docs the spec leans on ππ Each one is listed with all its details so nothing gets lost.
- [IEEE.754.1985] IEEE, "Standard for Binary Floating-Point Arithmetic", IEEE 754-1985, DOI 10.1109/IEEESTD.2019.8766229, August 1985, <https://doi.org/10.1109/IEEESTD.2019.8766229>.
- [ISO_IEC_9899] ISO, "Information technology -- Programming languages -- C", ISO/IEC 9899:2018, June 2018.
- [RFC0768] Postel, J., "User Datagram Protocol", STD 6, RFC 768, DOI 10.17487/RFC0768, August 1980, <https://www.rfc-editor.org/info/rfc768>.
- [RFC0791] Postel, J., "Internet Protocol", STD 5, RFC 791, DOI 10.17487/RFC0791, September 1981, <https://www.rfc-editor.org/info/rfc791>.
- [RFC0792] Postel, J., "Internet Control Message Protocol", STD 5, RFC 792, DOI 10.17487/RFC0792, September 1981, <https://www.rfc-editor.org/info/rfc792>.
- [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, RFC 793, DOI 10.17487/RFC0793, September 1981, <https://www.rfc-editor.org/info/rfc793>.
- [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, <https://www.rfc-editor.org/info/rfc2119>.
- [RFC2474] Nichols, K., Blake, S., Baker, F., and D. Black, "Definition of the Differentiated Services Field (DS Field) in the IPv4 and IPv6 Headers", RFC 2474, DOI 10.17487/RFC2474, December 1998, <https://www.rfc-editor.org/info/rfc2474>.
- [RFC4271] Rekhter, Y., Ed., Li, T., Ed., and S. Hares, Ed., "A Border Gateway Protocol 4 (BGP-4)", RFC 4271, DOI 10.17487/RFC4271, January 2006, <https://www.rfc-editor.org/info/rfc4271>.
- [RFC4360] Sangli, S., Tappan, D., and Y. Rekhter, "BGP Extended Communities Attribute", RFC 4360, DOI 10.17487/RFC4360, February 2006, <https://www.rfc-editor.org/info/rfc4360>.
- [RFC4364] Rosen, E. and Y. Rekhter, "BGP/MPLS IP Virtual Private Networks (VPNs)", RFC 4364, DOI 10.17487/RFC4364, February 2006, <https://www.rfc-editor.org/info/rfc4364>.
- [RFC4456] Bates, T., Chen, E., and R. Chandra, "BGP Route Reflection: An Alternative to Full Mesh Internal BGP (IBGP)", RFC 4456, DOI 10.17487/RFC4456, April 2006, <https://www.rfc-editor.org/info/rfc4456>.
- [RFC4760] Bates, T., Chandra, R., Katz, D., and Y. Rekhter, "Multiprotocol Extensions for BGP-4", RFC 4760, DOI 10.17487/RFC4760, January 2007, <https://www.rfc-editor.org/info/rfc4760>.
- [RFC5668] Rekhter, Y., Sangli, S., and D. Tappan, "4-Octet AS Specific BGP Extended Community", RFC 5668, DOI 10.17487/RFC5668, October 2009, <https://www.rfc-editor.org/info/rfc5668>.
- [RFC7153] Rosen, E. and Y. Rekhter, "IANA Registries for BGP Extended Communities", RFC 7153, DOI 10.17487/RFC7153, March 2014, <https://www.rfc-editor.org/info/rfc7153>.
- [RFC7606] Chen, E., Ed., Scudder, J., Ed., Mohapatra, P., and K. Patel, "Revised Error Handling for BGP UPDATE Messages", RFC 7606, DOI 10.17487/RFC7606, August 2015, <https://www.rfc-editor.org/info/rfc7606>.
- [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for Writing an IANA Considerations Section in RFCs", BCP 26, RFC 8126, DOI 10.17487/RFC8126, June 2017, <https://www.rfc-editor.org/info/rfc8126>.
- [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, <https://www.rfc-editor.org/info/rfc8174>.
13.2. Informative References πΈ
These ones are the extra reading, the "ooh tell me more" section π§ Not required, but so good to have.
- [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", RFC 4303, DOI 10.17487/RFC4303, December 2005, <https://www.rfc-editor.org/info/rfc4303>.
- [RFC5575] Marques, P., Sheth, N., Raszuk, R., Greene, B., Mauch, J., and D. McPherson, "Dissemination of Flow Specification Rules", RFC 5575, DOI 10.17487/RFC5575, August 2009, <https://www.rfc-editor.org/info/rfc5575>.
- [RFC6811] Mohapatra, P., Scudder, J., Ward, D., Bush, R., and R. Austein, "BGP Prefix Origin Validation", RFC 6811, DOI 10.17487/RFC6811, January 2013, <https://www.rfc-editor.org/info/rfc6811>.
- [RFC7674] Haas, J., Ed., "Clarification of the Flowspec Redirect Extended Community", RFC 7674, DOI 10.17487/RFC7674, October 2015, <https://www.rfc-editor.org/info/rfc7674>.
- [RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", RFC 7950, DOI 10.17487/RFC7950, August 2016, <https://www.rfc-editor.org/info/rfc7950>.
- [RFC8205] Lepinski, M., Ed. and K. Sriram, Ed., "BGPsec Protocol Specification", RFC 8205, DOI 10.17487/RFC8205, September 2017, <https://www.rfc-editor.org/info/rfc8205>.
- [RFC8294] Liu, X., Qu, Y., Lindem, A., Hopps, C., and L. Berger, "Common YANG Data Types for the Routing Area", RFC 8294, DOI 10.17487/RFC8294, December 2017, <https://www.rfc-editor.org/info/rfc8294>.
- [RFC8956] Loibl, C., Ed., Raszuk, R., Ed., and S. Hares, Ed., "Dissemination of Flow Specification Rules for IPv6", RFC 8956, DOI 10.17487/RFC8956, December 2020, <https://www.rfc-editor.org/info/rfc8956>.
Appendix A. Example Python code: flow_rule_cmp ππ
Here's the example Python code for the flow rule comparison, copied exactly as the RFC has it π«Ά
<CODE BEGINS>
"""
Copyright (c) 2020 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, is permitted pursuant to, and subject to the license
terms contained in, the Simplified BSD License set forth in Section
4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info).
"""
import itertools
import collections
import ipaddress
EQUAL = 0
A_HAS_PRECEDENCE = 1
B_HAS_PRECEDENCE = 2
IP_DESTINATION = 1
IP_SOURCE = 2
FS_component = collections.namedtuple('FS_component',
'component_type op_value')
class FS_nlri(object):
"""
FS_nlri class implementation that allows sorting.
By calling .sort() on an array of FS_nlri objects these will be
sorted according to the flow_rule_cmp algorithm.
Example:
nlri = [ FS_nlri(components=[
FS_component(component_type=IP_DESTINATION,
op_value=ipaddress.ip_network('10.1.0.0/16') ),
FS_component(component_type=4,
op_value=bytearray([0,1,2,3,4,5,6])),
]),
FS_nlri(components=[
FS_component(component_type=5,
op_value=bytearray([0,1,2,3,4,5,6])),
FS_component(component_type=6,
op_value=bytearray([0,1,2,3,4,5,6])),
]),
]
nlri.sort() # sorts the array according to the algorithm
"""
def __init__(self, components = None):
"""
components: list of type FS_component
"""
self.components = components
def __lt__(self, other):
# use the below algorithm for sorting
result = flow_rule_cmp(self, other)
if result == B_HAS_PRECEDENCE:
return True
else:
return False
def flow_rule_cmp(a, b):
"""
Example of the flowspec comparison algorithm.
"""
for comp_a, comp_b in itertools.zip_longest(a.components,
b.components):
# If a component type does not exist in one rule
# this rule has lower precedence
if not comp_a:
return B_HAS_PRECEDENCE
if not comp_b:
return A_HAS_PRECEDENCE
# Higher precedence for lower component type
if comp_a.component_type < comp_b.component_type:
return A_HAS_PRECEDENCE
if comp_a.component_type > comp_b.component_type:
return B_HAS_PRECEDENCE
# component types are equal -> type specific comparison
if comp_a.component_type in (IP_DESTINATION, IP_SOURCE):
# assuming comp_a.op_value, comp_b.op_value of
# type ipaddress.IPv4Network
if comp_a.op_value.overlaps(comp_b.op_value):
# longest prefixlen has precedence
if comp_a.op_value.prefixlen > \
comp_b.op_value.prefixlen:
return A_HAS_PRECEDENCE
if comp_a.op_value.prefixlen < \
comp_b.op_value.prefixlen:
return B_HAS_PRECEDENCE
# components equal -> continue with next component
elif comp_a.op_value > comp_b.op_value:
return B_HAS_PRECEDENCE
elif comp_a.op_value < comp_b.op_value:
return A_HAS_PRECEDENCE
else:
# assuming comp_a.op_value, comp_b.op_value of type
# bytearray
if len(comp_a.op_value) == len(comp_b.op_value):
if comp_a.op_value > comp_b.op_value:
return B_HAS_PRECEDENCE
if comp_a.op_value < comp_b.op_value:
return A_HAS_PRECEDENCE
# components equal -> continue with next component
else:
common = min(len(comp_a.op_value),
len(comp_b.op_value))
if comp_a.op_value[:common] > \
comp_b.op_value[:common]:
return B_HAS_PRECEDENCE
elif comp_a.op_value[:common] < \
comp_b.op_value[:common]:
return A_HAS_PRECEDENCE
# the first common bytes match
elif len(comp_a.op_value) > len(comp_b.op_value):
return A_HAS_PRECEDENCE
else:
return B_HAS_PRECEDENCE
return EQUAL
<CODE ENDS>
Appendix B. Comparison with RFC 5575 β¨
okay bestie, this is the glow-up tea π΅ This document has tons of editorial changes compared to [RFC5575]. It also fully bakes in the redirect action clarification doc [RFC7674]. It is recommended to read the entire document π The authors do want to flag these technical changes to [RFC5575]:
- Section 1 introduces the Flow Specification NLRI π¦. In [RFC5575], BGP treats this NLRI as an opaque key to an entry in its databases. This specification has removed all references to an opaque key property. BGP implementations are able to understand the NLRI encoding.
- Section 4.2.1.1 defines a numeric operator and comparison bit combinations π§. In [RFC5575], the meaning of those bit combination was not explicitly defined and left open to the reader.
- Sections 4.2.2.3 - 4.2.2.8, 4.2.2.10, and 4.2.2.11 make use of the above numeric operator π. The allowed length of the comparison value was not consistently defined in [RFC5575].
- Section 7 defines all Traffic Filtering Action Extended Communities as transitive Extended Communities π. [RFC5575] defined the traffic-rate action to be non-transitive and did not define the transitivity of the other Traffic Filtering Action communities at all.
- Section 7.2 introduces a new Traffic Filtering Action (
traffic-rate-packets) π₯. This action did not exist in [RFC5575]. - Section 7.4 contains the same redirect actions already defined in [RFC5575], however, these actions have been renamed to
rt-redirectπΈ to make it clearer that the redirection is based on route-target. This section also completely incorporates the [RFC7674] clarifications of the Flowspec Redirect Extended Community. - Section 7.7 contains general considerations on interfering traffic actions π. Section 7.3 also cross-references Section 7.7. [RFC5575] did not mention this.
- Section 10 contains new error handling β¨.
Acknowledgments π«Ά
The authors would like to thank Yakov Rekhter, Dennis Ferguson, Chris Morrow, Charlie Kaufman, and David Smith for their comments on the original [RFC5575]. Chaitanya Kodeboyina helped design the flow validation procedure, and Steven Lin and Jim Washburn ironed out all the details necessary to produce a working implementation in the original [RFC5575].
A packet rate Traffic Filtering Action was also described in a Flow Specification extension draft and the authors would like to thank Wesley Eddy, Justin Dailey, and Gilbert Clark for their work π.
Additionally, the authors would like to thank Alexander Mayrhofer, Nicolas Fevrier, Job Snijders, Jeffrey Haas, and Adam Chappell for their comments and review π .
Contributors π
Barry Greene, Pedro Marques, Jared Mauch, and Nischal Sheth were authors on [RFC5575] and, therefore, are contributing authors on this document β.
Authors' Addresses π¦
Christoph Loibl
next layer Telekom GmbH
Mariahilfer Guertel 37/7
1150 Vienna
Austria
Phone: +43 664 1176414
Email: cl@tix.at
Susan Hares
Huawei
7453 Hickory Hill
Saline, MI 48176
United States of America
Email: shares@ndzh.com
Robert Raszuk
NTT Network Innovations
940 Stewart Dr
Sunnyvale, CA 94085
United States of America
Email: robert@raszuk.net
Danny McPherson
Verisign
United States of America
Email: dmcpherson@verisign.com
Martin Bacher
T-Mobile Austria
Rennweg 97-99
1030 Vienna
Austria
Email: mb.ietf@gmail.com
π¦ where this page comes from
- ietf: rfc8955 2020-12
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms