Message processing method and device and storage medium
By introducing identification information into the forwarding table entry to indicate the control information type and only necessary information is saved, the problem of limited cache memory space is solved and efficient utilization of storage space is achieved.
Patent Information
- Application Number
- CN202410134995.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-30
- Publication Date
- 2025-08-01
AI Technical Summary
The cache memory space of network nodes is limited and costly, so how to save the storage space occupied by forwarded table items has become an urgent problem.
By introducing identification information into the forwarding entry to indicate the type of control information, only the control information required for processing is saved, unnecessary information is reduced, and storage space is allocated reasonably.
It effectively reduces the amount of data in forwarded table entries, saves the storage space of cache memory, and avoids waste of resources.
Smart Images

Figure CN120416152A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communications, and particularly to a method, apparatus, and storage medium for processing packets. Background Art
[0002] A network node is used to forward network traffic. The network node includes a forwarding table, the forwarding table includes multiple forwarding entries, and each forwarding entry includes control information. When the network node receives a packet of network traffic, it matches a forwarding entry in the forwarding table based on the information of the network traffic, and processes the packet based on the control information included in the forwarding entry.
[0003] For example, the following one or more processes can be performed on the packet: security control processing, filtering, classification, mirroring, operation administration and maintenance (OAM), statistics, or flow rate control, etc. The network node often receives a large amount of network traffic and needs to frequently and quickly read the forwarding entries from the forwarding table. Therefore, a cache memory can be used to store the forwarding entries included in the forwarding table. However, the space of the cache memory is limited and the cost is high. How to save the storage space occupied by the forwarding entries is an urgent problem to be solved. Summary of the Invention
[0004] This application provides a method, apparatus, and storage medium for processing packets to save the storage space occupied by the forwarding entries. The technical solutions are as follows:
[0005] In a first aspect, this application provides a method for processing packets. The method is applied to a network device. The network device includes a cache memory, and the cache memory stores a first forwarding entry. The first forwarding entry includes first identification information and at least one first control information. The at least one first control information is the information required for processing the first traffic, and the first identification information is used to indicate the type of the at least one first control information. In the method, a first packet is received, and the first packet belongs to the first traffic. The first forwarding entry stored in the cache memory is read. Based on the type indicated by the first identification information, at least one first control information in the first forwarding entry is identified. Based on the identified at least one first control information, the first packet is processed.
[0006] Since the first forwarding entry includes first identification information and at least one first control information required for processing the first traffic, when the first packet is received, at least one first control information in the first forwarding entry can be identified based on the first identification information. In this way, the first forwarding entry can include the control information required for processing the first traffic and can exclude the control information not required for processing the first traffic, thereby reducing the data volume of the first forwarding entry and the storage space occupied by the first forwarding entry in the cache memory.
[0007] In a possible implementation, at least one first control information configured by a user is received. A first forwarding entry including the first identification information and at least one first control information is generated. The first forwarding entry is stored in the cache memory. Since the first identification information is used to indicate the type of at least one first control information, the first forwarding entry can include the control information required for processing the first traffic and can exclude the control information not required for processing the first traffic, thereby reducing the data volume of the first forwarding entry.
[0008] In another possible implementation, the first identification information is used to identify a first template, and the first template is used to define the type of at least one first control information. Based on the first identification information, the first template is obtained. Based on the first template, at least one first control information in the first forwarding entry is identified. Since the first template identified by the first identification information defines the type of at least one first control information in the first forwarding entry, each first control information included in the first forwarding entry can be identified based on the first identification information.
[0009] In another possible implementation, the cache memory includes a first storage space that stores the first forwarding entry. The cache memory also stores a second forwarding entry, which is a forwarding entry for processing the first traffic. The second forwarding entry is the upper-level forwarding entry of the first forwarding entry. The second forwarding entry is associated with a first address, which is the address of the first storage space. After the first packet is processed using the second forwarding entry, the first forwarding entry is read from the cache memory based on the first address associated with the second forwarding entry.
[0010] In another possible implementation, the size of the first storage space is equal to the first gear, the data volume of the first forwarding entry is less than or equal to the first gear and greater than the second gear, and the first gear is greater than the second gear. Receive at least one second control information configured by the user, where the at least one second control information is the information required to process the first traffic. Generate a third forwarding entry including second identification information and at least one second control information, where the second identification information is used to indicate the type of the at least one second control information. If the data volume of the third forwarding entry is greater than the first gear or the data volume of the third forwarding entry is less than or equal to the second gear, apply for a second storage space in the cache memory. Save the third forwarding entry in the second storage space, and update the first address associated with the third forwarding entry to the second address of the second storage space. In this way, when modifying the first forwarding entry to obtain the third forwarding entry, if the data volume of the third forwarding entry is greater than the first gear, it means that the data volume of the third forwarding entry is greater than the capacity of the first storage space, so a second storage space is re-applied to ensure that the third forwarding entry can be saved. If the data volume of the third forwarding entry is less than or equal to the second gear, it means that the capacity of the first storage space is much larger than the data volume of the third forwarding entry, so the storage space can be allocated according to the data volume of the third forwarding entry, thereby reducing the storage space occupied by the third forwarding entry in the cache memory.
[0011] In another possible implementation, if the data volume of the third forwarding entry is greater than the second gear and less than or equal to the first gear, update the first forwarding entry saved in the first storage space to the third forwarding entry. If the data volume of the third forwarding entry is greater than the second gear and less than or equal to the first gear, it means that the capacity of the first storage space is sufficient to save the third forwarding entry, and after saving the third forwarding entry, the free space in the first storage space is also less, so that the storage space does not need to be re-applied, improving the efficiency of saving the third forwarding entry.
[0012] In another possible implementation, the first forwarding entry includes a type field and a content field, the type field includes first identification information, and the content field includes at least one first control information.
[0013] In a second aspect, the present application provides a device for processing packets, which is used to execute the method in the first aspect or any possible implementation manner of the first aspect. Specifically, the device includes units for executing the method in the first aspect or any possible implementation manner of the first aspect.
[0014] In a third aspect, the present application provides a network device, which includes a memory, a processor, and a computer program stored on the memory. When the processor executes the computer program, the network device completes the method in the first aspect or any possible implementation manner of the first aspect.
[0015] In a fourth aspect, the present application provides a computer program product, which includes a computer program stored in a computer-readable storage medium, and the computer program is loaded by a processor to implement the method according to the first aspect or any possible implementation manner of the first aspect.
[0016] In a fifth aspect, the present application provides a computer-readable storage medium for storing a computer program or instructions, and the computer program or instructions are loaded by a processor to implement the method according to the first aspect or any possible implementation manner of the first aspect.
[0017] In a sixth aspect, the present application provides a chip, which includes a memory and a processor. The memory is used for storing computer instructions, and the processor is used for calling and running the computer instructions from the memory to implement the method according to the first aspect or any possible implementation manner of the first aspect. Description of the Drawings
[0018] Figure 1 is a schematic structural diagram of a communication network provided by an embodiment of the present application;
[0019] Figure 2 is a schematic structural diagram of a network device provided by an embodiment of the present application;
[0020] Figure 3 is a schematic structural diagram of a forwarding table entry provided by an embodiment of the present application;
[0021] Figure 4 is a flowchart of a method for processing a packet provided by an embodiment of the present application;
[0022] Figure 5 is a flowchart of a method for modifying a forwarding table entry provided by an embodiment of the present application;
[0023] Figure 6 is a schematic structural diagram of a device for processing a packet provided by an embodiment of the present application;
[0024] Figure 7 is a schematic structural diagram of a network device provided by an embodiment of the present application. Detailed Embodiments
[0025] Referring to Figure 1 , an embodiment of the present application provides a communication network 100, which includes a plurality of network devices 101. For each network device 101, the network device 101 can receive a first traffic transmitted on the communication network 100 and process the first traffic.
[0026] The first traffic is any network traffic transmitted on the communication network 100, and the first traffic includes a plurality of packets.
[0027] See Figure 2 , the network device 101 includes a cache memory 1011 and a processor 1012. The cache memory 1011 stores a forwarding table, and the forwarding table includes a plurality of forwarding table entries for processing network traffic.
[0028] Thus, when the network device 101 receives a first packet, the first packet belongs to a first traffic flow. The processor 1012 of the network device 101 reads a first forwarding table entry stored in the cache memory 1011, and the first forwarding table entry is a forwarding table entry for processing the first traffic flow. The processor 1012 of the network device 101 processes the first packet based on the first forwarding table entry.
[0029] Optionally, the first forwarding table entry includes control information for processing the first traffic flow. Therefore, the network device 101 processes the first packet based on the control information included in the first forwarding table entry.
[0030] Among them, the network device 101 receives each packet of the first traffic flow and processes each received packet of the first traffic flow based on the control information included in the first forwarding table entry, thereby implementing the processing of the first traffic flow.
[0031] Optionally, the network device 101 may be a device such as an access network, a transport network, a switch, a router, or a firewall.
[0032] See Figure 3 , each forwarding table entry included in the forwarding table has a fixed structure. For each forwarding table entry included in the forwarding table, the forwarding table entry includes the following multiple pieces of information: next-hop information, single-flow control information, flow-group control information, operation administration and maintenance (OAM) information, single-flow statistics information, flow-group statistics information, mirroring indication information, access control lists (ACL) information, and security control information.
[0033] Each forwarding table entry included in the forwarding table has a fixed structure and all include the above multiple pieces of information. Therefore, the data volume of each forwarding table entry is equal. Optionally, the data volume of each forwarding table entry in the forwarding table may be 256 bits.
[0034] Among them, the next-hop information is used for forwarding control and is the control information required to implement basic forwarding control. A single flow control information is the control information required to control the transmission rate of a single flow. A flow group control information is the control information required to control the transmission rate of a group of flows. The OAM information is the control information required to perform OAM on the traffic. A single flow statistic information is the control information required to count the number of packets of a single flow. A flow group statistic information is the control information required to count the number of packets of a group of flows. The mirroring indication information is used to indicate whether to mirror the traffic. The ACL information is the control information required to filter and / or classify the traffic. The security control information is the control information required to perform security processing on the traffic.
[0035] In some embodiments, the forwarding table may include multiple levels of forwarding table entries. For example, the forwarding table may include the upper-level forwarding table entry of the first forwarding table entry and / or the lower-level forwarding table entry of the first forwarding table entry.
[0036] Assume that the forwarding table includes the upper-level forwarding table entry of the first forwarding table entry. For ease of explanation, this upper-level forwarding table entry is referred to as the second forwarding table entry. The second forwarding table entry is associated with the first address, and the first address is the address of the first storage space in the cache memory 1011 for storing the first forwarding table entry.
[0037] When the network device 101 receives the first packet, the network device 101 reads the second forwarding table entry saved in the cache memory 1011 and processes the first packet based on the second forwarding table entry. After processing the first packet based on the second forwarding table entry, the first forwarding table entry is read from the cache memory 1011 based on the first address associated with the second forwarding table entry, and the first packet is processed based on the first forwarding table entry.
[0038] In some embodiments, when the network device 101 processes the first packet, at least one required control information is selected from the control information included in the first forwarding table entry, and the first packet is processed based on the at least one control information.
[0039] However, the first forwarding table entry is a fixed structure. In addition to including at least one control information required to process the first packet, the first forwarding table entry also includes control information that is not required to process the first packet. Therefore, storing the first forwarding table entry in the cache memory wastes a large amount of storage space of the cache memory. For this reason, any of the following embodiments can be used to reduce the storage space of the forwarding table entry occupied by the cache memory.
[0040] See Figure 4 , the embodiment of the present application provides a method 400 for processing packets, and the method 400 is applied to Figure 1For the communication network 100 shown, the execution subject of the method 400 may be the network device 101 included in the communication network 100. The method 400 includes the following steps 401 to 407.
[0041] Step 401: The network device receives a first configuration request, and the first configuration request includes at least one first control information, and the at least one first control information is the information required for processing the first traffic.
[0042] In step 401, the administrator may configure the at least one first control information on the management device. The management device obtains the at least one first control information, sends a first configuration request to the network device, and the first configuration request includes the at least one first control information. The network device receives the first configuration request, thereby obtaining the at least one first control information.
[0043] The first configuration request is used to request the network device to generate a first forwarding entry including the at least one first control information.
[0044] In some embodiments, the first configuration request further includes the port number of the first port or the identification information of the second forwarding entry. The traffic that can be processed using the first forwarding entry includes the traffic received by the network device on the first port. The second forwarding entry is the upper-level forwarding entry of the first forwarding entry, and the traffic that can be processed using the first forwarding entry and the traffic that can be processed using the second forwarding entry may be the same.
[0045] In some embodiments, if the first forwarding entry requested by the first configuration request to be generated by the network device is the first-level forwarding entry in the forwarding table, the first configuration request includes the port number of the first port, and the port number of the first port is configured by the administrator on the management device.
[0046] In some embodiments, if the first forwarding entry requested by the first configuration request to be generated by the network device is a forwarding entry other than the first-level forwarding entry in the forwarding table, the first configuration request includes the identification information of the second forwarding entry.
[0047] For example, if the first forwarding entry is the second-level forwarding entry in the forwarding table, the first configuration request includes the identification information of the second forwarding entry. For another example, if the first forwarding entry is the third-level forwarding entry in the forwarding table, the first configuration request includes the identification information of the second forwarding entry.
[0048] In some embodiments, the at least one first control information includes one or more of the following information: next-hop information, single-flow control information, flow-group control information, OAM information, single-flow statistics information, flow-group statistics information, mirroring indication information, ACL information, or security control information, etc. <~
[0049] The first control information is information of a fixed size, and the network device includes the data volume of each piece of first control information. That is, the network device includes the data volume of the next-hop information, the data volume of a single flow control information, the data volume of a flow group control information, the data volume of OAM information, the data volume of a single flow statistics information, the data volume of a flow group statistics information, the data volume of a mirror indication information, the data volume of ACL information, and the data volume of security control information.
[0050] Step 402: The network device generates a first forwarding table entry, which includes first identification information and the at least one piece of first control information, and the first identification information is used to indicate the type of the at least one piece of first control information.
[0051] In some embodiments, the first forwarding table entry includes a type field and a content field. The type field includes the first identification information, and the content field includes the at least one piece of first control information.
[0052] Optionally, the first forwarding table entry may be a type length value (TLV). The Type field of the TLV includes the first identification information, and the Value field of the TLV includes the at least one piece of first control information.
[0053] In step 402, the network device generates a first template and first identification information. The first identification information is used to identify the first template, and the first template is used to define the type of the at least one piece of first control information. The network device generates a first forwarding table entry including the first identification information and the at least one piece of first control information.
[0054] In some embodiments, the first template is further used to define the combination manner of the at least one piece of first control information. Optionally, the combination manner is the order between each piece of first control information in the at least one piece of first control information.
[0055] In some embodiments, the first template includes the type identifier of each piece of first control information in the at least one piece of first control information. The order between the type identifiers of each piece of first control information included in the first template is the same as the order between each piece of first control information included in the first forwarding table entry. Thus, the first template is used to define the type and combination manner of the at least one piece of first control information.
[0056] Optionally, the type identifier of the first control information may include the name of the first control information, etc.
[0057] For example, assume that the at least one first control information includes next-hop information, single-flow control information, single-flow statistics information, and security control information. Assume that the type identifier of the next-hop information is "message1", the type identifier of the single-flow control information is "message2", the type identifier of the single-flow statistics information is "message3", and the type identifier of the security control information is "message4".
[0058] The network device generates a first template and first identification information "ID1" as shown in Table 1 below. The first identification information "ID1" is used to identify the first template shown in Table 1. Among them, the first template shown in Table 1 includes the type identifier "message1" of the next-hop information, the type identifier "message2" of the single-flow control information, the type identifier "message3" of the single-flow statistics information, and the type identifier "message4" of the security control information.
[0059] Table 1
[0060]
[0061] The network device generates a first forwarding table entry as shown in Table 2 below. The type field of the first forwarding table entry shown in Table 2 includes the first identification information "ID1", and the content field of the first forwarding table entry includes the next-hop information, the single-flow control information, the single-flow statistics information, and the security control information.
[0062] Table 2
[0063]
[0064] The order among the type identifiers of each first control information included in the first template shown in Table 1 is the same as the order among each first control information included in the first forwarding table entry shown in Table 2. Thus, the first template shown in Table 1 is used to define the type of each first control information included in the first forwarding table entry shown in Table 2 and the combination method of each first control information.
[0065] Optionally, the first template can be saved in the disk of the network device or the memory of the network device.
[0066] Step 403: The network device applies for a first storage space in the cache memory of the network device based on the data volume of the first forwarding table entry, and saves the first forwarding table entry in the first storage space.
[0067] In some embodiments, the network device includes multiple levels, the size of the first storage space is equal to the first level, the data volume of the first forwarding table entry is less than or equal to the first level and greater than the second level, the first level is greater than the second level, and the multiple levels include the first level and the second level. Optionally, the first level and the second level are two adjacent levels.
[0068] In step 403, when the network device determines that the data volume of the first forwarding table entry is greater than the second level and less than or equal to the first level, it applies for a first storage space with a size equal to the first level in the cache storage memory of the network device and saves the first forwarding table entry in the first storage space.
[0069] For example, assume that the multiple levels included in the network device are 256 bits, 128 bits, and 64 bits, and assume that the data volume of the first forwarding table entry shown in Table 2 is 120 bits. It is determined that the data volume of the first forwarding table entry is greater than 64 bits and less than 128 bits. That is, the first level is 128 bits and the second level is 64 bits. Apply for a first storage space with a size equal to 128 bits in the cache memory and save the first forwarding table entry shown in Table 2 in the first storage space.
[0070] In some embodiments, if the cache memory also stores a second forwarding table entry, and the second forwarding table entry is a higher-level forwarding table entry of the first forwarding table entry, the network device also associates the second forwarding table entry with a first address, where the first address is the address of the first storage space.
[0071] In implementation, the first configuration request includes the identification information of the second forwarding table entry. The network device determines the second forwarding table entry from the cache memory of the network device based on the identification information of the second forwarding table entry and associates the second forwarding table entry with the first address.
[0072] In some embodiments, the network device can add the first address to the second forwarding table entry to thereby associate the second forwarding table entry with the first address.
[0073] Optionally, the second forwarding table entry includes a type field and a content field. The network device adds the first address to the content field of the second forwarding table entry to associate the second forwarding table entry with the first address. In this implementation manner of associating the second forwarding table entry with the first address, the size of the storage space applied for by the network device to store the second forwarding table entry can be greater than the data volume of the second forwarding table entry, so that the storage space has sufficient storage capacity for the network device to add the first address to the content field of the second forwarding table entry.
[0074] Optionally, the network device may store the identification information of the second forwarding entry and the first address in the correspondence relationship between the identification information and the address of the forwarding entry to associate the second forwarding entry with the first address.
[0075] In some embodiments, if the first forwarding entry is the first-level forwarding entry included in the forwarding table of the network device, the first configuration request further includes the port number of the first port. The network device determines the first port based on the port number of the first port and associates the first port with the first forwarding entry.
[0076] Optionally, the network device stores the port number of the first port and the identification information of the first forwarding entry in the correspondence relationship between the port number and the identification information of the forwarding entry to associate the first port with the first forwarding entry. The identification information of the first forwarding entry is assigned after the network device generates the first forwarding entry.
[0077] Optionally, the correspondence relationship between the identification information of the forwarding entry and the address may be stored in the disk of the network device or the memory of the network device.
[0078] Optionally, the correspondence relationship between the port number and the identification information of the forwarding entry may be stored in the disk of the network device or the memory of the network device.
[0079] In some embodiments, the size of the first storage space is an integer multiple of the cacheline size of the cache memory, and the cacheline is the smallest cache unit of the cache memory. Optionally, the smallest cache unit may be a storage space of 8 bytes, 16 bytes, 32 bytes, or 64 bytes.
[0080] Assume that the size of the cacheline is 8 bytes, and the size of the first storage space is an integer multiple of 8 bytes.
[0081] The forwarding entries for processing different traffic can be stored in the cache memory of the network device according to the process of step 401-step 403 above. Then, when the network device receives traffic, the received traffic can be processed according to the process of step 404-step 407 below.
[0082] Step 404: The network device receives a first packet, and the first packet belongs to the first traffic.
[0083] The first traffic is any traffic transmitted in the communication network. The first traffic includes multiple packets, and the first packet is a packet included in the first traffic. In step 404, the network device receives the first packet of the first traffic through the first port.
[0084] Step 405: The network device reads the first forwarding entry stored in the cache memory of the network device.
[0085] In some embodiments, if the first forwarding entry is the first-level forwarding entry in the forwarding table, the first-level forwarding entry is associated with the first port, the network device obtains the identification information of the first forwarding entry associated with the first port, and based on the identification information of the first forwarding entry, reads the first forwarding entry from the cache memory of the network device.
[0086] Optionally, in implementation, the operation of obtaining the identification information of the first forwarding entry associated with the first port may be: the network device obtains the identification information of the first forwarding entry based on the port number of the first port from the port numbers and the identification information of the forwarding entries.
[0087] In some embodiments, if the first forwarding entry is a forwarding entry in the forwarding table other than the first-level forwarding entry, that is, the forwarding table includes the upper-level forwarding entry of the first forwarding entry, for the sake of convenience of description, the upper-level forwarding entry of the first forwarding entry is referred to as the second forwarding entry. After processing the first packet using the second forwarding entry, the first forwarding entry is read from the cache memory of the network device based on the first address associated with the second forwarding entry.
[0088] Optionally, the network device also needs to obtain the first address associated with the second forwarding entry. The operation of obtaining the first address may be: the content field of the second forwarding entry includes the first address, and the network device reads the first address from the content field of the second forwarding entry. Or, the network device obtains the first address based on the identification information of the second forwarding entry from the correspondence between the identification information of the forwarding entries and the addresses.
[0089] Step 406: The network device identifies at least one first control information in the first forwarding entry based on the type indicated by the first identification information.
[0090] In step 406, the network device obtains the first template identified by the first identification information based on the first identification information, and based on the type identifier of each control information included in the at least one first control information included in the first template, identifies at least one first control information in the first forwarding entry.
[0091] Since the order between the type identifiers of each first control information included in the first template is the same as the order between each first control information included in the first forwarding entry, the network device can identify each first control information from the first forwarding entry based on the type identifier of each first control information included in the first template and the data volume of each first control information.
[0092] For example, assume that the first forwarding entry is the forwarding entry shown in Table 2. The network device reads the first identification information "ID1" from the type field included in the first forwarding entry shown in Table 2, and obtains the first template shown in Table 1 based on the first identification information "ID1".
[0093] Based on the type identifiers of "message1" for the next-hop information included in the first template, "message2" for the single flow control information, "message3" for the single flow statistics information, and "message4" for the security control information, as well as the data volumes of the next-hop information, the single flow control information, the single flow statistics information, and the security control information, identify the next-hop information, the single flow control information, the single flow statistics information, and the security control information from the first forwarding entry shown in Table 2.
[0094] Step 407: The network device processes the first packet based on the identified at least one first control information.
[0095] In some embodiments, when the at least one first control information includes next-hop information, the network device performs forwarding control on the first packet based on the next-hop information.
[0096] When the at least one first control information includes single flow control information, the network device controls the transmission rate of the first packet based on the single flow control information.
[0097] When the at least one first control information includes flow group control information and the first traffic is one of a group of traffic indicated by the flow group control information, the network device controls the transmission rate of the first packet based on the flow group control information.
[0098] When the at least one first control information includes OAM information, the network device performs OAM on the first packet based on the OAM information.
[0099] When the at least one first control information includes single flow statistics information, the network device increases the number of packets included in the first traffic based on the single flow statistics information. Among them, if the first packet is the first packet received by the network device that belongs to the first traffic and at this time the number of packets included in the first traffic is 0, the network device increases the number of packets included in the first traffic to obtain the number of packets included in the first traffic as 1. If the first packet is not the first packet received by the network device that belongs to the first traffic and at this time the number of packets included in the first traffic is greater than 0, the network device adds 1 to the number of packets included in the first traffic.
[0100] When the at least one first control information includes flow group statistical information, the network device increases the number of packets included in a group of traffic based on the flow group statistical information, where the group of traffic includes a first traffic. Among them, if the first packet is the first packet received by the network device that belongs to the group of traffic, at this time the number of packets included in the group of traffic is 0, and the network device increases the number of packets included in the group of traffic to obtain that the number of packets included in the group of traffic is 1. If the first packet is not the first packet received by the network device that belongs to the group of traffic, at this time the number of packets included in the group of traffic is greater than 0, and the network device adds 1 to the number of packets included in the group of traffic.
[0101] When the at least one first control information includes mirroring indication information, the network device determines whether to mirror the first packet based on the mirroring indication information. If the first packet is to be mirrored, then the first packet is mirrored.
[0102] When the at least one first control information includes ACL information, the network device filters and / or classifies the first packet included in the first traffic based on the ACL information.
[0103] When the at least one first control information includes security control information, the network device performs security processing on the first packet based on the security control information. For example, the security control information includes a whitelist and / or a blacklist, and the network device can filter the first packet based on the whitelist and / or the blacklist.
[0104] In the embodiment of the present application, the first forwarding entry generated by the network device includes first identification information and at least one first control information. Since the first identification information is used to indicate the type of the at least one first control information, the network device can identify each first control information in the first forwarding entry based on the first indication information. The at least one first control information is the effective information required to process the first traffic, and the first forwarding entry may not include the invalid information that is not required to process the first traffic, thereby reducing the data volume of the first forwarding entry. Based on the data volume of the first forwarding entry, a first storage space is allocated in the cache memory, and it is realized that based on the data volume of the first forwarding entry, as much storage space as needed is allocated in the cache memory, thereby avoiding wasting the storage space of the cache memory and saving the storage space occupied by the first forwarding entry.
[0105] See Figure 5 In the embodiment of the present application, a method 500 for modifying a forwarding entry is provided. The method 500 is applied to Figure 1For the communication network 100 shown, the execution subject of the method 500 may be the network device 101 included in the communication network 100. The method 500 is used to modify the control information in the first forwarding table entry included in the network device 101, and includes the following steps 501 to 505.
[0106] Step 501: The network device receives a second configuration request, which includes the identification information of the first forwarding table entry and at least one second control information, and the at least one second control information is the information required for processing the first traffic.
[0107] In step 501, the administrator can configure on the management device to update at least one first control information included in the first forwarding table entry to at least one second control information. The management device obtains the at least one second control information and the identification information of the first forwarding table entry, and sends a second configuration request to the network device. The second configuration request includes the at least one second control information and the identification information of the first forwarding table entry. The network device receives the second configuration request, thereby obtaining the at least one second control information and the identification information of the first forwarding table entry.
[0108] The second configuration request is used to request the network device to update at least one first control information included in the first forwarding table entry to at least one second control information.
[0109] In some embodiments, if the first forwarding table entry requested by the second configuration request is a forwarding table entry other than the first-level forwarding table entry in the forwarding table, the second configuration request includes the identification information of the second forwarding table entry, and the second forwarding table entry is the upper-level forwarding table entry of the first forwarding table entry.
[0110] In some embodiments, the at least one second control information includes one or more of the following information: next-hop information, single-flow control information, flow-group control information, OAM information, single-flow statistics information, flow-group statistics information, mirroring indication information, ACL information, and security control information.
[0111] Step 502: The network device generates a third forwarding table entry, which includes second identification information and the at least one second control information, and the second identification information is used to indicate the type of the at least one second control information.
[0112] In some embodiments, the third forwarding table entry includes a type field and a content field. The type field includes the second identification information, and the content field includes the at least one second control information.
[0113] Optionally, the third forwarding table entry may be a TLV. The Type field of the TLV includes the second identification information, and the Value field of the TLV includes the at least one second control information.
[0114] In step 502, the network device generates a second template and second identification information. The second identification information is used to identify the second template, and the second template is used to define the types of the at least one second control information. The network device generates a third forwarding entry including the second identification information and the at least one second control information.
[0115] In some embodiments, the second template is further used to define the combination manner of the at least one second control information. Optionally, the combination manner is the order between each of the at least one second control information.
[0116] In some embodiments, the second template includes type identifiers of each of the at least one second control information, and the order between the type identifiers of each of the second control information included in the second template is the same as the order between each of the second control information included in the third forwarding entry.
[0117] For example, assume that the at least one second control information includes next-hop information, single-flow control information, single-flow statistic information, ACL information, and security control information. Assume that the type identifier of the ACL information is "message5". The network device generates the second template and the second identification information "ID2" as shown in Table 3 below. The second identification information "ID2" is used to identify the second template shown in Table 3. Among them, the second template shown in Table 3 includes the type identifier "message1" of the next-hop information, the type identifier "message2" of the single-flow control information, the type identifier "message3" of the single-flow statistic information, the type identifier "message5" of the ACL information, and the type identifier "message4" of the security control information.
[0118] Table 3
[0119]
[0120] The network device generates a third forwarding entry as shown in Table 4 below. The type field of the third forwarding entry shown in Table 4 includes the second identification information "ID2", and the content field of the third forwarding entry includes the next-hop information, the single-flow control information, the single-flow statistic information, the ACL information, and the security control information.
[0121] Table 4
[0122]
[0123] The order among the type identifiers of each second control information included in the second template shown in Table 3 is the same as the order among each second control information included in the third forwarding table entry shown in Table 4. Thus, the second template shown in Table 3 is used to define the type of each second control information included in the third forwarding table entry shown in Table 4 and the combination manner of each second control information.
[0124] Optionally, the second template can be stored in the disk of the network device or in the memory of the network device. The network device can also delete the first template.
[0125] Step 503: The network device determines the range where the data volume of the third forwarding table entry is located based on the first gear and the second gear. If the data volume of the third forwarding table entry is greater than the first gear or the data volume of the third forwarding table entry is less than or equal to the second gear, then step 504 is executed. If the data volume of the third forwarding table entry is greater than the second gear and less than or equal to the first gear, then step 505 is executed.
[0126] In step 503, based on the identification information of the first forwarding table entry, the network device obtains the size of the first storage space where the first forwarding table entry is located in the cache memory as the first gear, obtains the second gear that is adjacent to and less than the first gear, and determines the range where the data volume of the third forwarding table entry is located based on the first gear and the second gear.
[0127] For example, based on the identification information of the first forwarding table entry, the network device obtains the size of the first storage space where the first forwarding table entry is located in the cache memory as 128 bits, that is, the first gear is equal to 128 bits. The second gear that is adjacent to and less than the first gear is obtained, and the second gear is 64 bits. Assuming that the data volume of the third forwarding table entry is 140 bits, the range where the data volume of the third forwarding table entry is located is determined to be the range greater than 128 bits based on the first gear "128 bits" and the second gear "64 bits".
[0128] Step 504: The network device applies for a second storage space in the cache memory of the network device based on the data volume of the third forwarding table entry, stores the third forwarding table entry in the second storage space, and ends.
[0129] In some embodiments, the network device includes multiple gears. The size of the third storage space is equal to the third gear. The data volume of the third forwarding table entry is less than or equal to the third gear and the data volume of the third forwarding table entry is greater than the fourth gear. The third gear is greater than the fourth gear. The multiple gears include the third gear and the fourth gear. Optionally, the third gear and the fourth gear are two adjacent gears.
[0130] In step 504, when the network device determines that the data volume of the third forwarding entry is greater than the fourth gear and less than or equal to the third gear, the network device applies for a second storage space with a size equal to the third gear in the cache storage memory of the network device, and saves the third forwarding entry in the second storage space.
[0131] For example, the data volume of the third forwarding entry shown in Table 4 is 140 bits. It is determined that the data volume of the third forwarding entry is greater than 128 bits and less than 256 bits. That is to say, the third gear is 256 bits, and the fourth gear is 128 bits. Apply for a second storage space with a size equal to 256 bits in the cache memory, and save the third forwarding entry shown in Table 4 in the second storage space.
[0132] In some embodiments, if the cache memory also stores a second forwarding entry, and the second forwarding entry is a higher-level forwarding entry of the first forwarding entry, the network device also updates the first address associated with the second forwarding entry to a second address, where the second address is the address of the second storage space.
[0133] In implementation, the second configuration request includes the identification information of the first forwarding entry. The network device obtains the first address of the first storage space for storing the first forwarding entry based on the identification information of the first forwarding entry. Based on the first address, the second forwarding entry is determined from the cache memory of the network device, and the first address associated with the second forwarding entry is updated to the second address.
[0134] In some embodiments, the second forwarding entry includes a first address. The network device can query the second forwarding entry including the first address from the cache memory, and then the network device updates the first address included in the second forwarding entry to the second address.
[0135] Optionally, the second forwarding entry includes a type field and a content field. The network device updates the first address included in the content field of the second forwarding entry to the second address.
[0136] Optionally, the network device can obtain the identification information of the second forwarding entry based on the first address in the correspondence between the identification information of the forwarding entry and the address, and update the first address corresponding to the identification information of the second forwarding entry to the second address in the correspondence between the identification information of the forwarding entry and the address.
[0137] In some embodiments, the network device can also clear the content stored in the first storage space included in the cache memory.
[0138] Among them, if the data volume of the third forwarding entry is greater than the first gear, it means that the data volume of the third forwarding entry is greater than the capacity of the first storage space. Therefore, a second storage space is re-applied to ensure that the third forwarding entry can be saved. If the data volume of the third forwarding entry is less than or equal to the second gear, it means that the capacity of the first storage space is much larger than the data volume of the third forwarding entry. Therefore, the storage space can be allocated according to the data volume of the third forwarding entry, so as to reduce the storage space occupied by the third forwarding entry in the cache memory.
[0139] Step 505: The network device updates the first forwarding entry saved in the first storage space to the third forwarding entry.
[0140] If the data volume of the third forwarding entry is greater than the second gear and less than or equal to the first gear, it means that the size of the first storage space is greater than or equal to the data volume of the third forwarding entry, and the first storage space can be used to save the third forwarding entry.
[0141] Among them, if the data volume of the third forwarding entry is greater than the second gear and less than or equal to the first gear, it means that the capacity of the first storage space is sufficient to save the third forwarding entry, and after saving the third forwarding entry, the free space in the first storage space is also less. Therefore, the storage space does not need to be re-applied, and the efficiency of saving the third forwarding entry is improved.
[0142] In the embodiment of the present application, the third forwarding entry generated by the network device includes second identification information and at least one second control information. If the data volume of the third forwarding entry is greater than the first gear or the data volume of the third forwarding entry is less than or equal to the second gear, a second storage space is applied in the cache memory. The third forwarding entry is saved in the second storage space, and the first address associated with the third forwarding entry is updated to the second address of the second storage space. To implement based on the data volume of the third forwarding entry, the storage space as large as needed is applied in the cache memory, so as to avoid wasting the storage space of the cache memory and save the storage space occupied by the third forwarding entry. If the data volume of the third forwarding entry is greater than the second gear and less than or equal to the first gear, the first forwarding entry saved in the first storage space is updated to the third forwarding entry. Therefore, there is no need to re-apply for storage space, and the implementation complexity of modifying the first forwarding entry to the third forwarding entry is simplified.
[0143] See Figure 6 In the embodiment of the present application, a device 600 for processing packets is provided. The device 600 can be deployed on Figure 1 the network device in the communication network shown, or can be deployed on Figure 4 the network device of the method 400 shown, or can be deployed on Figure 5on the network device of the method 500 shown. The device 600 includes a cache memory, and the cache memory stores a first forwarding table entry. The first forwarding table entry includes first identification information and at least one first control information. The at least one first control information is the information required to process the first traffic, and the first identification information is used to indicate the type of the at least one first control information. The device 600 includes:
[0144] a receiving unit 601, configured to receive a first packet, where the first packet belongs to the first traffic;
[0145] a processing unit 602, configured to read the first forwarding table entry stored in the cache memory;
[0146] The processing unit 602 is further configured to identify at least one first control information in the first forwarding table entry based on the type indicated by the first identification information;
[0147] The processing unit 602 is further configured to process the first packet based on the at least one first control information identified.
[0148] Optionally, for the detailed implementation process of the receiving unit 601 receiving the first packet, refer to Figure 4 the relevant content of step 404 of the method 400 shown, which will not be elaborated here.
[0149] Optionally, for the detailed implementation process of the processing unit 602 reading the first forwarding table entry, refer to Figure 4 the relevant content of step 405 of the method 400 shown, which will not be elaborated here.
[0150] Optionally, for the detailed implementation process of the processing unit 602 identifying at least one first control information in the first forwarding table entry, refer to Figure 4 the relevant content of step 406 of the method 400 shown, which will not be elaborated here.
[0151] Optionally, for the detailed implementation process of the processing unit 602 processing the first packet based on the at least one first control information identified, refer to Figure 4 the relevant content of step 407 of the method 400 shown, which will not be elaborated here.
[0152] [[ID=�5]]Optionally, the receiving unit 601 is further configured to receive at least one first control information configured by a user;
[0153] The processing unit 602 is further configured to generate a first forwarding table entry including the first identification information and at least one first control information;
[0154] The processing unit 602 is further configured to store the first forwarding table entry in the cache memory.
[0155] Optionally, for the detailed implementation process of the receiving unit 601 receiving at least one piece of first control information configured by the user, refer to Figure 4 the relevant content of step 401 of the method 400 shown in
[0156] Optionally, for the detailed implementation process of the processing unit 602 generating the first forwarding entry, refer to Figure 4 the relevant content of step 402 of the method 400 shown in
[0157] Optionally, for the detailed implementation process of the processing unit 602 storing the first forwarding entry in the cache memory, refer to Figure 4 the relevant content of step 403 of the method 400 shown in
[0158] Optionally, the first identification information is used to identify the first template, and the first template is used to define the type of at least one piece of first control information;
[0159] The processing unit 602 is configured to:
[0160] Obtain the first template based on the first identification information;
[0161] Identify at least one piece of first control information in the first forwarding entry based on the first template.
[0162] Optionally, for the detailed implementation process of the processing unit 602 obtaining the first template based on the first identification information, refer to Figure 4 the relevant content of step 406 of the method 400 shown in
[0163] Optionally, for the detailed implementation process of the processing unit 602 identifying at least one piece of first control information in the first forwarding entry based on the first template, refer to Figure 4 the relevant content of step 406 of the method 400 shown in
[0164] Optionally, the cache memory includes a first storage space, the first storage space stores the first forwarding entry, the cache memory also stores a second forwarding entry, the second forwarding entry is the forwarding entry for processing the first traffic, the second forwarding entry is the upper-level forwarding entry of the first forwarding entry, the second forwarding entry is associated with the first address, and the first address is the address of the first storage space;
[0165] The processing unit 602 is configured to, after processing the first packet using the second forwarding entry, read the first forwarding entry from the cache memory based on the first address associated with the second forwarding entry.
[0166] Optionally, the processing unit 602 reads from the cache memory based on the first address associated with the second forwarding table entry. The detailed implementation process of the first forwarding table entry refers to Figure 4 the relevant content of step 405 of the method 400 shown, which will not be elaborated here.
[0167] Optionally, the size of the first storage space is equal to the first gear, the data volume of the first forwarding table entry is less than or equal to the first gear and greater than the second gear, and the first gear is greater than the second gear;
[0168] The receiving unit 601 is further configured to receive at least one second control information configured by the user, and the at least one second control information is the information required for processing the first traffic;
[0169] The processing unit 602 is further configured to generate a third forwarding table entry including second identification information and at least one second control information, where the second identification information is used to indicate the type of the at least one second control information;
[0170] The processing unit 602 is further configured to, if the data volume of the third forwarding table entry is greater than the first gear or the data volume of the third forwarding table entry is less than or equal to the second gear, apply for a second storage space in the cache memory;
[0171] The processing unit 602 is further configured to store the third forwarding table entry in the second storage space and update the first address associated with the third forwarding table entry to the second address of the second storage space.
[0172] Optionally, the detailed implementation process of the receiving unit 601 receiving at least one second control information configured by the user refers to Figure 5 the relevant content of step 501 of the method 500 shown, which will not be elaborated here.
[0173] Optionally, the detailed implementation process of the processing unit 602 generating the third forwarding table entry refers to Figure 5 the relevant content of step 502 of the method 500 shown, which will not be elaborated here.
[0174] Optionally, the detailed implementation process of the processing unit 602 applying for a second storage space in the cache memory refers to Figure 5 the relevant content of step 504 of the method 500 shown, which will not be elaborated here.
[0175] Optionally, the detailed implementation process of the processing unit 602 storing the third forwarding table entry in the second storage space and updating the first address associated with the third forwarding table entry to the second address of the second storage space refers to Figure 5 the relevant content of step 504 of the method 500 shown, which will not be elaborated here.
[0176] Optionally, the processing unit 602 is further configured to update the first forwarding entry stored in the first storage space to the third forwarding entry if the data volume of the third forwarding entry is greater than the second gear and less than or equal to the first gear.
[0177] Optionally, for the detailed implementation process of the processing unit 602 to update the first forwarding entry stored in the first storage space to the third forwarding entry, refer to Figure 5 the relevant content of step 505 of the method 500 shown in the figure, which will not be elaborated here.
[0178] Optionally, the first forwarding entry includes a type field and a content field. The type field includes first identification information, and the content field includes at least one first control information.
[0179] In the embodiments of the present application, the receiving unit receives a first message, and the first message belongs to a first traffic flow. The processing unit reads the first forwarding entry stored in the cache memory. Based on the type indicated by the first identification information, at least one first control information in the first forwarding entry is identified. Based on the identified at least one first control information, the first message is processed. Since the first forwarding entry includes the first identification information and at least one first control information required for processing the first traffic flow, when the receiving unit receives the first message, the processing unit can identify at least one first control information in the first forwarding entry based on the first identification information. In this way, the first forwarding entry can include the control information required for processing the first traffic flow and may not include the control information not required for processing the first traffic flow, thereby reducing the data volume of the first forwarding entry and reducing the storage space occupied by the first forwarding entry in the cache memory.
[0180] Refer to Figure 7 , the embodiments of the present application provide a schematic diagram of a network device 700. The network device 700 may be the network device provided in any of the above embodiments. For example, the network device 700 may be the network device in the communication network 100 as shown in Figure 1 the figure, or may be the network device in the method 400 as shown in Figure 4 the figure, or may be the network device in the method 500 as shown in Figure 5 the figure. The network device 700 includes at least one processor 701, an internal connection 702, a memory 703, and at least one communication interface 704.
[0181] The network device 700 is a hardware-structured device.
[0182] In some embodiments, the network device 700 may be used to implement Figure 6 the functional modules in the device 600 described above. For example, those skilled in the art can think of Figure 6The processing unit 602 in the illustrated apparatus 600 can be implemented by the at least one processor 701 invoking code in the memory 703. Figure 6 The receiving unit 601 in the illustrated apparatus 600 can be implemented by the at least one communication interface 704. The device 700 can also be used to implement the functions of the network device in any of the above embodiments.
[0183] The above-mentioned processor 701 is, for example, a general-purpose central processing unit (CPU), a digital signal processor (DSP), a network processor (NP), a graphics processing unit (GPU), a neural-network processing unit (NPU), a data processing unit (DPU), a microprocessor, or one or more integrated circuits for implementing the solution of this application. For example, the processor 701 includes an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. The PLD is, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. It can implement or execute various logic blocks, modules, and circuits described in connection with the disclosure of the embodiments of this application. The processor can also be a combination for implementing computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and so on.
[0184] The above-mentioned internal connection 702 can include a path for transmitting information between the above-mentioned components. The internal connection 702 can be a single board or a bus, etc. The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7It is represented only by a thick line, but it does not mean that there is only one bus or one type of bus.
[0185] The above-mentioned at least one communication interface 704 uses any device such as a transceiver for communicating with other devices or communication networks, and the communication network can be an Ethernet, a radio access network, or a wireless local area network (WLAN), etc. The communication interface 704 can include a wired communication interface and can also include a wireless communication interface. Specifically, the communication interface 704 can be an Ethernet interface, a Fast Ethernet (FE) interface, a Gigabit Ethernet (GE) interface, an Asynchronous Transfer Mode (ATM) interface, a wireless local area network WLAN interface, a cellular network communication interface, or a combination thereof. The Ethernet interface can be an optical interface, an electrical interface, or a combination thereof. In the embodiment of the present application, the communication interface 704 can be used for the device 700 to communicate with other devices.
[0186] The above-mentioned memory 703 can be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or can also be an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM), or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory can exist independently and be connected to the processor through a bus. The memory 703 can also be integrated with the processor 701.
[0187] In a specific implementation, as an embodiment, the processor 701 can include one or more CPUs, such as Figure 7 CPU0 and CPU1 in. Each of these CPUs can be a single-core processor or a multi-core processor. Here, the processor can refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).
[0188] In a specific implementation, as an example, the device 700 may include multiple processors, such as Figure 7 the processor 701 and the processor 707 in
[0189] Those of ordinary skill in the art can understand that all or part of the steps to implement the above embodiments can be completed by hardware, or can be completed by instructing relevant hardware through a program. The program can be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a magnetic disk, an optical disc, etc.
[0190] The above are only optional embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for processing a message, characterized in that, The method is applied to a network device, which includes a cache memory that stores a first forwarding entry. The first forwarding entry includes first identification information and at least one first control information, where the at least one first control information is the information required for processing a first traffic flow, and the first identification information is used to indicate the type of the at least one first control information, including: Receiving a first packet that belongs to the first traffic flow; Reading the first forwarding entry stored in the cache memory; Identifying the at least one first control information in the first forwarding entry based on the type indicated by the first identification information; Processing the first packet based on the identified at least one first control information.
2. The method according to claim 1, characterized in that The method further includes: Receiving the at least one first control information configured by a user; Generating the first forwarding entry including the first identification information and the at least one first control information; Storing the first forwarding entry in the cache memory.
3. The method according to claim 1 or 2, characterized in that, The first identification information is used to identify a first template, and the first template is used to define the type of the at least one first control information; The identifying the at least one first control information in the first forwarding entry based on the type indicated by the first identification information includes: Obtaining the first template based on the first identification information; Identifying the at least one first control information in the first forwarding entry based on the first template.
4. The method according to any one of claims 1 to 3, characterized in that, The cache memory includes a first storage space that stores the first forwarding entry. The cache memory also stores a second forwarding entry, which is a forwarding entry for processing the first traffic flow and is the upper-level forwarding entry of the first forwarding entry. The second forwarding entry is associated with a first address, which is the address of the first storage space; The reading the first forwarding entry stored in the cache memory includes: After processing the first packet using the second forwarding entry, reading the first forwarding entry from the cache memory based on the first address associated with the second forwarding entry.
5. The method according to claim 4, wherein The size of the first storage space is equal to a first gear. The data volume of the first forwarding entry is less than or equal to the first gear and greater than a second gear, where the first gear is greater than the second gear. The method further includes: Receiving at least one second control information configured by a user, where the at least one second control information is the information required for processing the first traffic flow; Generating a third forwarding entry including second identification information and the at least one second control information, where the second identification information is used to indicate the type of the at least one second control information; If the data volume of the third forwarding entry is greater than the first gear or the data volume of the third forwarding entry is less than or equal to the second gear, applying for a second storage space in the cache memory; Storing the third forwarding entry in the second storage space and updating the first address associated with the third forwarding entry to a second address of the second storage space.
6. The method according to claim 5, wherein The method further includes: If the data volume of the third forwarding entry is greater than the second gear and less than or equal to the first gear, updating the first forwarding entry saved in the first storage space to the third forwarding entry.
7. The method according to any one of claims 1-6, characterized in that, The first forwarding entry includes a type field and a content field. The type field includes the first identification information, and the content field includes the at least one first control information.
8. A device for processing a message, characterized in that, The apparatus includes a cache memory, which stores a first forwarding entry. The first forwarding entry includes first identification information and at least one first control information. The at least one first control information is information required to process the first traffic. The first identification information is used to indicate the type of the at least one first control information. The apparatus includes: a receiving unit, configured to receive a first packet, where the first packet belongs to the first traffic; a processing unit, configured to read the first forwarding entry stored in the cache memory; The processing unit is further configured to identify the at least one first control information in the first forwarding entry based on the type indicated by the first identification information; The processing unit is further configured to process the first packet based on the identified at least one first control information.
9. The apparatus according to claim 8, wherein: The receiving unit is further configured to receive the at least one first control information configured by a user; The processing unit is further configured to generate the first forwarding entry including the first identification information and the at least one first control information; The processing unit is further configured to store the first forwarding entry in the cache memory.
10. The device according to claim 8 or 9, characterized in that, The first identification information is used to identify a first template, and the first template is used to define the type of the at least one first control information; The processing unit is configured to: obtain the first template based on the first identification information; identify the at least one first control information in the first forwarding entry based on the first template.
11. The device according to any one of claims 8-10, characterized in that, The cache memory includes a first storage space, which stores the first forwarding entry. The cache memory further stores a second forwarding entry, which is a forwarding entry for processing the first traffic. The second forwarding entry is a higher-level forwarding entry of the first forwarding entry. The second forwarding entry is associated with a first address, and the first address is the address of the first storage space; The processing unit is configured to, after processing the first packet using the second forwarding entry, read the first forwarding entry from the cache memory based on the first address associated with the second forwarding entry.
12. The device according to claim 11, characterized in that, The size of the first storage space is equal to a first gear. The data volume of the first forwarding entry is less than or equal to the first gear and greater than a second gear, and the first gear is greater than the second gear; The receiving unit is further configured to receive at least one second control information configured by a user, where the at least one second control information is information required to process the first traffic; The processing unit is further configured to generate a third forwarding entry including second identification information and the at least one second control information, where the second identification information is used to indicate the type of the at least one second control information; The processing unit is further configured to, if the data volume of the third forwarding entry is greater than the first gear or the data volume of the third forwarding entry is less than or equal to the second gear, apply for a second storage space in the cache memory; The processing unit is further configured to store the third forwarding entry in the second storage space, and update the first address associated with the third forwarding entry to a second address of the second storage space.
13. The apparatus according to claim 12, wherein The processing unit is further configured to, if the data volume of the third forwarding entry is greater than the second gear and less than or equal to the first gear, update the first forwarding entry stored in the first storage space to the third forwarding entry.
14. The device according to any one of claims 8-13, characterized in that, The first forwarding entry includes a type field and a content field, the type field includes the first identification information, and the content field includes the at least one first control information.
15. A network device, characterized in that, The network device includes a memory, a processor, and a computer program stored on the memory. When the processor executes the computer program, the network device implements the method according to any one of claims 1-7.
16. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instruction is executed by the processor, the method according to any one of claims 1-7 is implemented.
17. A computer program product having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the method according to any one of claims 1-7 is implemented.