draft-ietf-idr-flow-spec-v6-11.txt   draft-ietf-idr-flow-spec-v6-12.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
Intended status: Standards Track R. Raszuk, Ed. Intended status: Standards Track R. Raszuk, Ed.
Expires: October 22, 2020 Bloomberg LP Expires: January 11, 2021 Bloomberg LP
S. Hares, Ed. S. Hares, Ed.
Huawei Huawei
April 20, 2020 July 10, 2020
Dissemination of Flow Specification Rules for IPv6 Dissemination of Flow Specification Rules for IPv6
draft-ietf-idr-flow-spec-v6-11 draft-ietf-idr-flow-spec-v6-12
Abstract Abstract
Dissemination of Flow Specification Rules [I-D.ietf-idr-rfc5575bis] Dissemination of Flow Specification Rules I-D.ietf-idr-rfc5575bis
provides a protocol extension for propagation of traffic flow provides a protocol extension for propagation of traffic flow
information for the purpose of rate limiting or filtering. The information for the purpose of rate limiting or filtering. I-D.ietf-
[I-D.ietf-idr-rfc5575bis] specifies those extensions for IPv4 idr-rfc5575bis specifies those extensions for IPv4 protocol data
protocol data packets only. packets only.
This specification extends [I-D.ietf-idr-rfc5575bis] and defines This specification extends I-D.ietf-idr-rfc5575bis and defines
changes to the original document in order to make it also usable and changes to the original document in order to make it also usable and
applicable to IPv6 data packets. applicable to IPv6 data packets.
Status of This Memo Status of This Memo
This Internet-Draft is submitted in full conformance with the This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79. provisions of BCP 78 and BCP 79.
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 October 22, 2020. This Internet-Draft will expire on January 11, 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 32 skipping to change at page 2, line 32
3.5. Type 8 - ICMPv6 code . . . . . . . . . . . . . . . . . . 5 3.5. Type 8 - ICMPv6 code . . . . . . . . . . . . . . . . . . 5
3.6. Type 12 - Fragment . . . . . . . . . . . . . . . . . . . 5 3.6. Type 12 - Fragment . . . . . . . . . . . . . . . . . . . 5
3.7. Type 13 - Flow Label (new) . . . . . . . . . . . . . . . 6 3.7. Type 13 - Flow Label (new) . . . . . . . . . . . . . . . 6
3.8. Encoding Example . . . . . . . . . . . . . . . . . . . . 6 3.8. Encoding Example . . . . . . . . . . . . . . . . . . . . 6
4. Ordering of Flow Specifications . . . . . . . . . . . . . . . 8 4. Ordering of Flow Specifications . . . . . . . . . . . . . . . 8
5. Validation Procedure . . . . . . . . . . . . . . . . . . . . 8 5. Validation Procedure . . . . . . . . . . . . . . . . . . . . 8
6. IPv6 Traffic Filtering Action changes . . . . . . . . . . . . 8 6. IPv6 Traffic Filtering Action changes . . . . . . . . . . . . 8
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 . 9
7. Security Considerations . . . . . . . . . . . . . . . . . . . 9 7. Security Considerations . . . . . . . . . . . . . . . . . . . 9
8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 9 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 9
9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 10 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 11
10. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 10 10. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 11
11. References . . . . . . . . . . . . . . . . . . . . . . . . . 11 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 11
11.1. Normative References . . . . . . . . . . . . . . . . . . 11 11.1. Normative References . . . . . . . . . . . . . . . . . . 12
11.2. Informative References . . . . . . . . . . . . . . . . . 12 11.2. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 13
11.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Appendix A. Example python code: flow_rule_cmp_v6 . . . . . . . 13
Appendix A. Python code: flow_rule_cmp_v6 . . . . . . . . . . . 12 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 16
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 14
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 the IPv4 only networks to be requires the extension of tools used in the IPv4 only networks to be
also capable of supporting IPv6 data packets. also capable of supporting IPv6 data packets.
In this document authors analyze the differences of IPv6 [RFC2460] In this document authors analyze the differences of IPv6 [RFC8200]
flows description from those of traditional IPv4 packets and propose flows description from those of traditional IPv4 packets and propose
subset of new encoding formats to enable Dissemination of Flow subset of new encoding formats to enable Dissemination of Flow
Specification Rules [I-D.ietf-idr-rfc5575bis] for IPv6. Specification Rules [I-D.ietf-idr-rfc5575bis] for IPv6.
This specification should be treated as an extension of base This specification should be treated as an extension of base
[I-D.ietf-idr-rfc5575bis] specification and not its replacement. It [I-D.ietf-idr-rfc5575bis] specification and not its replacement. It
only defines the delta changes required to support IPv6 while all only defines the delta changes required to support IPv6 while all
other definitions and operation mechanisms of Dissemination of Flow other definitions and operation mechanisms of Dissemination of Flow
Specification Rules will remain in the main specification and will Specification Rules will remain in the main specification and will
not be repeated here. not be repeated here.
skipping to change at page 3, line 51 skipping to change at page 3, line 51
(AFI=1) only, the (AFI, SAFI) pair carried in the Multiprotocol (AFI=1) only, the (AFI, SAFI) pair carried in the Multiprotocol
Extension Capability MUST be: (AFI=2, SAFI=133) for IPv6 Flow Extension Capability MUST be: (AFI=2, SAFI=133) for IPv6 Flow
Specification, and (AFI=2, SAFI=134) for VPNv6 Flow Specification. Specification, and (AFI=2, SAFI=134) for VPNv6 Flow Specification.
For both SAFIs the indication to which address family they are For both SAFIs the indication to which address family they are
referring to will be recognized by AFI value (AFI=1 for IPv4 or referring to will be recognized by AFI value (AFI=1 for IPv4 or
VPNv4, AFI=2 for IPv6 and VPNv6 respectively). VPNv4, AFI=2 for IPv6 and VPNv6 respectively).
It needs to be observed that such choice of proposed encoding is It needs to be observed that such choice of proposed encoding is
compatible with filter validation against routing reachability compatible with filter validation against routing reachability
information as described in section 6 of [I-D.ietf-idr-rfc5575bis]. information as described in Section 6 of [I-D.ietf-idr-rfc5575bis].
3. IPv6 Flow Specification components 3. IPv6 Flow Specification components
The following components are redefined or added for the purpose of The following components are redefined or added for the purpose of
accommodating the IPv6 header encoding. Unless otherwise specified accommodating the IPv6 header encoding. Unless otherwise specified
all other components defined in [I-D.ietf-idr-rfc5575bis] all other components defined in [I-D.ietf-idr-rfc5575bis]
Section 4.2.2 also apply to IPv6 Flow Specification. Section 4.2.2 also apply to IPv6 Flow Specification.
3.1. Type 1 - Destination IPv6 Prefix 3.1. Type 1 - Destination IPv6 Prefix
skipping to change at page 4, line 38 skipping to change at page 4, line 38
(variable)> (variable)>
Defines the source prefix to match. The length, offset and prefix Defines the source prefix to match. The length, offset and prefix
are the same as in Section 3.1 are the same as in Section 3.1
3.3. Type 3 - Next Header 3.3. Type 3 - Next Header
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 last Next Header ([RFC2460] Section 3) value octet in IPv6 the last Next Header ([RFC8200] Section 3) value octet in IPv6
packets. packets.
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 byte (numeric_op len=00). SHOULD be encoded as single byte (numeric_op len=00).
Note: While IPv6 allows for more then one Next Header field in the Note: While IPv6 allows for more then one Next Header field in the
packet the main goal of Type 3 flow specification component is to packet the main goal of Type 3 flow specification component is to
match on the subsequent IP protocol value. Therefor the definition match on the subsequent IP protocol value. Therefore the definition
is limited to match only on last Next Header field in the packet. is limited to match only on last Next Header field in the packet.
3.4. Type 7 - ICMPv6 type 3.4. Type 7 - ICMPv6 type
Encoding: <type (1 octet), [numeric_op, value]+> Encoding: <type (1 octet), [numeric_op, value]+>
Defines a list of {numeric_op, value} pairs used to match the type Defines a list of {numeric_op, value} pairs used to match the type
field of an ICMPv6 packet (see also [RFC4443] Section 2.1). field of an ICMPv6 packet (see also [RFC4443] Section 2.1).
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 7 component values [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 7 component values
SHOULD be encoded as single byte (numeric_op len=00). SHOULD be encoded as single byte (numeric_op len=00).
In case of the presence of the ICMPv6 type (code) component only In case of the presence of the ICMPv6 type component only ICMPv6
ICMPv6 packets can match the entire Flow Specification. The ICMPv6 packets can match the entire Flow Specification. The ICMPv6 type
type (code) component, if present, never matches when the packet's component, if present, never matches when the packet's last Next
last Next Header field value is not 58 (ICMPv6), if the packet is Header field value is not 58 (ICMPv6), if the packet is fragmented
fragmented and this is not the first fragment, or if the system is and this is not the first fragment, or if the system is unable to
unable to locate the transport header. Different implementations may locate the transport header. Different implementations may or may
or may not be able to decode the transport header. not be able to decode the transport header.
3.5. Type 8 - ICMPv6 code 3.5. Type 8 - ICMPv6 code
Encoding: <type (1 octet), [numeric_op, value]+> Encoding: <type (1 octet), [numeric_op, value]+>
Defines a list of {numeric_op, value} pairs used to match the code Defines a list of {numeric_op, value} pairs used to match the code
field of an ICMPv6 packet (see also [RFC4443] Section 2.1). field of an ICMPv6 packet (see also [RFC4443] Section 2.1).
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 8 component values [I-D.ietf-idr-rfc5575bis] Section 4.2.1.1. Type 8 component values
SHOULD be encoded as single byte (numeric_op len=00). SHOULD be encoded as single byte (numeric_op len=00).
The last paragraph of Section 3.4 also applies to this component. In case of the presence of the ICMPv6 code component only ICMPv6
packets can match the entire Flow Specification. The ICMPv6 code
component, if present, never matches when the packet's last Next
Header field value is not 58 (ICMPv6), if the packet is fragmented
and this is not the first fragment, or if the system is unable to
locate the transport header. Different implementations may or may
not be able to decode the transport header.
3.6. Type 12 - Fragment 3.6. Type 12 - Fragment
Encoding: <type (1 octet), [bitmask_op, bitmask]+> Encoding: <type (1 octet), [bitmask_op, bitmask]+>
Defines a list of {bitmask_op, bitmask} pairs used to match specific Defines a list of {bitmask_op, bitmask} pairs used to match specific
IP fragments. IP fragments.
This component uses the Bitmask Operator (bitmask_op) described in This component uses the Bitmask Operator (bitmask_op) described in
[I-D.ietf-idr-rfc5575bis] Section 4.2.1.2. The Type 12 component [I-D.ietf-idr-rfc5575bis] Section 4.2.1.2. The Type 12 component
skipping to change at page 6, line 14 skipping to change at page 6, line 14
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
+---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+
| 0 | 0 | 0 | 0 |LF |FF |IsF| 0 | | 0 | 0 | 0 | 0 |LF |FF |IsF| 0 |
+---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+
Figure 1: Fragment Bitmask Operand Figure 1: Fragment Bitmask Operand
Bitmask values: Bitmask values:
IsF - Is a fragment - match if IPv6 Fragment Header ([RFC2460] IsF - Is a fragment - match if IPv6 Fragment Header ([RFC8200]
Section 4.5) Fragment Offset is not 0 Section 4.5) Fragment Offset is not 0
FF - First fragment - match if IPv6 Fragment Header ([RFC2460] FF - First fragment - match if IPv6 Fragment Header ([RFC8200]
Section 4.5) Fragment Offset is 0 AND M flag is 1 Section 4.5) Fragment Offset is 0 AND M flag is 1
LF - Last fragment - match if IPv6 Fragment Header ([RFC2460] LF - Last fragment - match if IPv6 Fragment Header ([RFC8200]
Section 4.5) Fragment Offset is not 0 AND M flag is 0 Section 4.5) Fragment Offset is not 0 AND M flag is 0
0 - SHOULD be set to 0 on NLRI encoding, and MUST be ignored during 0 - MUST be set to 0 on NLRI encoding, and MUST be ignored during
decoding decoding
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 ([RFC2460] 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 1-, 2-, or 4-byte quantities (numeric_op len=00,
len=01 or 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
skipping to change at page 8, line 32 skipping to change at page 8, line 32
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 can be reused with new [I-D.ietf-idr-rfc5575bis] Section 5.1 can be 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 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/flowspec- 3.7.2 and can be obtained at https://github.com/stoffi92/draft-ietf-
cmp-v6 [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)
of the validation procedure should now read as follows: of the validation procedure should now read as follows:
a) A destination prefix component with offset=0 is embedded in the a) A destination prefix component with offset=0 is embedded in the
Flow Specification Flow Specification
skipping to change at page 10, line 25 skipping to change at page 10, line 25
| 8 | ICMPv6 code | [this document] | | 8 | ICMPv6 code | [this document] |
| 9 | TCP flags | [this document] | | 9 | TCP flags | [this document] |
| 10 | Packet length | [this document] | | 10 | Packet length | [this document] |
| 11 | DSCP | [this document] | | 11 | DSCP | [this document] |
| 12 | Fragment | [this document] | | 12 | Fragment | [this document] |
| 13 | Flow Label | [this document] | | 13 | Flow Label | [this document] |
+-------+-------------------------+-----------------+ +-------+-------------------------+-----------------+
Table 1: Registry: Flow Spec IPv6 Component Types Table 1: Registry: Flow Spec IPv6 Component Types
In order to manage the limited number space and accommodate several
usages, the following policies defined by [RFC8126] are used:
+--------------+------------------------+
| Type Values | Policy |
+--------------+------------------------+
| 0 | Reserved |
| [1 .. 127] | Specification Required |
| [128 .. 254] | Expert Review |
| 255 | Reserved |
+--------------+------------------------+
Table 2: Flow Spec IPv6 Component Types Registration Policy
Guidance for Experts:
128-254 requires Expert Review as the registration policy. The
Experts are expected to check the clarity of purpose and use of
the requested code points. The Experts must also verify that
any specification produced in the IETF that requests one of
these code points has been made available for review by the IDR
working group and that any specification produced outside the
IETF does not conflict with work that is active or already
published within the IETF. It must be pointed out that
introducing new component types may break existing
implementations of this protocol. Unused and available for
assignment via documented procedures.
IANA maintains a registry entitled "Generic Transitive Experimental IANA maintains a registry entitled "Generic Transitive Experimental
Use Extended Community Sub-Types". For the purpose of this work, Use Extended Community Sub-Types". For the purpose of this work,
IANA is requested to assign a new value: IANA is requested to assign a new value:
+------------+----------------------------------------+-------------+ +------------+----------------------------------------+-------------+
| Sub-Type | Name | Reference | | Sub-Type | Name | Reference |
| Value | | | | Value | | |
+------------+----------------------------------------+-------------+ +------------+----------------------------------------+-------------+
| TBD | Flow spec rt-redirect-ipv6 | [this | | TBD | Flow spec rt-redirect-ipv6 | [this |
| | format | document] | | | format | document] |
+------------+----------------------------------------+-------------+ +------------+----------------------------------------+-------------+
Table 2: Registry: Generic Transitive Experimental Use Extended Table 3: Registry: Generic Transitive Experimental Use Extended
Community Sub-Types Community Sub-Types
9. Acknowledgements 9. Acknowledgements
Authors would like to thank Pedro Marques, Hannes Gredler and Bruno Authors would like to thank Pedro Marques, Hannes Gredler and Bruno
Rijsman, Brian Carpenter, and Thomas Mangin for their valuable input. Rijsman, Brian Carpenter, and Thomas Mangin for their valuable input.
10. Contributors 10. Contributors
Danny McPherson Danny McPherson
skipping to change at page 11, line 18 skipping to change at page 12, line 4
Andy Karch Andy Karch
Cisco Systems Cisco Systems
170 West Tasman Drive 170 West Tasman Drive
San Jose, CA 95134 San Jose, CA 95134
USA USA
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-22 (work in progress), April draft-ietf-idr-rfc5575bis-25 (work in progress), May 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>.
[RFC2460] Deering, S. and R. Hinden, "Internet Protocol, Version 6
(IPv6) Specification", RFC 2460, DOI 10.17487/RFC2460,
December 1998, <https://www.rfc-editor.org/info/rfc2460>.
[RFC2474] Nichols, K., Blake, S., Baker, F., and D. Black,
"Definition of the Differentiated Services Field (DS
Field) in the IPv4 and IPv6 Headers", RFC 2474,
DOI 10.17487/RFC2474, December 1998,
<https://www.rfc-editor.org/info/rfc2474>.
[RFC4271] Rekhter, Y., Ed., Li, T., Ed., and S. Hares, Ed., "A [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,
<https://www.rfc-editor.org/info/rfc4271>. <https://www.rfc-editor.org/info/rfc4271>.
[RFC4443] Conta, A., Deering, S., and M. Gupta, Ed., "Internet [RFC4443] Conta, A., Deering, S., and M. Gupta, Ed., "Internet
Control Message Protocol (ICMPv6) for the Internet Control Message Protocol (ICMPv6) for the Internet
Protocol Version 6 (IPv6) Specification", STD 89, Protocol Version 6 (IPv6) Specification", STD 89,
RFC 4443, DOI 10.17487/RFC4443, March 2006, RFC 4443, DOI 10.17487/RFC4443, March 2006,
<https://www.rfc-editor.org/info/rfc4443>. <https://www.rfc-editor.org/info/rfc4443>.
[RFC4760] Bates, T., Chandra, R., Katz, D., and Y. Rekhter, [RFC4760] Bates, T., Chandra, R., Katz, D., and Y. Rekhter,
"Multiprotocol Extensions for BGP-4", RFC 4760, "Multiprotocol Extensions for BGP-4", RFC 4760,
DOI 10.17487/RFC4760, January 2007, DOI 10.17487/RFC4760, January 2007,
<https://www.rfc-editor.org/info/rfc4760>. <https://www.rfc-editor.org/info/rfc4760>.
[RFC5492] Scudder, J. and R. Chandra, "Capabilities Advertisement
with BGP-4", RFC 5492, DOI 10.17487/RFC5492, February
2009, <https://www.rfc-editor.org/info/rfc5492>.
[RFC5701] Rekhter, Y., "IPv6 Address Specific BGP Extended Community [RFC5701] Rekhter, Y., "IPv6 Address Specific BGP Extended Community
Attribute", RFC 5701, DOI 10.17487/RFC5701, November 2009, Attribute", RFC 5701, DOI 10.17487/RFC5701, November 2009,
<https://www.rfc-editor.org/info/rfc5701>. <https://www.rfc-editor.org/info/rfc5701>.
[RFC6437] Amante, S., Carpenter, B., Jiang, S., and J. Rajahalme,
"IPv6 Flow Label Specification", RFC 6437,
DOI 10.17487/RFC6437, November 2011,
<https://www.rfc-editor.org/info/rfc6437>.
[RFC7153] Rosen, E. and Y. Rekhter, "IANA Registries for BGP [RFC7153] Rosen, E. and Y. Rekhter, "IANA Registries for BGP
Extended Communities", RFC 7153, DOI 10.17487/RFC7153, Extended Communities", RFC 7153, DOI 10.17487/RFC7153,
March 2014, <https://www.rfc-editor.org/info/rfc7153>. March 2014, <https://www.rfc-editor.org/info/rfc7153>.
[RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for
Writing an IANA Considerations Section in RFCs", BCP 26,
RFC 8126, DOI 10.17487/RFC8126, June 2017,
<https://www.rfc-editor.org/info/rfc8126>.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
May 2017, <https://www.rfc-editor.org/info/rfc8174>. May 2017, <https://www.rfc-editor.org/info/rfc8174>.
11.2. Informative References [RFC8200] Deering, S. and R. Hinden, "Internet Protocol, Version 6
(IPv6) Specification", STD 86, RFC 8200,
DOI 10.17487/RFC8200, July 2017,
<https://www.rfc-editor.org/info/rfc8200>.
[RFC5095] Abley, J., Savola, P., and G. Neville-Neil, "Deprecation 11.2. URIs
of Type 0 Routing Headers in IPv6", RFC 5095,
DOI 10.17487/RFC5095, December 2007,
<https://www.rfc-editor.org/info/rfc5095>.
11.3. URIs [1] https://github.com/stoffi92/draft-ietf-idr-flow-spec-
v6/tree/master/flowspec-cmp
[1] https://github.com/stoffi92/flowspec-cmp-v6 Appendix A. Example python code: flow_rule_cmp_v6
Appendix A. Python code: flow_rule_cmp_v6 <CODE BEGINS>
"""
Copyright (c) 2020 IETF Trust and the persons identified as authors
of draft-ietf-idr-flow-spec-v6. All rights reserved.
<CODE BEGINS> Redistribution and use in source and binary forms, with or without
""" modification, is permitted pursuant to, and subject to the license
Copyright (c) 2019 IETF Trust and the persons identified as authors of terms contained in, the Simplified BSD License set forth in Section
the code. All rights reserved. 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info).
"""
Redistribution and use in source and binary forms, with or without import itertools
modification, is permitted pursuant to, and subject to the license import collections
terms contained in, the Simplified BSD License set forth in Section import ipaddress
4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info).
"""
import itertools EQUAL = 0
import ipaddress A_HAS_PRECEDENCE = 1
B_HAS_PRECEDENCE = 2
IP_DESTINATION = 1
IP_SOURCE = 2
def flow_rule_cmp_v6(a, b): FS_component = collections.namedtuple('FS_component',
for comp_a, comp_b in itertools.zip_longest(a.components, 'component_type value')
b.components):
# If a component type does not exist in one rule
# this rule has lower precedence
if not comp_a:
return B_HAS_PRECEDENCE
if not comp_b:
return A_HAS_PRECEDENCE
# Higher precedence for lower component type
if comp_a.component_type < comp_b.component_type:
return A_HAS_PRECEDENCE
if comp_a.component_type > comp_b.component_type:
return B_HAS_PRECEDENCE
# component types are equal -> type specific comparison
if comp_a.component_type in (IP_DESTINATION, IP_SOURCE):
if comp_a.offset < comp_b.offset:
return A_HAS_PRECEDENCE
if comp_a.offset < comp_b.offset:
return B_HAS_PRECEDENCE
# both components have the same offset
# assuming comp_a.value, comp_b.value of type
# ipaddress.IPv6Network
# and the offset bits are reset to 0 (since they are not
# represented in the NLRI)
if comp_a.value.overlaps(comp_b.value):
# longest prefixlen has precedence
if comp_a.value.prefixlen > comp_b.value.prefixlen:
return A_HAS_PRECEDENCE
if comp_a.value.prefixlen < comp_b.value.prefixlen:
return B_HAS_PRECEDENCE
# components equal -> continue with next component
elif comp_a.value > comp_b.value:
return B_HAS_PRECEDENCE
elif comp_a.value < comp_b.value:
return A_HAS_PRECEDENCE
else: class FS_IPv6_prefix_component:
# assuming comp_a.value, comp_b.value of type bytearray def __init__(self, prefix, offset=0,
if len(comp_a.value) == len(comp_b.value): component_type=IP_DESTINATION):
if comp_a.value > comp_b.value: self.offset = offset
return B_HAS_PRECEDENCE self.component_type = component_type
if comp_a.value < comp_b.value: # make sure if offset != 0 that non of the
return A_HAS_PRECEDENCE # first offset bits are set in the prefix
# components equal -> continue with next component self.value = prefix
else: if offset != 0:
common = min(len(comp_a.value), len(comp_b.value))
if comp_a.value[:common] > comp_b.value[:common]: i = ipaddress.IPv6Interface(
return B_HAS_PRECEDENCE (self.value.network_address, offset))
elif comp_a.value[:common] < comp_b.value[:common]: if i.network.network_address != \
return A_HAS_PRECEDENCE ipaddress.ip_address('0::0'):
# the first common bytes match raise ValueError('Bits set in the offset')
elif len(comp_a.value) > len(comp_b.value):
return A_HAS_PRECEDENCE class FS_nlri(object):
else: """
return B_HAS_PRECEDENCE FS_nlri class implementation that allows sorting.
return EQUAL
<CODE ENDS> By calling .sort() on a array of FS_nlri objects these
will be sorted according to the flow_rule_cmp algorithm.
Example:
nlri = [ FS_nlri(components=[
FS_component(component_type=4,
value=bytearray([0,1,2,3,4,5,6])),
]),
FS_nlri(components=[
FS_component(component_type=5,
value=bytearray([0,1,2,3,4,5,6])),
FS_component(component_type=6,
value=bytearray([0,1,2,3,4,5,6])),
]),
]
nlri.sort() # sorts the array accorinding to the algorithm
"""
def __init__(self, components = None):
"""
components: list of type FS_component
"""
self.components = components
def __lt__(self, other):
# use the below algorithm for sorting
result = flow_rule_cmp_v6(self, other)
if result == B_HAS_PRECEDENCE:
return True
else:
return False
def flow_rule_cmp_v6(a, b):
"""
Implementation of the flowspec sorting algorithm in
draft-ietf-idr-flow-spec-v6.
"""
for comp_a, comp_b in itertools.zip_longest(a.components,
b.components):
# If a component type does not exist in one rule
# this rule has lower precedence
if not comp_a:
return B_HAS_PRECEDENCE
if not comp_b:
return A_HAS_PRECEDENCE
# Higher precedence for lower component type
if comp_a.component_type < comp_b.component_type:
return A_HAS_PRECEDENCE
if comp_a.component_type > comp_b.component_type:
return B_HAS_PRECEDENCE
# component types are equal -> type specific comparison
if comp_a.component_type in (IP_DESTINATION, IP_SOURCE):
if comp_a.offset < comp_b.offset:
return A_HAS_PRECEDENCE
if comp_a.offset < comp_b.offset:
return B_HAS_PRECEDENCE
# both components have the same offset
# assuming comp_a.value, comp_b.value of type
# ipaddress.IPv6Network
# and the offset bits are reset to 0 (since they are
# not represented in the NLRI)
if comp_a.value.overlaps(comp_b.value):
# longest prefixlen has precedence
if comp_a.value.prefixlen > \
comp_b.value.prefixlen:
return A_HAS_PRECEDENCE
if comp_a.value.prefixlen < \
comp_b.value.prefixlen:
return B_HAS_PRECEDENCE
# components equal -> continue with next
# component
elif comp_a.value > comp_b.value:
return B_HAS_PRECEDENCE
elif comp_a.value < comp_b.value:
return A_HAS_PRECEDENCE
else:
# assuming comp_a.value, comp_b.value of type
# bytearray
if len(comp_a.value) == len(comp_b.value):
if comp_a.value > comp_b.value:
return B_HAS_PRECEDENCE
if comp_a.value < comp_b.value:
return A_HAS_PRECEDENCE
# components equal -> continue with next
# component
else:
common = min(len(comp_a.value),
len(comp_b.value))
if comp_a.value[:common] > \
comp_b.value[:common]:
return B_HAS_PRECEDENCE
elif comp_a.value[:common] < \
comp_b.value[:common]:
return A_HAS_PRECEDENCE
# the first common bytes match
elif len(comp_a.value) > len(comp_b.value):
return A_HAS_PRECEDENCE
else:
return B_HAS_PRECEDENCE
return EQUAL
<CODE ENDS>
Authors' Addresses Authors' Addresses
Christoph Loibl (editor) Christoph Loibl (editor)
next layer Telekom GmbH next layer Telekom GmbH
Mariahilfer Guertel 37/7 Mariahilfer Guertel 37/7
Vienna 1150 Vienna 1150
AT AT
Phone: +43 664 1176414 Phone: +43 664 1176414
 End of changes. 39 change blocks. 
135 lines changed or deleted 223 lines changed or added

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