idnits 2.17.1 draft-ietf-idr-flow-spec-v6-20.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 'Updates: ' line in the draft header should list only the _numbers_ of the RFCs which will be updated by this document (if approved); it should not include the word 'RFC' in the list. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (November 16, 2020) is 1256 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: '1' on line 645 Summary: 0 errors (**), 0 flaws (~~), 2 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 IDR Working Group C. Loibl, Ed. 3 Internet-Draft next layer Telekom GmbH 4 Updates: I-D.ietf-idr-rfc5575bis (if R. Raszuk, Ed. 5 approved) Bloomberg LP 6 Intended status: Standards Track S. Hares, Ed. 7 Expires: May 20, 2021 Huawei 8 November 16, 2020 10 Dissemination of Flow Specification Rules for IPv6 11 draft-ietf-idr-flow-spec-v6-20 13 Abstract 15 Dissemination of Flow Specification Rules I-D.ietf-idr-rfc5575bis 16 provides a Border Gateway Protocol extension for the propagation of 17 traffic flow information for the purpose of rate limiting or 18 filtering IPv4 protocol data packets. 20 This document extends I-D.ietf-idr-rfc5575bis with IPv6 21 functionality. It also updates I-D.ietf-idr-rfc5575bis by changing 22 the IANA Flow Spec Component Types registry. 24 Status of This Memo 26 This Internet-Draft is submitted in full conformance with the 27 provisions of BCP 78 and BCP 79. 29 Internet-Drafts are working documents of the Internet Engineering 30 Task Force (IETF). Note that other groups may also distribute 31 working documents as Internet-Drafts. The list of current Internet- 32 Drafts is at https://datatracker.ietf.org/drafts/current/. 34 Internet-Drafts are draft documents valid for a maximum of six months 35 and may be updated, replaced, or obsoleted by other documents at any 36 time. It is inappropriate to use Internet-Drafts as reference 37 material or to cite them other than as "work in progress." 39 This Internet-Draft will expire on May 20, 2021. 41 Copyright Notice 43 Copyright (c) 2020 IETF Trust and the persons identified as the 44 document authors. All rights reserved. 46 This document is subject to BCP 78 and the IETF Trust's Legal 47 Provisions Relating to IETF Documents 48 (https://trustee.ietf.org/license-info) in effect on the date of 49 publication of this document. Please review these documents 50 carefully, as they describe your rights and restrictions with respect 51 to this document. Code Components extracted from this document must 52 include Simplified BSD License text as described in Section 4.e of 53 the Trust Legal Provisions and are provided without warranty as 54 described in the Simplified BSD License. 56 Table of Contents 58 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 59 1.1. Definitions of Terms Used in This Memo . . . . . . . . . 3 60 2. IPv6 Flow Specification encoding in BGP . . . . . . . . . . . 3 61 3. IPv6 Flow Specification components . . . . . . . . . . . . . 3 62 3.1. Type 1 - Destination IPv6 Prefix . . . . . . . . . . . . 4 63 3.2. Type 2 - Source IPv6 Prefix . . . . . . . . . . . . . . . 4 64 3.3. Type 3 - Upper-Layer Protocol . . . . . . . . . . . . . . 5 65 3.4. Type 7 - ICMPv6 Type . . . . . . . . . . . . . . . . . . 5 66 3.5. Type 8 - ICMPv6 Code . . . . . . . . . . . . . . . . . . 5 67 3.6. Type 12 - Fragment . . . . . . . . . . . . . . . . . . . 6 68 3.7. Type 13 - Flow Label (new) . . . . . . . . . . . . . . . 7 69 3.8. Encoding Example . . . . . . . . . . . . . . . . . . . . 7 70 4. Ordering of Flow Specifications . . . . . . . . . . . . . . . 9 71 5. Validation Procedure . . . . . . . . . . . . . . . . . . . . 10 72 6. IPv6 Traffic Filtering Action changes . . . . . . . . . . . . 10 73 6.1. Redirect IPv6 (rt-redirect-ipv6) Type/Sub-Type 0x80/TBD . 10 74 7. Security Considerations . . . . . . . . . . . . . . . . . . . 10 75 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11 76 8.1. Flow Spec IPv6 Component Types . . . . . . . . . . . . . 11 77 8.1.1. Registry Template . . . . . . . . . . . . . . . . . . 11 78 8.1.2. Registry Contents . . . . . . . . . . . . . . . . . . 11 79 8.2. Extended Community Flow Spec IPv6 Actions . . . . . . . . 13 80 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 14 81 10. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 14 82 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 14 83 11.1. Normative References . . . . . . . . . . . . . . . . . . 14 84 11.2. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 15 85 Appendix A. Example python code: flow_rule_cmp_v6 . . . . . . . 15 86 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 18 88 1. Introduction 90 The growing amount of IPv6 traffic in private and public networks 91 requires the extension of tools used in IPv4-only networks to also 92 support IPv6 data packets. 94 This document analyzes the differences between describing IPv6 95 [RFC8200] flows and those of IPv4 packets. It specifies new Border 96 Gateway Protocol [RFC4271] encoding formats to enable Dissemination 97 of Flow Specification Rules [I-D.ietf-idr-rfc5575bis] for IPv6. 99 This specification is an extension of the base 100 [I-D.ietf-idr-rfc5575bis]. It only defines the delta changes 101 required to support IPv6 while all other definitions and operation 102 mechanisms of Dissemination of Flow Specification Rules will remain 103 in the main specification and will not be repeated here. 105 1.1. Definitions of Terms Used in This Memo 107 AFI - Address Family Identifier. 109 AS - Autonomous System. 111 NLRI - Network Layer Reachability Information. 113 SAFI - Subsequent Address Family Identifier. 115 VRF - Virtual Routing and Forwarding instance. 117 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 118 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 119 "OPTIONAL" in this document are to be interpreted as described in BCP 120 14 [RFC2119] [RFC8174] when, and only when, they appear in all 121 capitals, as shown here. 123 2. IPv6 Flow Specification encoding in BGP 125 [I-D.ietf-idr-rfc5575bis] defines SAFIs 133 (Dissemination of Flow 126 Specification) and 134 (L3VPN Dissemination of Flow Specification) in 127 order to carry the corresponding Flow Specification. 129 Implementations wishing to exchange IPv6 Flow Specifications MUST use 130 BGP's Capability Advertisement facility to exchange the Multiprotocol 131 Extension Capability Code (Code 1) as defined in [RFC4760]. The 132 (AFI, SAFI) pair carried in the Multiprotocol Extension Capability 133 MUST be: (AFI=2, SAFI=133) for IPv6 Flow Specification, and (AFI=2, 134 SAFI=134) for VPNv6 Flow Specification. 136 3. IPv6 Flow Specification components 138 The encoding of each of the components begins with a type field (1 139 octet) followed by a variable length parameter. The following 140 sections define component types and parameter encodings for IPv6. 142 Types 4 (Port), 5 (Destination Port), 6 (Source Port), 9 (TCP flags), 143 10 (Packet length) and 11 (DSCP), as defined in 145 [I-D.ietf-idr-rfc5575bis], also apply to IPv6. Note that IANA is 146 requested to update the "Flow Spec Component Types" registry in order 147 to contain both IPv4 and IPv6 Flow Specification component type 148 numbers in a single registry (Section 8). 150 3.1. Type 1 - Destination IPv6 Prefix 152 Encoding: 155 Defines the destination prefix to match. The offset has been defined 156 to allow for flexible matching to portions of an IPv6 address where 157 one is required to skip over the first N bits of the address (these 158 bits skipped are often indicated as "don't care" bits). This can be 159 especially useful where part of the IPv6 address consists of an 160 embedded IPv4 address and matching needs to happen only on the 161 embedded IPv4 address. The encoded pattern contains enough octets 162 for the bits used in matching (length minus offset bits). 164 length - The length field indicates the N-th most significant bit in 165 the address where bitwise pattern matching stops. 167 offset - The offset field indicates the number of most significant 168 address bits to skip before bitwise pattern matching starts. 170 pattern - Contains the matching pattern. The length of the pattern 171 is defined by the number of bits needed for pattern matching 172 (length minus offset). 174 padding - The minimum number of bits required to pad the component 175 to an octet boundary. Padding bits MUST be 0 on encoding and MUST 176 be ignored on decoding. 178 length = offset = 0 matches every address, otherwise length MUST be 179 in the range offset < length < 129 or the component is malformed. 181 Note: This Flow Specification component can be represented by the 182 notation ipv6address/length if offset is 0, or ipv6address/offset- 183 length. The ipv6address in this notation is the textual IPv6 184 representation of the pattern shifted to the right by the number of 185 offset bits. See also Section 3.8. 187 3.2. Type 2 - Source IPv6 Prefix 189 Encoding: 191 Defines the source prefix to match. The length, offset, pattern and 192 padding are the same as in Section 3.1. 194 3.3. Type 3 - Upper-Layer Protocol 196 Encoding: 198 Contains a list of {numeric_op, value} pairs that are used to match 199 the first Next Header value octet in IPv6 packets that is not an 200 extension header and thus indicates that the next item in the packet 201 is the corresponding upper-layer header (see [RFC8200] Section 4). 203 This component uses the Numeric Operator (numeric_op) described in 204 [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 3 component values 205 SHOULD be encoded as single octet (numeric_op len=00). 207 Note: While IPv6 allows for more than one Next Header field in the 208 packet, the main goal of the Type 3 Flow Specification component is 209 to match on the first upper-layer IP protocol value. Therefore the 210 definition is limited to match only on this specific Next Header 211 field in the packet. 213 3.4. Type 7 - ICMPv6 Type 215 Encoding: 217 Defines a list of {numeric_op, value} pairs used to match the type 218 field of an ICMPv6 packet (see also [RFC4443] Section 2.1). 220 This component uses the Numeric Operator (numeric_op) described in 221 [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 7 component values 222 SHOULD be encoded as single octet (numeric_op len=00). 224 In case of the presence of the ICMPv6 Type component only ICMPv6 225 packets can match the entire Flow Specification. The ICMPv6 Type 226 component, if present, never matches when the packet's upper-layer IP 227 protocol value is not 58 (ICMPv6), if the packet is fragmented and 228 this is not the first fragment, or if the system is unable to locate 229 the transport header. Different implementations may or may not be 230 able to decode the transport header. 232 3.5. Type 8 - ICMPv6 Code 234 Encoding: 236 Defines a list of {numeric_op, value} pairs used to match the code 237 field of an ICMPv6 packet (see also [RFC4443] Section 2.1). 239 This component uses the Numeric Operator (numeric_op) described in 240 [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 8 component values 241 SHOULD be encoded as single octet (numeric_op len=00). 243 In case of the presence of the ICMPv6 Code component only ICMPv6 244 packets can match the entire Flow Specification. The ICMPv6 code 245 component, if present, never matches when the packet's upper-layer IP 246 protocol value is not 58 (ICMPv6), if the packet is fragmented and 247 this is not the first fragment, or if the system is unable to locate 248 the transport header. Different implementations may or may not be 249 able to decode the transport header. 251 3.6. Type 12 - Fragment 253 Encoding: 255 Defines a list of {bitmask_op, bitmask} pairs used to match specific 256 IP fragments. 258 This component uses the Bitmask Operator (bitmask_op) described in 259 [I-D.ietf-idr-rfc5575bis] Section 4.2.1.2. The Type 12 component 260 bitmask MUST be encoded as single octet bitmask (bitmask_op len=00). 262 0 1 2 3 4 5 6 7 263 +---+---+---+---+---+---+---+---+ 264 | 0 | 0 | 0 | 0 |LF |FF |IsF| 0 | 265 +---+---+---+---+---+---+---+---+ 267 Figure 1: Fragment Bitmask Operand 269 Bitmask values: 271 IsF - Is a fragment other than the first - match if IPv6 Fragment 272 Header ([RFC8200] Section 4.5) Fragment Offset is not 0 274 FF - First fragment - match if IPv6 Fragment Header ([RFC8200] 275 Section 4.5) Fragment Offset is 0 AND M flag is 1 277 LF - Last fragment - match if IPv6 Fragment Header ([RFC8200] 278 Section 4.5) Fragment Offset is not 0 AND M flag is 0 280 0 - MUST be set to 0 on NLRI encoding, and MUST be ignored during 281 decoding 283 3.7. Type 13 - Flow Label (new) 285 Encoding: 287 Contains a list of {numeric_op, value} pairs that are used to match 288 the 20-bit Flow Label IPv6 header field ([RFC8200] Section 3). 290 This component uses the Numeric Operator (numeric_op) described in 291 [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 13 component values 292 SHOULD be encoded as 4-octet quantities (numeric_op len=10). 294 3.8. Encoding Example 296 3.8.1. Example 1 298 The following example demonstrates the prefix encoding for: "packets 299 from ::1234:5678:9a00:0/64-104 to 2001:db8::/32 and upper-layer- 300 protocol tcp". 302 +--------+----------------------+-------------------------+----------+ 303 | length | destination | source | ul-proto | 304 +--------+----------------------+-------------------------+----------+ 305 | 0x12 | 01 20 00 20 01 0D B8 | 02 68 40 12 34 56 78 9A | 03 81 06 | 306 +--------+----------------------+-------------------------+----------+ 308 Decoded: 310 +-------+------------+-------------------------------+ 311 | Value | | | 312 +-------+------------+-------------------------------+ 313 | 0x12 | length | 18 octets (len<240 1-octet) | 314 | 0x01 | type | Type 1 - Dest. IPv6 Prefix | 315 | 0x20 | length | 32 bit | 316 | 0x00 | offset | 0 bit | 317 | 0x20 | pattern | | 318 | 0x01 | pattern | | 319 | 0x0D | pattern | | 320 | 0xB8 | pattern | (no padding needed) | 321 | 0x02 | type | Type 2 - Source IPv6 Prefix | 322 | 0x68 | length | 104 bit | 323 | 0x40 | offset | 64 bit | 324 | 0x12 | pattern | | 325 | 0x34 | pattern | | 326 | 0x56 | pattern | | 327 | 0x78 | pattern | | 328 | 0x9A | pattern | (no padding needed) | 329 | 0x03 | type | Type 3 - upper-layer-proto | 330 | 0x81 | numeric_op | end-of-list, value size=1, == | 331 | 0x06 | value | 06 | 332 +-------+------------+-------------------------------+ 334 This constitutes a NLRI with a NLRI length of 18 octets. 336 Padding is not needed either for the destination prefix pattern 337 (length - offset = 32 bit) or for the source prefix pattern (length - 338 offset = 40 bit), as both patterns end on an octet boundary. 340 3.8.2. Example 2 342 The following example demonstrates the prefix encoding for: "all 343 packets from ::1234:5678:9a00:0/65-104 to 2001:db8::/32". 345 +--------+----------------------+-------------------------+ 346 | length | destination | source | 347 +--------+----------------------+-------------------------+ 348 | 0x0f | 01 20 00 20 01 0D B8 | 02 68 41 24 68 ac f1 34 | 349 +--------+----------------------+-------------------------+ 351 Decoded: 353 +-------+-------------+-------------------------------+ 354 | Value | | | 355 +-------+-------------+-------------------------------+ 356 | 0x0f | length | 15 octets (len<240 1-octet) | 357 | 0x01 | type | Type 1 - Dest. IPv6 Prefix | 358 | 0x20 | length | 32 bit | 359 | 0x00 | offset | 0 bit | 360 | 0x20 | pattern | | 361 | 0x01 | pattern | | 362 | 0x0D | pattern | | 363 | 0xB8 | pattern | (no padding needed) | 364 | 0x02 | type | Type 2 - Source IPv6 Prefix | 365 | 0x68 | length | 104 bit | 366 | 0x41 | offset | 65 bit | 367 | 0x24 | pattern | | 368 | 0x68 | pattern | | 369 | 0xac | pattern | | 370 | 0xf1 | pattern | | 371 | 0x34 | pattern/pad | (contains 1 bit padding) | 372 +-------+-------------+-------------------------------+ 374 This constitutes a NLRI with a NLRI length of 15 octets. 376 The source prefix pattern is 104 - 65 = 39 bits in length. After the 377 pattern one bit of padding needs to be added so that the component 378 ends on a octet boundary. However, only the first 39 bits are 379 actually used for bitwise pattern matching starting with a 65 bit 380 offset from the topmost bit of the address. 382 4. Ordering of Flow Specifications 384 The definition for the order of traffic filtering rules from 385 [I-D.ietf-idr-rfc5575bis] Section 5.1 is reused with new 386 consideration for the IPv6 prefix offset. As long as the offsets are 387 equal, the comparison is the same, retaining longest-prefix-match 388 semantics. If the offsets are not equal, the lowest offset has 389 precedence, as this Flow Specification matches the most significant 390 bit. 392 The code in Appendix A shows a Python3 implementation of the 393 resulting comparison algorithm. The full code was tested with Python 394 3.7.2 and can be obtained at https://github.com/stoffi92/draft-ietf- 395 idr-flow-spec-v6/tree/master/flowspec-cmp [1]. 397 5. Validation Procedure 399 The validation procedure is the same as specified in 400 [I-D.ietf-idr-rfc5575bis] Section 6 with the exception that item a) 401 of the validation procedure should now read as follows: 403 a) A destination prefix component with offset=0 is embedded in the 404 Flow Specification 406 6. IPv6 Traffic Filtering Action changes 408 Traffic Filtering Actions from [I-D.ietf-idr-rfc5575bis] Section 7 409 can also be applied to IPv6 Flow Specifications. To allow an IPv6 410 address specific route-target, a new Traffic Filtering Action IPv6 411 address specific extended community is specified in Section 6.1 412 below. 414 6.1. Redirect IPv6 (rt-redirect-ipv6) Type/Sub-Type 0x80/TBD 416 The redirect IPv6 address specific extended community allows the 417 traffic to be redirected to a VRF routing instance that lists the 418 specified IPv6 address specific route-target in its import policy. 419 If several local instances match this criteria, the choice between 420 them is a local matter (for example, the instance with the lowest 421 Route Distinguisher value can be elected). 423 This extended community uses the same encoding as the IPv6 address 424 specific Route Target extended community [RFC5701] Section 2 with the 425 high-order octet of the Type always set to 0x80 and the Sub-Type 426 always TBD. 428 The Local Administrator sub-field contains a number from a numbering 429 space that is administered by the organization to which the IP 430 address carried in the Global Administrator sub-field has been 431 assigned by an appropriate authority. 433 Interferes with: All BGP Flow Specification redirect Traffic 434 Filtering Actions (with itself and those specified in 435 [I-D.ietf-idr-rfc5575bis] Section 7.4). 437 7. Security Considerations 439 This document extends the functionality in [I-D.ietf-idr-rfc5575bis] 440 to be applicable to IPv6 data packets. The same Security 441 Considerations from [I-D.ietf-idr-rfc5575bis] now also apply to IPv6 442 networks. Otherwise, no new security issues are added to the BGP 443 protocol. 445 8. IANA Considerations 447 This section complies with [RFC7153]. 449 8.1. Flow Spec IPv6 Component Types 451 IANA has created and maintains a registry entitled "Flow Spec 452 Component Types". IANA is requested to add [this document] to the 453 reference for this registry. Furthermore the registry should be 454 rewritten to also contain the IPv6 Flow Specification Component Types 455 as described below. The registration procedure should remain 456 unchanged. 458 8.1.1. Registry Template 460 Type Value: 461 Contains the assigned Flow Specification component type value. 463 IPv4 Name: 464 Contains the associated IPv4 Flow Specification component name 465 as specified in [I-D.ietf-idr-rfc5575bis]. 467 IPv6 Name: 468 Contains the associated IPv6 Flow Specification component name 469 as specified in this document. 471 Reference: 472 Contains referenced to the specifications. 474 8.1.2. Registry Contents 476 + Type Value: 0 477 + IPv4 Name: Reserved 478 + IPv6 Name: Reserved 479 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 481 + Type Value: 1 482 + IPv4 Name: Destination Prefix 483 + IPv6 Name: Destination IPv6 Prefix 484 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 486 + Type Value: 2 487 + IPv4 Name: Source Prefix 488 + IPv6 Name: Source IPv6 Prefix 489 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 490 + Type Value: 3 491 + IPv4 Name: IP Protocol 492 + IPv6 Name: Upper-Layer Protocol 493 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 495 + Type Value: 4 496 + IPv4 Name: Port 497 + IPv6 Name: Port 498 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 500 + Type Value: 5 501 + IPv4 Name: Destination Port 502 + IPv6 Name: Destination Port 503 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 505 + Type Value: 6 506 + IPv4 Name: Source Port 507 + IPv6 Name: Source Port 508 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 510 + Type Value: 7 511 + IPv4 Name: ICMP Type 512 + IPv6 Name: ICMPv6 Type 513 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 515 + Type Value: 8 516 + IPv4 Name: ICMP Code 517 + IPv6 Name: ICMPv6 Code 518 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 520 + Type Value: 9 521 + IPv4 Name: TCP flags 522 + IPv6 Name: TCP flags 523 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 525 + Type Value: 10 526 + IPv4 Name: Packet length 527 + IPv6 Name: Packet length 528 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 529 + Type Value: 11 530 + IPv4 Name: DSCP 531 + IPv6 Name: DSCP 532 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 534 + Type Value: 12 535 + IPv4 Name: Fragment 536 + IPv6 Name: Fragment 537 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 539 + Type Value: 13 540 + IPv4 Name: Unassigned 541 + IPv6 Name: Flow Label 542 + Reference: [this document] 544 + Type Value: 14-254 545 + IPv4 Name: Unassigned 546 + IPv6 Name: Unassigned 547 + Reference: 549 + Type Value: 255 550 + IPv4 Name: Reserved 551 + IPv6 Name: Reserved 552 + Reference: [I-D.ietf-idr-rfc5575bis] [this document] 554 8.2. Extended Community Flow Spec IPv6 Actions 556 IANA maintains a registry entitled "Generic Transitive Experimental 557 Use Extended Community Sub-Types". For the purpose of this work, 558 IANA is requested to assign a new value: 560 +----------------+--------------------------------+-----------------+ 561 | Sub-Type Value | Name | Reference | 562 +----------------+--------------------------------+-----------------+ 563 | TBD | Flow spec rt-redirect-ipv6 | [this document] | 564 | | format | | 565 +----------------+--------------------------------+-----------------+ 567 Table 1: Registry: Generic Transitive Experimental Use Extended 568 Community Sub-Types 570 9. Acknowledgements 572 Authors would like to thank Pedro Marques, Hannes Gredler, Bruno 573 Rijsman, Brian Carpenter, and Thomas Mangin for their valuable input. 575 10. Contributors 577 Danny McPherson 578 Verisign, Inc. 580 Email: dmcpherson@verisign.com 582 Burjiz Pithawala 583 Individual 585 Email: burjizp@gmail.com 587 Andy Karch 588 Cisco Systems 589 170 West Tasman Drive 590 San Jose, CA 95134 591 USA 593 Email: akarch@cisco.com 595 11. References 597 11.1. Normative References 599 [I-D.ietf-idr-rfc5575bis] 600 Loibl, C., Hares, S., Raszuk, R., McPherson, D., and M. 601 Bacher, "Dissemination of Flow Specification Rules", 602 draft-ietf-idr-rfc5575bis-27 (work in progress), October 603 2020. 605 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 606 Requirement Levels", BCP 14, RFC 2119, 607 DOI 10.17487/RFC2119, March 1997, 608 . 610 [RFC4271] Rekhter, Y., Ed., Li, T., Ed., and S. Hares, Ed., "A 611 Border Gateway Protocol 4 (BGP-4)", RFC 4271, 612 DOI 10.17487/RFC4271, January 2006, 613 . 615 [RFC4443] Conta, A., Deering, S., and M. Gupta, Ed., "Internet 616 Control Message Protocol (ICMPv6) for the Internet 617 Protocol Version 6 (IPv6) Specification", STD 89, 618 RFC 4443, DOI 10.17487/RFC4443, March 2006, 619 . 621 [RFC4760] Bates, T., Chandra, R., Katz, D., and Y. Rekhter, 622 "Multiprotocol Extensions for BGP-4", RFC 4760, 623 DOI 10.17487/RFC4760, January 2007, 624 . 626 [RFC5701] Rekhter, Y., "IPv6 Address Specific BGP Extended Community 627 Attribute", RFC 5701, DOI 10.17487/RFC5701, November 2009, 628 . 630 [RFC7153] Rosen, E. and Y. Rekhter, "IANA Registries for BGP 631 Extended Communities", RFC 7153, DOI 10.17487/RFC7153, 632 March 2014, . 634 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 635 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 636 May 2017, . 638 [RFC8200] Deering, S. and R. Hinden, "Internet Protocol, Version 6 639 (IPv6) Specification", STD 86, RFC 8200, 640 DOI 10.17487/RFC8200, July 2017, 641 . 643 11.2. URIs 645 [1] https://github.com/stoffi92/draft-ietf-idr-flow-spec- 646 v6/tree/master/flowspec-cmp 648 Appendix A. Example python code: flow_rule_cmp_v6 650 651 """ 652 Copyright (c) 2020 IETF Trust and the persons identified as authors 653 of the code. All rights reserved. 655 Redistribution and use in source and binary forms, with or without 656 modification, is permitted pursuant to, and subject to the license 657 terms contained in, the Simplified BSD License set forth in Section 658 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents 659 (https://trustee.ietf.org/license-info). 660 """ 662 import itertools 663 import collections 664 import ipaddress 666 EQUAL = 0 667 A_HAS_PRECEDENCE = 1 668 B_HAS_PRECEDENCE = 2 669 IP_DESTINATION = 1 670 IP_SOURCE = 2 672 FS_component = collections.namedtuple('FS_component', 673 'component_type value') 675 class FS_IPv6_prefix_component: 676 def __init__(self, prefix, offset=0, 677 component_type=IP_DESTINATION): 678 self.offset = offset 679 self.component_type = component_type 680 # make sure if offset != 0 that none of the 681 # first offset bits are set in the prefix 682 self.value = prefix 683 if offset != 0: 684 i = ipaddress.IPv6Interface( 685 (self.value.network_address, offset)) 686 if i.network.network_address != \ 687 ipaddress.ip_address('0::0'): 688 raise ValueError('Bits set in the offset') 690 class FS_nlri(object): 691 """ 692 FS_nlri class implementation that allows sorting. 694 By calling .sort() on an array of FS_nlri objects these 695 will be sorted according to the flow_rule_cmp algorithm. 697 Example: 698 nlri = [ FS_nlri(components=[ 699 FS_component(component_type=4, 700 value=bytearray([0,1,2,3,4,5,6])), 701 ]), 702 FS_nlri(components=[ 703 FS_component(component_type=5, 704 value=bytearray([0,1,2,3,4,5,6])), 705 FS_component(component_type=6, 706 value=bytearray([0,1,2,3,4,5,6])), 707 ]), 709 ] 710 nlri.sort() # sorts the array according to the algorithm 711 """ 712 def __init__(self, components = None): 713 """ 714 components: list of type FS_component 715 """ 716 self.components = components 718 def __lt__(self, other): 719 # use the below algorithm for sorting 720 result = flow_rule_cmp_v6(self, other) 721 if result == B_HAS_PRECEDENCE: 722 return True 723 else: 724 return False 726 def flow_rule_cmp_v6(a, b): 727 """ 728 Implementation of the flowspec sorting algorithm in 729 draft-ietf-idr-flow-spec-v6. 730 """ 731 for comp_a, comp_b in itertools.zip_longest(a.components, 732 b.components): 733 # If a component type does not exist in one rule 734 # this rule has lower precedence 735 if not comp_a: 736 return B_HAS_PRECEDENCE 737 if not comp_b: 738 return A_HAS_PRECEDENCE 739 # Higher precedence for lower component type 740 if comp_a.component_type < comp_b.component_type: 741 return A_HAS_PRECEDENCE 742 if comp_a.component_type > comp_b.component_type: 743 return B_HAS_PRECEDENCE 744 # component types are equal -> type specific comparison 745 if comp_a.component_type in (IP_DESTINATION, IP_SOURCE): 746 if comp_a.offset < comp_b.offset: 747 return A_HAS_PRECEDENCE 748 if comp_a.offset > comp_b.offset: 749 return B_HAS_PRECEDENCE 750 # both components have the same offset 751 # assuming comp_a.value, comp_b.value of type 752 # ipaddress.IPv6Network 753 # and the offset bits are reset to 0 (since they are 754 # not represented in the NLRI) 755 if comp_a.value.overlaps(comp_b.value): 757 # longest prefixlen has precedence 758 if comp_a.value.prefixlen > \ 759 comp_b.value.prefixlen: 760 return A_HAS_PRECEDENCE 761 if comp_a.value.prefixlen < \ 762 comp_b.value.prefixlen: 763 return B_HAS_PRECEDENCE 764 # components equal -> continue with next 765 # component 766 elif comp_a.value > comp_b.value: 767 return B_HAS_PRECEDENCE 768 elif comp_a.value < comp_b.value: 769 return A_HAS_PRECEDENCE 770 else: 771 # assuming comp_a.value, comp_b.value of type 772 # bytearray 773 if len(comp_a.value) == len(comp_b.value): 774 if comp_a.value > comp_b.value: 775 return B_HAS_PRECEDENCE 776 if comp_a.value < comp_b.value: 777 return A_HAS_PRECEDENCE 778 # components equal -> continue with next 779 # component 780 else: 781 common = min(len(comp_a.value), 782 len(comp_b.value)) 783 if comp_a.value[:common] > \ 784 comp_b.value[:common]: 785 return B_HAS_PRECEDENCE 786 elif comp_a.value[:common] < \ 787 comp_b.value[:common]: 788 return A_HAS_PRECEDENCE 789 # the first common bytes match 790 elif len(comp_a.value) > len(comp_b.value): 791 return A_HAS_PRECEDENCE 792 else: 793 return B_HAS_PRECEDENCE 794 return EQUAL 795 797 Authors' Addresses 798 Christoph Loibl (editor) 799 next layer Telekom GmbH 800 Mariahilfer Guertel 37/7 801 Vienna 1150 802 AT 804 Phone: +43 664 1176414 805 Email: cl@tix.at 807 Robert Raszuk (editor) 808 Bloomberg LP 809 731 Lexington Ave 810 New York City, NY 10022 811 USA 813 Email: robert@raszuk.net 815 Susan Hares (editor) 816 Huawei 817 7453 Hickory Hill 818 Saline, MI 48176 819 USA 821 Email: shares@ndzh.com