idnits 2.17.1 draft-ietf-idr-rfc5575bis-27.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- -- The document has examples using IPv4 documentation addresses according to RFC6890, but does not use any IPv6 documentation addresses. Maybe there should be IPv6 examples, too? -- The draft header indicates that this document obsoletes RFC7674, but the abstract doesn't seem to directly say this. It does mention RFC7674 though, so this could be OK. -- The draft header indicates that this document obsoletes RFC5575, but the abstract doesn't seem to directly say this. It does mention RFC5575 though, so this could be OK. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (October 15, 2020) is 1289 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '137' on line 654 -- Looks like a reference, but probably isn't: '139' on line 654 -- Looks like a reference, but probably isn't: '1' on line 1615 -- Looks like a reference, but probably isn't: '2' on line 1617 -- Possible downref: Non-RFC (?) normative reference: ref. 'IEEE.754.1985' ** Obsolete normative reference: RFC 793 (Obsoleted by RFC 9293) == Outdated reference: A later version (-22) exists of draft-ietf-idr-flow-spec-v6-15 -- Obsolete informational reference (is this intentional?): RFC 5575 (Obsoleted by RFC 8955) -- Obsolete informational reference (is this intentional?): RFC 7674 (Obsoleted by RFC 8955) Summary: 1 error (**), 0 flaws (~~), 2 warnings (==), 11 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 IDR Working Group C. Loibl 3 Internet-Draft next layer Telekom GmbH 4 Obsoletes: 5575,7674 (if approved) S. Hares 5 Intended status: Standards Track Huawei 6 Expires: April 18, 2021 R. Raszuk 7 Bloomberg LP 8 D. McPherson 9 Verisign 10 M. Bacher 11 T-Mobile Austria 12 October 15, 2020 14 Dissemination of Flow Specification Rules 15 draft-ietf-idr-rfc5575bis-27 17 Abstract 19 This document defines a Border Gateway Protocol Network Layer 20 Reachability Information (BGP NLRI) encoding format that can be used 21 to distribute traffic Flow Specifications. This allows the routing 22 system to propagate information regarding more specific components of 23 the traffic aggregate defined by an IP destination prefix. 25 It also specifies BGP Extended Community encoding formats, that can 26 be used to propagate Traffic Filtering Actions along with the Flow 27 Specification NLRI. Those Traffic Filtering Actions encode actions a 28 routing system can take if the packet matches the Flow Specification. 30 Additionally, it defines two applications of that encoding format: 31 one that can be used to automate inter-domain coordination of traffic 32 filtering, such as what is required in order to mitigate 33 (distributed) denial-of-service attacks, and a second application to 34 provide traffic filtering in the context of a BGP/MPLS VPN service. 35 Other applications (e.g. centralized control of traffic in a SDN or 36 NFV context) are also possible. Other documents may specify Flow 37 Specification extensions. 39 The information is carried via BGP, thereby reusing protocol 40 algorithms, operational experience, and administrative processes such 41 as inter-provider peering agreements. 43 This document obsoletes both RFC5575 and RFC7674. 45 Status of This Memo 47 This Internet-Draft is submitted in full conformance with the 48 provisions of BCP 78 and BCP 79. 50 Internet-Drafts are working documents of the Internet Engineering 51 Task Force (IETF). Note that other groups may also distribute 52 working documents as Internet-Drafts. The list of current Internet- 53 Drafts is at https://datatracker.ietf.org/drafts/current/. 55 Internet-Drafts are draft documents valid for a maximum of six months 56 and may be updated, replaced, or obsoleted by other documents at any 57 time. It is inappropriate to use Internet-Drafts as reference 58 material or to cite them other than as "work in progress." 60 This Internet-Draft will expire on April 18, 2021. 62 Copyright Notice 64 Copyright (c) 2020 IETF Trust and the persons identified as the 65 document authors. All rights reserved. 67 This document is subject to BCP 78 and the IETF Trust's Legal 68 Provisions Relating to IETF Documents 69 (https://trustee.ietf.org/license-info) in effect on the date of 70 publication of this document. Please review these documents 71 carefully, as they describe your rights and restrictions with respect 72 to this document. Code Components extracted from this document must 73 include Simplified BSD License text as described in Section 4.e of 74 the Trust Legal Provisions and are provided without warranty as 75 described in the Simplified BSD License. 77 Table of Contents 79 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 80 2. Definitions of Terms Used in This Memo . . . . . . . . . . . 5 81 3. Flow Specifications . . . . . . . . . . . . . . . . . . . . . 5 82 4. Dissemination of IPv4 Flow Specification Information . . . . 6 83 4.1. Length Encoding . . . . . . . . . . . . . . . . . . . . . 7 84 4.2. NLRI Value Encoding . . . . . . . . . . . . . . . . . . . 7 85 4.2.1. Operators . . . . . . . . . . . . . . . . . . . . . . 7 86 4.2.2. Components . . . . . . . . . . . . . . . . . . . . . 9 87 4.3. Examples of Encodings . . . . . . . . . . . . . . . . . . 14 88 5. Traffic Filtering . . . . . . . . . . . . . . . . . . . . . . 16 89 5.1. Ordering of Flow Specifications . . . . . . . . . . . . . 17 90 6. Validation Procedure . . . . . . . . . . . . . . . . . . . . 18 91 7. Traffic Filtering Actions . . . . . . . . . . . . . . . . . . 19 92 7.1. Traffic Rate in Bytes (traffic-rate-bytes) sub-type 0x06 21 93 7.2. Traffic Rate in Packets (traffic-rate-packets) sub-type 94 TBD . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 95 7.3. Traffic-action (traffic-action) sub-type 0x07 . . . . . . 21 96 7.4. RT Redirect (rt-redirect) sub-type 0x08 . . . . . . . . . 22 97 7.5. Traffic Marking (traffic-marking) sub-type 0x09 . . . . . 23 98 7.6. Interaction with other Filtering Mechanisms in Routers . 23 99 7.7. Considerations on Traffic Filtering Action Interference . 24 100 8. Dissemination of Traffic Filtering in BGP/MPLS VPN Networks . 24 101 9. Traffic Monitoring . . . . . . . . . . . . . . . . . . . . . 25 102 10. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 25 103 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 25 104 11.1. AFI/SAFI Definitions . . . . . . . . . . . . . . . . . . 25 105 11.2. Flow Component Definitions . . . . . . . . . . . . . . . 27 106 11.3. Extended Community Flow Specification Actions . . . . . 28 107 12. Security Considerations . . . . . . . . . . . . . . . . . . . 30 108 13. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 32 109 14. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 32 110 15. References . . . . . . . . . . . . . . . . . . . . . . . . . 32 111 15.1. Normative References . . . . . . . . . . . . . . . . . . 32 112 15.2. Informative References . . . . . . . . . . . . . . . . . 34 113 15.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 35 114 Appendix A. Example Python code: flow_rule_cmp . . . . . . . . . 35 115 Appendix B. Comparison with RFC 5575 . . . . . . . . . . . . . . 38 116 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 39 118 1. Introduction 120 This document obsoletes "Dissemination of Flow Specification Rules" 121 [RFC5575] (see Appendix B for the differences). This document also 122 obsoletes "Clarification of the Flowspec Redirect Extended Community" 123 [RFC7674] since it incorporates the encoding of the BGP Flow 124 Specification Redirect Extended Community in Section 7.4. 126 Modern IP routers have the capability to forward traffic and to 127 classify, shape, rate limit, filter, or redirect packets based on 128 administratively defined policies. These traffic policy mechanisms 129 allow the operator to define match rules that operate on multiple 130 fields of the packet header. Actions such as the ones described 131 above can be associated with each rule. 133 The n-tuple consisting of the matching criteria defines an aggregate 134 traffic Flow Specification. The matching criteria can include 135 elements such as source and destination address prefixes, IP 136 protocol, and transport protocol port numbers. 138 Section 4 of this document defines a general procedure to encode Flow 139 Specifications for aggregated traffic flows so that they can be 140 distributed as a BGP [RFC4271] NLRI. Additionally, Section 7 of this 141 document defines the required Traffic Filtering Actions BGP Extended 142 Communities and mechanisms to use BGP for intra- and inter-provider 143 distribution of traffic filtering rules to filter (distributed) 144 denial-of-service (DoS) attacks. 146 By expanding routing information with Flow Specifications, the 147 routing system can take advantage of the ACL (Access Control List) or 148 firewall capabilities in the router's forwarding path. Flow 149 Specifications can be seen as more specific routing entries to a 150 unicast prefix and are expected to depend upon the existing unicast 151 data information. 153 A Flow Specification received from an external autonomous system will 154 need to be validated against unicast routing before being accepted 155 (Section 6). The Flow Specification received from an internal BGP 156 peer within the same autonomous system [RFC4271] is assumed to have 157 been validated prior to transmission within the internal BGP (iBGP) 158 mesh of an autonomous system. If the aggregate traffic flow defined 159 by the unicast destination prefix is forwarded to a given BGP peer, 160 then the local system can install more specific Flow Specifications 161 that may result in different forwarding behavior, as requested by 162 this system. 164 From an operational perspective, the utilization of BGP as the 165 carrier for this information allows a network service provider to 166 reuse both internal route distribution infrastructure (e.g., route 167 reflector or confederation design) and existing external 168 relationships (e.g., inter-domain BGP sessions to a customer 169 network). 171 While it is certainly possible to address this problem using other 172 mechanisms, this solution has been utilized in deployments because of 173 the substantial advantage of being an incremental addition to already 174 deployed mechanisms. 176 In current deployments, the information distributed by this extension 177 is originated both manually as well as automatically, the latter by 178 systems that are able to detect malicious traffic flows. When 179 automated systems are used, care should be taken to ensure the 180 correctness of the automated system. The the limitations of the 181 receiving systems that need to process these automated Flow 182 Specifications need to be taken in consideration as well (see also 183 Section 12). 185 This specification defines required protocol extensions to address 186 most common applications of IPv4 unicast and VPNv4 unicast filtering. 187 The same mechanism can be reused and new match criteria added to 188 address similar filtering needs for other BGP address families such 189 as IPv6 families [I-D.ietf-idr-flow-spec-v6]. 191 2. Definitions of Terms Used in This Memo 193 AFI - Address Family Identifier. 195 AS - Autonomous System. 197 Loc-RIB - The Loc-RIB contains the routes that have been selected 198 by the local BGP speaker's Decision Process [RFC4271]. 200 NLRI - Network Layer Reachability Information. 202 PE - Provider Edge router. 204 RIB - Routing Information Base. 206 SAFI - Subsequent Address Family Identifier. 208 VRF - Virtual Routing and Forwarding instance. 210 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 211 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 212 "OPTIONAL" in this document are to be interpreted as described in BCP 213 14 [RFC2119] [RFC8174] when, and only when, they appear in all 214 capitals, as shown here. 216 3. Flow Specifications 218 A Flow Specification is an n-tuple consisting of several matching 219 criteria that can be applied to IP traffic. A given IP packet is 220 said to match the defined Flow Specification if it matches all the 221 specified criteria. This n-tuple is encoded into a BGP NLRI defined 222 below. 224 A given Flow Specification may be associated with a set of 225 attributes, depending on the particular application; such attributes 226 may or may not include reachability information (i.e., NEXT_HOP). 227 Well-known or AS-specific community attributes can be used to encode 228 a set of predetermined actions. 230 A particular application is identified by a specific (Address Family 231 Identifier, Subsequent Address Family Identifier (AFI, SAFI)) pair 232 [RFC4760] and corresponds to a distinct set of RIBs. Those RIBs 233 should be treated independently from each other in order to assure 234 non-interference between distinct applications. 236 BGP itself treats the NLRI as a key to an entry in its databases. 237 Entries that are placed in the Loc-RIB are then associated with a 238 given set of semantics, which is application dependent. This is 239 consistent with existing BGP applications. For instance, IP unicast 240 routing (AFI=1, SAFI=1) and IP multicast reverse-path information 241 (AFI=1, SAFI=2) are handled by BGP without any particular semantics 242 being associated with them until installed in the Loc-RIB. 244 Standard BGP policy mechanisms, such as UPDATE filtering by NLRI 245 prefix as well as community matching and must apply to the Flow 246 specification defined NLRI-type. Network operators can also control 247 propagation of such routing updates by enabling or disabling the 248 exchange of a particular (AFI, SAFI) pair on a given BGP peering 249 session. 251 4. Dissemination of IPv4 Flow Specification Information 253 This document defines a Flow Specification NLRI type (Figure 1) that 254 may include several components such as destination prefix, source 255 prefix, protocol, ports, and others (see Section 4.2 below). 257 This NLRI information is encoded using MP_REACH_NLRI and 258 MP_UNREACH_NLRI attributes as defined in [RFC4760]. When advertising 259 Flow Specifications, the Length of Next Hop Network Address MUST be 260 set to 0. The Network Address of Next Hop field MUST be ignored. 262 The NLRI field of the MP_REACH_NLRI and MP_UNREACH_NLRI is encoded as 263 one or more 2-tuples of the form . It consists 264 of a 1- or 2-octet length field followed by a variable-length NLRI 265 value. The length is expressed in octets. 267 +-------------------------------+ 268 | length (0xnn or 0xfnnn) | 269 +-------------------------------+ 270 | NLRI value (variable) | 271 +-------------------------------+ 273 Figure 1: Flow Specification NLRI for IPv4 275 Implementations wishing to exchange Flow Specification MUST use BGP's 276 Capability Advertisement facility to exchange the Multiprotocol 277 Extension Capability Code (Code 1) as defined in [RFC4760]. The 278 (AFI, SAFI) pair carried in the Multiprotocol Extension Capability 279 MUST be (AFI=1, SAFI=133) for IPv4 Flow Specification, and (AFI=1, 280 SAFI=134) for VPNv4 Flow Specification. 282 4.1. Length Encoding 284 o If the NLRI length is smaller than 240 (0xf0 hex) octets, the 285 length field can be encoded as a single octet. 287 o Otherwise, it is encoded as an extended-length 2-octet value in 288 which the most significant nibble has the hex value 0xf. 290 In Figure 1 above, values less-than 240 are encoded using two hex 291 digits (0xnn). Values above 239 are encoded using 3 hex digits 292 (0xfnnn). The highest value that can be represented with this 293 encoding is 4095. For example the length value of 239 is encoded as 294 0xef (single octet) while 240 is encoded as 0xf0f0 (2-octet). 296 4.2. NLRI Value Encoding 298 The Flow Specification NLRI value consists of a list of optional 299 components and is encoded as follows: 301 Encoding: <[component]+> 303 A specific packet is considered to match the Flow Specification when 304 it matches the intersection (AND) of all the components present in 305 the Flow Specification. 307 Components MUST follow strict type ordering by increasing numerical 308 order. A given component type MAY (exactly once) be present in the 309 Flow Specification. If present, it MUST precede any component of 310 higher numeric type value. 312 All combinations of components within a single Flow Specification are 313 allowed. However, some combinations cannot match any packets (e.g. 314 "ICMP Type AND Port" will never match any packets), and thus SHOULD 315 NOT be propagated by BGP. 317 A NLRI value not encoded as specified here, including a NLRI that 318 contains an unknown component type, is considered malformed and error 319 handling according to Section 10 is performed. 321 4.2.1. Operators 323 Most of the components described below make use of comparison 324 operators. Which of the two operators is used is defined by the 325 components in Section 4.2.2. The operators are encoded as a single 326 octet. 328 4.2.1.1. Numeric Operator (numeric_op) 330 This operator is encoded as shown in Figure 2. 332 0 1 2 3 4 5 6 7 333 +---+---+---+---+---+---+---+---+ 334 | e | a | len | 0 |lt |gt |eq | 335 +---+---+---+---+---+---+---+---+ 337 Figure 2: Numeric Operator (numeric_op) 339 e - end-of-list bit: Set in the last {op, value} pair in the list. 341 a - AND bit: If unset, the result of the previous {op, value} pair 342 is logically ORed with the current one. If set, the operation is 343 a logical AND. In the first operator octet of a sequence it MUST 344 be encoded as unset and MUST be treated as always unset on 345 decoding. The AND operator has higher priority than OR for the 346 purposes of evaluating logical expressions. 348 len - length: The length of the value field for this operator given 349 as (1 << len). This encodes 1 (len=00), 2 (len=01), 4 (len=10), 8 350 (len=11) octets. 352 0 - MUST be set to 0 on NLRI encoding, and MUST be ignored during 353 decoding 355 lt - less than comparison between data and value. 357 gt - greater than comparison between data and value. 359 eq - equality between data and value. 361 The bits lt, gt, and eq can be combined to produce common relational 362 operators such as "less or equal", "greater or equal", and "not equal 363 to" as shown in Table 1. 365 +----+----+----+-----------------------------------+ 366 | lt | gt | eq | Resulting operation | 367 +----+----+----+-----------------------------------+ 368 | 0 | 0 | 0 | false (independent of the value) | 369 | 0 | 0 | 1 | == (equal) | 370 | 0 | 1 | 0 | > (greater than) | 371 | 0 | 1 | 1 | >= (greater than or equal) | 372 | 1 | 0 | 0 | < (less than) | 373 | 1 | 0 | 1 | <= (less than or equal) | 374 | 1 | 1 | 0 | != (not equal value) | 375 | 1 | 1 | 1 | true (independent of the value) | 376 +----+----+----+-----------------------------------+ 378 Table 1: Comparison operation combinations 380 4.2.1.2. Bitmask Operator (bitmask_op) 382 This operator is encoded as shown in Figure 3. 384 0 1 2 3 4 5 6 7 385 +---+---+---+---+---+---+---+---+ 386 | e | a | len | 0 | 0 |not| m | 387 +---+---+---+---+---+---+---+---+ 389 Figure 3: Bitmask Operator (bitmask_op) 391 e, a, len - Most significant nibble: (end-of-list bit, AND bit, and 392 length field), as defined in the Numeric Operator format in 393 Section 4.2.1.1. 395 not - NOT bit: If set, logical negation of operation. 397 m - Match bit: If set, this is a bitwise match operation defined as 398 "(data AND value) == value"; if unset, (data AND value) evaluates 399 to TRUE if any of the bits in the value mask are set in the data 401 0 - all 0 bits: MUST be set to 0 on NLRI encoding, and MUST be 402 ignored during decoding 404 4.2.2. Components 406 The encoding of each of the components begins with a type field (1 407 octet) followed by a variable length parameter. The following 408 sections define component types and parameter encodings for the IPv4 409 IP layer and transport layer headers. IPv6 NLRI component types are 410 described in [I-D.ietf-idr-flow-spec-v6]. 412 4.2.2.1. Type 1 - Destination Prefix 414 Encoding: 416 Defines the destination prefix to match. The length and prefix 417 fields are encoded as in BGP UPDATE messages [RFC4271] 419 4.2.2.2. Type 2 - Source Prefix 421 Encoding: 423 Defines the source prefix to match. The length and prefix fields are 424 encoded as in BGP UPDATE messages [RFC4271] 426 4.2.2.3. Type 3 - IP Protocol 428 Encoding: 430 Contains a list of {numeric_op, value} pairs that are used to match 431 the IP protocol value octet in IP packet header (see [RFC0791] 432 Section 3.1). 434 This component uses the Numeric Operator (numeric_op) described in 435 Section 4.2.1.1. Type 3 component values SHOULD be encoded as single 436 octet (numeric_op len=00). 438 4.2.2.4. Type 4 - Port 440 Encoding: 442 Defines a list of {numeric_op, value} pairs that matches source OR 443 destination TCP/UDP ports (see [RFC0793] Section 3.1 and [RFC0768] 444 Section "Format"). This component matches if either the destination 445 port OR the source port of a IP packet matches the value. 447 This component uses the Numeric Operator (numeric_op) described in 448 Section 4.2.1.1. Type 4 component values SHOULD be encoded as 1- or 449 2-octet quantities (numeric_op len=00 or len=01). 451 In case of the presence of the port (destination-port 452 Section 4.2.2.5, source-port Section 4.2.2.6) component only TCP or 453 UDP packets can match the entire Flow Specification. The port 454 component, if present, never matches when the packet's IP protocol 455 value is not 6 (TCP) or 17 (UDP), if the packet is fragmented and 456 this is not the first fragment, or if the system is unable to locate 457 the transport header. Different implementations may or may not be 458 able to decode the transport header in the presence of IP options or 459 Encapsulating Security Payload (ESP) NULL [RFC4303] encryption. 461 4.2.2.5. Type 5 - Destination Port 463 Encoding: 465 Defines a list of {numeric_op, value} pairs used to match the 466 destination port of a TCP or UDP packet (see also [RFC0793] 467 Section 3.1 and [RFC0768] Section "Format"). 469 This component uses the Numeric Operator (numeric_op) described in 470 Section 4.2.1.1. Type 5 component values SHOULD be encoded as 1- or 471 2-octet quantities (numeric_op len=00 or len=01). 473 The last paragraph of Section 4.2.2.4 also applies to this component. 475 4.2.2.6. Type 6 - Source Port 477 Encoding: 479 Defines a list of {numeric_op, value} pairs used to match the source 480 port of a TCP or UDP packet (see also [RFC0793] Section 3.1 and 481 [RFC0768] Section "Format"). 483 This component uses the Numeric Operator (numeric_op) described in 484 Section 4.2.1.1. Type 6 component values SHOULD be encoded as 1- or 485 2-octet quantities (numeric_op len=00 or len=01). 487 The last paragraph of Section 4.2.2.4 also applies to this component. 489 4.2.2.7. Type 7 - ICMP type 491 Encoding: 493 Defines a list of {numeric_op, value} pairs used to match the type 494 field of an ICMP packet (see also [RFC0792] Section "Message 495 Formats"). 497 This component uses the Numeric Operator (numeric_op) described in 498 Section 4.2.1.1. Type 7 component values SHOULD be encoded as single 499 octet (numeric_op len=00). 501 In case of the presence of the ICMP type component only ICMP packets 502 can match the entire Flow Specification. The ICMP type component, if 503 present, never matches when the packet's IP protocol value is not 1 504 (ICMP), if the packet is fragmented and this is not the first 505 fragment, or if the system is unable to locate the transport header. 506 Different implementations may or may not be able to decode the 507 transport header in the presence of IP options or Encapsulating 508 Security Payload (ESP) NULL [RFC4303] encryption. 510 4.2.2.8. Type 8 - ICMP code 512 Encoding: 514 Defines a list of {numeric_op, value} pairs used to match the code 515 field of an ICMP packet (see also [RFC0792] Section "Message 516 Formats"). 518 This component uses the Numeric Operator (numeric_op) described in 519 Section 4.2.1.1. Type 8 component values SHOULD be encoded as single 520 octet (numeric_op len=00). 522 In case of the presence of the ICMP code component only ICMP packets 523 can match the entire Flow Specification. The ICMP code component, if 524 present, never matches when the packet's IP protocol value is not 1 525 (ICMP), if the packet is fragmented and this is not the first 526 fragment, or if the system is unable to locate the transport header. 527 Different implementations may or may not be able to decode the 528 transport header in the presence of IP options or Encapsulating 529 Security Payload (ESP) NULL [RFC4303] encryption. 531 4.2.2.9. Type 9 - TCP flags 533 Encoding: 535 Defines a list of {bitmask_op, bitmask} pairs used to match TCP 536 Control Bits (see also [RFC0793] Section 3.1). 538 This component uses the Bitmask Operator (bitmask_op) described in 539 Section 4.2.1.2. Type 9 component bitmasks MUST be encoded as 1- or 540 2-octet bitmask (bitmask_op len=00 or len=01). 542 When a single octet (bitmask_op len=00) is specified, it matches 543 octet 14 of the TCP header (see also [RFC0793] Section 3.1), which 544 contains the TCP Control Bits. When a 2-octet (bitmask_op len=01) 545 encoding is used, it matches octets 13 and 14 of the TCP header with 546 the data offset (leftmost 4 bits) always treated as 0. 548 In case of the presence of the TCP flags component only TCP packets 549 can match the entire Flow Specification. The TCP flags component, if 550 present, never matches when the packet's IP protocol value is not 6 551 (TCP), if the packet is fragmented and this is not the first 552 fragment, or if the system is unable to locate the transport header. 553 Different implementations may or may not be able to decode the 554 transport header in the presence of IP options or Encapsulating 555 Security Payload (ESP) NULL [RFC4303] encryption. 557 4.2.2.10. Type 10 - Packet length 559 Encoding: 561 Defines a list of {numeric_op, value} pairs used to match on the 562 total IP packet length (excluding Layer 2 but including IP header). 564 This component uses the Numeric Operator (numeric_op) described in 565 Section 4.2.1.1. Type 10 component values SHOULD be encoded as 1- or 566 2-octet quantities (numeric_op len=00 or len=01). 568 4.2.2.11. Type 11 - DSCP (Diffserv Code Point) 570 Encoding: 572 Defines a list of {numeric_op, value} pairs used to match the 6-bit 573 DSCP field (see also [RFC2474]). 575 This component uses the Numeric Operator (numeric_op) described in 576 Section 4.2.1.1. Type 11 component values MUST be encoded as single 577 octet (numeric_op len=00). 579 The six least significant bits contain the DSCP value. All other 580 bits SHOULD be treated as 0. 582 4.2.2.12. Type 12 - Fragment 584 Encoding: 586 Defines a list of {bitmask_op, bitmask} pairs used to match specific 587 IP fragments. 589 This component uses the Bitmask Operator (bitmask_op) described in 590 Section 4.2.1.2. The Type 12 component bitmask MUST be encoded as 591 single octet bitmask (bitmask_op len=00). 593 0 1 2 3 4 5 6 7 594 +---+---+---+---+---+---+---+---+ 595 | 0 | 0 | 0 | 0 |LF |FF |IsF|DF | 596 +---+---+---+---+---+---+---+---+ 598 Figure 4: Fragment Bitmask Operand 600 Bitmask values: 602 DF - Don't fragment - match if [RFC0791] IP Header Flags Bit-1 (DF) 603 is 1 605 IsF - Is a fragment other than the first - match if [RFC0791] IP 606 Header Fragment Offset is not 0 608 FF - First fragment - match if [RFC0791] IP Header Fragment Offset 609 is 0 AND Flags Bit-2 (MF) is 1 611 LF - Last fragment - match if [RFC0791] IP Header Fragment Offset is 612 not 0 AND Flags Bit-2 (MF) is 0 614 0 - MUST be set to 0 on NLRI encoding, and MUST be ignored during 615 decoding 617 4.3. Examples of Encodings 619 4.3.1. Example 1 621 An example of a Flow Specification NLRI encoding for: "all packets to 622 192.0.2.0/24 and TCP port 25". 624 +--------+----------------+----------+----------+ 625 | length | destination | protocol | port | 626 +--------+----------------+----------+----------+ 627 | 0x0b | 01 18 c0 00 02 | 03 81 06 | 04 81 19 | 628 +--------+----------------+----------+----------+ 630 Decoded: 632 +-------+------------+-------------------------------+ 633 | Value | | | 634 +-------+------------+-------------------------------+ 635 | 0x0b | length | 11 octets (len<240 1-octet) | 636 | 0x01 | type | Type 1 - Destination Prefix | 637 | 0x18 | length | 24 bit | 638 | 0xc0 | prefix | 192 | 639 | 0x00 | prefix | 0 | 640 | 0x02 | prefix | 2 | 641 | 0x03 | type | Type 3 - IP Protocol | 642 | 0x81 | numeric_op | end-of-list, value size=1, == | 643 | 0x06 | value | 6 (TCP) | 644 | 0x04 | type | Type 4 - Port | 645 | 0x81 | numeric_op | end-of-list, value size=1, == | 646 | 0x19 | value | 25 | 647 +-------+------------+-------------------------------+ 649 This constitutes a NLRI with a NLRI length of 11 octets. 651 4.3.2. Example 2 653 An example of a Flow Specification NLRI encoding for: "all packets to 654 192.0.2.0/24 from 203.0.113.0/24 and port {range [137, 139] or 655 8080}". 657 +--------+----------------+----------------+-------------------------+ 658 | length | destination | source | port | 659 +--------+----------------+----------------+-------------------------+ 660 | 0x12 | 01 18 c0 00 02 | 02 18 cb 00 71 | 04 03 89 45 8b 91 1f 90 | 661 +--------+----------------+----------------+-------------------------+ 663 Decoded: 665 +--------+------------+-------------------------------+ 666 | Value | | | 667 +--------+------------+-------------------------------+ 668 | 0x12 | length | 18 octets (len<240 1-octet) | 669 | 0x01 | type | Type 1 - Destination Prefix | 670 | 0x18 | length | 24 bit | 671 | 0xc0 | prefix | 192 | 672 | 0x00 | prefix | 0 | 673 | 0x02 | prefix | 2 | 674 | 0x02 | type | Type 2 - Source Prefix | 675 | 0x18 | length | 24 bit | 676 | 0xcb | prefix | 203 | 677 | 0x00 | prefix | 0 | 678 | 0x71 | prefix | 113 | 679 | 0x04 | type | Type 4 - Port | 680 | 0x03 | numeric_op | value size=1, >= | 681 | 0x89 | value | 137 | 682 | 0x45 | numeric_op | "AND", value size=1, <= | 683 | 0x8b | value | 139 | 684 | 0x91 | numeric_op | end-of-list, value size=2, == | 685 | 0x1f90 | value | 8080 | 686 +--------+------------+-------------------------------+ 688 This constitutes a NLRI with a NLRI length of 18 octets. 690 4.3.3. Example 3 692 An example of a Flow Specification NLRI encoding for: "all packets to 693 192.0.2.1/32 and fragment { DF or FF } (matching packet with DF bit 694 set or First Fragments) 695 +--------+-------------------+----------+ 696 | length | destination | fragment | 697 +--------+-------------------+----------+ 698 | 0x09 | 01 20 c0 00 02 01 | 0c 80 05 | 699 +--------+-------------------+----------+ 701 Decoded: 703 +-------+------------+------------------------------+ 704 | Value | | | 705 +-------+------------+------------------------------+ 706 | 0x09 | length | 9 octets (len<240 1-octet) | 707 | 0x01 | type | Type 1 - Destination Prefix | 708 | 0x20 | length | 32 bit | 709 | 0xc0 | prefix | 192 | 710 | 0x00 | prefix | 0 | 711 | 0x02 | prefix | 2 | 712 | 0x01 | prefix | 1 | 713 | 0x0c | type | Type 12 - Fragment | 714 | 0x80 | bitmask_op | end-of-list, value size=1 | 715 | 0x05 | bitmask | DF=1, FF=1 | 716 +-------+------------+------------------------------+ 718 This constitutes a NLRI with a NLRI length of 9 octets. 720 5. Traffic Filtering 722 Traffic filtering policies have been traditionally considered to be 723 relatively static. Limitations of these static mechanisms caused 724 this new dynamic mechanism to be designed for the three new 725 applications of traffic filtering: 727 o Prevention of traffic-based, denial-of-service (DOS) attacks. 729 o Traffic filtering in the context of BGP/MPLS VPN service. 731 o Centralized traffic control for SDN/NFV networks. 733 These applications require coordination among service providers and/ 734 or coordination among the AS within a service provider. 736 The Flow Specification NLRI defined in Section 4 conveys information 737 about traffic filtering rules for traffic that should be discarded or 738 handled in a manner specified by a set of pre-defined actions (which 739 are defined in BGP Extended Communities). This mechanism is 740 primarily designed to allow an upstream autonomous system to perform 741 inbound filtering in their ingress routers of traffic that a given 742 downstream AS wishes to drop. 744 In order to achieve this goal, this document specifies two 745 application-specific NLRI identifiers that provide traffic filters, 746 and a set of actions encoding in BGP Extended Communities. The two 747 application-specific NLRI identifiers are: 749 o IPv4 Flow Specification identifier (AFI=1, SAFI=133) along with 750 specific semantic rules for IPv4 routes, and 752 o VPNv4 Flow Specification identifier (AFI=1, SAFI=134) value, which 753 can be used to propagate traffic filtering information in a BGP/ 754 MPLS VPN environment. 756 Encoding of the NLRI is described in Section 4 for IPv4 Flow 757 Specification and in Section 8 for VPNv4 Flow Specification. The 758 filtering actions are described in Section 7. 760 5.1. Ordering of Flow Specifications 762 More than one Flow Specification may match a particular traffic flow. 763 Thus, it is necessary to define the order in which Flow 764 Specifications get matched and actions being applied to a particular 765 traffic flow. This ordering function is such that it does not depend 766 on the arrival order of the Flow Specification via BGP and thus is 767 consistent in the network. 769 The relative order of two Flow Specifications is determined by 770 comparing their respective components. The algorithm starts by 771 comparing the left-most components (lowest component type value) of 772 the Flow Specifications. If the types differ, the Flow Specification 773 with lowest numeric type value has higher precedence (and thus will 774 match before) than the Flow Specification that doesn't contain that 775 component type. If the component types are the same, then a type- 776 specific comparison is performed (see below). If the types are equal 777 the algorithm continues with the next component. 779 For IP prefix values (IP destination or source prefix): If one of the 780 two prefixes to compare is a more specific prefix of the other, the 781 more specific prefix has higher precedence. Otherwise the one with 782 the lowest IP value has higher precedence. 784 For all other component types, unless otherwise specified, the 785 comparison is performed by comparing the component data as a binary 786 string using the memcmp() function as defined by [ISO_IEC_9899]. For 787 strings with equal lengths the lowest string (memcmp) has higher 788 precedence. For strings of different lengths, the common prefix is 789 compared. If the common prefix is not equal the string with the 790 lowest prefix has higher precedence. If the common prefix is equal, 791 the longest string is considered to have higher precedence than the 792 shorter one. 794 The code in Appendix A shows a Python3 implementation of the 795 comparison algorithm. The full code was tested with Python 3.6.3 and 796 can be obtained at 797 https://github.com/stoffi92/rfc5575bis/tree/master/flowspec-cmp [1]. 799 6. Validation Procedure 801 Flow Specifications received from a BGP peer that are accepted in the 802 respective Adj-RIB-In are used as input to the route selection 803 process. Although the forwarding attributes of two routes for the 804 same Flow Specification prefix may be the same, BGP is still required 805 to perform its path selection algorithm in order to select the 806 correct set of attributes to advertise. 808 The first step of the BGP Route Selection procedure (Section 9.1.2 of 809 [RFC4271] is to exclude from the selection procedure routes that are 810 considered non-feasible. In the context of IP routing information, 811 this step is used to validate that the NEXT_HOP attribute of a given 812 route is resolvable. 814 The concept can be extended, in the case of the Flow Specification 815 NLRI, to allow other validation procedures. 817 The validation process described below validates Flow Specifications 818 against unicast routes received over the same AFI but the associated 819 unicast routing information SAFI: 821 Flow Specification received over SAFI=133 will be validated 822 against routes received over SAFI=1 824 Flow Specification received over SAFI=134 will be validated 825 against routes received over SAFI=128 827 In the absence of explicit configuration a Flow Specification NLRI 828 MUST be validated such that it is considered feasible if and only if 829 all of the conditions below are true: 831 a) A destination prefix component is embedded in the Flow 832 Specification. 834 b) The originator of the Flow Specification matches the originator 835 of the best-match unicast route for the destination prefix 836 embedded in the Flow Specification (this is the unicast route with 837 the longest possible prefix length covering the destination prefix 838 embedded in the Flow Specification). 840 c) There are no "more-specific" unicast routes, when compared with 841 the flow destination prefix, that have been received from a 842 different neighboring AS than the best-match unicast route, which 843 has been determined in rule b). 845 However, rule a) MAY be relaxed by explicit configuration, permitting 846 Flow Specifications that include no destination prefix component. If 847 such is the case, rules b) and c) are moot and MUST be disregarded. 849 By "originator" of a BGP route, we mean either the address of the 850 originator in the ORIGINATOR_ID Attribute [RFC4456], or the source IP 851 address of the BGP peer, if this path attribute is not present. 853 BGP implementations MUST also enforce that the AS_PATH attribute of a 854 route received via the External Border Gateway Protocol (eBGP) 855 contains the neighboring AS in the left-most position of the AS_PATH 856 attribute. While this rule is optional in the BGP specification, it 857 becomes necessary to enforce it here for security reasons. 859 The best-match unicast route may change over the time independently 860 of the Flow Specification NLRI. Therefore, a revalidation of the 861 Flow Specification NLRI MUST be performed whenever unicast routes 862 change. Revalidation is defined as retesting rules a) to c) as 863 described above. 865 Explanation: 867 The underlying concept is that the neighboring AS that advertises the 868 best unicast route for a destination is allowed to advertise Flow 869 Specification information that conveys a destination prefix that is 870 more or equally specific. Thus, as long as there are no "more- 871 specific" unicast routes, received from a different neighboring AS, 872 which would be affected by that Flow Specification, the Flow 873 Specification is validated successfully. 875 The neighboring AS is the immediate destination of the traffic 876 described by the Flow Specification. If it requests these flows to 877 be dropped, that request can be honored without concern that it 878 represents a denial of service in itself. The reasoning is that this 879 is as if the traffic is being dropped by the downstream autonomous 880 system, and there is no added value in carrying the traffic to it. 882 7. Traffic Filtering Actions 884 This document defines a minimum set of Traffic Filtering Actions that 885 it standardizes as BGP extended communities [RFC4360]. This is not 886 meant to be an inclusive list of all the possible actions, but only a 887 subset that can be interpreted consistently across the network. 889 Additional actions can be defined as either requiring standards or as 890 vendor specific. 892 The default action for a matching Flow Specification is to accept the 893 packet (treat the packet according to the normal forwarding behaviour 894 of the system). 896 This document defines the following extended communities values shown 897 in Table 2 in the form 0xttss where tt indicates the type and ss 898 indicates the sub-type of the extended community. Encodings for 899 these extended communities are described below. 901 +-------------+---------------------------+-------------------------+ 902 | community | action | encoding | 903 | 0xttss | | | 904 +-------------+---------------------------+-------------------------+ 905 | 0x8006 | traffic-rate-bytes | 2-octet AS, 4-octet | 906 | | (Section 7.1) | float | 907 | TBD | traffic-rate-packets | 2-octet AS, 4-octet | 908 | | (Section 7.1) | float | 909 | 0x8007 | traffic-action | bitmask | 910 | | (Section 7.3) | | 911 | 0x8008 | rt-redirect AS-2octet | 2-octet AS, 4-octet | 912 | | (Section 7.4) | value | 913 | 0x8108 | rt-redirect IPv4 | 4-octet IPv4 address, | 914 | | (Section 7.4) | 2-octet value | 915 | 0x8208 | rt-redirect AS-4octet | 4-octet AS, 2-octet | 916 | | (Section 7.4) | value | 917 | 0x8009 | traffic-marking | DSCP value | 918 | | (Section 7.5) | | 919 +-------------+---------------------------+-------------------------+ 921 Table 2: Traffic Filtering Action Extended Communities 923 Multiple Traffic Filtering Actions defined in this document may be 924 present for a single Flow Specification and SHOULD be applied to the 925 traffic flow (for example traffic-rate-bytes and rt-redirect can be 926 applied to packets at the same time). If not all of the Traffic 927 Filtering Actions can be applied to a traffic flow they should be 928 treated as interfering Traffic Filtering Actions (see below). 930 Some Traffic Filtering Actions may interfere with each other or even 931 contradict. Section 7.7 of this document provides general 932 considerations on such Traffic Filtering Action interference. Any 933 additional definition of Traffic Filtering Actions SHOULD specify the 934 action to take if those Traffic Filtering Actions interfere (also 935 with existing Traffic Filtering Actions). 937 All Traffic Filtering Actions are specified as transitive BGP 938 Extended Communities. 940 7.1. Traffic Rate in Bytes (traffic-rate-bytes) sub-type 0x06 942 The traffic-rate-bytes extended community uses the following extended 943 community encoding: 945 The first two octets carry the 2-octet id, which can be assigned from 946 a 2-octet AS number. When a 4-octet AS number is locally present, 947 the 2 least significant octets of such an AS number can be used. 948 This value is purely informational and SHOULD NOT be interpreted by 949 the implementation. 951 The remaining 4 octets carry the maximum rate information in IEEE 952 floating point [IEEE.754.1985] format, units being bytes per second. 953 A traffic-rate of 0 should result on all traffic for the particular 954 flow to be discarded. On encoding the traffic-rate MUST NOT be 955 negative. On decoding negative values MUST be treated as zero 956 (discard all traffic). 958 Interferes with: May interfere with the traffic-rate-packets (see 959 Section 7.2). A policy may allow both filtering by traffic-rate- 960 packets and traffic-rate-bytes. If the policy does not allow this, 961 these two actions will conflict. 963 7.2. Traffic Rate in Packets (traffic-rate-packets) sub-type TBD 965 The traffic-rate-packets extended community uses the same encoding as 966 the traffic-rate-bytes extended community. The floating point value 967 carries the maximum packet rate in packets per second. A traffic- 968 rate-packets of 0 should result in all traffic for the particular 969 flow to be discarded. On encoding the traffic-rate-packets MUST NOT 970 be negative. On decoding negative values MUST be treated as zero 971 (discard all traffic). 973 Interferes with: May interfere with the traffic-rate-bytes (see 974 Section 7.1). A policy may allow both filtering by traffic-rate- 975 packets and traffic-rate-bytes. If the policy does not allow this, 976 these two actions will conflict. 978 7.3. Traffic-action (traffic-action) sub-type 0x07 980 The traffic-action extended community consists of 6 octets of which 981 only the 2 least significant bits of the 6th octet (from left to 982 right) are defined by this document as shown in Figure 5. 984 0 1 2 3 985 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 986 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 987 | Traffic Action Field | 988 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 989 | Tr. Action Field (cont.) |S|T| 990 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 992 Figure 5: Traffic-action Extended Community Encoding 994 where S and T are defined as: 996 o T: Terminal Action (bit 47): When this bit is set, the traffic 997 filtering engine will evaluate any subsequent Flow Specifications 998 (as defined by the ordering procedure Section 5.1). If not set, 999 the evaluation of the traffic filters stops when this Flow 1000 Specification is evaluated. 1002 o S: Sample (bit 46): Enables traffic sampling and logging for this 1003 Flow Specification (only effective when set). 1005 o Traffic Action Field: Other Traffic Action Field (see Section 11) 1006 bits unused in this specification. These bits MUST be set to 0 on 1007 encoding, and MUST be ignored during decoding. 1009 The use of the Terminal Action (bit 47) may result in more than one 1010 Flow Specification matching a particular traffic flow. All the 1011 Traffic Filtering Actions from these Flow Specifications shall be 1012 collected and applied. In case of interfering Traffic Filtering 1013 Actions it is an implementation decision which Traffic Filtering 1014 Actions are selected. See also Section 7.7. 1016 Interferes with: No other BGP Flow Specification Traffic Filtering 1017 Action in this document. 1019 7.4. RT Redirect (rt-redirect) sub-type 0x08 1021 The redirect extended community allows the traffic to be redirected 1022 to a VRF routing instance that lists the specified route-target in 1023 its import policy. If several local instances match this criteria, 1024 the choice between them is a local matter (for example, the instance 1025 with the lowest Route Distinguisher value can be elected). 1027 This Extended Community allows 3 different encodings formats for the 1028 route-target (type 0x80, 0x81, 0x82). It uses the same encoding as 1029 the Route Target Extended Community in Sections 3.1 (type 0x80: 1030 2-octet AS, 4-octet value), 3.2 (type 0x81: 4-octet IPv4 address, 1031 2-octet value) and 4 of [RFC4360] and Section 2 (type 0x82: 4-octet 1032 AS, 2-octet value) of [RFC5668] with the high-order octet of the Type 1033 field 0x80, 0x81, 0x82 respectively and the low-order of the Type 1034 field (Sub-Type) always 0x08. 1036 Interferes with: No other BGP Flow Specification Traffic Filtering 1037 Action in this document. 1039 7.5. Traffic Marking (traffic-marking) sub-type 0x09 1041 The traffic marking extended community instructs a system to modify 1042 the DSCP bits in the IP header ([RFC2474] Section 3) of a transiting 1043 IP packet to the corresponding value encoded in the 6 least 1044 significant bits of the extended community value as shown in 1045 Figure 6. 1047 The extended is encoded as follows: 1049 0 1 2 3 1050 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 1051 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1052 | reserved | reserved | reserved | reserved | 1053 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1054 | reserved | r.| DSCP | 1055 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1057 Figure 6: Traffic Marking Extended Community Encoding 1059 o DSCP: new DSCP value for the transiting IP packet. 1061 o reserved, r.: MUST be set to 0 on encoding, and MUST be ignored 1062 during decoding. 1064 Interferes with: No other BGP Flow Specification Traffic Filtering 1065 Action in this document. 1067 7.6. Interaction with other Filtering Mechanisms in Routers 1069 Implementations should provide mechanisms that map an arbitrary BGP 1070 community value (normal or extended) to Traffic Filtering Actions 1071 that require different mappings on different systems in the network. 1072 For instance, providing packets with a worse-than-best-effort per-hop 1073 behavior is a functionality that is likely to be implemented 1074 differently in different systems and for which no standard behavior 1075 is currently known. Rather than attempting to define it here, this 1076 can be accomplished by mapping a user-defined community value to 1077 platform-/network-specific behavior via user configuration. 1079 7.7. Considerations on Traffic Filtering Action Interference 1081 Since Traffic Filtering Actions are represented as BGP extended 1082 community values, Traffic Filtering Actions may interfere with each 1083 other (e.g. there may be more than one conflicting traffic-rate-bytes 1084 Traffic Filtering Action associated with a single Flow 1085 Specification). Traffic Filtering Action interference has no impact 1086 on BGP propagation of Flow Specifications (all communities are 1087 propagated according to policies). 1089 If a Flow Specification associated with interfering Traffic Filtering 1090 Actions is selected for packet forwarding, it is an implementation 1091 decision which of the interfering Traffic Filtering Actions are 1092 selected. Implementors of this specification SHOULD document the 1093 behaviour of their implementation in such cases. 1095 Operators are encouraged to make use of the BGP policy framework 1096 supported by their implementation in order to achieve a predictable 1097 behaviour. See also Section 12. 1099 8. Dissemination of Traffic Filtering in BGP/MPLS VPN Networks 1101 Provider-based Layer 3 VPN networks, such as the ones using a BGP/ 1102 MPLS IP VPN [RFC4364] control plane, may have different traffic 1103 filtering requirements than Internet service providers. But also 1104 Internet service providers may use those VPNs for scenarios like 1105 having the Internet routing table in a VRF, resulting in the same 1106 traffic filtering requirements as defined for the global routing 1107 table environment within this document. This document defines an 1108 additional BGP NLRI type (AFI=1, SAFI=134) value, which can be used 1109 to propagate Flow Specification in a BGP/MPLS VPN environment. 1111 The NLRI format for this address family consists of a fixed-length 1112 Route Distinguisher field (8 octets) followed by the Flow 1113 Specification NLRI value (Section 4.2). The NLRI length field shall 1114 include both the 8 octets of the Route Distinguisher as well as the 1115 subsequent Flow Specification NLRI value. The resulting encoding is 1116 shown in Figure 7. 1118 +--------------------------------+ 1119 | length (0xnn or 0xfn nn) | 1120 +--------------------------------+ 1121 | Route Distinguisher (8 octets) | 1122 +--------------------------------+ 1123 | NLRI value (variable) | 1124 +--------------------------------+ 1126 Figure 7: Flow Specification NLRI for MPLS 1128 Propagation of this NLRI is controlled by matching Route Target 1129 extended communities associated with the BGP path advertisement with 1130 the VRF import policy, using the same mechanism as described in BGP/ 1131 MPLS IP VPNs [RFC4364]. 1133 Flow Specifications received via this NLRI apply only to traffic that 1134 belongs to the VRF(s) in which it is imported. By default, traffic 1135 received from a remote PE is switched via an MPLS forwarding decision 1136 and is not subject to filtering. 1138 Contrary to the behavior specified for the non-VPN NLRI, Flow 1139 Specifications are accepted by default, when received from remote PE 1140 routers. 1142 The validation procedure (Section 6) and Traffic Filtering Actions 1143 (Section 7) are the same as for IPv4. 1145 9. Traffic Monitoring 1147 Traffic filtering applications require monitoring and traffic 1148 statistics facilities. While this is an implementation specific 1149 choice, implementations SHOULD provide: 1151 o A mechanism to log the packet header of filtered traffic. 1153 o A mechanism to count the number of matches for a given Flow 1154 Specification. 1156 10. Error Handling 1158 Error handling according to [RFC7606] and [RFC4760] applies to this 1159 specification. 1161 This document introduces Traffic Filtering Action Extended 1162 Communities. Malformed Traffic Filtering Action Extended Communities 1163 in the sense of [RFC7606] Section 7.14. are Extended Community values 1164 that cannot be decoded according to Section 7 of this document. 1166 11. IANA Considerations 1168 This section complies with [RFC7153]. 1170 11.1. AFI/SAFI Definitions 1172 IANA maintains a registry entitled "SAFI Values". For the purpose of 1173 this work, IANA is requested to update the following SAFIs to read 1174 according to the table below (Note: This document obsoletes both 1175 RFC7674 and RFC5575 and all references to those documents should be 1176 deleted from the registry below): 1178 +-------+------------------------------------------+----------------+ 1179 | Value | Name | Reference | 1180 +-------+------------------------------------------+----------------+ 1181 | 133 | Dissemination of Flow Specification | [this | 1182 | | rules | document] | 1183 | 134 | L3VPN Dissemination of Flow | [this | 1184 | | Specification rules | document] | 1185 +-------+------------------------------------------+----------------+ 1187 Table 3: Registry: SAFI Values 1189 The above textual changes generalise the definition of the SAFIs 1190 rather than change its underlying meaning. Therefore, based on 1191 "The YANG 1.1 Data Modeling Language" [RFC7950], the above text 1192 implies that the following YANG enums from 1193 "Common YANG Data Types for the Routing Area" [RFC8294] need to have 1194 their names and descriptions at https://www.iana.org/assignments/ 1195 iana-routing-types [2] changed to: 1197 1198 enum flow-spec-safi { 1199 value 133; 1200 description 1201 "Dissemination of Flow Specification rules SAFI."; 1202 } 1203 enum l3vpn-flow-spec-safi { 1204 value 134; 1205 description 1206 "L3VPN Dissemination of Flow Specification rules SAFI."; 1207 } 1208 1210 A new revision statement should be added to the module as follows: 1212 1213 revision [revision date] { 1214 description "Non-backwards-compatible change of SAFI names 1215 (SAFI values 133, 134)."; 1216 reference 1217 "[this document]: Dissemination of Flow Specification Rules."; 1218 } 1219 1221 11.2. Flow Component Definitions 1223 A Flow Specification consists of a sequence of flow components, which 1224 are identified by an 8-bit component type. IANA has created and 1225 maintains a registry entitled "Flow Spec Component Types". IANA is 1226 requested to update the reference for this registry to [this 1227 document]. Furthermore the references to the values should be 1228 updated according to the table below (Note: This document obsoletes 1229 both RFC7674 and RFC5575 and all references to those documents should 1230 be deleted from the registry below). 1232 +-------+--------------------+-----------------+ 1233 | Value | Name | Reference | 1234 +-------+--------------------+-----------------+ 1235 | 1 | Destination Prefix | [this document] | 1236 | 2 | Source Prefix | [this document] | 1237 | 3 | IP Protocol | [this document] | 1238 | 4 | Port | [this document] | 1239 | 5 | Destination port | [this document] | 1240 | 6 | Source port | [this document] | 1241 | 7 | ICMP type | [this document] | 1242 | 8 | ICMP code | [this document] | 1243 | 9 | TCP flags | [this document] | 1244 | 10 | Packet length | [this document] | 1245 | 11 | DSCP | [this document] | 1246 | 12 | Fragment | [this document] | 1247 +-------+--------------------+-----------------+ 1249 Table 4: Registry: Flow Spec Component Types 1251 In order to manage the limited number space and accommodate several 1252 usages, the following policies defined by [RFC8126] are used: 1254 +--------------+------------------------+ 1255 | Type Values | Policy | 1256 +--------------+------------------------+ 1257 | 0 | Reserved | 1258 | [1 .. 127] | Specification Required | 1259 | [128 .. 254] | Expert Review | 1260 | 255 | Reserved | 1261 +--------------+------------------------+ 1263 Table 5: Flow Spec Component Types Policies 1265 Guidance for Experts: 1266 128-254 requires Expert Review as the registration policy. The 1267 Experts are expected to check the clarity of purpose and use of 1268 the requested code points. The Experts must also verify that 1269 any specification produced in the IETF that requests one of 1270 these code points has been made available for review by the IDR 1271 working group and that any specification produced outside the 1272 IETF does not conflict with work that is active or already 1273 published within the IETF. It must be pointed out that 1274 introducing new component types may break interoperability with 1275 existing implementations of this protocol. 1277 11.3. Extended Community Flow Specification Actions 1279 The Extended Community Flow Specification Action types defined in 1280 this document consist of two parts: 1282 Type (BGP Transitive Extended Community Type) 1284 Sub-Type 1286 For the type-part, IANA maintains a registry entitled "BGP Transitive 1287 Extended Community Types". For the purpose of this work (Section 7), 1288 IANA is requested to update the references to the following entries 1289 according to the table below (Note: This document obsoletes both 1290 RFC7674 and RFC5575 and all references to those documents should be 1291 deleted in the registry below): 1293 +-------+-----------------------------------------------+-----------+ 1294 | Type | Name | Reference | 1295 | Value | | | 1296 +-------+-----------------------------------------------+-----------+ 1297 | 0x81 | Generic Transitive Experimental | [this | 1298 | | Use Extended Community Part 2 (Sub-Types are | document] | 1299 | | defined in the "Generic Transitive | | 1300 | | Experimental Use Extended Community Part 2 | | 1301 | | Sub-Types" Registry) | | 1302 | 0x82 | Generic Transitive Experimental | [this | 1303 | | Use Extended Community Part 3 | document] | 1304 | | (Sub-Types are defined in the "Generic | | 1305 | | Transitive Experimental Use | | 1306 | | Extended Community Part 3 Sub-Types" | | 1307 | | Registry) | | 1308 +-------+-----------------------------------------------+-----------+ 1310 Table 6: Registry: BGP Transitive Extended Community Types 1312 For the sub-type part of the extended community Traffic Filtering 1313 Actions IANA maintains the following registries. IANA is requested 1314 to update all names and references according to the tables below and 1315 assign a new value for the "Flow spec traffic-rate-packets" Sub-Type 1316 (Note: This document obsoletes both RFC7674 and RFC5575 and all 1317 references to those documents should be deleted from the registries 1318 below). 1320 +----------+--------------------------------------------+-----------+ 1321 | Sub-Type | Name | Reference | 1322 | Value | | | 1323 +----------+--------------------------------------------+-----------+ 1324 | 0x06 | Flow spec traffic-rate-bytes | [this | 1325 | | | document] | 1326 | TBD | Flow spec traffic-rate-packets | [this | 1327 | | | document] | 1328 | 0x07 | Flow spec traffic-action (Use | [this | 1329 | | of the "Value" field is defined in the | document] | 1330 | | "Traffic Action Fields" registry) | | 1331 | 0x08 | Flow spec rt-redirect | [this | 1332 | | AS-2octet format | document] | 1333 | 0x09 | Flow spec traffic-remarking | [this | 1334 | | | document] | 1335 +----------+--------------------------------------------+-----------+ 1337 Table 7: Registry: Generic Transitive Experimental Use Extended 1338 Community Sub-Types 1340 +------------+----------------------------------------+-------------+ 1341 | Sub-Type | Name | Reference | 1342 | Value | | | 1343 +------------+----------------------------------------+-------------+ 1344 | 0x08 | Flow spec rt-redirect IPv4 | [this | 1345 | | format | document] | 1346 +------------+----------------------------------------+-------------+ 1348 Table 8: Registry: Generic Transitive Experimental Use Extended 1349 Community Part 2 Sub-Types 1351 +------------+-----------------------------------------+------------+ 1352 | Sub-Type | Name | Reference | 1353 | Value | | | 1354 +------------+-----------------------------------------+------------+ 1355 | 0x08 | Flow spec rt-redirect | [this | 1356 | | AS-4octet format | document] | 1357 +------------+-----------------------------------------+------------+ 1359 Table 9: Registry: Generic Transitive Experimental Use Extended 1360 Community Part 3 Sub-Types 1362 Furthermore IANA is requested to update the reference for the 1363 registries "Generic Transitive Experimental Use Extended Community 1364 Part 2 Sub-Types" and "Generic Transitive Experimental Use Extended 1365 Community Part 3 Sub-Types" to [this document]. 1367 The "traffic-action" extended community (Section 7.3) defined in this 1368 document has 46 unused bits, which can be used to convey additional 1369 meaning. IANA created and maintains a registry entitled: "Traffic 1370 Action Fields". IANA is requested to update the reference for this 1371 registry to [this document]. Furthermore IANA is requested to update 1372 the references according to the table below. These values should be 1373 assigned via IETF Review rules only (Note: This document obsoletes 1374 both RFC7674 and RFC5575 and all references to those documents should 1375 be deleted from the registry below). 1377 +-----+-----------------+-----------------+ 1378 | Bit | Name | Reference | 1379 +-----+-----------------+-----------------+ 1380 | 47 | Terminal Action | [this document] | 1381 | 46 | Sample | [this document] | 1382 +-----+-----------------+-----------------+ 1384 Table 10: Registry: Traffic Action Fields 1386 12. Security Considerations 1388 As long as Flow Specifications are restricted to match the 1389 corresponding unicast routing paths for the relevant prefixes 1390 (Section 6), the security characteristics of this proposal are 1391 equivalent to the existing security properties of BGP unicast 1392 routing. Any relaxation of the validation procedure described in 1393 Section 6 may allow unwanted Flow Specifications to be propagated and 1394 thus unwanted Traffic Filtering Actions may be applied to flows. 1396 Where the above mechanisms are not in place, this could open the door 1397 to further denial-of-service attacks such as unwanted traffic 1398 filtering, remarking or redirection. 1400 Deployment of specific relaxations of the validation within an 1401 administrative boundary of a network are useful in some networks for 1402 quickly distributing filters to prevent denial-of-service attacks. 1403 For a network to utilize this relaxation, the BGP policies must 1404 support additional filtering since the origin AS field is empty. 1405 Specifications relaxing the validation restrictions MUST contain 1406 security considerations that provide details on the required 1407 additional filtering. For example, the use of Origin validation can 1408 provide enhanced filtering within an AS confederation. 1410 Inter-provider routing is based on a web of trust. Neighboring 1411 autonomous systems are trusted to advertise valid reachability 1412 information. If this trust model is violated, a neighboring 1413 autonomous system may cause a denial-of-service attack by advertising 1414 reachability information for a given prefix for which it does not 1415 provide service (unfiltered address space hijack). Since validation 1416 of the Flow Specification is tied to the announcement of the best 1417 unicast route, the failure in the validation of best path route may 1418 prevent the Flow Specificaiton from being used by a local router. 1419 Possible mitigations are [RFC6811] and [RFC8205]. 1421 On IXPs routes are often exchanged via route servers which do not 1422 extend the AS_PATH. In such cases it is not possible to enforce the 1423 left-most AS in the AS_PATH to be the neighbor AS (the AS of the 1424 route server). Since the validation of Flow Specification 1425 (Section 6) depends on this, additional care must be taken. It is 1426 advised to use a strict inbound route policy in such scenarios. 1428 Enabling firewall-like capabilities in routers without centralized 1429 management could make certain failures harder to diagnose. For 1430 example, it is possible to allow TCP packets to pass between a pair 1431 of addresses but not ICMP packets. It is also possible to permit 1432 packets smaller than 900 or greater than 1000 octets to pass between 1433 a pair of addresses, but not packets whose length is in the range 1434 900- 1000. Such behavior may be confusing and these capabilities 1435 should be used with care whether manually configured or coordinated 1436 through the protocol extensions described in this document. 1438 Flow Specification BGP speakers (e.g. automated DDoS controllers) not 1439 properly programmed, algorithms that are not performing as expected, 1440 or simply rogue systems may announce unintended Flow Specifications, 1441 send updates at a high rate or generate a high number of Flow 1442 Specifications. This may stress the receiving systems, exceed their 1443 capacity, or lead to unwanted Traffic Filtering Actions being applied 1444 to flows. 1446 While the general verification of the Flow Specification NLRI is 1447 specified in this document (Section 6) the Traffic Filtering Actions 1448 received by a third party may need custom verification or filtering. 1449 In particular all non traffic-rate actions may allow a third party to 1450 modify packet forwarding properties and potentially gain access to 1451 other routing-tables/VPNs or undesired queues. This can be avoided 1452 by proper filtering/screening of the Traffic Filtering Action 1453 communities at network borders and only exposing a predefined subset 1454 of Traffic Filtering Actions (see Section 7) to third parties. One 1455 way to achieve this is by mapping user-defined communities, that can 1456 be set by the third party, to Traffic Filtering Actions and not 1457 accepting Traffic Filtering Action extended communities from third 1458 parties. 1460 This extension adds additional information to Internet routers. 1461 These are limited in terms of the maximum number of data elements 1462 they can hold as well as the number of events they are able to 1463 process in a given unit of time. Service providers need to consider 1464 the maximum capacity of their devices and may need to limit the 1465 number of Flow Specifications accepted and processed. 1467 13. Contributors 1469 Barry Greene, Pedro Marques, Jared Mauch and Nischal Sheth were 1470 authors on [RFC5575], and therefore are contributing authors on this 1471 document. 1473 14. Acknowledgements 1475 The authors would like to thank Yakov Rekhter, Dennis Ferguson, Chris 1476 Morrow, Charlie Kaufman, and David Smith for their comments for the 1477 comments on the original [RFC5575]. Chaitanya Kodeboyina helped 1478 design the flow validation procedure; and Steven Lin and Jim Washburn 1479 ironed out all the details necessary to produce a working 1480 implementation in the original [RFC5575]. 1482 A packet rate Traffic Filtering Action was also described in a Flow 1483 Specification extension draft and the authors like to thank Wesley 1484 Eddy, Justin Dailey and Gilbert Clark for their work. 1486 Additionally, the authors would like to thank Alexander Mayrhofer, 1487 Nicolas Fevrier, Job Snijders, Jeffrey Haas and Adam Chappell for 1488 their comments and review. 1490 15. References 1492 15.1. Normative References 1494 [IEEE.754.1985] 1495 IEEE, "Standard for Binary Floating-Point Arithmetic", 1496 IEEE 754-1985, August 1985. 1498 [ISO_IEC_9899] 1499 ISO, "Information technology -- Programming languages -- 1500 C", ISO/IEC 9899:2018, June 2018. 1502 [RFC0768] Postel, J., "User Datagram Protocol", STD 6, RFC 768, 1503 DOI 10.17487/RFC0768, August 1980, 1504 . 1506 [RFC0791] Postel, J., "Internet Protocol", STD 5, RFC 791, 1507 DOI 10.17487/RFC0791, September 1981, 1508 . 1510 [RFC0792] Postel, J., "Internet Control Message Protocol", STD 5, 1511 RFC 792, DOI 10.17487/RFC0792, September 1981, 1512 . 1514 [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, 1515 RFC 793, DOI 10.17487/RFC0793, September 1981, 1516 . 1518 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1519 Requirement Levels", BCP 14, RFC 2119, 1520 DOI 10.17487/RFC2119, March 1997, 1521 . 1523 [RFC2474] Nichols, K., Blake, S., Baker, F., and D. Black, 1524 "Definition of the Differentiated Services Field (DS 1525 Field) in the IPv4 and IPv6 Headers", RFC 2474, 1526 DOI 10.17487/RFC2474, December 1998, 1527 . 1529 [RFC4271] Rekhter, Y., Ed., Li, T., Ed., and S. Hares, Ed., "A 1530 Border Gateway Protocol 4 (BGP-4)", RFC 4271, 1531 DOI 10.17487/RFC4271, January 2006, 1532 . 1534 [RFC4360] Sangli, S., Tappan, D., and Y. Rekhter, "BGP Extended 1535 Communities Attribute", RFC 4360, DOI 10.17487/RFC4360, 1536 February 2006, . 1538 [RFC4364] Rosen, E. and Y. Rekhter, "BGP/MPLS IP Virtual Private 1539 Networks (VPNs)", RFC 4364, DOI 10.17487/RFC4364, February 1540 2006, . 1542 [RFC4456] Bates, T., Chen, E., and R. Chandra, "BGP Route 1543 Reflection: An Alternative to Full Mesh Internal BGP 1544 (IBGP)", RFC 4456, DOI 10.17487/RFC4456, April 2006, 1545 . 1547 [RFC4760] Bates, T., Chandra, R., Katz, D., and Y. Rekhter, 1548 "Multiprotocol Extensions for BGP-4", RFC 4760, 1549 DOI 10.17487/RFC4760, January 2007, 1550 . 1552 [RFC5668] Rekhter, Y., Sangli, S., and D. Tappan, "4-Octet AS 1553 Specific BGP Extended Community", RFC 5668, 1554 DOI 10.17487/RFC5668, October 2009, 1555 . 1557 [RFC7153] Rosen, E. and Y. Rekhter, "IANA Registries for BGP 1558 Extended Communities", RFC 7153, DOI 10.17487/RFC7153, 1559 March 2014, . 1561 [RFC7606] Chen, E., Ed., Scudder, J., Ed., Mohapatra, P., and K. 1562 Patel, "Revised Error Handling for BGP UPDATE Messages", 1563 RFC 7606, DOI 10.17487/RFC7606, August 2015, 1564 . 1566 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 1567 Writing an IANA Considerations Section in RFCs", BCP 26, 1568 RFC 8126, DOI 10.17487/RFC8126, June 2017, 1569 . 1571 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1572 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1573 May 2017, . 1575 15.2. Informative References 1577 [I-D.ietf-idr-flow-spec-v6] 1578 Loibl, C., Raszuk, R., and S. Hares, "Dissemination of 1579 Flow Specification Rules for IPv6", draft-ietf-idr-flow- 1580 spec-v6-15 (work in progress), September 2020. 1582 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 1583 RFC 4303, DOI 10.17487/RFC4303, December 2005, 1584 . 1586 [RFC5575] Marques, P., Sheth, N., Raszuk, R., Greene, B., Mauch, J., 1587 and D. McPherson, "Dissemination of Flow Specification 1588 Rules", RFC 5575, DOI 10.17487/RFC5575, August 2009, 1589 . 1591 [RFC6811] Mohapatra, P., Scudder, J., Ward, D., Bush, R., and R. 1592 Austein, "BGP Prefix Origin Validation", RFC 6811, 1593 DOI 10.17487/RFC6811, January 2013, 1594 . 1596 [RFC7674] Haas, J., Ed., "Clarification of the Flowspec Redirect 1597 Extended Community", RFC 7674, DOI 10.17487/RFC7674, 1598 October 2015, . 1600 [RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", 1601 RFC 7950, DOI 10.17487/RFC7950, August 2016, 1602 . 1604 [RFC8205] Lepinski, M., Ed. and K. Sriram, Ed., "BGPsec Protocol 1605 Specification", RFC 8205, DOI 10.17487/RFC8205, September 1606 2017, . 1608 [RFC8294] Liu, X., Qu, Y., Lindem, A., Hopps, C., and L. Berger, 1609 "Common YANG Data Types for the Routing Area", RFC 8294, 1610 DOI 10.17487/RFC8294, December 2017, 1611 . 1613 15.3. URIs 1615 [1] https://github.com/stoffi92/rfc5575bis/tree/master/flowspec-cmp 1617 [2] https://www.iana.org/assignments/iana-routing-types 1619 Appendix A. Example Python code: flow_rule_cmp 1621 1622 """ 1623 Copyright (c) 2020 IETF Trust and the persons identified as authors 1624 of draft-ietf-idr-rfc5575bis. All rights reserved. 1626 Redistribution and use in source and binary forms, with or without 1627 modification, is permitted pursuant to, and subject to the license 1628 terms contained in, the Simplified BSD License set forth in Section 1629 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents 1630 (http://trustee.ietf.org/license-info). 1631 """ 1633 import itertools 1634 import collections 1635 import ipaddress 1637 EQUAL = 0 1638 A_HAS_PRECEDENCE = 1 1639 B_HAS_PRECEDENCE = 2 1640 IP_DESTINATION = 1 1641 IP_SOURCE = 2 1643 FS_component = collections.namedtuple('FS_component', 1644 'component_type op_value') 1646 class FS_nlri(object): 1647 """ 1648 FS_nlri class implementation that allows sorting. 1650 By calling .sort() on a array of FS_nlri objects these will be 1651 sorted according to the flow_rule_cmp algorithm. 1653 Example: 1654 nlri = [ FS_nlri(components=[ 1655 FS_component(component_type=IP_DESTINATION, 1656 op_value=ipaddress.ip_network('10.1.0.0/16') ), 1657 FS_component(component_type=4, 1658 op_value=bytearray([0,1,2,3,4,5,6])), 1659 ]), 1660 FS_nlri(components=[ 1661 FS_component(component_type=5, 1662 op_value=bytearray([0,1,2,3,4,5,6])), 1663 FS_component(component_type=6, 1664 op_value=bytearray([0,1,2,3,4,5,6])), 1665 ]), 1666 ] 1667 nlri.sort() # sorts the array accorinding to the algorithm 1668 """ 1669 def __init__(self, components = None): 1670 """ 1671 components: list of type FS_component 1672 """ 1673 self.components = components 1675 def __lt__(self, other): 1676 # use the below algorithm for sorting 1677 result = flow_rule_cmp(self, other) 1678 if result == B_HAS_PRECEDENCE: 1679 return True 1680 else: 1681 return False 1683 def flow_rule_cmp(a, b): 1684 """ 1685 Example of the flowspec comparison algorithm. 1686 """ 1687 for comp_a, comp_b in itertools.zip_longest(a.components, 1688 b.components): 1689 # If a component type does not exist in one rule 1690 # this rule has lower precedence 1691 if not comp_a: 1692 return B_HAS_PRECEDENCE 1694 if not comp_b: 1695 return A_HAS_PRECEDENCE 1696 # Higher precedence for lower component type 1697 if comp_a.component_type < comp_b.component_type: 1698 return A_HAS_PRECEDENCE 1699 if comp_a.component_type > comp_b.component_type: 1700 return B_HAS_PRECEDENCE 1701 # component types are equal -> type specific comparison 1702 if comp_a.component_type in (IP_DESTINATION, IP_SOURCE): 1703 # assuming comp_a.op_value, comp_b.op_value of 1704 # type ipaddress.IPv4Network 1705 if comp_a.op_value.overlaps(comp_b.op_value): 1706 # longest prefixlen has precedence 1707 if comp_a.op_value.prefixlen > \ 1708 comp_b.op_value.prefixlen: 1709 return A_HAS_PRECEDENCE 1710 if comp_a.op_value.prefixlen < \ 1711 comp_b.op_value.prefixlen: 1712 return B_HAS_PRECEDENCE 1713 # components equal -> continue with next component 1714 elif comp_a.op_value > comp_b.op_value: 1715 return B_HAS_PRECEDENCE 1716 elif comp_a.op_value < comp_b.op_value: 1717 return A_HAS_PRECEDENCE 1718 else: 1719 # assuming comp_a.op_value, comp_b.op_value of type 1720 # bytearray 1721 if len(comp_a.op_value) == len(comp_b.op_value): 1722 if comp_a.op_value > comp_b.op_value: 1723 return B_HAS_PRECEDENCE 1724 if comp_a.op_value < comp_b.op_value: 1725 return A_HAS_PRECEDENCE 1726 # components equal -> continue with next component 1727 else: 1728 common = min(len(comp_a.op_value), len(comp_b.op_value)) 1729 if comp_a.op_value[:common] > comp_b.op_value[:common]: 1730 return B_HAS_PRECEDENCE 1731 elif comp_a.op_value[:common] < \ 1732 comp_b.op_value[:common]: 1733 return A_HAS_PRECEDENCE 1734 # the first common bytes match 1735 elif len(comp_a.op_value) > len(comp_b.op_value): 1736 return A_HAS_PRECEDENCE 1737 else: 1738 return B_HAS_PRECEDENCE 1739 return EQUAL 1740 1741 Appendix B. Comparison with RFC 5575 1743 This document includes numerous editorial changes to [RFC5575]. It 1744 also completely incorporates the redirect action clarification 1745 document [RFC7674]. It is recommended to read the entire document. 1746 The authors, however want to point out the following technical 1747 changes to [RFC5575]: 1749 Section 1 introduces the Flow Specification NLRI. In [RFC5575] 1750 this NLRI was defined as an opaque-key in BGPs database. This 1751 specification has removed all references to an opaque-key 1752 property. BGP implementations are able to understand the NLRI 1753 encoding. 1755 Section 4.2.1.1 defines a numeric operator and comparison bit 1756 combinations. In [RFC5575] the meaning of those bit combination 1757 was not explicitly defined and left open to the reader. 1759 Section 4.2.2.3 - Section 4.2.2.8, Section 4.2.2.10, 1760 Section 4.2.2.11 make use of the above numeric operator. The 1761 allowed length of the comparison value was not consistently 1762 defined in [RFC5575]. 1764 Section 7 defines all Traffic Filtering Action Extended 1765 communities as transitive extended communities. [RFC5575] defined 1766 the traffic-rate action to be non-transitive and did not define 1767 the transitivity of the other Traffic Filtering Action communities 1768 at all. 1770 Section 7.2 introduces a new Traffic Filtering Action (traffic- 1771 rate-packets). This action did not exist in [RFC5575]. 1773 Section 7.4 contains the same redirect actions already defined in 1774 [RFC5575] however, these actions have been renamed to "rt- 1775 redirect" to make it clearer that the redirection is based on 1776 route-target. This section also completely incorporates the 1777 [RFC7674] clarifications of the Flowspec Redirect Extended 1778 Community. 1780 Section 7.7 contains general considerations on interfering traffic 1781 actions. Section 7.3 also cross-references Section 7.7. 1782 [RFC5575] did not mention this. 1784 Section 10 contains new error handling. 1786 Authors' Addresses 1788 Christoph Loibl 1789 next layer Telekom GmbH 1790 Mariahilfer Guertel 37/7 1791 Vienna 1150 1792 AT 1794 Phone: +43 664 1176414 1795 Email: cl@tix.at 1797 Susan Hares 1798 Huawei 1799 7453 Hickory Hill 1800 Saline, MI 48176 1801 USA 1803 Email: shares@ndzh.com 1805 Robert Raszuk 1806 Bloomberg LP 1807 731 Lexington Ave 1808 New York City, NY 10022 1809 USA 1811 Email: robert@raszuk.net 1813 Danny McPherson 1814 Verisign 1815 USA 1817 Email: dmcpherson@verisign.com 1819 Martin Bacher 1820 T-Mobile Austria 1821 Rennweg 97-99 1822 Vienna 1030 1823 AT 1825 Email: mb.ietf@gmail.com