A method, apparatus, program product, and network device for space management of routing tables

By determining the insertion position of the TCAM routing table based on the length of the mask to be inserted, the problem of insufficient space management units in the prior art is solved, and efficient routing table operation and space utilization are achieved.

CN119484378BActive Publication Date: 2025-12-30TP-LINK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411676818.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-12-30
Estimated Expiration
2044-11-21

AI Technical Summary

Technical Problem

In existing technologies, when the space management unit corresponding to the mask length of the routing table entry to be inserted is insufficient, a large number of table entries need to be moved to obtain free space, resulting in low efficiency of routing table operations.

Method used

Based on the length of the mask to be inserted, determine the space management unit to be inserted in the routing table for the routing table entry to be inserted. If there is no inserted routing table entry with a mask length greater than the length of the mask to be inserted, then the free space management unit with the smallest index is determined as the space management unit to be inserted. If there is an inserted routing table entry with a mask length greater than the length of the mask to be inserted, then the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index is determined as the space management unit to be inserted, and it is updated as the routing table entry to be inserted. Repeat this process until there is no inserted routing table entry with a length greater than the length of the mask to be inserted.

Benefits of technology

When inserting a routing table entry, each mask length that is larger than the mask length to be inserted only needs to move one routing table entry, which improves the operational efficiency of the routing table. Furthermore, the inserted space management units correspond one-to-one with the inserted routing table entries and are closely arranged, which improves space utilization and query speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119484378B_ABST
    Figure CN119484378B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of data communication, and particularly relates to a space management method and device of a routing table, a computer program product and a network device. The method comprises determining a to-be-inserted space management unit of a to-be-inserted routing table item in a routing table based on a to-be-inserted mask length, wherein the to-be-inserted mask length is a mask length of the to-be-inserted routing table item, the space management unit of the routing table comprises each continuous inserted space management unit and / or each continuous idle space management unit, and the inserted space management unit is in one-to-one correspondence with an inserted routing table item; and the to-be-inserted routing table item is inserted into the to-be-inserted space management unit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of data communication technology, and in particular relates to a method, apparatus, computer program product and network device for space management of routing tables. Background Technology

[0002] With the rapid development of the Internet and the continuous expansion of network scale, network devices such as network switches and network equipment need to process increasingly more routing information. The storage and management of routing information is one of the key factors in network device performance. Traditional routing tables are usually implemented using data structures such as hash tables or binary search trees, but these structures have performance bottlenecks when processing large-scale routing tables, especially in scenarios that require fast lookup and update of routing information.

[0003] Ternary Content Addressable Memory (TCAM) is a special type of memory that enables lookup operations with constant time complexity, and is therefore widely used in the routing table implementation of high-speed network devices. However, existing TCAM routing table space management methods require a large number of table entry movements to obtain free space when the space management unit corresponding to the mask length of the routing table entry to be inserted is insufficient, resulting in low operational efficiency of the routing table. Summary of the Invention

[0004] In view of this, embodiments of this application provide a method, apparatus, computer program product, and network device for space management of routing tables to solve the problem of low operational efficiency of routing tables in the prior art.

[0005] A first aspect of this application provides a method for managing the space of a routing table, which may include:

[0006] Based on the length of the mask to be inserted, the space management unit to be inserted in the routing table is determined; wherein, the length of the mask to be inserted is the mask length of the routing table entry to be inserted, and the space management unit of the routing table includes each consecutive inserted space management unit and / or each consecutive free space management unit, and the inserted space management unit corresponds one-to-one with the inserted routing table entry;

[0007] Insert the routing table entry to be inserted into the space management unit to be inserted;

[0008] The space management unit for determining the insertion space of the routing table entry in the routing table based on the length of the mask to be inserted includes:

[0009] If there is no inserted routing table entry with a mask length greater than the length of the mask to be inserted, then the free space management unit with the smallest index is determined as the space management unit to be inserted.

[0010] If there exists an inserted routing table entry with a mask length greater than the length of the mask to be inserted, then the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index is determined as the space management unit to be inserted, and the inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index is determined as the updated routing table entry to be inserted. Then, the process returns to the step of determining the space management unit to be inserted in the routing table based on the length of the mask to be inserted and its subsequent steps, until there are no inserted routing table entries with a mask length greater than the length of the mask to be inserted.

[0011] A second aspect of this application provides a space management device for routing tables, which may include:

[0012] The determination module is used to determine the space management unit to be inserted in the routing table for the routing table entry based on the length of the mask to be inserted; wherein the length of the mask to be inserted is the mask length of the routing table entry to be inserted, and the space management unit of the routing table includes each consecutive inserted space management unit and / or each consecutive free space management unit, and the inserted space management unit corresponds one-to-one with the inserted routing table entry;

[0013] An insertion module is used to insert the routing table entry to be inserted into the space management unit to be inserted.

[0014] The determining module includes:

[0015] The first determining submodule is used to determine the free space management unit with the smallest index as the space management unit to be inserted if there is no inserted routing table entry with a mask length greater than the mask length to be inserted.

[0016] The second determining submodule is used to determine the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index as the space management unit to be inserted if there is an inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index. It also determines the inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index as the updated routing table entry to be inserted. Then, it returns to the step of determining the space management unit to be inserted in the routing table based on the length of the mask to be inserted and its subsequent steps until there is no inserted routing table entry with a mask length greater than the length of the mask to be inserted.

[0017] A third aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the above-described routing table space management methods.

[0018] A fourth aspect of this application provides a network device including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the network device implements the steps of any of the above-described routing table space management methods.

[0019] A fifth aspect of this application provides a computer program product, including a computer program that, when run, causes any of the above-described routing table space management methods to be executed.

[0020] The beneficial effects of this application embodiment compared with the prior art are as follows: This application embodiment determines the space management unit to be inserted in the routing table for the routing table entry based on the length of the mask to be inserted; wherein, the length of the mask to be inserted is the mask length of the routing table entry to be inserted, and the space management unit of the routing table includes each consecutive inserted space management unit and / or each consecutive free space management unit, and the inserted space management unit corresponds one-to-one with the inserted routing table entry; the routing table entry to be inserted is inserted into the space management unit to be inserted; the step of determining the space management unit to be inserted in the routing table based on the length of the mask to be inserted includes: if there is no inserted space management unit with a mask length greater than the length of the mask to be inserted, the space management unit to be inserted is determined. If a routing table entry is inserted, the free space management unit with the smallest index is determined as the space management unit to be inserted. If there is an already inserted routing table entry with a mask length greater than the length of the mask to be inserted, the already inserted space management unit corresponding to the already inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index is determined as the space management unit to be inserted, and the already inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index is determined as the updated routing table entry to be inserted. Then, the process returns to the step of determining the space management unit to be inserted in the routing table based on the length of the mask to be inserted and its subsequent steps, until there is no already inserted routing table entry with a mask length greater than the length of the mask to be inserted. In this embodiment of the application, when inserting a routing table entry, each mask length larger than the mask to be inserted only needs to move one routing table entry, which greatly improves the operational efficiency of the routing table. Furthermore, the inserted space management units in the routing table are continuous spaces, and the inserted space management units correspond one-to-one with the inserted routing table entries. As a result, the inserted routing table entries in the routing table can be arranged tightly and continuously, which helps to improve the space utilization of the routing table. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is a first schematic diagram of a routing table in an embodiment of this application;

[0023] Figure 2 This is a second schematic diagram of a routing table in an embodiment of this application;

[0024] Figure 3 This is a flowchart of one embodiment of a space management method for a routing table in this application.

[0025] Figure 4 This is a third schematic diagram of a routing table in an embodiment of this application;

[0026] Figure 5 This is a fourth schematic diagram of a routing table in an embodiment of this application;

[0027] Figure 6 This is a fifth schematic diagram of a routing table in an embodiment of this application;

[0028] Figure 7 This is a sixth schematic diagram of a routing table in an embodiment of this application;

[0029] Figure 8 This is a seventh schematic diagram of a routing table in an embodiment of this application;

[0030] Figure 9 This is the eighth schematic diagram of a routing table in an embodiment of this application;

[0031] Figure 10 This is a ninth schematic diagram of a routing table in an embodiment of this application;

[0032] Figure 11 This is a tenth schematic diagram of a routing table in an embodiment of this application;

[0033] Figure 12 This is the eleventh schematic diagram of a routing table in an embodiment of this application;

[0034] Figure 13 This is the twelfth schematic diagram of a routing table in an embodiment of this application;

[0035] Figure 14 This is the thirteenth schematic diagram of a routing table in an embodiment of this application;

[0036] Figure 15This is the fourteenth schematic diagram of a routing table in an embodiment of this application;

[0037] Figure 16 This is the fifteenth schematic diagram of a routing table in an embodiment of this application;

[0038] Figure 17 This is a flowchart illustrating one embodiment of deleting a routing table entry in this application.

[0039] Figure 18 This is the sixteenth schematic diagram of a routing table in an embodiment of this application;

[0040] Figure 19 This is the seventeenth schematic diagram of a routing table in an embodiment of this application;

[0041] Figure 20 This is the eighteenth schematic diagram of a routing table in an embodiment of this application;

[0042] Figure 21 This is the nineteenth schematic diagram of a routing table in an embodiment of this application;

[0043] Figure 22 This is the twentieth schematic diagram of a routing table in an embodiment of this application;

[0044] Figure 23 This is the twenty-first schematic diagram of a routing table in an embodiment of this application;

[0045] Figure 24 This is the twenty-second schematic diagram of a routing table in an embodiment of this application;

[0046] Figure 25 This is a structural diagram of one embodiment of a space management device for a routing table in this application.

[0047] Figure 26 This is a schematic block diagram of a network device according to an embodiment of this application. Detailed Implementation

[0048] To make the inventive objectives, features, and advantages of this application more apparent and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0049] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0050] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0051] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0052] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [the described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [the described condition or event] is detected," or "in response to detection of [the described condition or event]."

[0053] Furthermore, in the description of this application, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0054] With the rapid development of the Internet and the continuous expansion of network scale, network devices such as network switches and network equipment need to process increasingly more routing information. The storage and management of routing information is one of the key factors in network device performance. Traditional routing tables are usually implemented using data structures such as hash tables or binary search trees, but these structures have performance bottlenecks when processing large-scale routing tables, especially in scenarios that require fast lookup and update of routing information.

[0055] Ternary Content Addressable Memory (TCAM) is a special type of memory that enables lookup operations with constant time complexity, and is therefore widely used in the routing table implementation of high-speed network devices. However, existing TCAM routing table space management methods require a large number of table entry movements to obtain free space when the space management unit corresponding to the mask length of the routing table entry to be inserted is insufficient, resulting in low operational efficiency of the routing table.

[0056] In view of this, embodiments of this application provide a method, apparatus, computer program product, and network device for space management of routing tables to solve the problem of low operational efficiency of routing tables in the prior art.

[0057] It should be noted that the subject of the method in this application is a network device, specifically a switch or a router.

[0058] The routing table in this embodiment can include various space management units, with the index of each space management unit increasing from smallest to largest. Specifically, each space management unit can be divided into consecutive inserted space management units and consecutive free space management units. The inserted space management units cache inserted routing table entries, and each inserted space management unit stores one inserted routing table entry, meaning there is a one-to-one correspondence between inserted space management units and inserted routing table entries. The free space management units do not store any inserted routing table entries; they are idle and unoccupied space management units. Therefore, the inserted and free space management units in the routing table of this embodiment are tightly packed and complete, without any overlapping distribution. When a new routing table entry needs to be inserted, there will be no situation where there is free space but no new routing table entry can be inserted, thus improving the space utilization of the routing table.

[0059] As an example, the routing table in this application embodiment can be as follows: Figure 1 As shown, the space management units corresponding to indices 0 to N are N+1 inserted space management units, and the space management units corresponding to indices N+1 to M are (M-(N+1))+1 free space management units. Each of the N+1 inserted space management units stores one inserted routing table entry. In this example, the inserted space management unit with index 0 stores inserted routing table entry 3, the inserted space management unit with index 1 stores inserted routing table entry 4, the inserted space management unit with index 2 stores inserted routing table entry 1, ..., and the inserted space management unit with index N stores inserted routing table entry 20.

[0060] In this embodiment, the routing table index increases from smallest to largest, and the mask length of the stored inserted routing table entries also increases from smallest to largest. For example, please refer to... Figure 2The routing table indices increase from smallest to largest, and the mask length of the stored inserted routing table entries also increases from smallest to largest. Specifically, the inserted space management units corresponding to indices 0 to 3 store inserted routing table entries with a mask length of 0; the inserted space management units corresponding to indices 4 to 6 store inserted routing table entries with a mask length of 1; the inserted space management units corresponding to indices 7 to 11 store inserted routing table entries with a mask length of 2; the inserted space management units corresponding to indices 12 to 13 store inserted routing table entries with a mask length of 3, and so on.

[0061] When querying routing table entries, the query can start from the inserted routing table entry with the larger index and move to the inserted routing table entry with the smaller index. The query process can end when the first query is successful, and the inserted routing table entry with the required mask length can be obtained without traversing and querying each inserted routing table entry, thereby improving query speed.

[0062] The following section will provide a detailed description of an embodiment of a routing table space management method based on the process of inserting and deleting routing table entries.

[0063] Please see Figure 3 An embodiment of a routing table space management method in this application may include steps S301 to S304:

[0064] Step S301: Based on the length of the mask to be inserted, determine the space management unit to be inserted in the routing table for the routing table entry to be inserted.

[0065] In this embodiment, the routing table entry to be inserted into the routing table can be referred to as the routing table entry to be inserted, and the mask length of the routing table entry to be inserted can be referred to as the insertion mask length. Before inserting the routing table entry to be inserted into the routing table, the insertion mask length can be calculated, and the position in the routing table to be inserted can be determined based on the insertion mask length.

[0066] Here, the position in the routing table where the entry to be inserted should be placed can be referred to as the space management unit to be inserted.

[0067] If there is no already inserted routing table entry with a mask length greater than the length of the mask to be inserted, then the free space management unit with the smallest index can be determined as the space management unit to be inserted.

[0068] For example, please see Figure 4The mask to be inserted has a length of 26, but the routing table only contains inserted routing table entries with a mask length of 16 and 24. That is, there are no inserted routing table entries with a mask length greater than 26. In this case, the free space management unit with the smallest index can be determined as the space management unit to be inserted, that is, the free space management unit with an index of 7 can be determined as the space management unit to be inserted.

[0069] For example, if there are no inserted routing entries in the routing table, meaning the first routing entry to be inserted is the first one that needs to be added, then the free space management unit with the smallest index can be identified as the space management unit to be inserted. In this example, since there are no inserted routing entries in the routing table, the free space management unit with the smallest index is also the space management unit with the smallest index (the space management unit corresponding to index 0). Figure 5 As shown.

[0070] If there is an already inserted routing table entry with a mask length greater than the length of the mask to be inserted, then the already inserted space management unit corresponding to the already inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index can be determined as the space management unit to be inserted.

[0071] For example, if the mask to be inserted is 16 characters long, then the routing table already contains an inserted routing table entry with a mask length of 16, an inserted routing table entry with a mask length of 24, and an inserted routing table entry with a mask length of 26. Figure 6 As shown; the inserted routing table entries with a mask length greater than 16 are the inserted routing table entries with a mask length of 24 and the inserted routing table entries with a mask length of 26; among them, the inserted space management unit corresponding to the inserted routing table entry with the smallest index is the inserted space management unit with an index of 4. Therefore, the inserted space management unit with an index of 4 can be determined as the space management unit to be inserted.

[0072] Step S302: Insert the routing table entry to be inserted into the space management unit to be inserted.

[0073] In this embodiment, the routing table entry to be inserted can be inserted into the space management unit to be inserted. Then, the previously inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index can be determined as the updated routing table entry to be inserted. This process can be repeated to insert the updated routing table entry until there are no previously inserted routing table entries with a mask length greater than the length of the mask to be inserted in the routing table. If there are no previously inserted routing table entries with a mask length greater than the length of the mask to be inserted, the free space management unit with the smallest index can be determined as the space management unit to be inserted, and the routing table entry to be inserted can be inserted into the space management unit. The insertion process can then be terminated.

[0074] For example, please see Figure 4 The free space management unit with index 7 is identified as the space management unit to be inserted. After inserting the routing table entry to be inserted into the free space management unit with index 7, if there is no inserted routing table entry in the routing table with a mask length greater than the mask length to be inserted, the insertion process can be ended.

[0075] For example, please see Figure 5 Before inserting the routing table entry to be inserted, there are no existing routing table entries in the routing table, that is, there are no existing routing table entries with a mask length greater than the mask length to be inserted. At this time, the routing table entry to be inserted can be directly inserted into the free space management unit with index 0, and the insertion process ends.

[0076] If, after updating the routing table entry to be inserted, there are still inserted routing table entries in the routing table with a mask length greater than the mask length to be inserted, then the space management unit to be inserted needs to be re-determined according to the above process and the corresponding insertion procedure needs to be performed.

[0077] For example, please see Figure 6 If the inserted space management unit with index 4 is identified as the space management unit to be inserted, then the routing table entry to be inserted can be inserted into the inserted space management unit with index 4. Afterwards, the routing table entry to be inserted can be updated to the original inserted routing table entry with index 4. At this point, the mask length to be inserted is 24. Since there are still inserted routing table entries with a mask length greater than 24 in the routing table (i.e., an inserted routing table entry with a mask length of 26), the inserted space management unit corresponding to the inserted routing table entry with a mask length of 26 and the smallest index (i.e., the inserted space management unit with index 7) can be selected. The first empty space management unit (OOM) with index 4 is designated as the updated OOM to be inserted, and the existing OOM entry with index 4 is inserted into the OOM entry with index 7. Then, the OOM entry can be updated to the existing OOM entry with index 7. Since there are no OOM entries with a mask length greater than 26, the OOM entry with the smallest index (i.e., the OOM entry with index 12) is designated as the updated OOM to be inserted. Then, the OOM entry with index 7 is inserted into the OOM entry with index 12, and the process ends.

[0078] For example, please see Figure 6The routing table entry to be inserted is inserted into the already inserted space management unit with index 7. Then, the routing table entry to be inserted can be updated to the original already inserted routing table entry with index 7, and the mask length to be inserted is updated to 26. At this time, since there is no already inserted routing table entry with a mask length greater than 26 in the routing table, the free space management unit with the smallest index can be determined as the updated space management unit to be inserted, and the updated routing table entry to be inserted can be inserted into the free space management unit with index 12. After that, the process can end.

[0079] The above process continues until the routing table entry to be inserted is inserted into the free space management unit with the smallest index. This process will be explained below with a specific example.

[0080] In a specific example, please refer to Figure 7 If the mask to be inserted has a length of 16, and there are already inserted routing entries in the routing table with a mask length greater than 16, then the inserted space management unit corresponding to the inserted routing entry with a mask length greater than the mask to be inserted and the smallest index can be identified as the space management unit to be inserted. That is, the inserted space management unit with an index of 4 and a mask length of 24 can be identified as the space management unit to be inserted. Then, the routing entry to be inserted can be inserted into the space management unit to be inserted.

[0081] After inserting the routing table entry to be inserted into the space management unit, it can be referred to as inserted routing table entry 13, such as... Figure 8 As shown, the next step is to update the routing table entry to be inserted to the already inserted routing table entry 5. At this point, there are already inserted routing table entries with a mask length greater than 24 in the routing table. Therefore, the already inserted routing table entry 5 can be inserted into the already inserted space management unit corresponding to the already inserted routing table entry with a mask length greater than 24 and the smallest index. That is, the already inserted routing table entry 5 can be inserted into the already inserted space management unit with index 7 and mask length 26. Next, the next step is to update the routing table entry to be inserted to the already inserted routing table entry 8, and update the mask length to 26. At this point, there are no already inserted routing table entries with a mask length greater than 26 in the routing table. Therefore, the free space management unit with the smallest index (i.e., the free space management unit with index 12) can be determined as the space management unit to be inserted, and the already inserted routing table entry 8 can be inserted into the free space management unit with index 12.

[0082] After that, you can end the process and get the following result: Figure 10 The routing table shown.

[0083] As can be seen, when inserting a routing table entry, each mask length that is larger than the mask length to be inserted only requires moving one routing table entry, with a time complexity of O(1). This does not lead to a decrease in operational efficiency as the number of inserted routing table entries increases, which helps to maintain the high-efficiency operation performance of the routing table.

[0084] For example, in the example above, when inserting a routing table entry with a mask length of 16, the existing routing table entries with a mask length greater than 16 are the existing routing table entries with a mask length of 24 and the existing routing table entries with a mask length of 26. During the insertion process, only one existing routing table entry with a mask length of 24 and one existing routing table entry with a mask length of 26 need to be moved.

[0085] In this embodiment of the application, the index of the start position and the index of the end position of each mask length inserted into the routing table can also be recorded. In addition, the index of the next free space management unit (i.e. the free space management unit with the smallest index) can also be recorded to manage the routing table.

[0086] In one specific implementation of this application, the indices of the start positions of each mask-length inserted routing table entry in the routing table can be recorded in the array `lpm_start`, and the indices of the end positions of each mask-length inserted routing table entry in the routing table can be recorded in the array `lpm_end`. The index of the start position of an inserted routing table entry with a mask length of `m` is an item in the array `lpm_start`, specifically `lpm_start[m]`; the index of the end position of an inserted routing table entry with a mask length of `m` is an item in the array `lpm_end`, specifically `lpm_end[m]`; and the index of the next free space management unit (i.e., the free space management unit with the smallest index) can be denoted as `free`. Here, `lpm_start`, `lpm_end`, and `free` can be referred to as the management information of the routing table.

[0087] The following section will explain the process of inserting a route table entry by combining the specific settings of lpm_start[m], lpm_end[m], and free.

[0088] Before managing the routing table, the management information of the routing table can be initialized. Specifically, during initialization, the values ​​stored in lpm_start and lpm_end can be set to preset illegal values ​​to indicate that there are no inserted routing table entries of any mask length in the routing table. In addition, the index 'free' of the next free space management unit can be set to the minimum value of the index (i.e., 0). The illegal values ​​can be set according to actual needs, and this embodiment does not impose specific limitations on them. Here, the illegal value can be set to -1, and the management information of the initialized routing table can be as follows:

[0089] lpm_start = -1;

[0090] lpm_end = -1;

[0091] free = 0;

[0092] Next, a routing table entry with a mask length of 24 needs to be inserted. Then, lpm_start and lpm_end can be queried to find that lpm_start

[24] = -1 and lpm_end

[24] = -1. Since lpm_start

[24] and lpm_end

[24] store illegal values, it can be determined that there is no inserted routing table entry with a mask length of 24 in the routing table at this time.

[0093] Then, we can iterate through the items in lpm_start

[24] after lpm_start and lpm_end

[24] after lpm_end. We can find that the items after lpm_start

[24] and lpm_end

[24] are all illegal values. Therefore, we can determine that there is no inserted routing table entry with a mask length greater than the mask length to be inserted. Thus, we can determine the free space management unit with the smallest index as the space management unit to be inserted.

[0094] The free space management unit with the smallest index is the next free space management unit, and at this time the value of free is 0. Therefore, the free space management unit with index 0 can be determined as the space management unit to be inserted.

[0095] Afterwards, the routing table entry to be inserted can be inserted into the free space management unit with index 0; and, according to the routing table entry to be inserted, the index lpm_start

[24] of the start position and the index lpm_end

[24] of the inserted routing table entry corresponding to the length of the mask to be inserted can be updated; in addition, since the space management unit with index 0 has already stored the inserted routing table entry after the routing table entry to be inserted is inserted, it is also necessary to increase the next free space management unit by one unit; the management information of the updated part of the routing table can be as follows:

[0096] lpm_start

[24] = 0;

[0097] lpm_end

[24] = 0;

[0098] free = 1;

[0099] After the entry to be inserted into the routing table is inserted, it can be marked as "Inserted Routing Table Entry 1". Then, after inserting the entry to be inserted, the routing table can be configured as follows: Figure 11 As shown, at this time, the space management unit with index 0 stores the inserted routing table entry 1, and lpm_start

[24] and lpm_end

[24] both point to the space management unit with index 0. The next free space management unit, free, points to the space management unit with index 1.

[0100] Afterwards, it is necessary to insert another routing table entry with a mask length of 24. Then, the index of the start position of the inserted routing table entry with a mask length of 24, lpm_start

[24] , and the index of the end position, lpm_end

[24] , can be queried. Then, the items after lpm_start

[24] and lpm_end

[24] can be traversed to determine that there is no inserted routing table entry with a mask length greater than 24 in the routing table. Therefore, the free space management unit with the smallest index can be determined as the space management unit to be inserted. That is, the free space management unit with index 1 pointed to by free can be determined as the space management unit to be inserted.

[0101] Afterwards, the routing table entry to be inserted can be inserted into the space management unit to be inserted, and lpm_start

[24] , lpm_end

[24] and free can be updated. The management information of the updated part of the routing table can be shown below:

[0102] lpm_start

[24] = 1;

[0103] lpm_end

[24] = 0;

[0104] free = 2;

[0105] After the entry to be inserted into the routing table is inserted, it can be recorded as "inserted routing table entry 2". Then, after inserting the entry to be inserted, the routing table can be as follows: Figure 12 As shown, at this time, the space management unit with index 0 stores the inserted routing table entry 1, the space management unit with index 1 stores the inserted routing table entry 2, lpm_start

[24] points to the space management unit with index 1, lpm_end

[24] points to the space management unit with index 0, and the next free space management unit free points to the space management unit with index 2.

[0106] Next, a routing table entry with a mask length of 26 needs to be inserted. At this time, lpm_start

[26] and lpm_end

[26] can be queried to determine that there is no inserted routing table entry with a mask length of 26 in the routing table. Then, the items after lpm_start

[26] and lpm_end

[26] can be traversed to determine that there is no inserted routing table entry with a mask length greater than 26. Therefore, the free space management unit with the smallest index can be determined as the space management unit to be inserted, that is, the free space management unit with index 2 pointed to by free can be determined as the space management unit to be inserted.

[0107] Afterwards, the routing table entry to be inserted can be inserted into the space management unit to be inserted, and lpm_start

[26] , lpm_end

[26] and free can be updated. The management information of the updated part of the routing table can be shown below:

[0108] lpm_start

[24] = 1;

[0109] lpm_end

[24] = 0;

[0110] lpm_start

[26] = 2;

[0111] lpm_end

[26] = 2;

[0112] free = 3.

[0113] After the entry to be inserted into the routing table is inserted, it can be recorded as "inserted routing table entry 3". Then, after inserting the entry to be inserted, the routing table can be as follows: Figure 13 As shown, at this time, the space management unit with index 0 stores the inserted routing table entry 1, the space management unit with index 1 stores the inserted routing table entry 2, the space management unit with index 3 stores the inserted routing table entry 3, lpm_start

[26] and lpm_end

[26] both point to the space management unit with index 2, and the next free space management unit free points to the space management unit with index 3.

[0114] Next, a routing table entry with a mask length of 16 needs to be inserted. At this time, lpm_start

[16] and lpm_end

[16] can be queried to determine that there is no inserted routing table entry with a mask length of 16 in the routing table. Then, the items after lpm_start

[16] and lpm_end

[16] can be traversed to determine that there is an inserted routing table entry with a mask length greater than 16. At this time, the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than 16 and the smallest index can be determined as the space management unit to be inserted. That is, the space management unit pointed to by lpm_end

[24] can be determined as the space management unit to be inserted.

[0115] Afterwards, the routing table entry to be inserted can be inserted into the space management unit to be inserted, and lpm_start

[16] , lpm_end

[16] , lpm_start

[24] and lpm_end

[24] can be updated. The management information of the updated part of the routing table can be shown below:

[0116] lpm_start

[16] = 0;

[0117] lpm_end

[16] = 0;

[0118] lpm_start

[24] = 1;

[0119] lpm_end

[24] = 1;

[0120] lpm_start

[26] = 2;

[0121] lpm_end

[26] = 2;

[0122] free = 3;

[0123] After the entry to be inserted into the routing table is inserted, it can be recorded as the 4th inserted routing table entry. Then, after inserting the entry to be inserted, the routing table can be as follows: Figure 14 As shown, at this time, the space management unit with index 0 stores the inserted routing table entry 4, the space management unit with index 1 stores the inserted routing table entry 2, the space management unit with index 3 stores the inserted routing table entry 3, lpm_start

[16] and lpm_end

[16] both point to the space management unit with index 0, lpm_start

[24] and lpm_end

[24] both point to the space management unit with index 1, lpm_start

[26] and lpm_end

[26] both point to the space management unit with index 2, and the next free space management unit free points to the space management unit with index 3.

[0124] After inserting the inserted routing table entry 4, the inserted routing table entry 1 can be updated to the routing table entry to be inserted, and the mask length to be inserted can be updated to 24. At this time, the items after lpm_start

[24] and lpm_end

[24] can be queried to determine that there is an inserted routing table entry with a mask length greater than 24. The inserted routing table entry 1 can be inserted into the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than 24 and the smallest index. That is, the inserted routing table entry 1 can be inserted into the space management unit pointed to by lpm_end

[26] .

[0125] After inserting the already inserted routing table entry 1 into the space management unit pointed to by lpm_end

[26] , lpm_start

[24] , lpm_end

[24] , lpm_start

[26] and lpm_end

[26] can be updated. The management information of the updated part of the routing table can be seen as follows:

[0126] lpm_start

[16] = 0;

[0127] lpm_end

[16] = 0;

[0128] lpm_start

[24] = 2;

[0129] lpm_end

[24] = 1;

[0130] lpm_start

[26] = -1;

[0131] lpm_end

[26] = -1;

[0132] free = 3;

[0133] Inserting the already inserted route table entry 1 into the route table after the space management unit pointed to by lpm_end

[26] can be done as follows: Figure 15 As shown, lpm_start

[24] points to the space management unit with index 2, lpm_end

[24] points to the space management unit with index 1, and the route table entry 1 has been inserted into the space management unit with index 2.

[0134] Afterwards, the routing table entry to be inserted can be updated to the already inserted routing table entry 3, and the mask length to be inserted can be updated to 26. At this time, the items after lpm_start

[26] and lpm_end

[26] can be queried to determine that there is no already inserted routing table entry with a mask length greater than 26. Therefore, the already inserted routing table entry 3 can be inserted into the free space management unit with the smallest index, that is, the already inserted routing table entry 3 can be inserted into the space management unit pointed to by free.

[0135] After inserting the already inserted routing table entry 3 into the space management unit pointed to by free, lpm_lp_start

[26] , lpm_end

[26] and free can be updated. The management information of the updated part of the routing table can be seen as follows:

[0136] lpm_start

[16] = 0;

[0137] lpm_end

[16] = 0;

[0138] lpm_start

[24] = 2;

[0139] lpm_end

[24] = 1;

[0140] lpm_start

[26] = 3;

[0141] lpm_end

[26] = 3;

[0142] free = 4;

[0143] Inserting the already inserted routing table entry 3 into the routing table after the space management unit pointed to by free can be done as follows: Figure 16 As shown, lpm_start

[26] and lpm_end

[26] both point to the space management unit with index 3, and free points to the space management unit with index 4. The inserted routing table entry 3 has been inserted into the space management unit with index 3. At this point, there are no inserted routing table entries with a mask length greater than 26, so the process of inserting routing table entries can be ended.

[0144] The following section details the process of deleting a routing table entry. For specifics, please refer to [link to relevant documentation]. Figure 17 One embodiment of the process for deleting a routing table entry in this application may include steps S1701 to S1704:

[0145] Step S1701: Based on the length of the mask to be deleted, determine the space management unit to be deleted and the overlay routing table entry in the routing table.

[0146] In the embodiments of this application, the routing table entry that needs to be deleted can be called the routing table entry to be deleted, the mask length of the routing table entry to be deleted can be called the mask length to be deleted, and the inserted space management unit corresponding to the routing table entry to be deleted can be called the space management unit to be deleted.

[0147] In this embodiment of the application, the routing table can be queried to determine the space management unit to be deleted. Specifically, the inserted routing table entries in the routing table can be matched with the routing table entries to be deleted to locate the position of the routing table entries to be deleted in the routing table.

[0148] Here, inserted routing table entries with the same mask length as the mask to be deleted can be identified as the routing table entries to be queried. Each routing table entry to be queried can be matched with the routing table entry to be deleted until a successfully queried routing table entry is obtained.

[0149] For example, if the mask to be deleted has a length of 16, and there are three inserted routing table entries with a mask length of 16 in the routing table, namely inserted routing table entry 1, inserted routing table entry 2, and inserted routing table entry 3, then inserted routing table entry 1, inserted routing table entry 2, and inserted routing table entry 3 can be identified as the respective routing table entries to be queried, and each of the routing table entries to be queried can be matched with the routing table entry to be deleted.

[0150] When querying routing table entries, each routing table entry to be queried can be matched with the routing table entry to be deleted in descending order of the index of the corresponding inserted space management unit.

[0151] Specifically, the query priority of each route entry can be determined based on the index of the inserted space management unit corresponding to each route entry to be queried; wherein, the query priority of the route entry to be queried is positively correlated with the index of the inserted space management unit corresponding to the route entry to be queried.

[0152] For example, if the routing table entries to be queried are inserted routing table entry 3 corresponding to the inserted space management unit with index 5, inserted routing table entry 2 corresponding to the inserted space management unit with index 4, and inserted routing table entry 1 corresponding to the inserted space management unit with index 3, then the query priority of inserted routing table entry 3 can be set to the highest value; the second largest index among the inserted space management units corresponding to the queried routing table entries is inserted routing table entry 2, then the query priority of inserted routing table entry 2 can be set to the second largest value; and the smallest index among the inserted space management units corresponding to the queried routing table entries is inserted routing table entry 1, then the query priority of inserted routing table entry 2 can be set to the lowest value.

[0153] Then, based on the matching priority of each route entry to be queried, each route entry to be queried can be matched with the route entry to be deleted until the route entry to be successfully queried is obtained.

[0154] For example, if the query priorities of the routing table entries to be queried, from highest to lowest, are inserted routing table entry 1, inserted routing table entry 2, and inserted routing table entry 3, then the highest priority routing table entry to be queried (i.e., inserted routing table entry 1) can be matched with the routing table entry to be deleted. If the match fails, the second highest priority routing table entry to be queried (i.e., inserted routing table entry 2) can be matched with the routing table entry to be deleted. If the match fails, the lowest priority routing table entry to be queried (i.e., inserted routing table entry 3) can be matched with the routing table entry to be deleted.

[0155] When querying a routing table entry, the mask length of the routing table entry to be queried must be the same as the mask length of the entry to be deleted, and the prefix of the routing table entry to be queried must be the same as the prefix of the routing table entry to be deleted. Only then can it be considered that the corresponding routing table entry to be deleted has been found, and the query result is a successful routing table entry.

[0156] For example, the route entry to be deleted is 10.20.20.20 / 24, and the route entries to be queried are 10.10.10.10 / 24 (inserted route entry 1), 10.20.20.20 / 24 (inserted route entry 2), and 10.30.30.30 / 24 (inserted route entry 3). Among them, only the mask length and prefix of the inserted route entry 2 match the corresponding content of the route entry to be deleted. Therefore, only the inserted route entry 2 is considered a successfully queried route entry.

[0157] In this embodiment of the application, after the first successful match, the successfully matched routing table entry will be used as the successfully queried routing table entry, and the query process will end.

[0158] Subsequently, the inserted space management unit corresponding to the successfully queried routing table entry can also be used as the space management unit to be deleted.

[0159] In this embodiment, other inserted routing table entries can be used to overwrite the space management unit to be deleted, thereby deleting the routing table entry. Here, the inserted routing table entry used to overwrite the space management unit to be deleted can be referred to as the overwriting routing table entry.

[0160] Specifically, if there exists an inserted routing table entry corresponding to an inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted, then the inserted routing table entry corresponding to the inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is the largest can be determined as an overlay routing table entry.

[0161] For example, please see Figure 4The routing table entry to be deleted is an inserted routing table entry with index 1 and mask length 16. There are other inserted routing table entries with mask length 16 in the routing table. Furthermore, among the other inserted routing table entries with mask length 16, there are inserted routing table entries corresponding to inserted space management units with index greater than 16. Specifically, there are inserted routing table entries corresponding to inserted space management units with index 2 and inserted space management units with index 3. Therefore, the inserted routing table entry corresponding to the inserted space management unit with index 3 can be determined as an overriding routing table entry.

[0162] If there is no inserted routing table entry with the same mask length as the mask to be deleted and an index greater than the index of the space management unit to be deleted, and there is an inserted routing table entry with a mask length greater than the mask to be deleted, then the inserted routing table entry corresponding to the inserted space management unit with the largest index and a mask length greater than the mask to be deleted and closest to the mask to be deleted is determined as the overlay routing table entry.

[0163] For example, please see Figure 18 The routing table entry to be deleted is the inserted routing table entry corresponding to the inserted space management unit with index 0. The mask length of this inserted routing table entry is 16. There are no other inserted routing table entries with a mask length of 16 in the routing table. Furthermore, there are inserted routing table entries with a mask length greater than 16, specifically the inserted routing table entries corresponding to the inserted space management unit with index 1, index 2, index 3, and index 4. Among these four inserted routing table entries, the inserted routing table entries with a mask length closest to the mask length to be deleted are the inserted routing table entries corresponding to the inserted space management units with indices 1 and 2, respectively. The mask length of these two inserted routing table entries is 24. In this case, the inserted routing table entry corresponding to the inserted space management unit with index 2 can be determined as the overriding routing table entry.

[0164] If there is no inserted routing table entry corresponding to an inserted space management unit with the same mask length as the mask to be deleted and an index greater than the index of the space management unit to be deleted, and there is no inserted routing table entry with a mask length greater than the mask length to be deleted, then it can be determined that there is no overriding routing table entry.

[0165] When it is determined that there is no overriding routing table entry, the inserted routing table entry corresponding to the space management unit to be deleted can be directly deleted; specifically, the data of the space management unit to be deleted can be cleared; afterwards, the deleted space management unit becomes the free space management unit with the smallest index.

[0166] For example, please see Figure 18 The routing table entry to be deleted is the inserted routing table entry corresponding to the inserted space management unit with index 4, and the mask length to be deleted is 26. At this time, there is no inserted routing table entry with a mask length of 26 and a corresponding inserted space management unit with an index greater than 4, and there is no inserted routing table entry with a mask length greater than 26. Therefore, it can be determined that there is no overriding routing table entry, and the inserted routing table entry corresponding to the space management unit to be deleted can be directly deleted. Specifically, the data in the inserted space management unit with index 4 can be cleared. After that, the space management unit with index 4 becomes the free space management unit with the smallest index.

[0167] Step S1702: Overwrite the space management unit to be deleted with the overwrite routing table entry.

[0168] In this embodiment, if there is an overriding routing table entry, the overriding routing table entry can be overridden with the routing table entry stored in the space management unit to be deleted, so as to delete the routing table entry to be deleted; if there is no overriding routing table entry, the inserted routing table entry corresponding to the space management unit to be deleted can be directly deleted.

[0169] For example, please see Figure 19 The routing table entry to be deleted is the inserted routing table entry 1 corresponding to the inserted space management unit with index 0. The mask length to be deleted is 16. At this time, it can be determined that there is no overriding routing table entry, so the inserted routing table entry 1 can be deleted directly. Specifically, the data in the inserted space management unit with index 0 can be cleared to delete the inserted routing table entry 1.

[0170] For example, please see Figure 20 If the route entry to be deleted is the inserted route entry 1 corresponding to the inserted space management unit with index 0, and the mask length to be deleted is 16, then it can be determined that the route entry to be covered is the inserted route entry 2 corresponding to the inserted space management unit with index 1. The mask length of the inserted route entry 2 is specifically 16, so the inserted route entry 2 can be used to cover the space management unit to be deleted.

[0171] For example, please see Figure 21 If the route entry to be deleted is the inserted route entry 1 corresponding to the inserted space management unit with index 0, and the mask length to be deleted is 16, then it can be determined that the route entry to be covered is the inserted route entry 2 corresponding to the inserted space management unit with index 1. The mask length of the inserted route entry 2 is specifically 24, so the inserted route entry 2 can be used to cover the space management unit to be deleted.

[0172] Since the overlay routing table entry already exists in the routing table before the overlay, after the overlay routing table entry overlays the space management unit to be deleted, both space management units of the routing table will store the overlay routing table entry, resulting in the overlay routing table entry being stored repeatedly. At this time, it is necessary to delete the overlay routing table entry from the original space management unit to avoid duplicate storage.

[0173] Specifically, an overriding routing table entry can be identified as the updated routing table entry to be deleted, and the process can be returned to perform the steps of determining the space management unit to be deleted and the overriding routing table entry in the routing table based on the length of the mask to be deleted, and the subsequent steps, until it is determined that there is no overriding routing table entry.

[0174] For example only, please refer to Figure 22 When it is necessary to delete the inserted routing table entry 1, if the overriding routing table entry is determined to be the inserted routing table entry 4 corresponding to the inserted space management unit with index 3, then the inserted routing table entry 4 can be used to overridden the inserted routing table entry 1. After that, the inserted routing table entry 4 corresponding to the inserted space management unit with index 3 can be determined as the updated routing table entry to be deleted, and the mask length to be deleted is 16. At this time, there is an inserted routing table entry with a mask length greater than 16. Then, the inserted routing table entry corresponding to the inserted space management unit with the largest index and a mask length greater than 16 can be determined as the target routing table entry to be overridden. That is, the inserted routing table entry 7 corresponding to the inserted space management unit with index 6 can be determined as the overriding routing table entry, and this overriding routing table entry can be used to overridden the inserted space management unit with index 3.

[0175] In the example above, after the inserted routing table entry 7 corresponding to the inserted space management unit with index 6 is used to overwrite the inserted routing table entry 4 corresponding to the inserted space management unit with index 3, the inserted routing table entry 7 corresponding to the inserted space management unit with index 6 can be updated to the space management unit to be deleted, and the length of the mask to be deleted is 24. At this time, it can be determined that there is no overwriting routing table entry, so the inserted routing table entry 7 corresponding to the inserted space management unit with index 6 can be deleted directly. Specifically, the data in the space management unit with index 6 can be cleared, and the space management unit with index 6 becomes the free space management unit with the smallest index. Then the process can be ended.

[0176] The following section will explain the process of deleting a routing table entry, taking into account the specific settings of the routing table management information (lpm_start, lpm_end, and free).

[0177] In one specific implementation, some management information of the routing table is as follows:

[0178] lpm_start

[16] = 0;

[0179] lpm_end

[16] = 0;

[0180] lpm_start

[24] = 2;

[0181] lpm_end

[24] = 1;

[0182] lpm_start

[26] = 4;

[0183] lpm_end

[26] = 3;

[0184] free = 5;

[0185] Please see Figure 23 The routing table entry to be deleted is the inserted routing table entry 3 corresponding to the inserted space management unit with index 3. The mask length to be deleted is 26. Since there is an inserted routing table entry 5 corresponding to the inserted space management unit with a mask length of 26 and an index greater than 3 in the routing table, the inserted routing table entry 5 can be overwritten by the inserted space management unit with index 3. At this time, the inserted routing table entry 5 corresponding to the inserted space management unit with index 4 can be updated to the routing table entry to be deleted. The mask length to be deleted is 26. Since there is no inserted routing table entry with a mask length greater than 26 in the routing table, it can be determined that there is no overwritten routing table entry. Therefore, the routing table entry to be deleted can be deleted directly. Specifically, the data of the inserted space management unit with index 4 can be cleared, and lpm_start

[26] , lpm_end

[26] and free can be updated. The management information of the updated routing table is as follows:

[0186] lpm_start

[16] = 0;

[0187] lpm_end

[16] = 0;

[0188] lpm_start

[24] = 2;

[0189] lpm_end

[24] = 1;

[0190] lpm_start

[26] = 3;

[0191] lpm_end

[26] = 3;

[0192] free = 4.

[0193] After that, the process can be ended.

[0194] In another specific implementation, some management information of the routing table is as follows:

[0195] lpm_start

[16] = 0;

[0196] lpm_end

[16] = 0;

[0197] lpm_start

[24] = 2;

[0198] lpm_end

[24] = 1;

[0199] lpm_start

[26] = 3;

[0200] lpm_end

[26] = 3;

[0201] free = 4.

[0202] Please see Figure 24 The route entry to be deleted is the inserted route entry 4 corresponding to the inserted space management unit with index 0. The mask length to be deleted is 16. At this time, there is no inserted route entry corresponding to the inserted space management unit with mask length of 16 and index greater than 0. Therefore, the inserted route entry 1 corresponding to the inserted space management unit with the inserted space management unit with the inserted space management unit with the inserted space management unit with the inserted space management unit with the inserted space management unit with the inserted space management unit with the inserted space management unit with the inserted space management unit with index 0 can be overwritten. lpm_start

[16] , lpm_start

[16] and lpm_end

[24] are updated. The management information of the updated route table is as follows:

[0203] lpm_start

[16] = -1;

[0204] lpm_end

[16] = -1;

[0205] lpm_start

[24] = 2;

[0206] lpm_end

[24] = 0;

[0207] lpm_start

[26] = 3;

[0208] lpm_end

[26] = 3;

[0209] free = 4;

[0210] Afterwards, the inserted routing table entry 1 corresponding to the inserted space management unit with index 2 can be updated to the routing table entry to be deleted. The mask length to be deleted is 24. At this time, there is an inserted routing table entry with a mask length greater than 24 in the routing table. Then, the inserted routing table entry corresponding to the inserted space management unit with a mask length greater than 24 and the closest to 24 and the largest index can be determined as the overlay routing table entry. That is, the inserted routing table entry 5 corresponding to the inserted space management unit with index 3 can be determined as the overlay routing table entry. Afterwards, the overlay routing table entry can be used to overlay the inserted space management unit with index 2 and update lpm_start

[24] and lpm_end

[26] . The management information of the updated routing table is as follows:

[0211] lpm_start

[16] = -1;

[0212] lpm_end

[16] = -1;

[0213] lpm_start

[24] = 1;

[0214] lpm_end

[24] = 0;

[0215] lpm_start

[26] = 3;

[0216] lpm_end

[26] = 2;

[0217] free = 4;

[0218] Afterwards, the inserted routing table entry 5 corresponding to the inserted space management unit with index 3 can be updated to the routing table entry to be deleted. The length of the mask to be deleted is 26. At this time, it can be determined that there is no overriding routing table entry. Therefore, the routing table entry to be deleted can be deleted directly. Specifically, the data of the inserted space management unit with index 3 can be cleared. The space management unit with index 3 becomes the free space management unit with the smallest index. Afterwards, lpm_start

[26] and free can be updated. The management information of the updated routing table is as follows:

[0219] lpm_start

[16] = -1;

[0220] lpm_end

[16] = -1;

[0221] lpm_start

[24] = 1;

[0222] lpm_end

[24] = 0;

[0223] lpm_start

[26] = 2;

[0224] lpm_end

[26] = 2;

[0225] free = 3;

[0226] After that, the process can be ended.

[0227] In the process of deleting a routing table entry in this application embodiment, when deleting a routing table entry to be deleted, each mask length that is larger than the mask length to be deleted only needs to move one routing table entry, with a time complexity of O(1). The operation efficiency will not decrease as the number of inserted routing table entries increases, which greatly improves the operation efficiency of the routing table.

[0228] In this embodiment, when performing route matching, matching can be performed in descending order of the index of the inserted space management unit corresponding to each route entry. Specifically, the matching priority of each inserted route entry can be determined based on the index of the inserted space management unit corresponding to each inserted route entry. Here, the matching priority of an inserted route entry is positively correlated with the index of the inserted space management unit corresponding to the inserted route entry; that is, the larger the index of the inserted space management unit corresponding to the inserted route entry, the higher the matching priority of the inserted route entry; the smaller the index of the inserted space management unit corresponding to the inserted route entry, the lower the matching priority of the inserted route entry. Then, route matching can be performed on each inserted route entry based on its matching priority.

[0229] For example, the routing table contains inserted routing table entry 1 with index 1, inserted routing table entry 2 with index 2, and inserted routing table entry 3 with index 3. When performing route matching, the matching priority can be set according to the index of the corresponding inserted spatial management unit from largest to smallest. Here, the inserted routing table entry with the largest corresponding inserted spatial management unit index is inserted routing table entry 3; therefore, the matching priority of inserted routing table entry 3 can be set to the largest. The inserted routing table entry with the second largest corresponding inserted spatial management unit index is also inserted routing table entry 3; therefore, the matching priority of inserted routing table entry 2 can be set to the second largest. Here, the inserted routing table entry with the smallest corresponding inserted spatial management unit index is inserted routing table entry 1; therefore, the matching priority of inserted routing table entry 1 can be set to the largest.

[0230] Since the size of the index of the inserted space management unit in the routing table of this application embodiment is positively correlated with the mask length, the index of the inserted space management unit corresponding to the routing table entry with a larger mask length is larger. Therefore, the routing matching according to the index of the corresponding inserted space management unit in descending order can meet the principle of long mask priority matching. After the first matching of the routing table entry, it can be determined that the routing table entry is the longest routing table entry with the required mask length. There is no need to traverse the routing table, so the routing table entry can be matched efficiently.

[0231] In summary, this application embodiment determines the space management unit to be inserted in the routing table for a routing table entry based on the length of the mask to be inserted; wherein, the length of the mask to be inserted is the mask length of the routing table entry to be inserted, and the space management unit of the routing table includes consecutive inserted space management units and / or consecutive free space management units, with each inserted space management unit corresponding one-to-one with an inserted routing table entry; the routing table entry to be inserted is inserted into the space management unit to be inserted; the step of determining the space management unit to be inserted in the routing table based on the length of the mask to be inserted includes: if there is no inserted routing table entry with a mask length greater than the length of the mask to be inserted, then The free space management unit with the smallest index is determined as the space management unit to be inserted. If there is an already inserted routing table entry with a mask length greater than the length of the mask to be inserted, the already inserted space management unit corresponding to the already inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index is determined as the space management unit to be inserted, and the already inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index is determined as the updated routing table entry to be inserted. The process returns to the step of determining the space management unit to be inserted in the routing table based on the length of the mask to be inserted and subsequent steps, until there are no already inserted routing table entries with a mask length greater than the length of the mask to be inserted. In this embodiment, when inserting a routing table entry, each mask length greater than the length of the mask to be inserted only requires moving one routing table entry, which greatly improves the operational efficiency of the routing table. Furthermore, the already inserted space management units in the routing table are contiguous spaces, and the already inserted space management units correspond one-to-one with the already inserted routing table entries, so that the already inserted routing table entries in the routing table can be arranged tightly and continuously, which helps to improve the space utilization of the routing table.

[0232] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0233] Corresponding to the space management method for routing tables described in the above embodiments, Figure 25This illustration shows a structural diagram of an embodiment of a space management device for routing tables provided in this application.

[0234] In this embodiment of the application, a space management device for a routing table may include:

[0235] The determination module 2501 is used to determine the space management unit to be inserted in the routing table for the routing table entry to be inserted based on the length of the mask to be inserted; wherein, the length of the mask to be inserted is the mask length of the routing table entry to be inserted, and the space management unit of the routing table includes each consecutive inserted space management unit and / or each consecutive free space management unit, and the inserted space management unit corresponds one-to-one with the inserted routing table entry;

[0236] Insertion module 2502 is used to insert the routing table entry to be inserted into the space management unit to be inserted;

[0237] The determining module includes:

[0238] The first determining submodule is used to determine the free space management unit with the smallest index as the space management unit to be inserted if there is no inserted routing table entry with a mask length greater than the mask length to be inserted.

[0239] The second determining submodule is used to determine the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index as the space management unit to be inserted if there is an inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index. It also determines the inserted routing table entry with a mask length greater than the length of the mask to be inserted and the smallest index as the updated routing table entry to be inserted. Then, it returns to the step of determining the space management unit to be inserted in the routing table based on the length of the mask to be inserted and its subsequent steps until there is no inserted routing table entry with a mask length greater than the length of the mask to be inserted.

[0240] In one specific implementation of this application embodiment, the space management device for the routing table further includes:

[0241] The unit and entry determination module is used to determine the space management unit to be deleted and the overriding route entry in the routing table based on the length of the mask to be deleted; wherein, the length of the mask to be deleted is the mask length of the route entry to be deleted, and the overriding route entry is used to overridden the space management unit to be deleted.

[0242] The overlay module is used to overlay the overlay routing table entry onto the space management unit to be deleted;

[0243] The unit and entry determination module includes:

[0244] The third determining submodule is used to determine the inserted routing table entry corresponding to the inserted space management unit with the same mask length as the mask to be deleted and the index greater than the index of the space management unit to be deleted as the overlay routing table entry if there is an inserted routing table entry corresponding to the inserted space management unit with the same mask length as the mask to be deleted and the largest index.

[0245] The fourth determining submodule is used to determine the inserted routing table entry corresponding to the inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted if there is no inserted routing table entry corresponding to the inserted space management unit whose mask length is greater than the mask length to be deleted and whose index is the largest.

[0246] The fifth determining submodule is used to determine that the overlay routing table entry does not exist if there is no inserted routing table entry corresponding to the inserted space management unit with the same mask length as the mask to be deleted and an index greater than the index of the space management unit to be deleted, and there is no inserted routing table entry with a mask length greater than the mask length to be deleted.

[0247] Return to the execution submodule, which is used to determine the overriding routing table entry as the updated routing table entry to be deleted, and return to execute the steps of determining the space management unit to be deleted and the machine of the overriding routing table entry in the routing table based on the length of the mask to be deleted, and the subsequent steps, until it is determined that the overriding routing table entry does not exist.

[0248] In one specific implementation of this application embodiment, the unit and entry determination module further includes:

[0249] The deletion submodule is used to delete the inserted routing table entry corresponding to the space management unit to be deleted when it is determined that the overlay routing table entry does not exist.

[0250] In one specific implementation of this application embodiment, the unit and entry determination module further includes:

[0251] The query matching submodule is used to match each routing table entry to be queried with the routing table entry to be deleted until a successfully queried routing table entry is obtained; wherein, the routing table entry to be queried is an inserted routing table entry with the same mask length as the mask length to be deleted;

[0252] The unit determination submodule is used to determine the inserted space management unit corresponding to the successfully queried routing table entry as the space management unit to be deleted.

[0253] In one specific implementation of this application embodiment, the query matching submodule includes:

[0254] The query priority determination unit is used to determine the query priority of each of the routing table entries to be queried based on the index of the inserted space management unit corresponding to each of the routing table entries to be queried; wherein, the query priority of the routing table entry to be queried is positively correlated with the index of the inserted space management unit corresponding to the routing table entry to be queried;

[0255] The query matching unit is used to match each of the routing table entries to be queried with the routing table entries to be deleted based on the query priority of each of the routing table entries to be queried, until the successfully queried routing table entry is obtained.

[0256] In one specific implementation of this application embodiment, the space management device for the routing table further includes:

[0257] The matching priority determination module is used to determine the matching priority of each inserted routing table entry based on the index of each inserted routing table entry; wherein, the matching priority of the inserted routing table entry is positively correlated with the index of the inserted space management unit corresponding to the inserted routing table entry;

[0258] The route matching module is used to perform route matching among each inserted route table entry based on the matching priority of each inserted route table entry.

[0259] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0260] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0261] Figure 26 A schematic block diagram of a network device provided in an embodiment of this application is shown. For ease of explanation, only the parts related to the embodiment of this application are shown.

[0262] like Figure 26 As shown, the network device 26 in this embodiment includes: a processor 260, a memory 261, and a computer program 262 stored in the memory 261 and executable on the processor 260. When the processor 260 executes the computer program 262, it implements the steps in the above-described embodiments of the space management methods for routing tables, for example... Figure 3Steps S301 to S302 are shown. Alternatively, when the processor 260 executes the computer program 262, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 25 The functions of modules 2501 to 2502 are shown.

[0263] For example, the computer program 262 may be divided into one or more modules / units, which are stored in the memory 261 and executed by the processor 260 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program 262 in the network device 26.

[0264] Those skilled in the art will understand that Figure 26 This is merely an example of network device 26 and does not constitute a limitation on network device 26. It may include more or fewer components than shown, or combine certain components, or different components. For example, network device 26 may also include input / output devices, network access devices, buses, etc.

[0265] The processor 260 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0266] The memory 261 can be an internal storage unit of the network device 26, such as a hard drive or memory of the network device 26. The memory 261 can also be an external storage device of the network device 26, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the network device 26. Furthermore, the memory 261 can include both internal and external storage units of the network device 26. The memory 261 is used to store the computer program and other programs and data required by the network device 26. The memory 261 can also be used to temporarily store data that has been output or will be output.

[0267] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0268] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0269] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0270] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0271] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0272] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0273] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable storage medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc. It should be noted that the content included in the computer-readable storage medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable storage medium does not include electrical carrier signals and telecommunication signals.

[0274] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A method for space management of routing tables, characterized by, The method comprises the steps of: determining a to-be-inserted space management unit of a to-be-inserted routing entry in a routing table based on a to-be-inserted mask length, wherein the to-be-inserted mask length is a mask length of the to-be-inserted routing entry, and the space management unit of the routing table comprises each continuous inserted space management unit and / or each continuous idle space management unit, and the inserted space management unit corresponds to an inserted routing entry in one-to-one correspondence; inserting the to-be-inserted routing entry into the to-be-inserted space management unit; the step of determining the to-be-inserted space management unit of the to-be-inserted routing entry in the routing table based on the to-be-inserted mask length comprises the steps of: if there is no inserted routing entry with a mask length greater than the to-be-inserted mask length, determining an idle space management unit with the smallest index as the to-be-inserted space management unit; if there is an inserted routing entry with a mask length greater than the to-be-inserted mask length, determining an inserted space management unit corresponding to an inserted routing entry with the largest index and the mask length greater than the to-be-inserted mask length as the to-be-inserted space management unit, and determining the inserted routing entry with the largest index and the mask length greater than the to-be-inserted mask length as an updated to-be-inserted routing entry, and returning to execute the step of determining the to-be-inserted space management unit of the to-be-inserted routing entry in the routing table based on the to-be-inserted mask length and subsequent steps until there is no inserted routing entry with a mask length greater than the to-be-inserted mask length.

2. The method of claim 1, wherein, The method further comprises the steps of: determining a to-be-deleted space management unit and a cover routing entry of a to-be-deleted routing entry in a routing table based on a to-be-deleted mask length, wherein the to-be-deleted mask length is a mask length of the to-be-deleted routing entry; covering the to-be-deleted space management unit by the cover routing entry; the determination process of the cover routing entry comprises the steps of: if there is an inserted routing entry with the same mask length as the to-be-deleted mask length and an index greater than an index of the to-be-deleted space management unit, determining an inserted routing entry corresponding to an inserted space management unit with the same mask length as the to-be-deleted mask length and the largest index as the cover routing entry; if there is no inserted routing entry with the same mask length as the to-be-deleted mask length and an index greater than an index of the to-be-deleted space management unit, and there is an inserted routing entry with a mask length greater than the to-be-deleted mask length, determining an inserted routing entry corresponding to an inserted space management unit with the mask length greater than the to-be-deleted mask length and closest to the to-be-deleted mask length as the cover routing entry; if there is no inserted routing entry with the same mask length as the to-be-deleted mask length and an index greater than an index of the to-be-deleted space management unit, and there is no inserted routing entry with a mask length greater than the to-be-deleted mask length, determining that there is no cover routing entry; The cover route entry is determined as the updated to-be-deleted route entry, and the step of determining the to-be-deleted space management unit and the cover route entry of the to-be-deleted route entry in the route table based on the to-be-deleted mask length and subsequent steps are returned until it is determined that the cover route entry does not exist.

3. The method of claim 2, wherein, Further comprising: When it is determined that the cover route entry does not exist, the inserted route entry corresponding to the to-be-deleted space management unit is deleted.

4. The method of claim 2, wherein, The determination process of the to-be-deleted space management unit comprises: Each to-be-queried route entry is matched with the to-be-deleted route entry respectively until a query successful route entry is obtained; wherein the to-be-queried route entry is an inserted route entry with the same mask length as the to-be-deleted mask length; The inserted space management unit corresponding to the query successful route entry is determined as the to-be-deleted space management unit.

5. The method for managing the space of routing tables according to claim 4, wherein, The matching of each to-be-queried route entry with the to-be-deleted route entry respectively until the query successful route entry is obtained comprises: Based on the index of the inserted space management unit corresponding to each to-be-queried route entry, the query priority of each to-be-queried route entry is determined; wherein the query priority of the to-be-queried route entry is positively correlated with the index of the inserted space management unit corresponding to the to-be-queried route entry; Based on the query priority of each to-be-queried route entry, each to-be-queried route entry is matched with the to-be-deleted route entry respectively until the query successful route entry is obtained.

6. The method of space management of routing tables according to any of claims 1 to 5, characterized in that, Further comprising: Based on the index of each inserted route entry, the matching priority of each inserted route entry is determined; wherein the matching priority of the inserted route entry is positively correlated with the index of the inserted space management unit corresponding to the inserted route entry; Based on the matching priority of each inserted route entry, route matching is performed in each inserted route entry.

7. A space management apparatus of a routing table, characterized by, Comprise: The determination module is used for determining the to-be-inserted space management unit of the to-be-inserted route entry in the route table based on the to-be-inserted mask length; wherein the to-be-inserted mask length is the mask length of the to-be-inserted route entry, and the space management unit of the route table comprises each continuous inserted space management unit and / or each continuous idle space management unit, and the inserted space management unit is one-to-one corresponding to the inserted route entry; The insertion module is used for inserting the to-be-inserted route entry into the to-be-inserted space management unit. The determination module comprises: The first determination submodule is used for determining the idle space management unit with the smallest index as the to-be-inserted space management unit if there is no inserted route entry with a mask length greater than the to-be-inserted mask length; The first determination submodule is used for determining the idle space management unit with the smallest index as the to-be-inserted space management unit if there is no inserted route entry with a mask length greater than the to-be-inserted mask length; a second determining submodule, configured to: if there is an inserted routing entry with a mask length greater than the to-be-inserted mask length, determine an inserted space management unit corresponding to an inserted routing entry with the greatest mask length and the smallest index as the to-be-inserted space management unit, and determine the inserted routing entry with the greatest mask length and the smallest index as the updated to-be-inserted routing entry; return to perform the step of determining the to-be-inserted space management unit of the to-be-inserted routing entry in the routing table based on the to-be-inserted mask length and subsequent steps until there is no inserted routing entry with a mask length greater than the to-be-inserted mask length.

8. A computer program product, characterised in that, The computer program, when executed, causes the network device to implement the steps of the space management method of the routing table according to any one of claims 1 to 6.

9. A network device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein, The processor executes the computer program, so that the network device implements the steps of the space management method of the routing table according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Route table space managing method, apparatus, switch and router

    CN101335706A

  • TCAM-based LPM routing lookup device and method

    CN118827542A