A method for matching message strategy and network device

By combining ACL rule range segments and utilizing the subtraction borrow rule and XOR algorithm, the problem of low matching efficiency of ACL rule ranges in existing technologies is solved, achieving a more efficient matching process and reducing computational resource consumption.

CN115580570BActive Publication Date: 2024-11-12新华三技术有限公司合肥分公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211158906.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-22
Publication Date
2024-11-12
Estimated Expiration
2042-09-22

AI Technical Summary

Technical Problem

Existing technologies suffer from low efficiency and wasted computational resources in ACL rule range matching, especially when TCAM chip capacity is limited and software acceleration instructions are used. It is necessary to match key values ​​with multiple range segments one by one, resulting in excessive time and wasted resources.

Method used

By combining multiple first-range segments into a second-range segment, and using the subtraction borrow rule and XOR algorithm, the key value is matched with the second-range segment, avoiding one-to-one matching and improving the efficiency of ACL rule range matching.

Benefits of technology

It effectively improves the efficiency of ACL rule range matching, reduces computation time and resource consumption, and the effect is more significant when the processor has strong processing power.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115580570B_ABST
    Figure CN115580570B_ABST
Patent Text Reader

Abstract

This specification provides a method and network device for matching message policies, the method comprising: obtaining a first range segment corresponding to each ACL in a database, combining several first range segments into a second range segment, matching the second range segment using a key value carried by a message to be matched, determining a target first range segment corresponding to the key value according to the matching result, obtaining a policy corresponding to the target first range segment and assigning it to the message to be matched. By this method, the efficiency of ACL rule range matching can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of communication technology, and in particular to a method and network device for matching message policies. Background Art

[0002] Common search models are mostly exact matches: each piece of data in the search database is an exact value, and the search key is also an exact value. If the key is exactly equal to the key of a piece of data in the database, the search result is considered to be found.

[0003] Correspondingly, there is also range matching, where the key of each record in the database is a range. If an exact value is entered and it falls within the key range of a certain data, the result is considered to be found. Typical examples of this are the FIB (forward information base) search and ACL (access control list) search models in the routing switching field.

[0004] ACL search is more technically difficult, and users can specify ACL rules at will. For example, for TCP / UDP port numbers, users can specify the port number range of rule 1 [100,150], the port number range of rule 2 [130,200], and the port number range of rule 3 [210,240]; if the port number of a message is 140, it will hit both rule 1 and rule 2. Summary of the invention

[0005] The embodiments of the present disclosure provide a method for matching message policies and a network device, through which the efficiency of ACL rule range matching can be improved.

[0006] The present disclosure provides a method for matching a message policy, the method comprising:

[0007] Obtain the first range segment corresponding to each ACL in the database;

[0008] Combining a plurality of first range segments into a second range segment;

[0009] Use the Key value carried in the message to be matched to match the second range segment, and determine the target first range segment corresponding to the Key value according to the matching result;

[0010] A policy corresponding to the target first range segment is obtained and assigned to the message to be matched.

[0011] The method further includes: combining a plurality of first range segments into a second range segment according to the processing capability of its own processor.

[0012] The first range segment and the second range segment include a low value and a high value respectively, and combining a plurality of first range segments into a second range segment includes:

[0013] Subtract one from each low value in the first range segment, and add a 1-bit carry bit in front to form the low value of the second range segment;

[0014] Add a 1-bit carry bit in front of each high value in several first range segments to combine them into the high value of the second range segment.

[0015] The size of the second range segment includes: 32 bits, 64 bits, 128 bits, or 256 bits.

[0016] The method of matching the second range segment with the Key value carried by the message to be matched, and determining the target first range segment corresponding to the Key value according to the matching result, includes:

[0017] Set the carry position of the Key value to zero, repeat the Key value and concatenate it to the same size as the second range segment;

[0018] The first value is obtained by using the difference between the low value of the second range segment and the concatenated Key value;

[0019] The second value is obtained by using the difference between the high value of the second range segment and the concatenated Key value;

[0020] The carry bit is obtained from the first value and the second value, and a matching target first range segment is obtained through an XOR algorithm.

[0021] It can be seen from the above method that by combining multiple first range segments corresponding to the ACL into a second range segment, the second range segment is used to match the Key value, thereby avoiding matching the Key with each first range segment one by one, thereby effectively improving the efficiency of ACL rule range matching.

[0022] The present disclosure also provides a network device, the network device comprising:

[0023] An acquisition module, used for acquiring a first range segment corresponding to each ACL in a database;

[0024] A first processing module, used for combining a plurality of first range segments into a second range segment;

[0025] A matching module, used to match the second range segment with the Key value carried by the message to be matched, and determine the target first range segment corresponding to the Key value according to the matching result;

[0026] The acquisition module is further used to acquire a policy corresponding to the target first range segment and assign it to the message to be matched.

[0027] Optionally, the first processing module is specifically configured to combine a plurality of first range segments into a second range segment according to the processing capability of its own processor.

[0028] Optionally, the first range segment and the second range segment include a low value and a high value respectively;

[0029] The first processing module is specifically used to reduce each low value in a plurality of first range segments by one, and add a carry bit of 1 bit in front to combine them into a low value of a second range segment;

[0030] Add a 1-bit carry bit in front of each high value in several first range segments to combine them into the high value of the second range segment.

[0031] Optionally, the size of the second range segment includes: 32 bits or 64 bits or 128 bits or 256 bits.

[0032] The matching module is specifically used to set the carry position of the Key value to zero, repeat the Key value and splice it to be the same size as the second range segment;

[0033] The first value is obtained by using the difference between the low value of the second range segment and the concatenated Key value;

[0034] The second value is obtained by using the difference between the high value of the second range segment and the concatenated Key value;

[0035] The carry bit is obtained from the first value and the second value, and a matching target first range segment is obtained through an XOR algorithm. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles of the specification.

[0037] Figure 1 A flowchart of a method for matching message policies provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0038] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0039] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0040] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0041] Currently, range matching can be performed through TCAM chips. For example, a range can be converted into multiple prefixes. As long as the key hits any prefix, the result is considered to be found.

[0042] Taking the above range [100,150] as an example, it needs to be expanded into 7 segments, as shown in Table 1:

[0043]

[0044]

[0045] Table 1

[0046] However, the capacity of TCAM chips is limited, and the way of expanding a rule into multiple prefixes has a great impact on the chip capacity. Taking the port number as an example, in the worst case, a port number range needs to be expanded into 31 prefixes; if the source port and destination port are both ranges, a rule needs to be expanded into 31×31 prefixes, resulting in a sharp reduction in the number of ACL rules with ranges that the TCAM chip can accommodate.

[0047] In another example, software or hardware acceleration instructions (NP / FPGA) are used to implement range matching, and a database is separately constructed for the specified range segments of all ACL rules (the implementation method can be a sequential table or interval tree), as shown in Table 2:

[0048] Range value Encoding ID [100,150] 001 [130,200] 002 [210,240] 003

[0049] Table 2

[0050] When forwarding a message, the port number value of each message is used to individually check the range database to determine whether the message is within a certain range.

[0051] Then, when implementing range matching based on software or hardware acceleration instructions (NP / FPGA), the Key value needs to be matched with each range value to determine whether it belongs to the range. For example, to determine whether an exact value K is within a range [Low, Hi], K needs to be compared with the boundaries of the range Low and Hi. If K>=Low and K<=Hi, then K is considered to match the range [Low,Hi]. As a result, the Key value needs to be matched in each range segment, which results in a long matching time and a waste of computing resources.

[0052] In order to solve the above technical problems, the present disclosure provides a method for matching message policies, such as Figure 1 As shown, the method includes:

[0053] S101 obtains a first range segment corresponding to each ACL in a database;

[0054] S102 combines a plurality of first range segments into a second range segment;

[0055] S103 uses the Key value carried in the message to be matched to match the second range segment, and determines the target first range segment corresponding to the Key value according to the matching result;

[0056] S104 obtains a policy corresponding to the target first range segment and assigns it to the message to be matched.

[0057] In this embodiment, the database stores the first range segments corresponding to each ACL rule, as shown in Table 2, including the first range segments: [100, 150], [130, 200], [210, 240]. The network device can obtain each first range segment from the database by calling a function.

[0058] In step S102, the network device can combine several first range segments into a second range segment according to the processing capability of the processor or according to the conventional configuration. Generally, the stronger the processing capability of the processor, the larger the combined second range segment. Usually, the size of the second range segment can be controlled to be one of 32 bits, 64 bits, 128 bits, and 256 bits (there is no limitation here, and the use of other bit sizes does not affect the implementation of this solution, and they all fall within the scope of protection of this solution).

[0059] In this embodiment, after the network device determines the size of the second range segment, it obtains several first range segments according to the size of the second range segment. Taking the second range segment as 32 bits as an example, four 7-bit wide first range segments [Low1, Hi1][Low2, Hi2][Low3, Hi3][Low4, Hi4] can be combined into a 32-bit wide second range segment.

[0060] When combining the second range segment, each low value in several first range segments can be reduced by one, and a 1-bit carry bit can be added in front to combine into the low value of the second range segment, and each high value in several first range segments can be added with a 1-bit carry bit in front to combine into the high value of the second range segment.

[0061] The following is an example with specific numerical values: 4 ranges [2,127][3,63][72,100][103,111].

[0062] Subtract 1 from the low bit in the 4-end range, i.e., 2-1, 3-1, 72-1, 103-1, and add the carry bit in front to get the low value of the 32-bit second range segment 0x8182C7E6 (where 81 corresponds to 2, 82 corresponds to 3, C7 corresponds to 72, and E6 corresponds to 103). Add the carry bit in front of the high bit in the 4-end range to get the high value of the 32-bit second range segment 0xFFBFE4EF (where FF corresponds to 127, BF corresponds to 63, E4 corresponds to 100, and EF corresponds to 111).

[0063] In step S103, the Key value to be matched is obtained, and the second range segment is used to match the Key value. In order to achieve matching, the size of the Key value needs to be the same as the size of the second range segment. Taking the second range segment as 32 bits as an example, the carry position of the Key value is set to zero, and the key value is repeated 4 times to splice it into a 32-bit Key value.

[0064] Taking the above specific numerical values ​​as an example, if the Key value is 16, set the carry position to zero and repeat 4 times, the resulting 32-bit Key value is 0x10101010.

[0065] In step S103, the first value is obtained by using the difference between the low value of the second range segment and the spliced ​​Key value, the second value is obtained by using the difference between the high value of the second range segment and the spliced ​​Key value, the carry bit is obtained from the first value and the second value, and the matching target first range segment is obtained through the XOR algorithm.

[0066] Taking the above specific values ​​as an example,

[0067] Using the low value-Key value of the second range segment:

[0068] (Low-K)&0x80808080=0x00008080, where the first 00 indicates that the carry bit is not flipped, that is, the K value is greater than 2; the second 00 indicates that the carry bit is not flipped, that is, the K value is greater than 3; the first 80 indicates that the carry bit is flipped, that is, the K value is less than 72; the second 80 indicates that the carry bit is flipped, that is, the K value is less than 103.

[0069] Using the high value of the second range segment - the Key value:

[0070] (High-K)&0x80808080=0x80808080, where the first 80 indicates a carry bit flip, that is, the K value is less than 127; the second 80 indicates a carry bit flip, that is, the K value is less than 63; the third 80 indicates a carry bit flip, that is, the K value is less than 100; the third 80 indicates a carry bit flip, that is, the K value is less than 111.

[0071] Using the XOR algorithm with 0x00008080 and 0x80808080, we get 0x80800000, which means that the Key value 16 matches the first range of the first two targets.

[0072] The ACL policy corresponding to the target first range segment is obtained and assigned to the message to be matched, thereby achieving policy matching of the message.

[0073] It can be seen from the above embodiments that by utilizing the borrow rule of subtraction and inserting an extra borrow bit into the range boundary value, an accurate value and simultaneous comparison of multiple ranges can be achieved, thereby improving search efficiency.

[0074] At the same time, in practical applications, if the range value is smaller, the data width that can support one operation is larger, and the effect is more obvious. For example, when the CPU or programmable hardware platform supports 256-bit bit width operation, 32 segments of 7-bit bit width ranges can be matched simultaneously: Assuming there are 320 segments of 7-bit bit width ranges, the range database is first converted into 10 Low values ​​and 10 High values ​​according to the above method. When matching an accurate k value, 20 large number comparisons + 10 XOR operations can complete the matching of all 320 segments.

[0075] The embodiment of the present disclosure further provides a network device, which may be a routing switching device, and includes:

[0076] An acquisition module, used for acquiring a first range segment corresponding to each ACL in a database;

[0077] A first processing module, used for combining a plurality of first range segments into a second range segment;

[0078] A matching module, used to match the second range segment with the Key value carried by the message to be matched, and determine the target first range segment corresponding to the Key value according to the matching result;

[0079] The acquisition module is further used to acquire a policy corresponding to the target first range segment and assign it to the message to be matched.

[0080] The first processing module is specifically configured to combine a plurality of first range segments into a second range segment according to the processing capability of its own processor.

[0081] Wherein, the first range segment and the second range segment include a low value and a high value respectively;

[0082] The first processing module is specifically used to reduce each low value in a plurality of first range segments by one, and add a carry bit of 1 bit in front to combine them into a low value of a second range segment;

[0083] Add a 1-bit carry bit in front of each high value in several first range segments to combine them into the high value of the second range segment.

[0084] The size of the second range segment includes: 32 bits, 64 bits, 128 bits, or 256 bits.

[0085] The matching module is specifically used to set the carry position of the Key value to zero, repeat the Key value and splice it to be the same size as the second range segment;

[0086] The first value is obtained by using the difference between the low value of the second range segment and the concatenated Key value;

[0087] The second value is obtained by using the difference between the high value of the second range segment and the concatenated Key value;

[0088] The carry bit is obtained from the first value and the second value, and a matching target first range segment is obtained through an XOR algorithm.

[0089] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0090] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention claimed herein. The specification is intended to cover any variations, uses or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not claimed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.

[0091] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

[0092] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.

Claims

1. A method for matching message strategies, characterized in that: The method comprises: Obtain the first range segment corresponding to each ACL in the database; Combining a plurality of first range segments into a second range segment; Use the Key value carried in the message to be matched to match the second range segment, and determine the target first range segment corresponding to the Key value according to the matching result; Obtain a policy corresponding to the target first range segment and assign it to the message to be matched; The first range segment and the second range segment include a low value and a high value respectively, and combining a plurality of first range segments into a second range segment includes: Subtract one from each low value in the first range segment, and add a 1-bit carry bit in front to form the low value of the second range segment; Add a 1-bit carry bit in front of each high value in the first range segment to combine them into the high value of the second range segment; The method of matching the second range segment with the Key value carried by the message to be matched, and determining the target first range segment corresponding to the Key value according to the matching result, includes: Set the carry position of the Key value to zero, repeat the Key value and concatenate it to the same size as the second range segment; The first value is obtained by using the difference between the low value of the second range segment and the concatenated Key value; The second value is obtained by using the difference between the high value of the second range segment and the concatenated Key value; The carry bit is obtained from the first value and the second value, and a matching target first range segment is obtained through an XOR algorithm.

2. The method according to claim 1, characterized in that: The method further comprises: According to the processing capability of its own processor, several first range segments are combined into one second range segment.

3. The method according to claim 1, characterized in that The size of the second range segment includes: 32 bits, 64 bits, 128 bits, or 256 bits.

4. A network device, characterized in that: The network equipment includes: An acquisition module, used for acquiring a first range segment corresponding to each ACL in a database; A first processing module, used for combining a plurality of first range segments into a second range segment; A matching module, used to match the second range segment with the Key value carried by the message to be matched, and determine the target first range segment corresponding to the Key value according to the matching result; The acquisition module is further used to acquire a policy corresponding to the target first range segment and assign it to the message to be matched; Wherein, the first range segment and the second range segment include a low value and a high value respectively; The first processing module is specifically used to reduce each low value in a plurality of first range segments by one, and add a carry bit of 1 bit in front to combine them into a low value of a second range segment; Add a 1-bit carry bit in front of each high value in the first range segment to combine them into the high value of the second range segment; The matching module is specifically used to set the carry position of the Key value to zero, repeat the Key value and splice it to be the same size as the second range segment; The first value is obtained by using the difference between the low value of the second range segment and the concatenated Key value; The second value is obtained by using the difference between the high value of the second range segment and the concatenated Key value; The carry bit is obtained from the first value and the second value, and a matching target first range segment is obtained through an XOR algorithm.

5. The network device according to claim 4, characterized in that: The first processing module is specifically configured to combine a plurality of first range segments into a second range segment according to the processing capability of its own processor.

6. The network device according to claim 4, characterized in that: The size of the second range segment includes: 32 bits, 64 bits, 128 bits, or 256 bits.