draft-ietf-idr-flow-spec-v6-19.txt   draft-ietf-idr-flow-spec-v6-20.txt 
IDR Working Group C. Loibl, Ed. IDR Working Group C. Loibl, Ed.
Internet-Draft next layer Telekom GmbH Internet-Draft next layer Telekom GmbH
Updates: I-D.ietf-idr-rfc5575bis (if R. Raszuk, Ed. Updates: I-D.ietf-idr-rfc5575bis (if R. Raszuk, Ed.
approved) Bloomberg LP approved) Bloomberg LP
Intended status: Standards Track S. Hares, Ed. Intended status: Standards Track S. Hares, Ed.
Expires: May 6, 2021 Huawei Expires: May 20, 2021 Huawei
November 2, 2020 November 16, 2020
Dissemination of Flow Specification Rules for IPv6 Dissemination of Flow Specification Rules for IPv6
draft-ietf-idr-flow-spec-v6-19 draft-ietf-idr-flow-spec-v6-20
Abstract Abstract
Dissemination of Flow Specification Rules I-D.ietf-idr-rfc5575bis Dissemination of Flow Specification Rules I-D.ietf-idr-rfc5575bis
provides a Border Gateway Protocol extension for the propagation of provides a Border Gateway Protocol extension for the propagation of
traffic flow information for the purpose of rate limiting or traffic flow information for the purpose of rate limiting or
filtering IPv4 protocol data packets. filtering IPv4 protocol data packets.
This document extends I-D.ietf-idr-rfc5575bis with IPv6 This document extends I-D.ietf-idr-rfc5575bis with IPv6
functionality. It also updates I-D.ietf-idr-rfc5575bis by changing functionality. It also updates I-D.ietf-idr-rfc5575bis by changing
skipping to change at page 1, line 40 skipping to change at page 1, line 40
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/. Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on May 6, 2021. This Internet-Draft will expire on May 20, 2021.
Copyright Notice Copyright Notice
Copyright (c) 2020 IETF Trust and the persons identified as the Copyright (c) 2020 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of (https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
skipping to change at page 2, line 19 skipping to change at page 2, line 19
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1. Definitions of Terms Used in This Memo . . . . . . . . . 3 1.1. Definitions of Terms Used in This Memo . . . . . . . . . 3
2. IPv6 Flow Specification encoding in BGP . . . . . . . . . . . 3 2. IPv6 Flow Specification encoding in BGP . . . . . . . . . . . 3
3. IPv6 Flow Specification components . . . . . . . . . . . . . 3 3. IPv6 Flow Specification components . . . . . . . . . . . . . 3
3.1. Type 1 - Destination IPv6 Prefix . . . . . . . . . . . . 4 3.1. Type 1 - Destination IPv6 Prefix . . . . . . . . . . . . 4
3.2. Type 2 - Source IPv6 Prefix . . . . . . . . . . . . . . . 4 3.2. Type 2 - Source IPv6 Prefix . . . . . . . . . . . . . . . 4
3.3. Type 3 - Upper-Layer Protocol . . . . . . . . . . . . . . 4 3.3. Type 3 - Upper-Layer Protocol . . . . . . . . . . . . . . 5
3.4. Type 7 - ICMPv6 Type . . . . . . . . . . . . . . . . . . 5 3.4. Type 7 - ICMPv6 Type . . . . . . . . . . . . . . . . . . 5
3.5. Type 8 - ICMPv6 Code . . . . . . . . . . . . . . . . . . 5 3.5. Type 8 - ICMPv6 Code . . . . . . . . . . . . . . . . . . 5
3.6. Type 12 - Fragment . . . . . . . . . . . . . . . . . . . 6 3.6. Type 12 - Fragment . . . . . . . . . . . . . . . . . . . 6
3.7. Type 13 - Flow Label (new) . . . . . . . . . . . . . . . 6 3.7. Type 13 - Flow Label (new) . . . . . . . . . . . . . . . 7
3.8. Encoding Example . . . . . . . . . . . . . . . . . . . . 7 3.8. Encoding Example . . . . . . . . . . . . . . . . . . . . 7
4. Ordering of Flow Specifications . . . . . . . . . . . . . . . 8 4. Ordering of Flow Specifications . . . . . . . . . . . . . . . 9
5. Validation Procedure . . . . . . . . . . . . . . . . . . . . 9 5. Validation Procedure . . . . . . . . . . . . . . . . . . . . 10
6. IPv6 Traffic Filtering Action changes . . . . . . . . . . . . 9 6. IPv6 Traffic Filtering Action changes . . . . . . . . . . . . 10
6.1. Redirect IPv6 (rt-redirect-ipv6) Type/Sub-Type 0x80/TBD . 9 6.1. Redirect IPv6 (rt-redirect-ipv6) Type/Sub-Type 0x80/TBD . 10
7. Security Considerations . . . . . . . . . . . . . . . . . . . 9 7. Security Considerations . . . . . . . . . . . . . . . . . . . 10
8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 10 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11
8.1. Flow Spec IPv6 Component Types . . . . . . . . . . . . . 10 8.1. Flow Spec IPv6 Component Types . . . . . . . . . . . . . 11
8.1.1. Registry Template . . . . . . . . . . . . . . . . . . 10 8.1.1. Registry Template . . . . . . . . . . . . . . . . . . 11
8.1.2. Registry Contents . . . . . . . . . . . . . . . . . . 10 8.1.2. Registry Contents . . . . . . . . . . . . . . . . . . 11
8.2. Extended Community Flow Spec IPv6 Actions . . . . . . . . 12 8.2. Extended Community Flow Spec IPv6 Actions . . . . . . . . 13
9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 13 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 14
10. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 13 10. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 14
11. References . . . . . . . . . . . . . . . . . . . . . . . . . 13 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 14
11.1. Normative References . . . . . . . . . . . . . . . . . . 13 11.1. Normative References . . . . . . . . . . . . . . . . . . 14
11.2. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 14 11.2. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Appendix A. Example python code: flow_rule_cmp_v6 . . . . . . . 14 Appendix A. Example python code: flow_rule_cmp_v6 . . . . . . . 15
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 18 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 18
1. Introduction 1. Introduction
The growing amount of IPv6 traffic in private and public networks The growing amount of IPv6 traffic in private and public networks
requires the extension of tools used in IPv4-only networks to be also requires the extension of tools used in IPv4-only networks to also
capable of supporting IPv6 data packets. support IPv6 data packets.
This document analyzes the differences of IPv6 [RFC8200] flows This document analyzes the differences between describing IPv6
description from those of traditional IPv4 packets and propose a [RFC8200] flows and those of IPv4 packets. It specifies new Border
subset of new Border Gateway Protocol [RFC4271] encoding formats to Gateway Protocol [RFC4271] encoding formats to enable Dissemination
enable Dissemination of Flow Specification Rules of Flow Specification Rules [I-D.ietf-idr-rfc5575bis] for IPv6.
[I-D.ietf-idr-rfc5575bis] for IPv6.
This specification is an extension of the base This specification is an extension of the base
[I-D.ietf-idr-rfc5575bis]. It only defines the delta changes [I-D.ietf-idr-rfc5575bis]. It only defines the delta changes
required to support IPv6 while all other definitions and operation required to support IPv6 while all other definitions and operation
mechanisms of Dissemination of Flow Specification Rules will remain mechanisms of Dissemination of Flow Specification Rules will remain
in the main specification and will not be repeated here. in the main specification and will not be repeated here.
1.1. Definitions of Terms Used in This Memo 1.1. Definitions of Terms Used in This Memo
AFI - Address Family Identifier. AFI - Address Family Identifier.
skipping to change at page 3, line 50 skipping to change at page 3, line 50
(AFI, SAFI) pair carried in the Multiprotocol Extension Capability (AFI, SAFI) pair carried in the Multiprotocol Extension Capability
MUST be: (AFI=2, SAFI=133) for IPv6 Flow Specification, and (AFI=2, MUST be: (AFI=2, SAFI=133) for IPv6 Flow Specification, and (AFI=2,
SAFI=134) for VPNv6 Flow Specification. SAFI=134) for VPNv6 Flow Specification.
3. IPv6 Flow Specification components 3. IPv6 Flow Specification components
The encoding of each of the components begins with a type field (1 The encoding of each of the components begins with a type field (1
octet) followed by a variable length parameter. The following octet) followed by a variable length parameter. The following
sections define component types and parameter encodings for IPv6. sections define component types and parameter encodings for IPv6.
Types 4, 5, 6, 9, 10 and 11, as defined in [I-D.ietf-idr-rfc5575bis], Types 4 (Port), 5 (Destination Port), 6 (Source Port), 9 (TCP flags),
also apply to IPv6. Note that IANA is requested to update the "Flow 10 (Packet length) and 11 (DSCP), as defined in
Spec Component Types" registry in order to contain both IPv4 and IPv6
Flow Specification component type numbers in a single registry [I-D.ietf-idr-rfc5575bis], also apply to IPv6. Note that IANA is
(Section 8). requested to update the "Flow Spec Component Types" registry in order
to contain both IPv4 and IPv6 Flow Specification component type
numbers in a single registry (Section 8).
3.1. Type 1 - Destination IPv6 Prefix 3.1. Type 1 - Destination IPv6 Prefix
Encoding: <type (1 octet), length (1 octet), offset (1 octet), Encoding: <type (1 octet), length (1 octet), offset (1 octet),
pattern (variable), padding(variable) > pattern (variable), padding(variable) >
Defines the destination prefix to match. The offset has been defined Defines the destination prefix to match. The offset has been defined
to allow for flexible matching to portions of an IPv6 address where to allow for flexible matching to portions of an IPv6 address where
one is required to skip over the first N bits of the address (these one is required to skip over the first N bits of the address (these
bits skipped are often indicated as "don't care" bits). This can be bits skipped are often indicated as "don't care" bits). This can be
skipping to change at page 4, line 36 skipping to change at page 4, line 38
address bits to skip before bitwise pattern matching starts. address bits to skip before bitwise pattern matching starts.
pattern - Contains the matching pattern. The length of the pattern pattern - Contains the matching pattern. The length of the pattern
is defined by the number of bits needed for pattern matching is defined by the number of bits needed for pattern matching
(length minus offset). (length minus offset).
padding - The minimum number of bits required to pad the component padding - The minimum number of bits required to pad the component
to an octet boundary. Padding bits MUST be 0 on encoding and MUST to an octet boundary. Padding bits MUST be 0 on encoding and MUST
be ignored on decoding. be ignored on decoding.
Length = Offset = 0 matches every address, otherwise Length MUST be length = offset = 0 matches every address, otherwise length MUST be
in the range Offset < Length < 129 or the component is malformed. in the range offset < length < 129 or the component is malformed.
Note: This Flow Specification component can be represented by the
notation ipv6address/length if offset is 0, or ipv6address/offset-
length. The ipv6address in this notation is the textual IPv6
representation of the pattern shifted to the right by the number of
offset bits. See also Section 3.8.
3.2. Type 2 - Source IPv6 Prefix 3.2. Type 2 - Source IPv6 Prefix
Encoding: <type (1 octet), length (1 octet), offset (1 octet), Encoding: <type (1 octet), length (1 octet), offset (1 octet),
pattern (variable), padding(variable) > pattern (variable), padding(variable) >
Defines the source prefix to match. The length, offset, pattern and Defines the source prefix to match. The length, offset, pattern and
padding are the same as in Section 3.1 padding are the same as in Section 3.1.
3.3. Type 3 - Upper-Layer Protocol 3.3. Type 3 - Upper-Layer Protocol
Encoding: <type (1 octet), [numeric_op, value]+> Encoding: <type (1 octet), [numeric_op, value]+>
Contains a list of {numeric_op, value} pairs that are used to match Contains a list of {numeric_op, value} pairs that are used to match
the first Next Header value octet in IPv6 packets that is not an the first Next Header value octet in IPv6 packets that is not an
extension header and thus indicates that the next item in the packet extension header and thus indicates that the next item in the packet
is the corresponding upper-layer header (see [RFC8200] Section 4). is the corresponding upper-layer header (see [RFC8200] Section 4).
This component uses the Numeric Operator (numeric_op) described in This component uses the Numeric Operator (numeric_op) described in
[I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 3 component values [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 3 component values
SHOULD be encoded as single octet (numeric_op len=00). SHOULD be encoded as single octet (numeric_op len=00).
Note: While IPv6 allows for more than one Next Header field in the Note: While IPv6 allows for more than one Next Header field in the
skipping to change at page 6, line 50 skipping to change at page 7, line 14
3.7. Type 13 - Flow Label (new) 3.7. Type 13 - Flow Label (new)
Encoding: <type (1 octet), [numeric_op, value]+> Encoding: <type (1 octet), [numeric_op, value]+>
Contains a list of {numeric_op, value} pairs that are used to match Contains a list of {numeric_op, value} pairs that are used to match
the 20-bit Flow Label IPv6 header field ([RFC8200] Section 3). the 20-bit Flow Label IPv6 header field ([RFC8200] Section 3).
This component uses the Numeric Operator (numeric_op) described in This component uses the Numeric Operator (numeric_op) described in
[I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 13 component values [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 13 component values
SHOULD be encoded as 1-, 2-, or 4-byte quantities (numeric_op len=00, SHOULD be encoded as 4-octet quantities (numeric_op len=10).
len=01 or len=10).
3.8. Encoding Example 3.8. Encoding Example
3.8.1. Example 1 3.8.1. Example 1
The following example demonstrates the prefix encoding for: "packets The following example demonstrates the prefix encoding for: "packets
from ::1234:5678:9A00:0/64-104 to 2001:DB8::/32 and upper-layer- from ::1234:5678:9a00:0/64-104 to 2001:db8::/32 and upper-layer-
protocol tcp". protocol tcp".
+--------+----------------------+-------------------------+----------+ +--------+----------------------+-------------------------+----------+
| length | destination | source | ul-proto | | length | destination | source | ul-proto |
+--------+----------------------+-------------------------+----------+ +--------+----------------------+-------------------------+----------+
| 0x12 | 01 20 00 20 01 0D B8 | 02 68 40 12 34 56 78 9A | 03 81 06 | | 0x12 | 01 20 00 20 01 0D B8 | 02 68 40 12 34 56 78 9A | 03 81 06 |
+--------+----------------------+-------------------------+----------+ +--------+----------------------+-------------------------+----------+
Decoded: Decoded:
skipping to change at page 8, line 8 skipping to change at page 8, line 38
This constitutes a NLRI with a NLRI length of 18 octets. This constitutes a NLRI with a NLRI length of 18 octets.
Padding is not needed either for the destination prefix pattern Padding is not needed either for the destination prefix pattern
(length - offset = 32 bit) or for the source prefix pattern (length - (length - offset = 32 bit) or for the source prefix pattern (length -
offset = 40 bit), as both patterns end on an octet boundary. offset = 40 bit), as both patterns end on an octet boundary.
3.8.2. Example 2 3.8.2. Example 2
The following example demonstrates the prefix encoding for: "all The following example demonstrates the prefix encoding for: "all
packets from ::1234:5678:9A00:0/65-104 to 2001:DB8::/32". packets from ::1234:5678:9a00:0/65-104 to 2001:db8::/32".
+--------+----------------------+-------------------------+ +--------+----------------------+-------------------------+
| length | destination | source | | length | destination | source |
+--------+----------------------+-------------------------+ +--------+----------------------+-------------------------+
| 0x0f | 01 20 00 20 01 0D B8 | 02 68 41 24 68 ac f1 34 | | 0x0f | 01 20 00 20 01 0D B8 | 02 68 41 24 68 ac f1 34 |
+--------+----------------------+-------------------------+ +--------+----------------------+-------------------------+
Decoded: Decoded:
+-------+-------------+-------------------------------+ +-------+-------------+-------------------------------+
skipping to change at page 9, line 5 skipping to change at page 9, line 41
actually used for bitwise pattern matching starting with a 65 bit actually used for bitwise pattern matching starting with a 65 bit
offset from the topmost bit of the address. offset from the topmost bit of the address.
4. Ordering of Flow Specifications 4. Ordering of Flow Specifications
The definition for the order of traffic filtering rules from The definition for the order of traffic filtering rules from
[I-D.ietf-idr-rfc5575bis] Section 5.1 is reused with new [I-D.ietf-idr-rfc5575bis] Section 5.1 is reused with new
consideration for the IPv6 prefix offset. As long as the offsets are consideration for the IPv6 prefix offset. As long as the offsets are
equal, the comparison is the same, retaining longest-prefix-match equal, the comparison is the same, retaining longest-prefix-match
semantics. If the offsets are not equal, the lowest offset has semantics. If the offsets are not equal, the lowest offset has
precedence, as this flow matches the most significant bit. precedence, as this Flow Specification matches the most significant
bit.
The code in Appendix A shows a Python3 implementation of the The code in Appendix A shows a Python3 implementation of the
resulting comparison algorithm. The full code was tested with Python resulting comparison algorithm. The full code was tested with Python
3.7.2 and can be obtained at https://github.com/stoffi92/draft-ietf- 3.7.2 and can be obtained at https://github.com/stoffi92/draft-ietf-
idr-flow-spec-v6/tree/master/flowspec-cmp [1]. idr-flow-spec-v6/tree/master/flowspec-cmp [1].
5. Validation Procedure 5. Validation Procedure
The validation procedure is the same as specified in The validation procedure is the same as specified in
[I-D.ietf-idr-rfc5575bis] Section 6 with the exception that item a) [I-D.ietf-idr-rfc5575bis] Section 6 with the exception that item a)
skipping to change at page 9, line 43 skipping to change at page 10, line 36
specified IPv6 address specific route-target in its import policy. specified IPv6 address specific route-target in its import policy.
If several local instances match this criteria, the choice between If several local instances match this criteria, the choice between
them is a local matter (for example, the instance with the lowest them is a local matter (for example, the instance with the lowest
Route Distinguisher value can be elected). Route Distinguisher value can be elected).
This extended community uses the same encoding as the IPv6 address This extended community uses the same encoding as the IPv6 address
specific Route Target extended community [RFC5701] Section 2 with the specific Route Target extended community [RFC5701] Section 2 with the
high-order octet of the Type always set to 0x80 and the Sub-Type high-order octet of the Type always set to 0x80 and the Sub-Type
always TBD. always TBD.
The Local Administrator sub-field contains a number from a numbering
space that is administered by the organization to which the IP
address carried in the Global Administrator sub-field has been
assigned by an appropriate authority.
Interferes with: All BGP Flow Specification redirect Traffic Interferes with: All BGP Flow Specification redirect Traffic
Filtering Actions (with itself and those specified in Filtering Actions (with itself and those specified in
[I-D.ietf-idr-rfc5575bis] Section 7.4). [I-D.ietf-idr-rfc5575bis] Section 7.4).
7. Security Considerations 7. Security Considerations
This document extends the functionality in [I-D.ietf-idr-rfc5575bis] This document extends the functionality in [I-D.ietf-idr-rfc5575bis]
to be applicable to IPv6 data packets. The same Security to be applicable to IPv6 data packets. The same Security
Considerations from [I-D.ietf-idr-rfc5575bis] now also apply to IPv6 Considerations from [I-D.ietf-idr-rfc5575bis] now also apply to IPv6
networks. Otherwise, no new security issues are added to the BGP networks. Otherwise, no new security issues are added to the BGP
skipping to change at page 13, line 47 skipping to change at page 14, line 37
Email: akarch@cisco.com Email: akarch@cisco.com
11. References 11. References
11.1. Normative References 11.1. Normative References
[I-D.ietf-idr-rfc5575bis] [I-D.ietf-idr-rfc5575bis]
Loibl, C., Hares, S., Raszuk, R., McPherson, D., and M. Loibl, C., Hares, S., Raszuk, R., McPherson, D., and M.
Bacher, "Dissemination of Flow Specification Rules", Bacher, "Dissemination of Flow Specification Rules",
draft-ietf-idr-rfc5575bis-26 (work in progress), August draft-ietf-idr-rfc5575bis-27 (work in progress), October
2020. 2020.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997, DOI 10.17487/RFC2119, March 1997,
<https://www.rfc-editor.org/info/rfc2119>. <https://www.rfc-editor.org/info/rfc2119>.
[RFC4271] Rekhter, Y., Ed., Li, T., Ed., and S. Hares, Ed., "A [RFC4271] Rekhter, Y., Ed., Li, T., Ed., and S. Hares, Ed., "A
Border Gateway Protocol 4 (BGP-4)", RFC 4271, Border Gateway Protocol 4 (BGP-4)", RFC 4271,
DOI 10.17487/RFC4271, January 2006, DOI 10.17487/RFC4271, January 2006,
skipping to change at page 15, line 4 skipping to change at page 15, line 43
11.2. URIs 11.2. URIs
[1] https://github.com/stoffi92/draft-ietf-idr-flow-spec- [1] https://github.com/stoffi92/draft-ietf-idr-flow-spec-
v6/tree/master/flowspec-cmp v6/tree/master/flowspec-cmp
Appendix A. Example python code: flow_rule_cmp_v6 Appendix A. Example python code: flow_rule_cmp_v6
<CODE BEGINS> <CODE BEGINS>
""" """
Copyright (c) 2020 IETF Trust and the persons identified as authors Copyright (c) 2020 IETF Trust and the persons identified as authors
of draft-ietf-idr-flow-spec-v6. All rights reserved. of the code. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, is permitted pursuant to, and subject to the license modification, is permitted pursuant to, and subject to the license
terms contained in, the Simplified BSD License set forth in Section terms contained in, the Simplified BSD License set forth in Section
4.c of the IETF Trust's Legal Provisions Relating to IETF Documents 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info). (https://trustee.ietf.org/license-info).
""" """
import itertools import itertools
import collections import collections
import ipaddress import ipaddress
EQUAL = 0 EQUAL = 0
A_HAS_PRECEDENCE = 1 A_HAS_PRECEDENCE = 1
B_HAS_PRECEDENCE = 2 B_HAS_PRECEDENCE = 2
IP_DESTINATION = 1 IP_DESTINATION = 1
IP_SOURCE = 2 IP_SOURCE = 2
FS_component = collections.namedtuple('FS_component', FS_component = collections.namedtuple('FS_component',
'component_type value') 'component_type value')
class FS_IPv6_prefix_component: class FS_IPv6_prefix_component:
def __init__(self, prefix, offset=0, def __init__(self, prefix, offset=0,
component_type=IP_DESTINATION): component_type=IP_DESTINATION):
self.offset = offset self.offset = offset
self.component_type = component_type self.component_type = component_type
# make sure if offset != 0 that non of the # make sure if offset != 0 that none of the
# first offset bits are set in the prefix # first offset bits are set in the prefix
self.value = prefix self.value = prefix
if offset != 0: if offset != 0:
i = ipaddress.IPv6Interface( i = ipaddress.IPv6Interface(
(self.value.network_address, offset)) (self.value.network_address, offset))
if i.network.network_address != \ if i.network.network_address != \
ipaddress.ip_address('0::0'): ipaddress.ip_address('0::0'):
raise ValueError('Bits set in the offset') raise ValueError('Bits set in the offset')
class FS_nlri(object): class FS_nlri(object):
""" """
FS_nlri class implementation that allows sorting. FS_nlri class implementation that allows sorting.
By calling .sort() on a array of FS_nlri objects these By calling .sort() on an array of FS_nlri objects these
will be sorted according to the flow_rule_cmp algorithm. will be sorted according to the flow_rule_cmp algorithm.
Example: Example:
nlri = [ FS_nlri(components=[ nlri = [ FS_nlri(components=[
FS_component(component_type=4, FS_component(component_type=4,
value=bytearray([0,1,2,3,4,5,6])), value=bytearray([0,1,2,3,4,5,6])),
]), ]),
FS_nlri(components=[ FS_nlri(components=[
FS_component(component_type=5, FS_component(component_type=5,
value=bytearray([0,1,2,3,4,5,6])), value=bytearray([0,1,2,3,4,5,6])),
FS_component(component_type=6, FS_component(component_type=6,
value=bytearray([0,1,2,3,4,5,6])), value=bytearray([0,1,2,3,4,5,6])),
]), ]),
skipping to change at page 16, line 15 skipping to change at page 17, line 4
nlri = [ FS_nlri(components=[ nlri = [ FS_nlri(components=[
FS_component(component_type=4, FS_component(component_type=4,
value=bytearray([0,1,2,3,4,5,6])), value=bytearray([0,1,2,3,4,5,6])),
]), ]),
FS_nlri(components=[ FS_nlri(components=[
FS_component(component_type=5, FS_component(component_type=5,
value=bytearray([0,1,2,3,4,5,6])), value=bytearray([0,1,2,3,4,5,6])),
FS_component(component_type=6, FS_component(component_type=6,
value=bytearray([0,1,2,3,4,5,6])), value=bytearray([0,1,2,3,4,5,6])),
]), ]),
] ]
nlri.sort() # sorts the array accorinding to the algorithm nlri.sort() # sorts the array according to the algorithm
""" """
def __init__(self, components = None): def __init__(self, components = None):
""" """
components: list of type FS_component components: list of type FS_component
""" """
self.components = components self.components = components
def __lt__(self, other): def __lt__(self, other):
# use the below algorithm for sorting # use the below algorithm for sorting
result = flow_rule_cmp_v6(self, other) result = flow_rule_cmp_v6(self, other)
skipping to change at page 17, line 4 skipping to change at page 17, line 42
return B_HAS_PRECEDENCE return B_HAS_PRECEDENCE
if not comp_b: if not comp_b:
return A_HAS_PRECEDENCE return A_HAS_PRECEDENCE
# Higher precedence for lower component type # Higher precedence for lower component type
if comp_a.component_type < comp_b.component_type: if comp_a.component_type < comp_b.component_type:
return A_HAS_PRECEDENCE return A_HAS_PRECEDENCE
if comp_a.component_type > comp_b.component_type: if comp_a.component_type > comp_b.component_type:
return B_HAS_PRECEDENCE return B_HAS_PRECEDENCE
# component types are equal -> type specific comparison # component types are equal -> type specific comparison
if comp_a.component_type in (IP_DESTINATION, IP_SOURCE): if comp_a.component_type in (IP_DESTINATION, IP_SOURCE):
if comp_a.offset < comp_b.offset: if comp_a.offset < comp_b.offset:
return A_HAS_PRECEDENCE return A_HAS_PRECEDENCE
if comp_a.offset < comp_b.offset: if comp_a.offset > comp_b.offset:
return B_HAS_PRECEDENCE return B_HAS_PRECEDENCE
# both components have the same offset # both components have the same offset
# assuming comp_a.value, comp_b.value of type # assuming comp_a.value, comp_b.value of type
# ipaddress.IPv6Network # ipaddress.IPv6Network
# and the offset bits are reset to 0 (since they are # and the offset bits are reset to 0 (since they are
# not represented in the NLRI) # not represented in the NLRI)
if comp_a.value.overlaps(comp_b.value): if comp_a.value.overlaps(comp_b.value):
# longest prefixlen has precedence # longest prefixlen has precedence
if comp_a.value.prefixlen > \ if comp_a.value.prefixlen > \
comp_b.value.prefixlen: comp_b.value.prefixlen:
return A_HAS_PRECEDENCE return A_HAS_PRECEDENCE
if comp_a.value.prefixlen < \ if comp_a.value.prefixlen < \
comp_b.value.prefixlen: comp_b.value.prefixlen:
return B_HAS_PRECEDENCE return B_HAS_PRECEDENCE
# components equal -> continue with next # components equal -> continue with next
# component # component
elif comp_a.value > comp_b.value: elif comp_a.value > comp_b.value:
 End of changes. 29 change blocks. 
52 lines changed or deleted 64 lines changed or added

This html diff was produced by rfcdiff 1.48. The latest version is available from http://tools.ietf.org/tools/rfcdiff/