Forwarding table storage method and search method, device, electronic equipment and storage medium
By setting the first field in the forwarding table to divide the data proportionally, the problem of low utilization of forwarding table items is solved, achieving efficient storage and retrieval under limited resources and improving network communication efficiency.
Patent Information
- Application Number
- CN202111615892.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-27
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2041-12-27
AI Technical Summary
In existing technologies, the forwarding table entries for communication between network nodes have low resource utilization, leading to increased costs and serious waste of entries. Especially when network applications are constantly changing, the chip entry definitions are not flexible enough and cannot effectively utilize limited resources.
By setting a first field in the forwarding table and determining the value of the first field based on the amount of table space required for the outgoing information, different proportions can be made to provide table space of various sizes for storing different types of outgoing information, thereby improving table utilization under the condition of fixed resources.
Without changing the table space corresponding to the forwarding table, the table utilization rate is improved, achieving efficient storage and retrieval under limited resource conditions, and improving the efficiency of network communication.
Smart Images

Figure CN116361280B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a forwarding table storage method and search method, device, electronic device and storage medium. Background Art
[0002] With the rapid development of the Internet, the number of network nodes continues to increase, and data traffic is ever-changing. In related technologies, communication between nodes is generally stored in two parts in the chip: path information and egress information. To improve the efficiency of message search and forwarding, chips usually use a large amount of path information storage at a high cost, which further limits the cost of table entries for storing egress information. At the same time, under normal circumstances, the editing behavior of data messages corresponding to communication between each node is different, which means that each storage of path information requires a table entry to store egress information. Therefore, in practice, the demand for table entry resources for storing egress information is very tight.
[0003] Due to the varying nature of network technologies, the egress information involved in communications varies. Existing chips typically define a given resource into several broad categories to store different egress behaviors, tailored to the application. However, network applications are ever-changing, and chips strive to be comprehensive when defining table entries to support a wider range of functions. This results in only a small portion of the fields in a table entry being used for basic Layer 2 and Layer 3 forwarding, leaving a significant number of unused fields and resulting in wasted table entries and low utilization. Improving table entry utilization within a cost-constrained environment is a pressing issue. Summary of the Invention
[0004] To solve the existing technical problems, embodiments of the present invention provide a forwarding table storage method and search method, device, electronic device and storage medium.
[0005] To achieve the above-mentioned purpose, the technical solution of the embodiment of the present invention is implemented as follows:
[0006] In a first aspect, an embodiment of the present invention provides a forwarding table storage method, comprising:
[0007] Obtaining forwarding table information to be stored, wherein the forwarding table information includes path information and egress information;
[0008] Determining a value of a first field according to the size of the table entry space consumed by the egress information, and determining a first index value based on the value of the first field; wherein the first field is set in a second forwarding table, and different values of the first field indicate that the entire table entry space included in the second forwarding table is divided into different proportions to obtain different table entry spaces; and the first index value points to a target table entry space included in the second forwarding table;
[0009] The path information and the first index value are stored in a first forwarding table, and the egress information is stored in the target table entry space.
[0010] In the above solution, determining the value of the first field according to the size of the table entry space consumed by the egress information includes:
[0011] When the required entry space consumed is no more than one-half of the total entry space included in the second forwarding table, determining that the first field is a first value; the first value indicates that the total entry space included in the second forwarding table is divided into two equal parts;
[0012] When the table entry space required to be consumed is greater than half of the total table entry space included in the second forwarding table, the first field is determined to be a second value; the second value indicates that the second forwarding table is not to be divided.
[0013] In the above solution, the method further includes:
[0014] The size of the table entry space consumed by the export information is determined according to the parameter type included in the export information.
[0015] In the above solution, determining the size of the table entry space required for the export information based on the parameter type included in the export information includes:
[0016] When the egress information does not include extended function information, determining that an entry space consumed by the egress information is no greater than one half of the total entry space included in the second forwarding table;
[0017] In a case where the egress information includes the extended function information, it is determined that the entry space consumed by the egress information is greater than half of the total entry space included in the second forwarding table.
[0018] In the above solution, the method further includes: configuring the first field in the second forwarding table based on the value of the first field.
[0019] In a second aspect, an embodiment of the present invention further provides a forwarding table search method, comprising:
[0020] Searching a first forwarding table based on the path information in the message to be forwarded to obtain a first index value; the first forwarding table includes at least one set of path information and corresponding index values;
[0021] Determining a second forwarding table according to the first index value; wherein the second forwarding table includes a first field, and different values of the first field indicate that all table entry spaces included in the second forwarding table are divided into different proportions to obtain different table entry spaces;
[0022] Based on the value of the first field in the second forwarding table and the first index value, a target table entry space included in the second forwarding table is determined; and the message information stored in the target table entry space is parsed to obtain the egress information corresponding to the path information.
[0023] In the above solution, determining the second forwarding table according to the first index value includes:
[0024] According to the first index value, a second index value pointing to all entry spaces included in the second forwarding table is determined; and according to the second index value, the second forwarding table is determined.
[0025] In the above solution, determining the target entry space included in the second forwarding table based on the value of the first field in the second forwarding table and the first index value includes:
[0026] Determining one or more entry spaces included in the second forwarding table according to a value of the first field;
[0027] When the second forwarding table includes only one table entry space, the target table entry space is determined to be all the table entry spaces included in the second forwarding table; when the second forwarding table includes multiple table entry spaces, the target table entry space is determined in the multiple table entry spaces based on the first index value.
[0028] In the above solution, determining one or more entry spaces included in the second forwarding table based on the value of the first field includes:
[0029] When the value of the first field is a first value, it is determined that the second forwarding table includes two entry spaces; the first value indicates that all entry spaces included in the second forwarding table are divided into two equal parts;
[0030] When the value of the first field is the second value, it is determined that the second forwarding table includes only one entry space; the second value indicates that the second forwarding table is not to be divided.
[0031] In the above solution, determining the target entry space from the multiple entry spaces based on the first index value includes:
[0032] The target entry space is determined in the plurality of entry spaces based on a distance value between the first index value and the second index value.
[0033] In a third aspect, an embodiment of the present invention further provides a forwarding table storage device, comprising:
[0034] A first acquisition module is used to obtain forwarding table information to be stored, wherein the forwarding table information includes path information and egress information;
[0035] a first determining module, configured to determine a value of a first field according to a size of an entry space consumed by the egress information obtained by the first acquiring module, and determine a first index value based on the value of the first field; wherein the first field is set in a second forwarding table, and different values of the first field indicate that all entry spaces included in the second forwarding table are divided into different proportions to obtain different entry spaces; and the first index value points to a target entry space included in the second forwarding table;
[0036] and a storage module, configured to store the path information obtained by the first acquisition module and the first index value determined by the first determination module into a first forwarding table, and to store the egress information obtained by the first acquisition module into the target table entry space.
[0037] In the above solution, the first determining module includes:
[0038] The first submodule is used to determine that the first field is a first value when the table entry space required to be consumed is not greater than half of the total table entry space included in the second forwarding table; the first value indicates that the total table entry space included in the second forwarding table is divided into two equal parts; and is also used to determine that the first field is a second value when the table entry space required to be consumed is greater than half of the total table entry space included in the second forwarding table; the second value indicates that the second forwarding table is not divided.
[0039] In the above solution, the first determining module is further configured to determine the size of the table entry space required to be consumed by the egress information according to the parameter type included in the egress information obtained by the first acquiring module.
[0040] In the above solution, the first determining module includes:
[0041] The second submodule is used to determine that the table entry space required to be consumed by the export information is not greater than one half of the total table entry space included in the second forwarding table when the export information does not include the extended function information; and is also used to determine that the table entry space required to be consumed by the export information is greater than one half of the total table entry space included in the second forwarding table when the export information includes the extended function information.
[0042] In the above solution, the device further includes a configuration module, configured to configure the first field in the second forwarding table based on the value of the first field determined by the first determination module.
[0043] In a fourth aspect, an embodiment of the present invention further provides a forwarding table search device, comprising:
[0044] A second acquisition module is used to search a first forwarding table based on the path information in the message to be forwarded to obtain a first index value; the first forwarding table includes at least one set of path information and corresponding index values;
[0045] a second determining module, configured to determine a second forwarding table according to the first index value obtained by the second obtaining module; wherein the second forwarding table includes a first field, and different values of the first field indicate that all entry spaces included in the second forwarding table are divided into different proportions to obtain different entry spaces;
[0046] and a search module for determining the target table entry space included in the second forwarding table based on the value of the first field in the second forwarding table determined by the second determination module and the first index value obtained by the second acquisition module; parsing the message information stored in the target table entry space to obtain the exit information corresponding to the path information.
[0047] In the above solution, the second determining module is used to determine the second index value pointing to the entire entry space included in the second forwarding table according to the first index value obtained by the second acquiring module; and determine the second forwarding table according to the second index value.
[0048] In the above solution, the search module includes:
[0049] A third submodule, configured to determine one or more entry spaces included in the second forwarding table according to a value of the first field;
[0050] and a fourth submodule, for determining, when the second forwarding table includes only one table entry space, that the target table entry space is all the table entry spaces included in the second forwarding table; and for determining, when the second forwarding table includes multiple table entry spaces, the target table entry space in the multiple table entry spaces based on the first index value.
[0051] In the above scheme, the third submodule is used to determine that the second forwarding table includes two table entry spaces when the value of the first field is a first value; the first value indicates that all the table entry spaces included in the second forwarding table are divided into two equal parts; and is also used to determine that the second forwarding table includes only one table entry space when the value of the first field is a second value; the second value indicates that the second forwarding table is not divided.
[0052] In the above solution, the fourth submodule is further configured to determine the target entry space in the multiple entry spaces based on a distance value between the first index value and the second index value.
[0053] In a fifth aspect, an embodiment of the present invention further provides an electronic device comprising: a processor and a memory for storing a computer program that can be run on the processor, wherein when the processor is used to run the computer program, the steps of the aforementioned forwarding table storage method are executed, or when the processor is used to run the computer program, the steps of the aforementioned forwarding table lookup method are executed.
[0054] In a sixth aspect, an embodiment of the present invention further provides a storage medium on which a computer program is stored, which, when executed by a processor, implements the steps of the aforementioned forwarding table storage method, or, when executed by a processor, implements the steps of the aforementioned forwarding table search method.
[0055] An embodiment of the present invention provides a forwarding table storage method and search method, device, electronic device and storage medium. By setting a first field in a second forwarding table, a plurality of table entry spaces of different sizes can be provided for storing different types of export information without changing the table entry space corresponding to the forwarding table, thereby improving the table entry utilization rate when resources are fixed. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 Schematic diagram of a flow chart of a forwarding table storage method according to an embodiment of the present invention;
[0057] Figure 2 A schematic diagram of a serial relationship between entries in the first forwarding table and the second forwarding table;
[0058] Figure 3 Figure 2.2 shows the serial relationship between FDB entries in the basic scenario and the VXLAN ECMP scenario.
[0059] Figure 4 A schematic diagram of a flow chart of a forwarding table search method according to an embodiment of the present invention;
[0060] Figure 5 Schematic diagram of a flow chart of a forwarding table search method when the DsMac table in the second-layer FDB includes a half table and a full table;
[0061] Figure 6 A schematic diagram of the structure of a forwarding table storage device according to an embodiment of the present invention;
[0062] Figure 7 A schematic diagram of the structure of a forwarding table search device according to an embodiment of the present invention;
[0063] Figure 8 FIG. 4 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0064] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0065] An embodiment of the present invention provides a forwarding table storage method. Figure 1 FIG. 1 is a flow chart of a forwarding table storage method according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0066] Step 101: Obtain forwarding table information to be stored, wherein the forwarding table information includes path information and egress information;
[0067] Step 102: Determine a value of a first field based on the size of the entry space consumed by the egress information, and determine a first index value based on the value of the first field; wherein the first field is set in a second forwarding table, the second forwarding table includes the first field, different values of the first field indicate that the entire entry space included in the second forwarding table is divided into different proportions to obtain different entry spaces; and the first index value points to a target entry space included in the second forwarding table;
[0068] Step 103: Store the path information and the first index value in a first forwarding table, and store the egress information in the target entry space.
[0069] The execution entity of the forwarding table storage method of this embodiment can be a switching chip or a system-level switching device (such as a switch). The method of this embodiment is executed by each module / unit in the switching chip or switching device to achieve storage of forwarding table information. The following embodiments are described using a switching chip as the execution entity.
[0070] In step 101, the switching chip obtains forwarding table information to be stored. Taking the Layer 2 forwarding table (FDB, Forwarding Data Base) as an example, the forwarding table information to be stored can be obtained through the switch self-learning method. The forwarding table information to be stored can be obtained based on the source media access control (MAC, Media Access Control) address, port, virtual local area network identifier (VLANID, Virtual Local Area Network Identity) of the received data packet, thereby automatically updating the FDB table entry; alternatively, the forwarding table information to be added to the FDB table entry can be obtained manually, that is, through the switch command line interface.
[0071] In this embodiment, forwarding table information includes path information and egress information. For example, in a Layer 2 FDB forwarding scenario, path information may include MAC addresses, VLAN information, and other information. Egress information may include primary functional information such as egress port information and next-hop edit indexes, as well as extended functional information such as equal-cost multi-path group indexes, automatic protection switching group indexes, and statistical information indexes. The path information is stored in the first forwarding table, and the egress information is stored in the second forwarding table.
[0072] This embodiment adds a first field to the second forwarding table for storing egress information. Based on different values of the first field, the total entry space of the second forwarding table can be divided into different proportions to obtain one or more entry spaces. Due to differences in network technologies, the egress information involved in the communication process also varies, resulting in differences in the amount of entry space required to store different types of egress information. It will be understood that in this embodiment, after obtaining the forwarding table information to be stored, the switching chip can determine the required amount of entry space based on the specific type of egress information and select an appropriate entry space to store the egress information accordingly. For example, if there are two types of egress information, the first field can be configured to have two values, each indicating two different proportions for dividing the total entry space of the second forwarding table, thereby dividing the second forwarding table into two types for storing the two types of egress information. Similarly, the second field can be configured to have more than two different values to divide the second forwarding table into more different proportions, thereby differentiating the second forwarding table into more types of entries for storing more types of egress information.
[0073] In step 102, first, the value of the first field is determined based on the size of the table entry space required for the export information, that is, it is determined what type of second forwarding table is used to store the export information, and then a first index value is assigned based on the table entry structure of the second forwarding table corresponding to the value of the first field, and the first index value points to the target table entry space in one or more table entry spaces obtained by dividing the second forwarding table. Exemplarily, one of the values of the first field indicates that the entire table entry space of the second forwarding table is divided into two equal parts. When the value of the first field is determined to be this value based on the size of the table entry space required for the export information, an address index (i.e., the first index value) is assigned to the export information based on the specification of the table entry being divided into two equal parts.
[0074] In step 103, the first index value and the path information in the forwarding table information are stored in the first forwarding table, and the egress information corresponding to the path information is stored in the target entry space in the second forwarding table indicated by the first index value.
[0075] It should be noted that this embodiment does not limit the storage method of the second forwarding table. The second forwarding table can be a separately stored table item or a partial table item space in a separately stored table item. It can be understood that when the second forwarding table is a partial table item space in a certain table item, the first field in this embodiment only indicates the division of this partial table item space. Figure 2 Schematic diagram of a series relationship between entries in the first forwarding table and the second forwarding table in this embodiment, as shown in FIG. Figure 2 As shown, the first forwarding table stores path information and a first index value associated with the second forwarding table, and the first index value points to a target entry space in the second forwarding table where the corresponding egress information is located.
[0076] In this embodiment, different values of the first field correspond to different division ratios, and the number of values of the first field corresponds to the type of the second forwarding table ultimately obtained. Exemplarily, the first field includes N different values, which are used to distinguish the second forwarding table into N types of table entries with different structures. More specifically, it can be used to distinguish the second forwarding table into N types of table entries with equally divided structures, where N is an integer greater than or equal to 2. For example, the first field only includes two values. In some embodiments, when the first field has the first value, it can indicate that the second forwarding table is divided into two equal parts, and when it has the second value, it indicates that the second forwarding table is not divided. In other embodiments, when the first field has the first value, it can also indicate that the second forwarding table is divided into four equal parts or other ratios (such as non-equal parts). When it has the second value, it still indicates that the second forwarding table is not divided, that is, the second forwarding table is divided into table entries that are not divided and table entries that are divided in the manner indicated by the first value. Similarly, when the first field has four possible values, the second forwarding table can be divided into four types of entries divided according to different proportions, such as no division, bisection, trisection, and quartering. The target entry spaces corresponding to the different types of second forwarding tables are further determined based on the first index value.
[0077] The forwarding table storage method of this embodiment, by setting the first field in the second forwarding table, can provide table entry spaces of multiple different sizes for storing different types of export information without changing the table entry space corresponding to the forwarding table, thereby improving table entry utilization while fixing resources.
[0078] In one embodiment, before step 102, the method may further include: configuring a first field in the second forwarding table based on the value of the first field. In this embodiment, when an unused second forwarding table is used to store egress information, the first field in the corresponding second forwarding table may be configured based on the value of the first field determined by the size of the table entry space consumed by the egress information.
[0079] As an optional implementation, determining the value of the first field based on the size of the table entry space required to be consumed by the export information may include: when the table entry space required to be consumed is not greater than half of the total table entry space included in the second forwarding table, determining that the first field is a first value; the first value indicates that the total table entry space included in the second forwarding table is divided into two equal parts; when the table entry space required to be consumed is greater than half of the total table entry space included in the second forwarding table, determining that the first field is a second value; the second value indicates that the second forwarding table is not divided.
[0080] Optionally, 1 bit is provided in the second forwarding table to configure the first field, the first field has two values of 0 and 1, wherein, when the first field value is 1 (i.e. the first value), the whole entry space included in the second forwarding table is indicated to be divided into two equal parts (the second forwarding table of this structure is called a half table), and when the first field value is 0 (i.e. the second value), the second forwarding table is not divided (the second forwarding table of this structure is called a full table). Thus, after determining the value of the first field according to the entry space size consumed by the egress information, the first field in the second forwarding table can be configured according to this value. Similarly, in other embodiments, the first field in the second forwarding table can also be 2bits, including four different values, so that the second forwarding table is distinguished into the entry of four different structures, and other second fields can be deduced by analogy.
[0081] The forwarding table storage method of this embodiment provides a single bit in the second forwarding table to distinguish between half and full entries. This allows fields related to commonly used and primary functions to be placed in the half table, while fields related to complete functions can be placed in the full table. This improves entry utilization while maintaining fixed resources, doubling the size of primary function entries. Furthermore, the second forwarding table is not limited to a single bit; using two bits allows for distinguishing between four different entry structures, and so on.
[0082] Based on the above embodiment, the method may further include: determining the size of table entry space required for the export information based on the parameter types included in the export information. Optionally, the size of table entry space required for the export information may be determined based on the size of table entry space required for each parameter type included in the export information; or the size of table entry space required for the export information may be determined based on whether the export information contains a parameter of a specific type.
[0083] Exemplarily, determining the size of the table entry space required to be consumed by the export information based on the parameter type included in the export information includes: when the export information does not include extended function information, determining that the table entry space required to be consumed by the export information is no greater than one-half of the total table entry space included in the second forwarding table; and when the export information includes the extended function information, determining that the table entry space required to be consumed by the export information is greater than one-half of the total table entry space included in the second forwarding table. Optionally, the extended function information may include one or more of an equivalent multi-path group index, an automatic protection switching group index, and a statistical information index.
[0084] Taking the second-layer FDB as an example, Figure 3 This is a schematic diagram of the series relationship between the corresponding FDB table entries in the basic scenario and the Virtual Extensible Local Area Network (VXLAN) ECMP scenario, wherein the path information in the FDB table is stored in the DsFibHost0MacHashKey table and points to the DsMac table storing the export information through the dsAdIndex index. The DsMac table may include multiple second forwarding tables, each of which includes a first field isHalf. When isHalf takes a value of 1, it indicates that the corresponding second forwarding table is divided into two equal parts, resulting in two half tables. When isHalf takes a value of 0, it indicates that the corresponding second forwarding table is not divided, resulting in a full table. The parameter types of the Layer 2 FDB export information may include the egress port destMap, the next hop edit index nexthopPtr, the equivalent multi-path group index ecmpGroupId, the automatic protection switching group index apsBridgeId, and the statistical information index statsPtr.
[0085] When the egress information obtained by the switching chip only includes the egress port information and the next hop edit index, it can be determined that the egress information corresponds to the Layer 2 FDB forwarding in the basic scenario. The table entries in this scenario are serially connected as follows: Figure 3As shown in the upper half of the table, the required table space size is only 30 bits. At this time, after the export information is stored in the corresponding position of the DsMac table according to the first index value, the first field isHalf in the corresponding second forwarding table is set to 1, and the second half of the second forwarding table can be used to store the export information in another basic scenario; and when the export information obtained by the switching chip includes the export port, the next hop editing index, the equal-cost multi-path group index, the automatic protection switching group index and the statistical information index at the same time, or when it is determined that the export information includes one or more of the equal-cost multi-path group index, the automatic protection switching group index and the statistical information index, it can be determined that the export information corresponds to the second-layer FDB forwarding in the VXLAN ECMP scenario. The table entry series relationship in this scenario is as follows: Figure 3 As shown in the lower half of the table, the required table entry space consumed is 60 bits. At this time, after the egress information is stored in the corresponding position in the DsMac table according to the first index value, the isHalf field in the corresponding second forwarding table is set to 0. This second forwarding table is only used to store the egress information in this ECMP scenario. Of course, the table entry space consumed by the egress information described in this embodiment is not limited to a specific space size, but can also be relative to the total table entry space corresponding to the second forwarding table. For example, it is determined that the required table entry space consumed is less than half of the total table entry space.
[0086] In existing networks, VXLAN ECMP is rarely used, and is generally used for Layer 2 forwarding in basic scenarios. However, the VXLAN encapsulation next hop consists of two parts: underlay and overlay. Among them, the underlay egress is mostly ECMP, that is, the egress information needs to support ECMP, which is not the main function supported by the half table. Therefore, when the switching chip assigns the first index value and writes it to the DsMac table, the isHalf field must be set to 0, indicating that the egress information corresponding to the path is stored in the full table. Thereafter, it can be used to support ECMP through the ecmpGroupId index. The forwarding table storage method of this embodiment takes Layer 2 FDB forwarding as an example. Assuming that the table entry specification of the switching chip for storing egress information is only 10k, and the egress information associated with each FDB entry is different, then the relevant technology can only support 10k FDB entries for editing and forwarding; if the table entries of half or full structures are used for storage in accordance with the present invention, then 20k (10k×2) FDB entries can be supported for editing and forwarding, and the utilization rate will be increased by a full fold.
[0087] The embodiment of the present invention also provides a forwarding table search method. Figure 4 FIG. 1 is a flow chart of a forwarding table search method according to an embodiment of the present invention. Figure 4 As shown, the method includes:
[0088] Step 201: searching a first forwarding table based on the path information in the message to be forwarded to obtain a first index value; the first forwarding table includes at least one set of path information and corresponding index values;
[0089] Step 202: Determine a second forwarding table based on the first index value; wherein the second forwarding table includes a first field, and different values of the first field indicate that the entire entry space included in the second forwarding table is divided into different proportions to obtain different entry spaces;
[0090] Step 203: Determine the target entry space included in the second forwarding table based on the value of the first field in the second forwarding table and the first index value; parse the message information stored in the target entry space to obtain the egress information corresponding to the path information.
[0091] The execution entity of the forwarding table search method of this embodiment can be a switching chip or a system-level switching device (such as a switch). The method of this embodiment is executed by each module / unit in the switching chip or the switching device to achieve the search of forwarding table information. The following embodiments are described using the switching chip as the execution entity.
[0092] When a switch port receives a message, the switching chip obtains path information from the message. This path information may include the destination MAC address and VLAN information of the message. In step 201, the switching chip searches a first forwarding table based on the path information and determines a first index value pointing to the egress information corresponding to the path information. The first forwarding table stores at least one set of path information and an index value pointing to the corresponding egress information.
[0093] As an optional embodiment, in step 202, determining the second forwarding table based on the first index value includes: determining, based on the first index value, a second index value pointing to all entry spaces included in the second forwarding table; and determining the second forwarding table based on the second index value. Exemplarily, when initializing the table entries, each first index value can be allocated according to the minimum entry space divided by the second forwarding table, and the relationship between the first index value pointing to the target entry space in the multiple entry spaces of the second forwarding table and the second index value pointing to the second forwarding table is recorded. For example, when the second forwarding table includes two specifications, a half table and a full table, after obtaining the exit information, the specification of the second forwarding table to store the exit information can be determined based on the size of the entry space required to be consumed. When it is determined that the half table is to be used, the first index value can be allocated according to the index value of the half table, so that the first index value can directly indicate whether the exit information is stored in the first half of the table entry or the second half of the table entry in the second forwarding table. When it is determined that the full table is to be used, the first index value can be allocated according to the index value of the full table. When reading data, the switching chip first determines the second index value pointing to the second forwarding table (which can be understood as the full table) based on the first index value. In this embodiment, the switching chip supports the coexistence of second forwarding tables with multiple table entry specifications, but does not change the data reading method of the second forwarding table.
[0094] In step 203, after determining the corresponding second forwarding table, the entry structure of the second forwarding table can be determined according to the value of the first field in the second forwarding table, and the target entry space is further determined according to the first index value to obtain corresponding egress information.
[0095] As an embodiment, in step 203, the target table entry space included in the second forwarding table is determined based on the value of the first field in the second forwarding table and the first index value, including: determining one or more table entry spaces included in the second forwarding table according to the value of the first field; when the second forwarding table includes only one table entry space, determining the target table entry space to be all table entry spaces included in the second forwarding table; when the second forwarding table includes multiple table entry spaces, determining the target table entry space among the multiple table entry spaces based on the first index value.
[0096] Optionally, determining one or more entry spaces included in the second forwarding table based on the value of the first field includes: when the value of the first field is a first value, determining that the second forwarding table includes two entry spaces; the first value indicates that all entry spaces included in the second forwarding table are divided into two equal parts; when the value of the first field is a second value, determining that the second forwarding table includes only one entry space; and the second value indicates that the second forwarding table is not divided. In this embodiment, the relevant descriptions of the first forwarding table, the second forwarding table, the first index value, and the first field can be referred to the detailed description in the aforementioned embodiment and will not be repeated here.
[0097] Based on the above embodiment, the step of determining the target entry space in the plurality of entry spaces based on the first index value includes: determining the target entry space in the plurality of entry spaces based on a distance between the first index value and the second index value. Exemplarily, when the second forwarding table may include four entry spaces, the first index value may be allocated according to the structure of the four entry spaces when initializing the entry. For example, if the second forwarding table indicated by the index value I includes four entry spaces, the first entry space, the second entry space, the third entry space, and the fourth entry space in the same second forwarding table are indicated by index values I, I+1 (or binary I+01), I+2 (or I+10), and I+3 (or I+11), respectively. After determining that the first index value is I+2, the second index value I may be obtained, and the second forwarding table may be read based on the second index value I. Simultaneously, based on the distance value 2 (or 10) between the first index value I+2 and the second index value I, the target entry space is determined to be the third entry space. It can be understood that the value of the first field in this embodiment indicates the division ratio of the entire table entry space corresponding to the second forwarding table, that is, it indicates the numerical relationship between the index values corresponding to the multiple table entry spaces obtained by division. Therefore, based on the distance value between the first index value and the second index value, the corresponding target table entry space can be determined.
[0098] Figure 5 FIG. 1 is a flow chart of a forwarding table search method when the DsMac table in the Layer 2 FDB includes a half table and a full table. The execution subject of the method shown is a switching chip. Figure 5 As shown, the method includes:
[0099] Step 301: The switching chip obtains a message to be forwarded, searches a first forwarding table based on path information, and obtains a first index value dsAdIndex.
[0100] Step 302: Read two half messages (or the entire full message) at once based on [dsAdIndex / 2]*2. That is, divide the first index value dsAdIndex by 2, round it up, and multiply by 2 to obtain the corresponding second index value [dsAdIndex / 2]*2, and read the entire second forwarding table based on the second index value.
[0101] Step 303: Analyze the isHalf field based on the read information to see if it is set to 1. In this step, determine whether the first field isHalf in the second forwarding table is 1. If isHalf is 1, it indicates that the second forwarding table is two half tables; if isHalf is 0, it indicates that the second forwarding table is one full table.
[0102] Step 304: If isHalf is set to 1, dsAdIndex%2 is determined. If dsAdIndex%2 is 1, the second half of the entry is parsed; if dsAdIndex%2 is 0, the first half of the entry is parsed. If isHalf is 0, the entire full entry is parsed. When the second forwarding table consists of two half tables, the first index value dsAdIndex is divided by 2 and the remainder is calculated to obtain the distance between the first and second index values. This is used to determine whether the target entry space is the first or second half of the entry.
[0103] Step 305: According to the analysis result, determine the egress port corresponding to the path information and edit the message to forward it.
[0104] An embodiment of the present invention also provides a forwarding table storage device. Figure 6 Schematic diagram of the structure of the forwarding table storage device according to an embodiment of the present invention Figure 1 ,like Figure 6 As shown, the forwarding table storage device 400 includes:
[0105] A first acquisition module 401 is configured to obtain forwarding table information to be stored, wherein the forwarding table information includes path information and egress information;
[0106] A first determining module 402 is configured to determine a value of a first field according to the size of the table entry space consumed by the egress information obtained by the first acquiring module 401, and determine a first index value based on the value of the first field; wherein the first field is set in a second forwarding table, the second forwarding table includes the first field, different values of the first field indicate that all table entry spaces included in the second forwarding table are divided into different proportions to obtain different table entry spaces; and the first index value points to a target table entry space included in the second forwarding table;
[0107] and a storage module 403, configured to store the path information obtained by the first acquisition module 401 and the first index value determined by the first determination module 402 into a first forwarding table, and to store the egress information obtained by the first acquisition module 401 into the target entry space.
[0108] In an optional embodiment of the present invention, the first determining module 402 includes:
[0109] The first submodule is used to determine that the first field is a first value when the table entry space required to be consumed is not greater than half of the total table entry space included in the second forwarding table; the first value indicates that the total table entry space included in the second forwarding table is divided into two equal parts; and is also used to determine that the first field is a second value when the table entry space required to be consumed is greater than half of the total table entry space included in the second forwarding table; the second value indicates that the second forwarding table is not divided.
[0110] In an optional embodiment of the present invention, the first determining module 402 is further configured to determine the size of the table entry space consumed by the egress information according to the parameter type included in the egress information obtained by the first acquiring module 401 .
[0111] In an optional embodiment of the present invention, the first determining module 402 includes:
[0112] The second submodule is used to determine that the table entry space required to be consumed by the export information is not greater than one half of the total table entry space included in the second forwarding table when the export information does not include the extended function information; and is also used to determine that the table entry space required to be consumed by the export information is greater than one half of the total table entry space included in the second forwarding table when the export information includes the extended function information.
[0113] In an optional embodiment of the present invention, the apparatus further includes a configuration module configured to configure the first field in the second forwarding table based on the value of the first field determined by the first determination module 402 .
[0114] In an embodiment of the present invention, the first acquisition module 401, the first determination module 402, the storage module 403, the configuration module and each sub-module in the device 400 can all be implemented by a central processing unit (CPU), a digital signal processor (DSP), a microcontroller unit (MCU) or a field-programmable gate array (FPGA) in the device 400 in practical applications.
[0115] It should be noted that: the forwarding table storage device that the above-described embodiment provides is only illustrated with the division of above-mentioned each program module when storing forwarding table information, and in actual application, can according to need, above-mentioned processing distribution is completed by different program modules, and the internal structure of device is divided into different program modules, to complete all or part of the processing described above. In addition, the forwarding table storage device that the above-described embodiment provides belongs to the same conception with the forwarding table storage method embodiment, and its specific implementation process is detailed in method embodiment, and will not be repeated here.
[0116] The embodiment of the present invention also provides a forwarding table search device. Figure 7 FIG. 1 is a schematic diagram showing the structure of a forwarding table search device according to an embodiment of the present invention. Figure 7 As shown, the forwarding table search device 500 includes:
[0117] A second acquisition module 501 is configured to search a first forwarding table based on the path information in the message to be forwarded to obtain a first index value; the first forwarding table includes at least one set of path information and corresponding index values;
[0118] A second determining module 502 is configured to determine a second forwarding table based on the first index value obtained by the second obtaining module 501; wherein the second forwarding table includes a first field, and different values of the first field indicate that the entire entry space included in the second forwarding table is divided into different proportions to obtain different entry spaces;
[0119] And a search module 503, which is used to determine the target table entry space included in the second forwarding table based on the value of the first field in the second forwarding table determined by the second determination module 502 and the first index value obtained by the second acquisition module 501; parse the message information stored in the target table entry space to obtain the exit information corresponding to the path information.
[0120] In an optional embodiment of the present invention, the second determination module 502 is used to determine a second index value pointing to all entry spaces included in the second forwarding table according to the first index value obtained by the second acquisition module 501; and determine the second forwarding table according to the second index value.
[0121] In an optional embodiment of the present invention, the search module 503 includes:
[0122] A third submodule, configured to determine one or more entry spaces included in the second forwarding table according to a value of the first field;
[0123] and a fourth submodule, for determining, when the second forwarding table includes only one table entry space, that the target table entry space is all the table entry spaces included in the second forwarding table; and for determining, when the second forwarding table includes multiple table entry spaces, the target table entry space in the multiple table entry spaces based on the first index value.
[0124] In an optional embodiment of the present invention, the third submodule is used to determine that the second forwarding table includes two table entry spaces when the value of the first field is a first value; the first value indicates that all table entry spaces included in the second forwarding table are divided into two equal parts; and is also used to determine that the second forwarding table includes only one table entry space when the value of the first field is a second value; the second value indicates that the second forwarding table is not divided.
[0125] In an optional embodiment of the present invention, the fourth submodule is further configured to determine the target entry space in the multiple entry spaces based on a distance value between the first index value and the second index value.
[0126] In the embodiment of the present invention, the second acquisition module 501, the second determination module 502, the search module 503 and each submodule in the apparatus 500 can be implemented by the CPU, DSP, MCU or FPGA in the apparatus 500 in practical applications.
[0127] It should be noted that: the forwarding table search device provided by the above embodiment is only illustrated by the division of the above-mentioned program modules when searching for forwarding table information. In actual application, the above-mentioned processing can be assigned to be completed by different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the forwarding table search device provided by the above embodiment and the forwarding table search method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0128] An embodiment of the present invention further provides an electronic device. Figure 8Schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. The electronic device 600 may be a switch or other switching device in network communication. Figure 8 The electronic device 600 shown includes: at least one processor 601, a memory 602 and at least one network interface 603. The various components in the electronic device 600 are coupled together via a bus system 604. It is understood that the bus system 604 is used to achieve connection and communication between these components. In addition to including a data bus, the bus system 604 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 604 is not shown in FIG. Figure 8 Various buses are labeled as bus system 604 .
[0129] It is understood that memory 602 can be volatile memory or non-volatile memory, or can include both volatile and non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disk, or compact disc read-only memory (CD-ROM); magnetic surface memory can be magnetic disk memory or tape memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memory 602 described in the embodiments of the present invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0130] The memory 602 in the embodiment of the present invention is used to store various types of data to support the operation of the electronic device 600. Examples of such data include: any computer program for operating on the electronic device 600, such as a program for implementing the forwarding table storage method and a program for implementing the forwarding table search method in the embodiment of the present invention; as well as a first forwarding table, a second forwarding table, etc.
[0131] The methods disclosed in the above embodiments of the present invention can be applied to or implemented by processor 601. Processor 601 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits in processor 601 or by software instructions. Processor 601 may be a general-purpose processor, a DSP, or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. Processor 601 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of the present invention can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules within the decoding processor. The software modules may be located in a storage medium located in memory 602. Processor 601 reads information from memory 602 and, in conjunction with its hardware, completes the steps of the above method.
[0132] In an exemplary embodiment, the electronic device 600 can be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), FPGAs, general-purpose processors, controllers, MCUs, microprocessors, or other electronic components to perform the aforementioned method.
[0133] In an exemplary embodiment, the present invention further provides a storage medium, such as a memory 602 including a computer program. The computer program can be executed by a processor 601 of an electronic device 600 to perform the steps of the aforementioned method. The storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface mount storage, optical disk, or CD-ROM; or various devices including any one or any combination of the aforementioned memories, such as a mobile phone, computer, tablet device, personal digital assistant, etc.
[0134] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0135] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0136] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0137] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0138] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0139] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0140] Those skilled in the art will appreciate that all or part of the steps of the above-mentioned method embodiments may be implemented by hardware associated with program instructions, and the aforementioned program may be stored in a computer-readable storage medium. When the program is executed, the program executes the steps of the above-mentioned method embodiments. The aforementioned storage medium includes various media that can store program codes, such as mobile storage devices, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.
[0141] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0142] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A forwarding table storage method, characterized in that: The method comprises: Obtaining forwarding table information to be stored, wherein the forwarding table information includes path information and egress information; Determining a value of a first field according to the size of the table entry space consumed by the egress information, and determining a first index value based on the value of the first field; wherein the first field is set in a second forwarding table, and different values of the first field indicate that the entire table entry space included in the second forwarding table is divided into different proportions to obtain different table entry spaces; and the first index value points to a target table entry space included in the second forwarding table; The path information and the first index value are stored in a first forwarding table, and the egress information is stored in the target table entry space.
2. The method according to claim 1, characterized in that The determining the value of the first field according to the size of the table entry space consumed by the egress information includes: When the required entry space consumed is no more than one-half of the total entry space included in the second forwarding table, determining that the first field is a first value; the first value indicates that the total entry space included in the second forwarding table is divided into two equal parts; When the table entry space required to be consumed is greater than half of the total table entry space included in the second forwarding table, the first field is determined to be a second value; the second value indicates that the second forwarding table is not to be divided.
3. The method according to claim 2, characterized in that The method further comprises: The size of the table entry space consumed by the export information is determined according to the parameter type included in the export information.
4. The method according to claim 3, characterized in that The determining, based on the parameter type included in the export information, the size of the table entry space required to be consumed by the export information includes: When the egress information does not include extended function information, determining that an entry space consumed by the egress information is no greater than one half of the total entry space included in the second forwarding table; In a case where the egress information includes the extended function information, it is determined that the entry space consumed by the egress information is greater than half of the total entry space included in the second forwarding table.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: The first field in the second forwarding table is configured based on the value of the first field.
6. A forwarding table search method, characterized in that: The method comprises: Searching a first forwarding table based on the path information in the message to be forwarded to obtain a first index value; the first forwarding table includes at least one set of path information and corresponding index values; Determining a second forwarding table according to the first index value; wherein the second forwarding table includes a first field, and different values of the first field indicate that all table entry spaces included in the second forwarding table are divided into different proportions to obtain different table entry spaces; Based on the value of the first field in the second forwarding table and the first index value, a target table entry space included in the second forwarding table is determined; and the message information stored in the target table entry space is parsed to obtain the egress information corresponding to the path information.
7. The method according to claim 6, characterized in that The determining a second forwarding table according to the first index value includes: According to the first index value, a second index value pointing to all entry spaces included in the second forwarding table is determined; and according to the second index value, the second forwarding table is determined.
8. The method according to claim 7, characterized in that The determining, based on the value of the first field in the second forwarding table and the first index value, a target entry space included in the second forwarding table includes: Determining one or more entry spaces included in the second forwarding table according to a value of the first field; When the second forwarding table includes only one table entry space, the target table entry space is determined to be all the table entry spaces included in the second forwarding table; when the second forwarding table includes multiple table entry spaces, the target table entry space is determined in the multiple table entry spaces based on the first index value.
9. The method according to claim 8, characterized in that The determining, according to the value of the first field, one or more entry spaces included in the second forwarding table includes: When the value of the first field is a first value, it is determined that the second forwarding table includes two entry spaces; the first value indicates that all entry spaces included in the second forwarding table are divided into two equal parts; When the value of the first field is the second value, it is determined that the second forwarding table includes only one entry space; the second value indicates that the second forwarding table is not to be divided.
10. The method according to claim 8 or 9, characterized in that The determining the target entry space in the plurality of entry spaces based on the first index value includes: The target entry space is determined in the plurality of entry spaces based on a distance value between the first index value and the second index value.
11. A forwarding table storage device, characterized in that: The device comprises: A first acquisition module is used to obtain forwarding table information to be stored, wherein the forwarding table information includes path information and egress information; a first determining module, configured to determine a value of a first field according to a size of an entry space consumed by the egress information obtained by the first acquiring module, and determine a first index value based on the value of the first field; wherein the first field is set in a second forwarding table, and different values of the first field indicate that all entry spaces included in the second forwarding table are divided into different proportions to obtain different entry spaces; and the first index value points to a target entry space included in the second forwarding table; and a storage module, configured to store the path information obtained by the first acquisition module and the first index value determined by the first determination module into a first forwarding table, and to store the egress information obtained by the first acquisition module into the target table entry space.
12. The device according to claim 11, characterized in that The first determining module includes: The first submodule is used to determine that the first field is a first value when the table entry space required to be consumed is not greater than half of the total table entry space included in the second forwarding table; the first value indicates that the total table entry space included in the second forwarding table is divided into two equal parts; and is also used to determine that the first field is a second value when the table entry space required to be consumed is greater than half of the total table entry space included in the second forwarding table; the second value indicates that the second forwarding table is not divided.
13. The device according to claim 12, characterized in that The first determining module is further configured to determine the size of the table entry space consumed by the egress information according to the parameter type included in the egress information obtained by the first acquiring module.
14. The device according to claim 13, characterized in that The first determining module includes: The second submodule is used to determine that the table entry space required to be consumed by the export information is not greater than one half of the total table entry space included in the second forwarding table when the export information does not include the extended function information; and is also used to determine that the table entry space required to be consumed by the export information is greater than one half of the total table entry space included in the second forwarding table when the export information includes the extended function information.
15. The device according to any one of claims 11 to 14, characterized in that The apparatus further includes a configuration module configured to configure the first field in the second forwarding table based on the value of the first field determined by the first determination module.
16. A forwarding table search device, characterized in that: The device comprises: A second acquisition module is used to search a first forwarding table based on the path information in the message to be forwarded to obtain a first index value; the first forwarding table includes at least one set of path information and corresponding index values; a second determining module, configured to determine a second forwarding table according to the first index value obtained by the second obtaining module; wherein the second forwarding table includes a first field, and different values of the first field indicate that all entry spaces included in the second forwarding table are divided into different proportions to obtain different entry spaces; and a search module for determining the target table entry space included in the second forwarding table based on the value of the first field in the second forwarding table determined by the second determination module and the first index value obtained by the second acquisition module; parsing the message information stored in the target table entry space to obtain the exit information corresponding to the path information.
17. The device according to claim 16, characterized in that The second determining module is configured to determine a second index value pointing to all entry spaces included in the second forwarding table according to the first index value obtained by the second acquiring module; and determine the second forwarding table according to the second index value.
18. The device according to claim 17, characterized in that The search module includes: A third submodule, configured to determine one or more entry spaces included in the second forwarding table according to a value of the first field; and a fourth submodule, for determining, when the second forwarding table includes only one table entry space, that the target table entry space is all the table entry spaces included in the second forwarding table; and for determining, when the second forwarding table includes multiple table entry spaces, the target table entry space in the multiple table entry spaces based on the first index value.
19. The device according to claim 18, characterized in that The third submodule is used to determine that the second forwarding table includes two table entry spaces when the value of the first field is a first value; the first value indicates that all table entry spaces included in the second forwarding table are divided into two equal parts; and is also used to determine that the second forwarding table includes only one table entry space when the value of the first field is a second value; the second value indicates that the second forwarding table is not divided.
20. The device according to claim 18 or 19, characterized in that The fourth submodule is further configured to determine the target entry space in the plurality of entry spaces based on a distance value between the first index value and the second index value.
21. An electronic device, characterized in that: include: A processor and a memory for storing a computer program that can be run on the processor, wherein when the processor is used to run the computer program, it performs the steps of the method according to any one of claims 1 to 5, or when the processor is used to run the computer program, it performs the steps of the method according to any one of claims 6 to 10.
22. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented; alternatively, when the computer program is executed by a processor, the steps of the method according to any one of claims 6 to 10 are implemented.
Citation Information
Patent Citations
Method and device for realizing rapid convergence of service path through batch operation
CN110336745A
Method for performing dynamic tunnel message forwarding and switch thereof
WO2011050644A1