<?xml version="1.0"encoding="UTF-8"?> <?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>encoding="US-ASCII"?> <!DOCTYPE rfc SYSTEM"rfc2629.dtd" [ <!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"> <!ENTITY RFC4271 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4271.xml"> <!ENTITY RFC4443 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4443.xml"> <!ENTITY RFC4760 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4760.xml"> <!ENTITY RFC5701 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5701.xml"> <!ENTITY RFC7112 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7112.xml"> <!ENTITY RFC7153 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7153.xml"> <!ENTITY RFC8174 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8174.xml"> <!ENTITY RFC8200 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8200.xml"> <!ENTITY RFC8883 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8883.xml"> <!ENTITY I-D.ietf-idr-rfc5575bis SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-idr-rfc5575bis.xml"> ]> <?rfc toc="yes" ?> <?rfc symrefs="yes" ?> <?rfc sortrefs="yes"?> <?rfc compact="yes" ?> <?rfc subcompact="no" ?> <?rfc iprnotified="no" ?> <?rfc strict="no" ?>"rfc2629-xhtml.ent"> <rfccategory="std"xmlns:xi="http://www.w3.org/2001/XInclude" docName="draft-ietf-idr-flow-spec-v6-22" number="8956" ipr="trust200902"updates="I-D.ietf-idr-rfc5575bis">updates="8955" obsoletes="" submissionType="IETF" category="std" consensus="true" xml:lang="en" tocInclude="true" tocDepth="2" symRefs="true" sortRefs="true" version="3"> <!-- xml2rfc v2v3 conversion 3.5.0 --> <front> <title abbrev="IPv6 Flow Specification">Dissemination of Flow Specification Rules for IPv6</title> <seriesInfo name="RFC" value="8956"/> <author role="editor" fullname="Christoph Loibl"initials="C.L."initials="C" surname="Loibl"> <organization>next layer Telekom GmbH</organization> <address> <postal> <street>Mariahilfer Guertel 37/7</street> <city>Vienna</city><region></region><region/> <code>1150</code><country>AT</country><country>Austria</country> </postal> <phone>+43 664 1176414</phone> <email>cl@tix.at</email> </address> </author> <authorfullname='Robert Raszuk' initials='R' surname='Raszuk'fullname="Robert Raszuk" initials="R" surname="Raszuk" role="editor"><organization>Bloomberg LP</organization><organization>NTT Network Innovations</organization> <address> <postal><street>731 Lexington Ave </street> <city>New York City</city> <region>NY</region> <code>10022</code> <country>USA</country><street>940 Stewart Dr</street> <city>Sunnyvale</city> <region>CA</region> <code>94085</code> <country>United States of America</country> </postal> <email>robert@raszuk.net</email> </address> </author> <author role="editor" fullname="Susan Hares" initials="S" surname="Hares"> <organization>Huawei</organization> <address> <postal> <street>7453 Hickory Hill</street> <city>Saline</city> <region>MI</region> <code>48176</code><country>USA</country><country>United States of America</country> </postal> <email>shares@ndzh.com</email> </address> </author> <date year="2020" month="December" /><area>Routing Area</area> <workgroup>IDR Working Group</workgroup> <keyword>RFC</keyword> <keyword>Request for Comments</keyword> <keyword>I-D</keyword> <keyword>Internet-Draft</keyword><area>Routing</area> <workgroup>IDR</workgroup> <keyword>BGP Flow Specification</keyword> <keyword>V6</keyword> <abstract> <t>Dissemination"Dissemination of Flow SpecificationRules I-D.ietf-idr-rfc5575bisRules" (RFC 8955) provides a Border Gateway Protocol (BGP) extension for the propagation of traffic flow information for the purpose of rate limiting or filtering IPv4 protocol data packets. </t> <t> This document extendsI-D.ietf-idr-rfc5575bisRFC 8955 with IPv6 functionality. It also updatesI-D.ietf-idr-rfc5575bisRFC 8955 by changing the IANA Flow Spec Component Types registry. </t> </abstract> </front> <middle> <section anchor="intro"title="Introduction">numbered="true" toc="default"> <name>Introduction</name> <t>The growing amount of IPv6 traffic in private and public networks requires the extension of tools used in IPv4-only networks to also support IPv6 data packets. </t> <t> This document analyzes the differences between describing IPv6 <xreftarget="RFC8200"></xref>target="RFC8200" format="default"/> flows and those of IPv4 packets. It specifies new Border Gateway Protocol <xreftarget="RFC4271"></xref>target="RFC4271" format="default"/> encoding formats to enableDissemination"Dissemination of Flow SpecificationRulesRules" <xreftarget="I-D.ietf-idr-rfc5575bis" />target="RFC8955" format="default"/> for IPv6. </t> <t> This specification is an extension of the base established in <xreftarget="I-D.ietf-idr-rfc5575bis" />.target="RFC8955" format="default"/>. It only defines the delta changes required to supportIPv6IPv6, while all other definitions and operation mechanisms ofDissemination"Dissemination of Flow SpecificationRulesRules" will remain in the main specification and will not be repeated here. </t> <sectiontitle="Definitionsnumbered="true" toc="default"> <name>Definitions of Terms Used in ThisMemo"> <t> <list style="hanging"> <t hangText="AFI - ">AddressMemo</name> <dl newline="false" spacing="normal" indent="10"> <dt>AFI:</dt> <dd>Address FamilyIdentifier.</t> <t hangText="AS - ">Autonomous System.</t> <t hangText="NLRI - ">NetworkIdentifier</dd> <dt>AS: </dt> <dd>Autonomous System</dd> <dt>NLRI: </dt> <dd>Network Layer ReachabilityInformation.</t> <t hangText="SAFI - ">SubsequentInformation</dd> <dt>SAFI: </dt> <dd>Subsequent Address FamilyIdentifier.</t> <t hangText="VRF - ">VirtualIdentifier</dd> <dt>VRF: </dt> <dd>Virtual Routing andForwarding instance.</t> </list> </t>Forwarding</dd> </dl> <t> The key words"MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY","<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>", "<bcp14>MAY</bcp14>", and"OPTIONAL""<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as described inBCP 14BCP 14 <xreftarget="RFC2119"></xref>target="RFC2119"/> <xreftarget="RFC8174"></xref>target="RFC8174"/> when, and only when, they appear in all capitals, as shown here. </t> </section> </section> <sectiontitle="IPv6numbered="true" toc="default"> <name>IPv6 Flow SpecificationencodingEncoding inBGP">BGP</name> <t> <xreftarget="I-D.ietf-idr-rfc5575bis" />target="RFC8955" format="default"/> defines SAFIs 133 (Dissemination of FlowSpecification)Specification rules) and 134 (L3VPN Dissemination of FlowSpecification)Specification rules) in order to carry the corresponding Flow Specification. </t> <t> Implementations wishing to exchange IPv6 Flow SpecificationsMUST<bcp14>MUST</bcp14> use BGP's Capability Advertisement facility to exchange the Multiprotocol Extension Capability Code (Code1)1), as defined in <xreftarget="RFC4760"></xref>.target="RFC4760" format="default"/>. The (AFI, SAFI) pair carried in the Multiprotocol Extension CapabilityMUST be:<bcp14>MUST</bcp14> be (AFI=2, SAFI=133) for IPv6 FlowSpecification,Specification rules and (AFI=2, SAFI=134) forVPNv6L3VPN Dissemination of FlowSpecification.Specification rules. </t> </section> <sectiontitle="IPv6numbered="true" toc="default"> <name>IPv6 Flow Specificationcomponents">Components</name> <t> The encoding of each of the components begins with atypeType field (1 octet) followed by a variable length parameter. The following sections define component types and parameter encodings for IPv6. </t> <t> Types 4 (Port), 5 (Destination Port), 6 (Source Port), 9 (TCPflags),Flags), 10 (Packetlength)Length), and 11 (DSCP), as defined in <xreftarget="I-D.ietf-idr-rfc5575bis" />,target="RFC8955" format="default"/>, also apply to IPv6. Note that IANAis requested to updatehas updated the "Flow Spec Component Types" registry in order to contain both IPv4 and IPv6 Flow Specification component type numbers in a single registry (<xref target="IANA"/>).format="default"/>). </t> <section anchor="type_1"title="Typetoc="include" numbered="true"> <name>Type 1 - Destination IPv6Prefix" toc="include"> <t>Encoding: <typePrefix</name> <dl newline="false" spacing="normal"> <dt>Encoding:</dt> <dd><type (1 octet), length (1 octet), offset (1 octet), pattern (variable),padding(variable) ></t> <t>Definespadding (variable) ></dd> </dl> <t>This defines the destination prefix to match. The offset has been defined to allow for flexible matching to portions of an IPv6 address where one is required to skip over the first N bits of theaddress (theseaddress. (These bits skipped are often indicated as"don’t"don't care"bits).bits.) This can be especially useful where part of the IPv6 address consists of an embedded IPv4addressaddress, and matching needs to happen only on the embedded IPv4 address. The encoded pattern contains enough octets for the bits used in matching (length minus offset bits). </t><t> <list style="hanging"> <t hangText="length -">The length field<dl newline="false" spacing="normal" indent="11"> <dt>length:</dt> <dd>This indicates the N-th most significant bit in the address where bitwise pattern matching stops.</t> <t hangText="offset -">The offset field</dd> <dt>offset:</dt> <dd>This indicates the number of most significant address bits to skip before bitwise pattern matching starts.</t> <t hangText="pattern -">Contains</dd> <dt>pattern:</dt> <dd>This contains the matching pattern. The length of the pattern is defined by the number of bits needed for pattern matching (length minus offset).</t> <t hangText="padding -">The</dd> <dt>padding:</dt> <dd>This contains the minimum number of bits required to pad the component to an octet boundary. Padding bitsMUST<bcp14>MUST</bcp14> be 0 on encoding andMUST<bcp14>MUST</bcp14> be ignored on decoding.</t> </list> </t></dd> </dl> <t> If length = 0 and offset =00, this component matches everyaddress, otherwiseaddress; otherwise, lengthMUST<bcp14>MUST</bcp14> be in the range offset < length < 129 or the component ismalformed. </t>malformed.</t> <t> Note: This Flow Specification component can be represented by the notation ipv6address/length if offset is0,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 <xref target="examples"/>.format="default"/>. </t> </section> <section anchor="type_2"title="Typetoc="include" numbered="true"> <name>Type 2 - Source IPv6Prefix" toc="include"> <t>Encoding: <typePrefix</name> <dl newline="false" spacing="normal"> <dt>Encoding:</dt> <dd><type (1 octet), length (1 octet), offset (1 octet), pattern (variable),padding(variable) ></t> <t>Definespadding (variable) ></dd> </dl> <t>This defines the source prefix to match. The length, offset,patternpattern, and padding are the same as in <xref target="type_1"/>.format="default"/>. </t> </section> <section anchor="type_3"title="Typenumbered="true" toc="default"> <name>Type 3 - Upper-LayerProtocol"> <t>Encoding: <typeProtocol</name> <dl newline="false" spacing="normal"> <dt>Encoding:</dt> <dd><type (1 octet), [numeric_op,value]+> </t> <t>Containsvalue]+></dd> </dl> <t>This 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 extension header and thus indicates that the next item in the packet is the corresponding upper-layer header (see <xref target="RFC8200"/> Section 4).sectionFormat="of" section="4"/>). </t> <t>This component uses the Numeric Operator (numeric_op) described in <xreftarget="I-D.ietf-idr-rfc5575bis" /> Section 4.2.1.1.target="RFC8955" sectionFormat="of" section="4.2.1.1"/>. Type 3 component valuesSHOULD<bcp14>SHOULD</bcp14> be encoded as a single octet (numeric_op len=00). </t> <t>Note: While IPv6 allows for more than one Next Header field in the packet, the main goal of the Type 3 Flow Specification component is to match on the first upper-layer IP protocol value.ThereforeTherefore, the definition is limited to match only on this specific Next Header field in the packet. </t> </section> <section anchor="type_7"title="Typetoc="include" numbered="true"> <name>Type 7 - ICMPv6Type" toc="include"> <t>Encoding: <typeType</name> <dl newline="false" spacing="normal"> <dt>Encoding:</dt> <dd><type (1 octet), [numeric_op,value]+> </t> <t>Definesvalue]+></dd> </dl> <t>This defines a list of {numeric_op, value} pairs used to match thetypeType field of an ICMPv6 packet (see also <xref target="RFC4443"/> Section 2.1).sectionFormat="of" section="2.1"/>). </t> <t> This component uses the Numeric Operator (numeric_op) described in <xreftarget="I-D.ietf-idr-rfc5575bis" /> Section 4.2.1.1.target="RFC8955" sectionFormat="of" section="4.2.1.1"/>. Type 7 component valuesSHOULD<bcp14>SHOULD</bcp14> be encoded as a single octet (numeric_op len=00). </t> <t> In case of the presence of the ICMPv6Type componenttype component, only ICMPv6 packets can match the entire Flow Specification. The ICMPv6Typetype component, if present, never matches when the packet's upper-layer IP protocol 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. </t> </section> <section anchor="type_8"title="Typetoc="include" numbered="true"> <name>Type 8 - ICMPv6Code" toc="include"> <t>Encoding: <typeCode</name> <dl newline="false" spacing="normal"> <dt>Encoding:</dt> <dd><type (1 octet), [numeric_op,value]+> </t>value]+></dd> </dl> <t>DefinesThis defines a list of {numeric_op, value} pairs used to match the code field of an ICMPv6 packet (see also <xref target="RFC4443"/> Section 2.1).sectionFormat="of" section="2.1"/>). </t> <t> This component uses the Numeric Operator (numeric_op) described in <xreftarget="I-D.ietf-idr-rfc5575bis" /> Section 4.2.1.1.target="RFC8955" sectionFormat="of" section="4.2.1.1"/>. Type 8 component valuesSHOULD<bcp14>SHOULD</bcp14> be encoded as a single octet (numeric_op len=00). </t> <t> In case of the presence of the ICMPv6Code componentcode component, only ICMPv6 packets can match the entire Flow Specification. The ICMPv6 code component, if present, never matches when the packet's upper-layer IP protocol 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. </t> </section> <sectionanchor="type_12 " title="Typeanchor="type_12" numbered="true" toc="default"> <name>Type 12 -Fragment"> <t>Encoding: <typeFragment</name> <dl newline="false" spacing="normal"> <dt>Encoding:</dt> <dd><type (1 octet), [bitmask_op,bitmask]+> </t> <t> Definesbitmask]+></dd> </dl> <t>This defines a list of {bitmask_op, bitmask} pairs used to match specific IPfragments. </t>fragments.</t> <t>This component uses the Bitmask Operator (bitmask_op) described in <xreftarget="I-D.ietf-idr-rfc5575bis" /> Section 4.2.1.2.target="RFC8955" sectionFormat="of" section="4.2.1.2"/>. The Type 12 component bitmaskMUST<bcp14>MUST</bcp14> be encoded as a single octet bitmask (bitmask_op len=00). </t><t><figuretitle="Fragment Bitmask Operand"anchor="figure_fragment_bitmask_operand"><artwork><name>Fragment Bitmask Operand</name> <artwork name="" type="" align="left" alt=""><![CDATA[ 0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ | 0 | 0 | 0 | 0 |LF |FF |IsF| 0 | +---+---+---+---+---+---+---+---+</artwork>]]></artwork> </figure></t><t>Bitmask values:<list style="hanging"> <t hangText="IsF -">Is</t> <dl newline="false" spacing="normal" indent="6"> <dt>IsF:</dt> <dd>Is a fragment other than the first--- match if IPv6 Fragment Header (<xref target="RFC8200"/> Section 4.5)sectionFormat="of" section="4.5"/>) Fragment Offset is not0 </t> <t hangText="FF -">First0</dd> <dt>FF:</dt> <dd>First fragment--- match if IPv6 Fragment Header (<xref target="RFC8200"/> Section 4.5)sectionFormat="of" section="4.5"/>) Fragment Offset is 0 AND M flag is1 </t> <t hangText="LF -">Last1</dd> <dt>LF:</dt> <dd>Last fragment--- match if IPv6 Fragment Header (<xref target="RFC8200"/> Section 4.5)sectionFormat="of" section="4.5"/>) Fragment Offset is not 0 AND M flag is0 </t> <t hangText="0 -">MUST0</dd> <dt>0:</dt> <dd><bcp14>MUST</bcp14> be set to 0 on NLRIencoding,encoding andMUST<bcp14>MUST</bcp14> be ignored duringdecoding </t> </list> </t>decoding</dd> </dl> </section> <section anchor="type_13"title="Typenumbered="true" toc="default"> <name>Type 13 - Flow Label(new)"> <t>Encoding: <type(new)</name> <dl newline="false" spacing="normal"> <dt>Encoding:</dt> <dd><type (1 octet), [numeric_op,value]+> </t> <t>Containsvalue]+></dd> </dl> <t>This contains a list of {numeric_op, value} pairs that are used to match the 20-bit Flow Label IPv6 header field (<xreftarget="RFC8200"></xref> Section 3).target="RFC8200" sectionFormat="of" section="3"/>). </t> <t>This component uses the Numeric Operator (numeric_op) described in <xreftarget="I-D.ietf-idr-rfc5575bis" /> Section 4.2.1.1.target="RFC8955" sectionFormat="of" section="4.2.1.1"/>. Type 13 component valuesSHOULD<bcp14>SHOULD</bcp14> be encoded as 4-octet quantities (numeric_op len=10). </t> </section> <sectiontitle="Encoding Example" anchor="examples"> <section title="Example 1" toc="exclude">anchor="examples" numbered="true" toc="default"> <name>Encoding Examples</name> <section numbered="true"> <name>Example 1</name> <t> The following example demonstrates the prefix encodingfor: "packetsfor packets from ::1234:5678:9a00:0/64-104 to 2001:db8::/32 andupper-layer-protocol tcp".upper-layer protocol tcp. </t><t> <figure> <artwork> +--------+----------------------+-------------------------+----------+ | length | destination | source | ul-proto | +--------+----------------------+-------------------------+----------+ | 0x12 | 01<table anchor="example-1" align="left"> <thead> <tr> <th>len</th> <th>destination</th> <th>source</th> <th>ul-proto</th> </tr> </thead> <tbody> <tr> <td>0x12</td> <td>01 20 00 20 01 0DB8 | 02B8</td> <td>02 68 40 12 34 56 789A | 039A</td> <td>03 8106 | +--------+----------------------+-------------------------+----------+ </artwork> </figure> </t> <t> Decoded: <figure> <artwork> +-------+------------+-------------------------------+ | Value | | | +-------+------------+-------------------------------+ | 0x12 | length | 1806</td> </tr> </tbody> </table> <t>Decoded:</t> <table anchor="example-1-decoded" align="left"> <thead> <tr> <th>Value</th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>0x12</td> <td>length</td> <td>18 octets(len<240 1-octet) | | 0x01 | type | Type(if len<240, 1 octet)</td> </tr> <tr> <td>0x01</td> <td>type</td> <td>Type 1 -Dest. IPv6 Prefix | | 0x20 | length | 32 bit | | 0x00 | offset | 0 bit | | 0x20 | pattern | | | 0x01 | pattern | | | 0x0D | pattern | | | 0xB8 | pattern | (noDest. IPv6 Prefix</td> </tr> <tr> <td>0x20</td> <td>length</td> <td>32 bits</td> </tr> <tr> <td>0x00</td> <td>offset</td> <td>0 bits</td> </tr> <tr> <td>0x20</td> <td>pattern</td> <td></td> </tr> <tr> <td>0x01</td> <td>pattern</td> <td></td> </tr> <tr> <td>0x0D</td> <td>pattern</td> <td></td> </tr> <tr> <td>0xB8</td> <td>pattern</td> <td>(no paddingneeded) | | 0x02 | type | Typeneeded)</td> </tr> <tr> <td>0x02</td> <td>type</td> <td>Type 2 - Source IPv6Prefix | | 0x68 | length | 104 bit | | 0x40 | offset | 64 bit | | 0x12 | pattern | | | 0x34 | pattern | | | 0x56 | pattern | | | 0x78 | pattern | | | 0x9A | pattern | (noPrefix</td> </tr> <tr> <td>0x68</td> <td>length</td> <td>104 bits</td> </tr> <tr> <td>0x40</td> <td>offset</td> <td>64 bits</td> </tr> <tr> <td>0x12</td> <td>pattern</td> <td></td> </tr> <tr> <td>0x34</td> <td>pattern</td> <td></td> </tr> <tr> <td>0x56</td> <td>pattern</td> <td></td> </tr> <tr> <td>0x78</td> <td>pattern</td> <td></td> </tr> <tr> <td>0x9A</td> <td>pattern</td> <td>(no paddingneeded) | | 0x03 | type | Typeneeded)</td> </tr> <tr> <td>0x03</td> <td>type</td> <td>Type 3 -upper-layer-proto | | 0x81 | numeric_op | end-of-list,Upper-Layer Protocol</td> </tr> <tr> <td>0x81</td> <td>numeric_op</td> <td>end-of-list, value size=1,== | | 0x06 | value | 06 | +-------+------------+-------------------------------+ </artwork> </figure> This==</td> </tr> <tr> <td>0x06</td> <td>value</td> <td>06</td> </tr> </tbody> </table> <t>This constitutesaan NLRI withaan NLRI length of 18octets. </t>octets.</t> <t> Padding is not needed either for the destination prefix pattern (length - offset = 32bit)bits) or for the source prefix pattern (length - offset = 40bit),bits), as both patterns end on an octet boundary. </t> </section> <sectiontitle="Example 2" toc="exclude">numbered="true"> <name>Example 2</name> <t> The following example demonstrates the prefix encodingfor: "allfor all packets from ::1234:5678:9a00:0/65-104 to2001:db8::/32".2001:db8::/32. </t><t> <figure> <artwork> +--------+----------------------+-------------------------+ | length | destination | source | +--------+----------------------+-------------------------+ | 0x0f | 01<table anchor="example-2" align="left"> <thead> <tr> <th>length</th> <th>destination</th> <th>source</th> </tr> </thead> <tbody> <tr> <td>0x0f</td> <td>01 20 00 20 01 0DB8 | 02B8</td> <td>02 68 41 24 68 ac f134 | +--------+----------------------+-------------------------+ </artwork> </figure> </t> <t> Decoded: <figure> <artwork> +-------+-------------+-------------------------------+ | Value | | | +-------+-------------+-------------------------------+ | 0x0f | length | 1534</td> </tr> </tbody> </table> <t>Decoded:</t> <table anchor="example-2-decoded" align="left"> <thead> <tr> <th>Value</th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>0x0f</td> <td>length</td> <td>15 octets(len<240 1-octet) | | 0x01 | type | Type(if len<240, 1 octet)</td> </tr> <tr> <td>0x01</td> <td>type</td> <td>Type 1 -Dest. IPv6 Prefix | | 0x20 | length | 32 bit | | 0x00 | offset | 0 bit | | 0x20 | pattern | | | 0x01 | pattern | | | 0x0D | pattern | | | 0xB8 | pattern | (noDest. IPv6 Prefix</td> </tr> <tr> <td>0x20</td> <td>length</td> <td>32 bits</td> </tr> <tr> <td>0x00</td> <td>offset</td> <td>0 bits</td> </tr> <tr> <td>0x20</td> <td>pattern</td> <td></td> </tr> <tr> <td>0x01</td> <td>pattern</td> <td></td> </tr> <tr> <td>0x0D</td> <td>pattern</td> <td></td> </tr> <tr> <td>0xB8</td> <td>pattern</td> <td>(no paddingneeded) | | 0x02 | type | Typeneeded)</td> </tr> <tr> <td>0x02</td> <td>type</td> <td>Type 2 - Source IPv6Prefix | | 0x68 | length | 104 bit | | 0x41 | offset | 65 bit | | 0x24 | pattern | | | 0x68 | pattern | | | 0xac | pattern | | | 0xf1 | pattern | | | 0x34 | pattern/pad | (containsPrefix</td> </tr> <tr> <td>0x68</td> <td>length</td> <td>104 bits</td> </tr> <tr> <td>0x41</td> <td>offset</td> <td>65 bits</td> </tr> <tr> <td>0x24</td> <td>pattern</td> <td></td> </tr> <tr> <td>0x68</td> <td>pattern</td> <td></td> </tr> <tr> <td>0xac</td> <td>pattern</td> <td></td> </tr> <tr> <td>0xf1</td> <td>pattern</td> <td></td> </tr> <tr> <td>0x34</td> <td>pattern/pad</td> <td>(contains 1 bitpadding) | +-------+-------------+-------------------------------+ </artwork> </figure> Thisof padding)</td> </tr> </tbody> </table> <t>This constitutesaan NLRI withaan NLRI length of 15octets. </t>octets.</t> <t> The source prefix pattern is 104 - 65 = 39 bits in length. After thepatternpattern, one bit of padding needs to be added so that the component ends onaan octet boundary. However, only the first 39 bits are actually used for bitwise patternmatchingmatching, starting with a65 bit65-bit offset from the topmost bit of the address. </t> </section> </section> </section> <sectiontitle="Orderingnumbered="true" toc="default"> <name>Ordering of FlowSpecifications">Specifications</name> <t> The definition for the order of traffic filtering rules from <xreftarget="I-D.ietf-idr-rfc5575bis" /> Section 5.1target="RFC8955" sectionFormat="of" section="5.1"/> is reused with new consideration for the IPv6 prefix offset. As long as the offsets are equal, the comparison is the same, retaining longest-prefix-match semantics. If the offsets are not equal, the lowest offset has precedence, as this Flow Specification matches the most significant bit. </t> <t> The code in <xref target="flow_rule_cmp_src"/>format="default"/> shows a Python3 implementation of the resulting comparison algorithm. The full code was tested with Python 3.7.2 and can be obtained at <ereftarget="https://github.com/stoffi92/draft-ietf-idr-flow-spec-v6/tree/master/flowspec-cmp">https://github.com/stoffi92/draft-ietf-idr-flow-spec-v6/tree/master/flowspec-cmp</eref>.target="https://github.com/stoffi92/draft-ietf-idr-flow-spec-v6/tree/master/flowspec-cmp" brackets="angle"/>. </t> </section> <sectiontitle="Validation Procedure">numbered="true" toc="default"> <name>Validation Procedure</name> <t> The validation procedure is the same as specified in <xreftarget="I-D.ietf-idr-rfc5575bis" /> Section 6target="RFC8955" sectionFormat="of" section="6"/> with the exception that item a) of the validation procedure should now read as follows:<list> <t> a) A</t> <blockquote> <ol type="%c)"> <li>A destination prefix component with offset=0 is embedded in the FlowSpecification </t> </list> </t>Specification</li> </ol> </blockquote> </section> <sectiontitle="IPv6numbered="true" toc="default"> <name>IPv6 Traffic Filtering Actionchanges">Changes</name> <t>Traffic Filtering Actions from <xreftarget="I-D.ietf-idr-rfc5575bis" /> Section 7target="RFC8955" sectionFormat="of" section="7"/> can also be applied to IPv6 Flow Specifications. To allow an IPv6-Address-Specific Route-Target, a new Traffic Filtering Action IPv6-Address-Specific Extended Community<xref target="RFC5701"></xref>is specified in <xref target="redirect_ipv6"/>format="default"/> below. </t> <section anchor="redirect_ipv6"title="Redirectnumbered="true" toc="default"> <name>Redirect IPv6 (rt-redirect-ipv6) TypeTBD">0x000d</name> <t>The redirect IPv6-Address-Specific Extended Community allows the traffic to be redirected to a VRF routing instance that lists the specified IPv6-Address-Specific Route-Target in its import policy. If several local instances match this criteria, the choice between them is a local matter (for example, the instance with the lowest Route Distinguisher value can be elected). </t> <t>This IPv6-Address-Specific Extended Community uses the same encoding as the IPv6-Address-Specific Route-Target Extended Community<xref target="RFC5701"></xref> Section 2(<xref target="RFC5701" sectionFormat="of" section="2"/>) with the Type value alwaysTBD.0x000d. </t> <t>The Local Administratorsub-fieldsubfield contains a number from a numbering space that is administered by the organization to which the IP address carried in the Global Administratorsub-fieldsubfield has been assigned by an appropriate authority. </t> <t>Interferes with: All BGP Flow Specification redirect Traffic Filtering Actions (with itself and those specified in <xreftarget="I-D.ietf-idr-rfc5575bis" /> Section 7.4).target="RFC8955" sectionFormat="of" section="7.4"/>). </t> </section> </section> <sectiontitle="Security Considerations"> <t> Thisnumbered="true" toc="default"> <name>Security Considerations</name> <t>This document extends the functionality in <xreftarget="I-D.ietf-idr-rfc5575bis" />target="RFC8955" format="default"/> to be applicable to IPv6 data packets. The sameSecurity Considerationssecurity considerations from <xreftarget="I-D.ietf-idr-rfc5575bis" />target="RFC8955" format="default"/> now also apply to IPv6networks. </t> <t> <xrefnetworks.</t> <t><xref target="RFC7112"/>format="default"/> describes the impact of oversized IPv6 header chains when trying to match on the transport header; <xref target="RFC8200"/> Section 4.5sectionFormat="of" section="4.5"/> also requires that the first fragment must include the upper-layerheaderheader, but there could be wrongly formatted packets not respecting <xref target="RFC8200"/>.format="default"/>. IPv6 Flow Specification componenttypeType 3 (<xreftarget="type_3"/>)target="type_3" format="default"/>) will not be enforced for those illegal packets. Moreover, there are hardware limitations in several routers (<xref target="RFC8883"/> Section 1)sectionFormat="of" section="1"/>) that may make it impossible to enforce a policy signaled by atypeType 3 Flow Specification component or Flow Specification components that match on upper-layer properties of thepacket. </t>packet.</t> </section> <section anchor="IANA"title="IANA Considerations">numbered="true" toc="default"> <name>IANA Considerations</name> <t>This section complies with <xreftarget="RFC7153"></xref>.target="RFC7153" format="default"/>. </t> <sectiontitle="Flownumbered="true" toc="default"> <name>Flow Spec IPv6 ComponentTypes">Types</name> <t> IANA has created and maintains a registry entitled "Flow Spec Component Types". IANAis requested to add [this document] to thehas added this document as a reference forthisthat registry.FurthermoreFurthermore, the registryshould be rewrittenhas been updated to also contain the IPv6 Flow Specification Component Types as described below. The registration procedureshould remainremains unchanged. </t> <sectiontitle="Registry Template"> <t> <list style="hanging" hangIndent="6"> <t hangText="Type Value:"> <vspace /> Containsnumbered="true" toc="default"> <name>Registry Template</name> <dl newline="false" spacing="normal" indent="13"> <dt>Type Value:</dt> <dd>contains the assigned Flow Specification component typevalue. </t> <t hangText="IPv4 Name:"> <vspace /> Containsvalue</dd> <dt>IPv4 Name:</dt> <dd>contains the associated IPv4 Flow Specification component name as specified in <xreftarget="I-D.ietf-idr-rfc5575bis" />. </t> <t hangText="IPv6 Name:"> <vspace /> Containstarget="RFC8955" format="default"/></dd> <dt>IPv6 Name:</dt> <dd>contains the associated IPv6 Flow Specification component name as specified in thisdocument. </t> <t hangText="Reference:"> <vspace /> Contains referenced to the specifications. </t> </list> </t> </section> <section title="Registry Contents"> <t> <list> <t> + Type Value: 0<vspace/> + IPv4 Name: Reserved<vspace/> + IPv6 Name: Reserved<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 1<vspace/> + IPv4 Name: Destination Prefix<vspace/> + IPv6 Name: Destination IPv6 Prefix<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 2<vspace/> + IPv4 Name: Source Prefix<vspace/> + IPv6 Name: Source IPv6 Prefix<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 3<vspace/> + IPv4 Name: IP Protocol<vspace/> + IPv6 Name: Upper-Layer Protocol<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 4<vspace/> + IPv4 Name: Port<vspace/> + IPv6 Name: Port<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 5<vspace/> + IPv4 Name: Destination Port<vspace/> + IPv6 Name: Destination Port<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 6<vspace/> + IPv4 Name: Source Port<vspace/> + IPv6 Name: Source Port<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 7<vspace/> + IPv4 Name: ICMP Type<vspace/> + IPv6 Name: ICMPv6 Type<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 8<vspace/> + IPv4 Name: ICMP Code<vspace/> + IPv6 Name: ICMPv6 Code<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 9<vspace/> + IPv4 Name: TCP Flags<vspace/> + IPv6 Name: TCP Flags<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 10<vspace/> + IPv4 Name: Packet Length<vspace/> + IPv6 Name: Packet Length<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 11<vspace/> + IPv4 Name: DSCP<vspace/> + IPv6 Name: DSCP<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 12<vspace/> + IPv4 Name: Fragment<vspace/> + IPv6 Name: Fragment<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> <t> + Type Value: 13<vspace/> + IPv4 Name: Unassigned<vspace/> + IPv6 Name: Flow Label<vspace/> + Reference: [this document]<vspace/> </t> <t> + Type Value: 14-254<vspace/> + IPv4 Name: Unassigned<vspace/> + IPv6 Name: Unassigned<vspace/> + Reference: <vspace/> </t> <t> + Type Value: 255<vspace/> + IPv4 Name: Reserved<vspace/> + IPv6 Name: Reserved<vspace/> + Reference: <xref target="I-D.ietf-idr-rfc5575bis" /> [this document]<vspace/> </t> </list> </t> </section> </section> <section title="IPv6-Address-Specificdocument</dd> <dt>Reference:</dt> <dd>contains references to the specifications</dd> </dl> </section> <section numbered="true" toc="default"> <name>Registry Contents</name> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>0</dd> <dt>IPv4 Name:</dt> <dd>Reserved</dd> <dt>IPv6 Name:</dt> <dd>Reserved</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>1</dd> <dt>IPv4 Name:</dt> <dd>Destination Prefix</dd> <dt>IPv6 Name:</dt> <dd>Destination IPv6 Prefix</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>2</dd> <dt>IPv4 Name:</dt> <dd>Source Prefix</dd> <dt>IPv6 Name:</dt> <dd>Source IPv6 Prefix</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>3</dd> <dt>IPv4 Name:</dt> <dd>IP Protocol</dd> <dt>IPv6 Name:</dt> <dd>Upper-Layer Protocol</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>4</dd> <dt>IPv4 Name:</dt> <dd>Port</dd> <dt>IPv6 Name:</dt> <dd>Port</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>5</dd> <dt>IPv4 Name:</dt> <dd>Destination Port</dd> <dt>IPv6 Name:</dt> <dd>Destination Port</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>6</dd> <dt>IPv4 Name:</dt> <dd>Source Port</dd> <dt>IPv6 Name:</dt> <dd>Source Port</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>7</dd> <dt>IPv4 Name:</dt> <dd>ICMP Type</dd> <dt>IPv6 Name:</dt> <dd>ICMPv6 Type</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>8</dd> <dt>IPv4 Name:</dt> <dd>ICMP Code</dd> <dt>IPv6 Name:</dt> <dd>ICMPv6 Code</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>9</dd> <dt>IPv4 Name:</dt> <dd>TCP Flags</dd> <dt>IPv6 Name:</dt> <dd>TCP Flags</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>10</dd> <dt>IPv4 Name:</dt> <dd>Packet Length</dd> <dt>IPv6 Name:</dt> <dd>Packet Length</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>11</dd> <dt>IPv4 Name:</dt> <dd>DSCP</dd> <dt>IPv6 Name:</dt> <dd>DSCP</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>12</dd> <dt>IPv4 Name:</dt> <dd>Fragment</dd> <dt>IPv6 Name:</dt> <dd>Fragment</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>13</dd> <dt>IPv4 Name:</dt> <dd>Unassigned</dd> <dt>IPv6 Name:</dt> <dd>Flow Label</dd> <dt>Reference:</dt> <dd>RFC 8956</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>14-254</dd> <dt>IPv4 Name:</dt> <dd>Unassigned</dd> <dt>IPv6 Name:</dt> <dd>Unassigned</dd> </dl> <dl newline="false" spacing="compact" indent="13"> <dt>Type Value:</dt> <dd>255</dd> <dt>IPv4 Name:</dt> <dd>Reserved</dd> <dt>IPv6 Name:</dt> <dd>Reserved</dd> <dt>Reference:</dt> <dd><xref target="RFC8955" format="default"/>, RFC 8956</dd> </dl> </section> </section> <section numbered="true" toc="default"> <name>IPv6-Address-Specific Extended Community Flow Spec IPv6Actions">Actions</name> <t> IANA maintains a registry entitled "Transitive IPv6-Address-Specific Extended Community Types". For the purpose of this work, IANAis requested to assignhas assigned a new value: </t><texttable anchor="iana_ext_comm_types" title="Registry: Transitive<table anchor="iana_ext_comm_subtypes" align="center"> <name>Transitive IPv6-Address-Specific Extended CommunityTypes"> <ttcolTypes Registry</name> <thead> <tr> <th align="left">TypeValue</ttcol> <ttcol align="left">Name</ttcol> <ttcol align="left">Reference</ttcol> <c>TBD</c> <c>FlowValue</th> <th align="left">Name</th> <th align="left">Reference</th> </tr> </thead> <tbody> <tr> <td align="left">0x000d</td> <td align="left">Flow spec rt-redirect-ipv6format</c> <c>[this document]</c> </texttable> </section> </section> <section title="Acknowledgements"> <t>Authors would like to thank Pedro Marques, Hannes Gredler, Bruno Rijsman, Brian Carpenter, and Thomas Mangin for their valuable input. </t>format</td> <td align="left">RFC 8956</td> </tr> </tbody> </table> </section><section title="Contributors"> <t> <figure> <artwork> Danny McPherson Verisign, Inc. Email: dmcpherson@verisign.com </artwork> </figure> </t><t> <figure> <artwork> Burjiz Pithawala Individual Email: burjizp@gmail.com </artwork> </figure> </t><t> <figure> <artwork> Andy Karch Cisco Systems 170 West Tasman Drive San Jose, CA 95134 USA Email: akarch@cisco.com </artwork> </figure> </t></section> </middle> <back><references title="Normative References"> &RFC2119; &RFC4271; &RFC4443; &RFC4760; &RFC5701; &RFC7112; &RFC7153; &RFC8174; &RFC8200; &RFC8883; &I-D.ietf-idr-rfc5575bis;<references> <name>Normative References</name> <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/> <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4271.xml"/> <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4443.xml"/> <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4760.xml"/> <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5701.xml"/> <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7112.xml"/> <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7153.xml"/> <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/> <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8200.xml"/> <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8883.xml"/> <!-- draft-ietf-idr-rfc5575bis - RFC-to-be 8955 companion document --> <reference anchor='RFC8955' target="https://www.rfc-editor.org/info/rfc8955"> <front> <title>Dissemination of Flow Specification Rules</title> <author initials='C' surname='Loibl' fullname='Christoph Loibl'> <organization /> </author> <author initials='S' surname='Hares' fullname='Susan Hares'> <organization /> </author> <author initials='R' surname='Raszuk' fullname='Robert Raszuk'> <organization /> </author> <author initials='D' surname='McPherson' fullname='Danny McPherson'> <organization /> </author> <author initials='M' surname='Bacher' fullname='Martin Bacher'> <organization /> </author> <date month='December' year='2020' /> </front> <seriesInfo name="RFC" value="8955"/> <seriesInfo name="DOI" value="10.17487/RFC8955"/> </reference> </references> <sectiontitle="Example python code: flow_rule_cmp_v6" anchor="flow_rule_cmp_src"> <t> <figure> <artwork><![CDATA[ <CODE BEGINS>anchor="flow_rule_cmp_src" numbered="true" toc="default"> <name>Example Python Code: flow_rule_cmp_v6</name> <sourcecode name="" type="python" markers="true"><![CDATA[ """ Copyright (c) 2020 IETF Trust and the persons identified as authors of the code. All rights reserved. Redistribution and use in source and binary forms, with or without modification, is permitted pursuant to, and subject to the license terms contained in, the Simplified BSD License set forth in Section 4.c of the IETFTrust’sTrust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info). """ import itertools import collections import ipaddress EQUAL = 0 A_HAS_PRECEDENCE = 1 B_HAS_PRECEDENCE = 2 IP_DESTINATION = 1 IP_SOURCE = 2 FS_component = collections.namedtuple('FS_component', 'component_type value') class FS_IPv6_prefix_component: def __init__(self, prefix, offset=0, component_type=IP_DESTINATION): self.offset = offset self.component_type = component_type # make sure if offset != 0 that none of the # first offset bits are set in the prefix self.value = prefix if offset != 0: i = ipaddress.IPv6Interface( (self.value.network_address, offset)) if i.network.network_address != \ ipaddress.ip_address('0::0'): raise ValueError('Bits set in the offset') class FS_nlri(object): """ FS_nlri class implementation that allows sorting. By calling .sort() on an 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 according 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 indraft-ietf-idr-flow-spec-v6.RFC 8956. """ 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 specifictype-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> ]]></artwork> </figure>]]></sourcecode> </section> <section numbered="false" toc="default"> <name>Acknowledgments</name> <t>The authors would like to thank <contact fullname="Pedro Marques"/>, <contact fullname="Hannes Gredler"/>, <contact fullname="Bruno Rijsman"/>, <contact fullname="Brian Carpenter"/>, and <contact fullname="Thomas Mangin"/> for their valuable input. </t> </section> <section numbered="false" toc="default"> <name>Contributors</name> <contact fullname="Danny McPherson"> <organization>Verisign, Inc.</organization> <address> <postal/> <email>dmcpherson@verisign.com</email> </address> </contact> <contact fullname="Burjiz Pithawala"> <organization>Individual</organization> <address> <postal/> <email>burjizp@gmail.com</email> </address> </contact> <contact fullname="Andy Karch"> <organization>Cisco Systems</organization> <address> <postal> <street>170 West Tasman Drive</street> <city>San Jose</city> <region>CA</region> <code>95134</code> <country>United States of America</country> </postal> <email>akarch@cisco.com</email> </address> </contact> </section> </back> </rfc>