idnits 2.17.1 draft-ietf-idr-flow-spec-v6-10.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 abstract seems to contain references ([I-D.ietf-idr-RFC5575bis]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (November 2, 2019) is 1635 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 525 == Unused Reference: 'RFC2474' is defined on line 473, but no explicit reference was found in the text == Unused Reference: 'RFC4271' is defined on line 479, but no explicit reference was found in the text == Unused Reference: 'RFC5492' is defined on line 495, but no explicit reference was found in the text == Unused Reference: 'RFC6437' is defined on line 503, but no explicit reference was found in the text == Unused Reference: 'RFC5095' is defined on line 518, but no explicit reference was found in the text == Outdated reference: A later version (-27) exists of draft-ietf-idr-rfc5575bis-17 ** Obsolete normative reference: RFC 2460 (Obsoleted by RFC 8200) Summary: 2 errors (**), 0 flaws (~~), 7 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 Communications 4 Intended status: Standards Track R. Raszuk, Ed. 5 Expires: May 5, 2020 Bloomberg LP 6 S. Hares, Ed. 7 Huawei 8 November 2, 2019 10 Dissemination of Flow Specification Rules for IPv6 11 draft-ietf-idr-flow-spec-v6-10 13 Abstract 15 Dissemination of Flow Specification Rules [I-D.ietf-idr-rfc5575bis] 16 provides a protocol extension for propagation of traffic flow 17 information for the purpose of rate limiting or filtering. The 18 [I-D.ietf-idr-rfc5575bis] specifies those extensions for IPv4 19 protocol data packets only. 21 This specification extends [I-D.ietf-idr-rfc5575bis] and defines 22 changes to the original document in order to make it also usable and 23 applicable to IPv6 data packets. 25 Status of This Memo 27 This Internet-Draft is submitted in full conformance with the 28 provisions of BCP 78 and BCP 79. 30 Internet-Drafts are working documents of the Internet Engineering 31 Task Force (IETF). Note that other groups may also distribute 32 working documents as Internet-Drafts. The list of current Internet- 33 Drafts is at https://datatracker.ietf.org/drafts/current/. 35 Internet-Drafts are draft documents valid for a maximum of six months 36 and may be updated, replaced, or obsoleted by other documents at any 37 time. It is inappropriate to use Internet-Drafts as reference 38 material or to cite them other than as "work in progress." 40 This Internet-Draft will expire on May 5, 2020. 42 Copyright Notice 44 Copyright (c) 2019 IETF Trust and the persons identified as the 45 document authors. All rights reserved. 47 This document is subject to BCP 78 and the IETF Trust's Legal 48 Provisions Relating to IETF Documents 49 (https://trustee.ietf.org/license-info) in effect on the date of 50 publication of this document. Please review these documents 51 carefully, as they describe your rights and restrictions with respect 52 to this document. Code Components extracted from this document must 53 include Simplified BSD License text as described in Section 4.e of 54 the Trust Legal Provisions and are provided without warranty as 55 described in the Simplified BSD License. 57 Table of Contents 59 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 60 1.1. Definitions of Terms Used in This Memo . . . . . . . . . 3 61 2. IPv6 Flow Specification encoding in BGP . . . . . . . . . . . 3 62 3. IPv6 Flow Specification components . . . . . . . . . . . . . 4 63 3.1. Type 1 - Destination IPv6 Prefix . . . . . . . . . . . . 4 64 3.2. Type 2 - Source IPv6 Prefix . . . . . . . . . . . . . . . 4 65 3.3. Type 3 - Next Header . . . . . . . . . . . . . . . . . . 4 66 3.4. Type 7 - ICMPv6 type . . . . . . . . . . . . . . . . . . 5 67 3.5. Type 8 - ICMPv6 code . . . . . . . . . . . . . . . . . . 5 68 3.6. Type 12 - Fragment . . . . . . . . . . . . . . . . . . . 5 69 3.7. Type 13 - Flow Label (new) . . . . . . . . . . . . . . . 6 70 3.8. Encoding Example . . . . . . . . . . . . . . . . . . . . 6 71 4. Ordering of Flow Specifications . . . . . . . . . . . . . . . 8 72 5. Validation Procedure . . . . . . . . . . . . . . . . . . . . 8 73 6. IPv6 Traffic Filtering Action changes . . . . . . . . . . . . 8 74 6.1. Redirect IPv6 (rt-redirect-ipv6) Type/Sub-Type 0x80/TBD . 9 75 7. Security Considerations . . . . . . . . . . . . . . . . . . . 9 76 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 9 77 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 10 78 10. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 10 79 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 11 80 11.1. Normative References . . . . . . . . . . . . . . . . . . 11 81 11.2. Informative References . . . . . . . . . . . . . . . . . 12 82 11.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 12 83 Appendix A. Python code: flow_rule_cmp_v6 . . . . . . . . . . . 12 84 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 14 86 1. Introduction 88 The growing amount of IPv6 traffic in private and public networks 89 requires the extension of tools used in the IPv4 only networks to be 90 also capable of supporting IPv6 data packets. 92 In this document authors analyze the differences of IPv6 [RFC2460] 93 flows description from those of traditional IPv4 packets and propose 94 subset of new encoding formats to enable Dissemination of Flow 95 Specification Rules [I-D.ietf-idr-rfc5575bis] for IPv6. 97 This specification should be treated as an extension of base 98 [I-D.ietf-idr-rfc5575bis] specification and not its replacement. It 99 only defines the delta changes required to support IPv6 while all 100 other definitions and operation mechanisms of Dissemination of Flow 101 Specification Rules will remain in the main specification and will 102 not be repeated here. 104 1.1. Definitions of Terms Used in This Memo 106 AFI - Address Family Identifier. 108 AS - Autonomous System. 110 NLRI - Network Layer Reachability Information. 112 SAFI - Subsequent Address Family Identifier. 114 VRF - Virtual Routing and Forwarding instance. 116 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 117 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 118 "OPTIONAL" in this document are to be interpreted as described in BCP 119 14 [RFC2119] [RFC8174] when, and only when, they appear in all 120 capitals, as shown here. 122 2. IPv6 Flow Specification encoding in BGP 124 The [I-D.ietf-idr-rfc5575bis] defines new SAFIs 133 (Dissemination of 125 Flow Specification) and 134 (L3VPN Dissemination of Flow 126 Specification) applications in order to carry corresponding to each 127 such application 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]. While 132 [I-D.ietf-idr-rfc5575bis] specifies Flow Specification for IPv4 133 (AFI=1) only, the (AFI, SAFI) pair carried in the Multiprotocol 134 Extension Capability MUST be: (AFI=2, SAFI=133) for IPv6 Flow 135 Specification, and (AFI=2, SAFI=134) for VPNv6 Flow Specification. 137 For both SAFIs the indication to which address family they are 138 referring to will be recognized by AFI value (AFI=1 for IPv4 or 139 VPNv4, AFI=2 for IPv6 and VPNv6 respectively). 141 It needs to be observed that such choice of proposed encoding is 142 compatible with filter validation against routing reachability 143 information as described in section 6 of [I-D.ietf-idr-rfc5575bis]. 145 3. IPv6 Flow Specification components 147 The following components are redefined or added for the purpose of 148 accommodating the IPv6 header encoding. Unless otherwise specified 149 all other components defined in [I-D.ietf-idr-rfc5575bis] 150 Section 4.2.2 also apply to IPv6 Flow Specification. 152 3.1. Type 1 - Destination IPv6 Prefix 154 Encoding: 157 Defines the destination prefix to match. The offset has been defined 158 to allow for flexible matching on part of the IPv6 address where it 159 is required to skip (don't care) of N first bits of the address. 160 This can be especially useful where part of the IPv6 address consists 161 of an embedded IPv4 address and matching needs to happen only on the 162 embedded IPv4 address. The encoded prefix contains enough octets for 163 the bits used in matching (length minus offset bits). 165 3.2. Type 2 - Source IPv6 Prefix 167 Encoding: 170 Defines the source prefix to match. The length, offset and prefix 171 are the same as in Section 3.1 173 3.3. Type 3 - Next Header 175 Encoding: 177 Contains a list of {numeric_op, value} pairs that are used to match 178 the last Next Header ([RFC2460] Section 3) value octet in IPv6 179 packets. 181 This component uses the Numeric Operator (numeric_op) described in 182 [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 3 component values 183 SHOULD be encoded as single byte (numeric_op len=00). 185 Note: While IPv6 allows for more then one Next Header field in the 186 packet the main goal of Type 3 flow specification component is to 187 match on the subsequent IP protocol value. Therefor the definition 188 is limited to match only on last Next Header field in the packet. 190 3.4. Type 7 - ICMPv6 type 192 Encoding: 194 Defines a list of {numeric_op, value} pairs used to match the type 195 field of an ICMPv6 packet (see also [RFC4443] Section 2.1). 197 This component uses the Numeric Operator (numeric_op) described in 198 [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 7 component values 199 SHOULD be encoded as single byte (numeric_op len=00). 201 In case of the presence of the ICMPv6 type (code) component only 202 ICMPv6 packets can match the entire Flow Specification. The ICMPv6 203 type (code) component, if present, never matches when the packet's 204 last Next Header field value is not 58 (ICMPv6), if the packet is 205 fragmented and this is not the first fragment, or if the system is 206 unable to locate the transport header. Different implementations may 207 or may not be able to decode the transport header. 209 3.5. Type 8 - ICMPv6 code 211 Encoding: 213 Defines a list of {numeric_op, value} pairs used to match the code 214 field of an ICMPv6 packet (see also [RFC4443] Section 2.1). 216 This component uses the Numeric Operator (numeric_op) described in 217 [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 8 component values 218 SHOULD be encoded as single byte (numeric_op len=00). 220 The last paragraph of Section 3.4 also applies to this component. 222 3.6. Type 12 - Fragment 224 Encoding: 226 Defines a list of {bitmask_op, bitmask} pairs used to match specific 227 IP fragments. 229 This component uses the Bitmask Operator (bitmask_op) described in 230 [I-D.ietf-idr-rfc5575bis] Section 4.2.1.2. The Type 12 component 231 bitmask MUST be encoded as single byte bitmask (bitmask_op len=00). 233 0 1 2 3 4 5 6 7 234 +---+---+---+---+---+---+---+---+ 235 | 0 | 0 | 0 | 0 |LF |FF |IsF| 0 | 236 +---+---+---+---+---+---+---+---+ 238 Figure 1: Fragment Bitmask Operand 240 Bitmask values: 242 IsF - Is a fragment - match if IPv6 Fragment Header ([RFC2460] 243 Section 4.5) Fragment Offset is not 0 245 FF - First fragment - match if IPv6 Fragment Header ([RFC2460] 246 Section 4.5) Fragment Offset is 0 AND M flag is 1 248 LF - Last fragment - match if IPv6 Fragment Header ([RFC2460] 249 Section 4.5) Fragment Offset is not 0 AND M flag is 0 251 0 - SHOULD be set to 0 on NLRI encoding, and MUST be ignored during 252 decoding 254 3.7. Type 13 - Flow Label (new) 256 Encoding: 258 Contains a list of {numeric_op, value} pairs that are used to match 259 the 20-bit Flow Label IPv6 header field ([RFC2460] Section 3). 261 This component uses the Numeric Operator (numeric_op) described in 262 [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 13 component values 263 SHOULD be encoded as 1-, 2-, or 4-byte quantities (numeric_op len=00, 264 len=01 or len=10). 266 3.8. Encoding Example 268 3.8.1. Example 1 270 The following example demonstrates the prefix encoding for: "all 271 packets to ::1234:5678:9A00:0/64-104 from 100::/8 and port 25". 273 +--------+-------------------------+-------------+----------+ 274 | length | destination | source | port | 275 +--------+-------------------------+-------------+----------+ 276 | 0x0f | 01 68 40 12 34 56 78 9A | 02 08 00 01 | 04 81 19 | 277 +--------+-------------------------+-------------+----------+ 279 Decoded: 281 +-------+------------+------------------------------+ 282 | Value | | | 283 +-------+------------+------------------------------+ 284 | 0x0f | length | 16 octets (len<240 1-octet) | 285 | 0x01 | type | Type 1 - Dest. IPv6 Prefix | 286 | 0x68 | length | 104 bit | 287 | 0x40 | offset | 64 bit | 288 | 0x12 | prefix | | 289 | 0x34 | prefix | | 290 | 0x56 | prefix | | 291 | 0x78 | prefix | | 292 | 0x9A | prefix | | 293 | 0x02 | type | Type 2 - Source IPv6 Prefix | 294 | 0x08 | length | 8 bit | 295 | 0x00 | offset | 0 bit | 296 | 0x01 | prefix | | 297 | 0x04 | type | Type 4 - Port | 298 | 0x81 | numeric_op | end-of-list, value size=1, = | 299 | 0x19 | value | 25 | 300 +-------+------------+------------------------------+ 302 This constitutes a NLRI with a NLRI length of 16 octets. 304 3.8.2. Example 2 306 The following example demonstrates the prefix encoding for: "all 307 packets to ::1234:5678:9A00:0/65-104". 309 +--------+-------------------------+ 310 | length | destination | 311 +--------+-------------------------+ 312 | 0x08 | 01 68 41 24 68 ac f1 34 | 313 +--------+-------------------------+ 315 Decoded: 317 +-------+------------+------------------------------+ 318 | Value | | | 319 +-------+------------+------------------------------+ 320 | 0x08 | length | 8 octets (len<240 1-octet) | 321 | 0x01 | type | Type 1 - Dest. IPv6 Prefix | 322 | 0x68 | length | 104 bit | 323 | 0x41 | offset | 65 bit | 324 | 0x24 | prefix | starting with the 66ths bit | 325 | 0x68 | prefix | | 326 | 0xac | prefix | | 327 | 0xf1 | prefix | | 328 | 0x34 | prefix | | 329 +-------+------------+------------------------------+ 331 This constitutes a NLRI with a NLRI length of 8 octets. 333 4. Ordering of Flow Specifications 335 The definition for the order of traffic filtering rules from 336 [I-D.ietf-idr-rfc5575bis] Section 5.1 can be reused with new 337 consideration for the IPv6 prefix offset. As long as the offsets are 338 equal, the comparison is the same, retaining longest-prefix-match 339 semantics. If the offsets are not equal, the lowest offset has 340 precedence, as this flow matches the most significant bit. 342 The code in Appendix A shows a Python3 implementation of the 343 resulting comparison algorithm. The full code was tested with Python 344 3.7.2 and can be obtained at https://github.com/stoffi92/flowspec- 345 cmp-v6 [1]. 347 5. Validation Procedure 349 The validation procedure is the same as specified in 350 [I-D.ietf-idr-rfc5575bis] Section 6 with the exception that item a) 351 of the validation procedure should now read as follows: 353 a) A destination prefix component with offset=0 is embedded in the 354 Flow Specification 356 6. IPv6 Traffic Filtering Action changes 358 Traffic Filtering Actions from [I-D.ietf-idr-rfc5575bis] Section 7 359 can also be applied to IPv6 Flow Specifications. To allow an IPv6 360 address specific route-target, a new Traffic Filtering Action IPv6 361 address specific extended community is specified in Section 6.1 362 below: 364 6.1. Redirect IPv6 (rt-redirect-ipv6) Type/Sub-Type 0x80/TBD 366 The redirect IPv6 address specific extended community allows the 367 traffic to be redirected to a VRF routing instance that lists the 368 specified IPv6 address specific route-target in its import policy. 369 If several local instances match this criteria, the choice between 370 them is a local matter (for example, the instance with the lowest 371 Route Distinguisher value can be elected). 373 This extended community uses the same encoding as the IPv6 address 374 specific Route Target extended community [RFC5701] Section 2 with the 375 high-order octet of the Type always set to 0x80 and the Sub-Type 376 always TBD. 378 Interferes with: All BGP Flow Specification redirect Traffic 379 Filtering Actions (with itself and those specified in 380 [I-D.ietf-idr-rfc5575bis] Section 7.4). 382 7. Security Considerations 384 No new security issues are introduced to the BGP protocol by this 385 specification over the security considerations in 386 [I-D.ietf-idr-rfc5575bis] 388 8. IANA Considerations 390 This section complies with [RFC7153] 392 IANA is requested to create and maintain a new registry entitled: 393 "Flow Spec IPv6 Component Types" containing the initial entries as 394 specified in Table 1. 396 +-------+-------------------------+-----------------+ 397 | Value | Name | Reference | 398 +-------+-------------------------+-----------------+ 399 | 1 | Destination IPv6 Prefix | [this document] | 400 | 2 | Source IPv6 Prefix | [this document] | 401 | 3 | Next Header | [this document] | 402 | 4 | Port | [this document] | 403 | 5 | Destination port | [this document] | 404 | 6 | Source port | [this document] | 405 | 7 | ICMPv6 type | [this document] | 406 | 8 | ICMPv6 code | [this document] | 407 | 9 | TCP flags | [this document] | 408 | 10 | Packet length | [this document] | 409 | 11 | DSCP | [this document] | 410 | 12 | Fragment | [this document] | 411 | 13 | Flow Label | [this document] | 412 +-------+-------------------------+-----------------+ 414 Table 1: Registry: Flow Spec IPv6 Component Types 416 IANA maintains a registry entitled "Generic Transitive Experimental 417 Use Extended Community Sub-Types". For the purpose of this work, 418 IANA is requested to assign a new value: 420 +----------------+--------------------------------+-----------------+ 421 | Sub-Type Value | Name | Reference | 422 +----------------+--------------------------------+-----------------+ 423 | TBD | Flow spec rt-redirect-ipv6 | [this document] | 424 | | format | | 425 +----------------+--------------------------------+-----------------+ 427 Table 2: Registry: Generic Transitive Experimental Use Extended 428 Community Sub-Types 430 9. Acknowledgements 432 Authors would like to thank Pedro Marques, Hannes Gredler and Bruno 433 Rijsman, Brian Carpenter, and Thomas Mangin for their valuable input. 435 10. Contributors 437 Danny McPherson 438 Verisign, Inc. 440 Email: dmcpherson@verisign.com 441 Burjiz Pithawala 442 Individual 444 Email: burjizp@gmail.com 446 Andy Karch 447 Cisco Systems 448 170 West Tasman Drive 449 San Jose, CA 95134 450 USA 452 Email: akarch@cisco.com 454 11. References 456 11.1. Normative References 458 [I-D.ietf-idr-rfc5575bis] 459 Loibl, C., Hares, S., Raszuk, R., McPherson, D., and M. 460 Bacher, "Dissemination of Flow Specification Rules", 461 draft-ietf-idr-rfc5575bis-17 (work in progress), June 462 2019. 464 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 465 Requirement Levels", BCP 14, RFC 2119, 466 DOI 10.17487/RFC2119, March 1997, 467 . 469 [RFC2460] Deering, S. and R. Hinden, "Internet Protocol, Version 6 470 (IPv6) Specification", RFC 2460, DOI 10.17487/RFC2460, 471 December 1998, . 473 [RFC2474] Nichols, K., Blake, S., Baker, F., and D. Black, 474 "Definition of the Differentiated Services Field (DS 475 Field) in the IPv4 and IPv6 Headers", RFC 2474, 476 DOI 10.17487/RFC2474, December 1998, 477 . 479 [RFC4271] Rekhter, Y., Ed., Li, T., Ed., and S. Hares, Ed., "A 480 Border Gateway Protocol 4 (BGP-4)", RFC 4271, 481 DOI 10.17487/RFC4271, January 2006, 482 . 484 [RFC4443] Conta, A., Deering, S., and M. Gupta, Ed., "Internet 485 Control Message Protocol (ICMPv6) for the Internet 486 Protocol Version 6 (IPv6) Specification", STD 89, 487 RFC 4443, DOI 10.17487/RFC4443, March 2006, 488 . 490 [RFC4760] Bates, T., Chandra, R., Katz, D., and Y. Rekhter, 491 "Multiprotocol Extensions for BGP-4", RFC 4760, 492 DOI 10.17487/RFC4760, January 2007, 493 . 495 [RFC5492] Scudder, J. and R. Chandra, "Capabilities Advertisement 496 with BGP-4", RFC 5492, DOI 10.17487/RFC5492, February 497 2009, . 499 [RFC5701] Rekhter, Y., "IPv6 Address Specific BGP Extended Community 500 Attribute", RFC 5701, DOI 10.17487/RFC5701, November 2009, 501 . 503 [RFC6437] Amante, S., Carpenter, B., Jiang, S., and J. Rajahalme, 504 "IPv6 Flow Label Specification", RFC 6437, 505 DOI 10.17487/RFC6437, November 2011, 506 . 508 [RFC7153] Rosen, E. and Y. Rekhter, "IANA Registries for BGP 509 Extended Communities", RFC 7153, DOI 10.17487/RFC7153, 510 March 2014, . 512 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 513 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 514 May 2017, . 516 11.2. Informative References 518 [RFC5095] Abley, J., Savola, P., and G. Neville-Neil, "Deprecation 519 of Type 0 Routing Headers in IPv6", RFC 5095, 520 DOI 10.17487/RFC5095, December 2007, 521 . 523 11.3. URIs 525 [1] https://github.com/stoffi92/flowspec-cmp-v6 527 Appendix A. Python code: flow_rule_cmp_v6 529 530 """ 531 Copyright (c) 2019 IETF Trust and the persons identified as authors of 532 the code. All rights reserved. 534 Redistribution and use in source and binary forms, with or without 535 modification, is permitted pursuant to, and subject to the license 536 terms contained in, the Simplified BSD License set forth in Section 537 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents 538 (http://trustee.ietf.org/license-info). 539 """ 541 import itertools 542 import ipaddress 544 def flow_rule_cmp_v6(a, b): 545 for comp_a, comp_b in itertools.zip_longest(a.components, 546 b.components): 547 # If a component type does not exist in one rule 548 # this rule has lower precedence 549 if not comp_a: 550 return B_HAS_PRECEDENCE 551 if not comp_b: 552 return A_HAS_PRECEDENCE 553 # Higher precedence for lower component type 554 if comp_a.component_type < comp_b.component_type: 555 return A_HAS_PRECEDENCE 556 if comp_a.component_type > comp_b.component_type: 557 return B_HAS_PRECEDENCE 558 # component types are equal -> type specific comparison 559 if comp_a.component_type in (IP_DESTINATION, IP_SOURCE): 560 if comp_a.offset < comp_b.offset: 561 return A_HAS_PRECEDENCE 562 if comp_a.offset < comp_b.offset: 563 return B_HAS_PRECEDENCE 564 # both components have the same offset 565 # assuming comp_a.value, comp_b.value of type 566 # ipaddress.IPv6Network 567 # and the offset bits are reset to 0 (since they are not 568 # represented in the NLRI) 569 if comp_a.value.overlaps(comp_b.value): 570 # longest prefixlen has precedence 571 if comp_a.value.prefixlen > comp_b.value.prefixlen: 572 return A_HAS_PRECEDENCE 573 if comp_a.value.prefixlen < comp_b.value.prefixlen: 574 return B_HAS_PRECEDENCE 575 # components equal -> continue with next component 576 elif comp_a.value > comp_b.value: 577 return B_HAS_PRECEDENCE 578 elif comp_a.value < comp_b.value: 579 return A_HAS_PRECEDENCE 581 else: 582 # assuming comp_a.value, comp_b.value of type bytearray 583 if len(comp_a.value) == len(comp_b.value): 584 if comp_a.value > comp_b.value: 585 return B_HAS_PRECEDENCE 586 if comp_a.value < comp_b.value: 587 return A_HAS_PRECEDENCE 588 # components equal -> continue with next component 589 else: 590 common = min(len(comp_a.value), len(comp_b.value)) 591 if comp_a.value[:common] > comp_b.value[:common]: 592 return B_HAS_PRECEDENCE 593 elif comp_a.value[:common] < comp_b.value[:common]: 594 return A_HAS_PRECEDENCE 595 # the first common bytes match 596 elif len(comp_a.value) > len(comp_b.value): 597 return A_HAS_PRECEDENCE 598 else: 599 return B_HAS_PRECEDENCE 600 return EQUAL 601 603 Authors' Addresses 605 Christoph Loibl (editor) 606 Next Layer Communications 607 Mariahilfer Guertel 37/7 608 Vienna 1150 609 AT 611 Phone: +43 664 1176414 612 Email: cl@tix.at 614 Robert Raszuk (editor) 615 Bloomberg LP 616 731 Lexington Ave 617 New York City, NY 10022 618 USA 620 Email: robert@raszuk.net 621 Susan Hares (editor) 622 Huawei 623 7453 Hickory Hill 624 Saline, MI 48176 625 USA 627 Email: shares@ndzh.com