Flow table processing method and related device, electronic device, medium and program product
By merging the flow table entries, the problem of excessive use of Conntrack connection status flow table in OVS is solved, and efficient network data forwarding is achieved in cloud computing networks.
Patent Information
- Application Number
- CN202210646690.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-28
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2042-01-28
AI Technical Summary
OVS's Conntrack connection status flow table has multiple flow table entries in the cloud computing network, resulting in excessive hardware resources, making it difficult to efficiently forward network data in the cloud computing network.
通过判断流表是否为待合并流表,查询并保存上级流表,合并流表项以减少资源占用,提升查询效率。
In the case of multi-level flow tables, merge the flow table entries to reduce resource usage, improve flow table query efficiency, and reduce hardware resource overhead.
Smart Images

Figure CN114884858B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electrical digital data processing in the new generation information technology industry, and in particular to a flow table processing method and related devices, electronic equipment, media and program products. Background Art
[0002] The virtual switch OpenVSwitch (OVS for short) is a high-quality virtual switch that supports multi-layer data forwarding. It is mainly deployed on servers. Compared with traditional switches, it has good programming scalability. It also has the network isolation and data forwarding functions implemented by traditional switches. It runs on each physical machine that implements virtualization and provides remote management. OVS provides two protocols for remote management in a virtualized environment: one is the network communication protocol (OpenFlow protocol), which manages the behavior of the switch through the flow table, and the other is the Open vSwitchDatabase Management Protocol (OVSDB management protocol), which is used to expose the port status of the switch. However, because the design of OVS itself requires soft interrupts, hard interrupts, and switching between kernel space and user space to complete the transmission of network data; on the other hand, OVS data forwarding is implemented in the system kernel space, and like other tasks, it occupies the time slice of the central processing unit (CPU) instead of the entire CPU resource. In this way, there is a possibility of resource preemption, and it cannot be guaranteed that resources will be occupied when network data needs to be forwarded. In order to improve its forwarding performance, it is necessary to offload its network forwarding to a dedicated forwarding chip.
[0003] Connection tracking Conntrack is a mechanism for discovering and tracking connection status for stream forwarding provided by the Netfilter subsystem framework of the Linux operating system. What connection tracking does is to discover and track the status of these connections, including: (1) extracting tuple information from data packets to identify data flows and corresponding connections; (2) maintaining a status database (conntrack table) for all connections, such as the creation time of the connection, the number of packets sent, the number of bytes sent, etc.; (3) recycling expired connections (GC); (4) providing services for higher-level functions (such as NAT).
[0004] OVS, combined with Conntrack, provides support for applications based on bidirectional traffic state forwarding control in cloud computing networks. It establishes state security groups, external Internet protocol (External IP), distributed layer 4 load balancing, network address translation (NAT) and other business applications through flow table orchestration and bidirectional connection. However, the flow table of OVS's Conntrack connection state usually has multiple flow table entries. Since hardware resources are very precious and costly, if all flow table entries are sent to the hardware, a lot of resources will be occupied. Therefore, how to reduce the resource usage of the flow table is a problem that needs to be solved. Summary of the invention
[0005] The embodiments of the present application provide a method for processing a flow table and related devices, electronic devices, media, and program products, which can reduce the resources occupied by the flow table when there are multiple levels of flow tables.
[0006] In a first aspect, an embodiment of the present application provides a method for flow table processing, including:
[0007] receiving a flow table, wherein the flow table includes a plurality of flow table entries;
[0008] According to the flow table entry, determining whether the flow table is a flow table to be merged;
[0009] In the case where the flow table is a flow table to be merged, querying and saving one or more upper-level flow tables of the flow table to be merged in the total flow table to a pending list, wherein the total flow table includes received flow tables that have not yet been processed;
[0010] The preset flow table entries of each flow table in the to-be-processed list are merged to obtain a merged flow table.
[0011] In a second aspect, an embodiment of the present application provides a flow table processing device, including:
[0012] A receiving module, used for receiving a flow table, wherein the flow table includes a plurality of flow table entries;
[0013] A processing module is used to determine whether the flow table is a flow table to be merged based on the flow table item; when the flow table is a flow table to be merged, query and save one or more upper-level flow tables of the flow table to be merged in the total flow table to a pending list, wherein the total flow table includes received flow tables that have not yet been processed; and merge the preset flow table items of each flow table in the pending list to obtain a merged flow table.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the processor and the memory are interconnected, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the method described in the first aspect.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method described in the first aspect.
[0016] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer is operable to cause the computer to execute the method described in the first aspect.
[0017] By implementing the embodiments of the present application, when there are multiple levels of flow tables, it is possible to determine whether a flow table is a flow table to be merged based on the flow table entries, and obtain a merged flow table by merging the flow tables to be merged, thereby reducing the resources occupied by the flow tables and improving the efficiency of flow table queries. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 A flowchart of a method for flow table processing provided in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of the composition of a flow table processing device provided in an embodiment of the present application;
[0021] Figure 3 A schematic diagram of the composition of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] The technical solutions in the embodiments of the present application are clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0023] The terms "first" and "second" in the specification and drawings of this application are used to distinguish different objects, or to distinguish different treatments of the same object, rather than to describe a specific order of objects. In addition, the terms "including" and "having" and any variations thereof mentioned in the description of this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes other steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0024] It should be noted that, in the embodiments of the present application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design method described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being better or more advantageous than other embodiments or design schemes. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a concrete way. In the embodiments of the present application, "A and / or B" means A and B, A or B. "A, and / or B, and / or C" means any one of A, B, C, or any two of A, B, C, or A and B and C.
[0025] Next, combine Figure 1 The flow table processing method provided in the embodiment of the present application is described in detail.
[0026] See also Figure 1 , which is a flow chart of a flow table processing method provided in an embodiment of the present application, may include the following steps S101 to S104:
[0027] Step S101: Receive a flow table, where the flow table includes multiple flow table entries.
[0028] A flow table is a forwarding table (ForwardingTable) that is used as the basis for flow forwarding. Each flow table is composed of multiple flow entries (FlowEntry), and each flow table corresponds to a flow of network transmission. A flow refers to a series of messages (data packets) with the same attributes that are sent sequentially through the same network over a period of time. A flow entry is the smallest unit of a flow table. A flow entry is used to represent various information of the flow corresponding to the flow table, such as input port number, source address, destination address, data packet type, executable actions, etc. Among them, the flow table is uninstalled from the traffic control tool (TrafficControl, referred to as TC) in the Linux operating system.
[0029] Step S102: judging whether the flow table is a flow table to be merged according to the flow table entry.
[0030] In a possible implementation, the method for determining whether the flow table is a flow table to be merged may include the following steps A1 to A3:
[0031] Step A1: judging whether the flow table is a flow table for which tracking has been established according to the first flow table entry in the flow table entry.
[0032] Among them, the first flow table entry can be the ct_state field of the flow table. ct_state is used to indicate the connection status, and possible values (flags) include new, est, rel, rpl, inv and trk. new indicates that the data packet comes from a new connection. est indicates that the data packet comes from an established connection. rel indicates that the data packet is associated with an existing connection. rpl indicates that the data packet comes from the reply direction of a connection. inv indicates that the state of the data packet is invalid and the conntrack module did not correctly identify the data packet. trk indicates that the data packet has been processed by the conntrack module. These flags need to be used in combination with "+" or "-", "+" means that it must match, and "-" means that it must not match. Multiple flags can be specified at the same time, for example, ct_state=+new+trk. The method for judging whether the flow table is a flow table for which tracking has been established according to ct_state is to judge whether the flag of ct_state contains "+new". If the flag of ct_state includes "+new", it is determined that the flow table is not a flow table for which tracking has been established; if the flag of ct_state does not include "+new", it is determined that the flow table is a flow table for which tracking has been established.
[0033] In a possible implementation manner, when the flow table is a flow table for which tracking has been established, the fourth flow table entry in the flow table is extracted, and a callback function is registered with the kernel.
[0034] Among them, the fourth flow table entry can be the ct_zone field of the flow table. Ct_zone is used to isolate connection tracking entries and can be set by the parameter zone of the ct action. Action is used to indicate the action that the data packet needs to perform. In the embodiment of the present application, the kernel refers to the Linux kernel unless otherwise specified. The operating system is a low-level support software used to deal with hardware and provide a limited set of services for user programs. A computer system is a symbiosis of hardware and software, which are interdependent and inseparable. The hardware of the computer, including peripherals, processors, memory, hard disks and other electronic devices, constitutes the engine of the computer. But without software to operate and control it, it cannot work by itself. The software that completes this control work is called an operating system, which is called a "kernel" in Linux terminology, or "core". The main modules (or components) of the Linux kernel are divided into the following parts: storage management, CPU and process management, file system, device management and driver, network communication, as well as system initialization (boot), system calls, etc.
[0035] A callback function refers to a function that is passed as a parameter. In other words, a callback function is a function called by another function. The callback functions registered with the kernel include but are not limited to callback functions for connection tracking establishment events, update events, and deletion events. Therefore, when a data packet triggers a flow table to generate events such as creation and deletion, the changed flow table can be synchronized and updated to the flow table stored in the total flow table in a timely manner. This allows for querying the connection information in the flow table and extracting the action in the flow table when the flow table is subsequently unloaded. The total flow table includes the flow tables that have been received and unloaded from the TC but have not yet been processed.
[0036] Step A2: When the flow table is a flow table for which tracking has been established, determine whether the flow table is a header flow table based on the second flow table entry in the flow table entry, and determine whether the flow table has a lower-level flow table based on the third flow table entry in the flow table entry.
[0037] The second flow table item may be the recirc_id field of the flow table. recirc_id is a flow identifier. When recirc_id=0, it indicates that the flow table is the first-level flow table of the data packet corresponding to the flow table. There may be second-level flow tables, third-level flow tables, etc. The recirc_id of the second-level flow table and the third-level flow table is not 0. Therefore, it can be determined whether the flow table is a header flow table (first-level flow table) by whether the value of recirc_id is 0.
[0038] Among them, the third flow table item can be the action field of the flow table. If the action field includes an action submitted to the next level flow table (for example, the gotorecirc_id action), that is to say, the flow table is connected to another flow table through the gotorecirc_id action, and the other flow table connected to the flow table is the next level flow table of the flow table. Therefore, it can be known that if the action field contains the gotorecirc_id action, it can be judged that the flow table is not a tail flow table (the last level flow table without a lower level flow table), and the flow table has a lower level flow table.
[0039] Step A3: If the flow table is not a header flow table and there is no lower-level flow table, the flow table is a flow table to be merged.
[0040] If the recirc_id of the flow table is not equal to 0, and there is no recirc action in the Action of the flow table, then the flow table is a flow table to be merged. It can be understood that the flow table to be merged is the tail flow table in the multi-level flow table corresponding to the flow.
[0041] By judging the first flow table entry, the second flow table entry and the third flow table entry, a flow table to be merged that meets the conditions can be found, so that other flow tables with the same flow as that represented by the flow table to be merged can be found and integrated according to the flow table to be merged.
[0042] In a possible implementation, when the flow table has a subordinate flow table, the flow table is marked as pending; the second flow table entry of the subordinate flow table of the flow table is recorded on the flow table to find the subordinate flow table of the flow table; and the flow table is saved in the total flow table.
[0043] In the case where a flow table has a subordinate flow table, that is to say, the action field of the flow table includes the gotorecirc_id action. In this case, the flow table is marked with a pending flag to indicate that the flow table is not the flow table to be merged that is currently needed, but the flow table may need to be processed in the subsequent processing. The value of the recirc_id of the subordinate flow table of the flow table is recorded on the flow table, so that the subordinate flow table can be found through the gotorecirc_id action in the flow table. Since the flow table has a subordinate flow table, the flow table does not belong to the flow table to be merged that needs to be found and processed at present, but the flow table may need to be processed later, so the flow table is saved in the total flow table for subsequent search and processing.
[0044] In one possible implementation, when the flow table is a header flow table and there is no lower-level flow table, determine whether the flow table exists in a lower-level table, the lower-level table includes a flow table sent to a forwarding chip; when the flow table does not exist in the lower-level table, send the flow table to the forwarding chip; save the flow table to the lower-level table and the total flow table.
[0045] When the flow table is both a header flow table and there is no lower-level flow table, it means that the flow table is an independent flow table, that is, the flow table contains all the flow table information of the corresponding flow, and there is no need to integrate or connect with other flow tables. In this case, check whether the table exists in the lower table. The lower table includes flow tables that have been sent to the forwarding chip. Therefore, if the flow table can be found in the lower table, it means that the flow table has been sent to the forwarding chip, then there is no need to process the flow table, and the execution of this process can be terminated directly. If the flow table cannot be found in the lower table, it means that the flow table has not been sent to the forwarding chip, then the flow table can be sent to the forwarding chip, and the flow table can be saved in the lower table and the total flow table.
[0046] Step S103: When the flow table is a flow table to be merged, query and save one or more upper-level flow tables of the flow table to be merged in the total flow table to a pending list, wherein the total flow table includes received flow tables that have not been processed.
[0047] The method for querying one or more upper-level flow tables of the flow table to be merged in the total flow table includes: searching the flow table whose gotorecirc_id value is the recirc_id value of the flow table to be merged in the total flow table, and the flow table found in the total flow table is the upper-level flow table of the flow table to be merged. After adding the upper-level flow table of the flow table to be merged to the list to be processed, if the value of recirc_id of the upper-level flow table of the flow table to be merged is not 0, then continue to search the total flow table for the flow table whose gotorecirc_id value is the recirc_id value of the upper-level flow table of the flow table to be merged, and the flow table found in the total flow table this time is the upper-level flow table of the upper-level flow table of the flow table to be merged (also belongs to the upper-level flow table of the flow table to be merged), and similarly, save the flow table to the list to be processed. Determine again whether the recirc_id of the flow table is 0. If not, continue to repeat the above operation until the recirc_id value of a parent flow table of the flow table to be merged is equal to 0 and save the parent flow table to the pending list, which means that all flow tables of the flow corresponding to the flow table to be merged have been found.
[0048] Exemplarily, the recirc_id value of the flow table to be merged (flow table A) is 3, then the flow table with the gotorecirc_id value of 3 is searched in the total flow table. If the flow table found is flow table B, the recirc_id value of flow table B is 2. It can be seen that since the gotorecirc_id value of flow table B is 3, and the gotorecirc_id action refers to the next level flow table, the next level flow table of flow table B is flow table A, that is, flow table B is the upper level flow table of flow table A. The found flow table B is saved in the pending list. Since the recirc_id of flow table B is 2, it is not 0. Then continue to search for the flow table with the gotorecirc_id value of 2 in the total flow table. If the flow table found is flow table C, the recirc_id value of flow table C is 1. It can be seen that flow table C is the upper level flow table of flow table B, so it also belongs to the upper level flow table of flow table A. After saving flow table C to the pending list, since the recirc_id of flow table C is still not 0, continue to search for the flow table with the value of gotorecirc_id of 1 in the total flow table. If the flow table found is flow table D, the recirc_id of flow table D is 0. Flow table D is also saved in the pending list. Since the recirc_id of flow table D is 0, it means that flow table D is the header flow table. At this time, all flow tables in the multi-level flow table of a certain flow have been found. It should be noted that the pending flow table (flow table A) is also saved in the pending list.
[0049] In a possible implementation, the pending flag of each flow table in the to-be-processed list is deleted, indicating that these flow tables have been processed.
[0050] Step S104: merging the preset flow table entries of each flow table in the to-be-processed list to obtain a merged flow table.
[0051] Each flow table in the to-be-processed list is traversed, and the preset flow table entries in each flow table are merged to obtain a merged flow table including the preset flow table entries of each flow table in the to-be-processed list.
[0052] In a possible implementation manner, the preset flow table entry includes a Key value and an Action.
[0053] Key values are some characteristic values extracted from the message, which are used to uniquely identify a flow table. The characteristic values include source MAC address, destination MAC address, VLAN information, protocol type, source IP address, destination IP address, port number and other information. MAC address refers to Media Access Control Address, which is literally translated as media access control address, also known as local area network address, MAC address, Ethernet address or physical address. It is an address used to confirm the location of network devices. The source MAC address represents the MAC address of the sender, and the destination MAC address refers to the MAC address of the receiver. The Chinese name of VLAN (Virtual Local Area Network) is "virtual local area network". Virtual local area network (VLAN) is a group of logical devices and users. These devices and users are not restricted by physical location and can be organized according to functions, departments and applications. Protocols include network layer protocols and transport layer protocols. Network layer protocols mainly include Internet Protocol (IP protocol), Internet Control Message Protocol (ICMP) and Address Resolution Protocol (ARP). IP protocol is designed to interconnect packet switching communication networks to form an Internet communication environment. It is responsible for transmitting data blocks called datagrams from its higher-level software between the source host and the destination host. It provides a connectionless delivery service between the source and the destination. ICMP is used to report certain errors on the network. ARP is used to perform translation between IP addresses and physical addresses. The transport layer protocol mainly includes the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP). TCP is responsible for establishing direct dialogues between user processes on the network, and it ensures reliable communication between processes. UDP is used to provide unreliable connectionless transport layer services, which allows data to be transmitted directly between the source and the destination without having to establish a dialogue before transmitting data. The IP address is a unified address format provided by the IP protocol, which assigns a logical address to each network and each host on the Internet to mask the difference in physical addresses. Similarly, the source IP address refers to the IP address of the sender, and the destination IP address refers to the IP address of the receiver. The main function of the port number is to indicate the service provided by a specific process in a computer. Similarly, the source port number and the destination port number can also be included.
[0054] Action refers to the action performed on the flow represented by the flow table as shown by the flow table entry in the flow table.
[0055] In one possible implementation, if the action in the flow table in the list to be processed includes a NAT action, then the NAT information is placed in the action, and the message corresponding to the flow table is placed in the key, and the message in the key is marked with a NAT tag, indicating that the NAT action needs to be performed on the message later.
[0056] The NAT action is used to specify the IP and port of the connection to be tracked.
[0057] In a possible implementation, after obtaining the merged flow table, the merged flow table is sent to the forwarding chip; the merged flow table is saved in a downstream table, which includes the flow table sent to the forwarding chip; and the flow table to be merged is saved in the total flow table.
[0058] The purpose of merging multi-level flow tables is to reduce the amount of data sent to the forwarding chip, thereby reducing the resource overhead of the forwarding chip (hardware) and saving resources. In addition, since the multi-level flow tables are merged into an independent flow table, the table lookup efficiency is improved (no need to perform multiple queries in the multi-level flow tables) and the complexity of chip design and processing can be reduced.
[0059] For example, if there is a flow table A, the information of each flow table entry includes: recirc_id(0), ct_state(-new-est-trk), in_port(1), eth(src=fa:16:3e:89:b6, dst=00:00:01:01:02:03), eth_type(0x0800), ipv4(src=192.168.0.141, dst=30.30.30.10, proto=6, ttl=64, frag=no), tcp(src=22), actions: set(eth(src=00:00:02:01:02:03, dst=5e:da:0c:1f:01:4d )), set(ipv4(ttl=63)), ct(zone=6, nat), recirc(0x4a), the information of each flow table entry of another flow table B includes: recirc_id(0x4a), ct_state(+est+trk), in_port(1), eth(src=00:00:02:01:02:03, dst=5e:da:0c:1f:01:4d), eth_type(0x0800), ipv4(src=0.0.0.0 / 224.0.0.0, dst=30.30.30.8 / 255.255.255.248, frag=no), tcp(src=22), actions: 2.
[0060] It can be seen that the information contained in flow table A includes: "recirc_id(0)" indicates that the recirc_id of flow table A is 0, ct_state(-new-est-trk) indicates that the data packet corresponding to flow table A has established a tracking connection but does not come from an established connection and has not been processed by the conntrack module. "in_port(1), eth(src=fa:16:3e:89:b6, dst=00:00:01:01:02:03), eth_type(0x0800), ipv4(src=192.168.0.141,dst=30.30.30.10, proto=6, ttl=64, frag=no), tcp(src=22)" are all key and key value of flow table A. Among them, in_port indicates the port from which the data packet comes, eth indicates the Ethernet information (including the source Mac address and the destination Mac address), eth_type indicates the Ethernet type, ipv4 indicates the IP address (including the source IP address, the destination IP address and the protocol type, etc.), and tcp indicates which port is used to start the listening service. "actions: set(eth(src=00:00:02:01:02:03,dst=5e:da:0c:1f:01:4d)), set(ipv4(ttl=63)), ct(zone=6,nat), recirc(0x4a)" all belong to the action of flow table A. It can be seen that the action of flow table A includes the recirc action, and the recirc_id of the next level flow table pointed to by the recirc action is 0x4a, that is, flow table B. In flow table B, "recirc_id(0x4a)" indicates that the recirc_id of flow table B is 0x4a, and "ct_state(+est+trk)" indicates that the data packet corresponding to flow table B comes from an established connection and has been processed by the conntrack module. "in_port(1),eth(src=00:00:02:01:02:03,dst=5e:da:0c:1f:01:4d),eth_type(0x0800),ipv4(src=0.0.0.0 / 224.0.0.0,dst=30.30.30.8 / 255.255.255.248,frag=no),tcp(src=22)" are all key and key value of flow table B, and "actions:2" is the action of flow table B.
[0061] After the steps involved in the embodiment of the present application are processed, by integrating the flow table and connection tracking information, the NAT action performed by the original key and the connection tracking and the forwarding action of flow table B are integrated, and finally a merged flow table is formed to match the original message key. The information of the merged flow table includes: recirc_id(0), in_port(1), eth(src=fa:16:3e:89:b6, dst=00:00:01:01:02:03), eth_type(0x0800 ),ipv4(src=192.168.0.141,dst=30.30.30.10,proto=6,ttl=64,frag=no),tcp(src=22),actions:set(e th(src=00:00:02:01:02:03,dst=5e:da:0c:1f:01:4d)),set(ipv4(src=30.30.30.100,dst=ttl=63)),2. Among them, key and key value include: recirc_id(0), in_port(1), eth(src=fa:16:3e:89:b6, dst=00:00:01:01:02:03), eth_type(0x0800), ipv4(src=192.168.0.141, dst=30.30.30.10, proto=6, ttl=64, frag=no), tcp(src=22), action includes set(eth(src=00:00:02:01:02:03, dst=5e:da:0c:1f:01:4d)), set(ipv4(src=30.30.30.100, dst=ttl=63)), 2.
[0062] See also Figure 2 , is a schematic diagram of the composition of a flow table processing device provided in an embodiment of the present application. The flow table processing device 200 may include:
[0063] Receiving module 201: used to receive a flow table, where the flow table includes multiple flow table entries;
[0064] Processing module 202: used to determine whether the flow table is a flow table to be merged based on the flow table item; used to query and save one or more upper-level flow tables of the flow table to be merged in the total flow table to a pending list if the flow table is a flow table to be merged, wherein the total flow table includes received flow tables that have not yet been processed; and used to merge the preset flow table items of each flow table in the pending list to obtain a merged flow table.
[0065] Optionally, the processing module 202 is also used to determine whether the flow table is a flow table for which tracking has been established based on the first flow table item in the flow table item; to determine whether the flow table is a header flow table based on the second flow table item in the flow table item if the flow table is a flow table for which tracking has been established, and to determine whether the flow table has a lower-level flow table based on the third flow table item in the flow table item; and to determine that the flow table is a flow table to be merged if the flow table is not a header flow table and does not have a lower-level flow table.
[0066] Optionally, the preset flow table entry includes a Key value and an Action.
[0067] Optionally, the flow table processing device 200 further includes an extraction module 203, which is used to extract a fourth flow table entry in the flow table and register a callback function with the kernel when the flow table is a flow table for which tracking has been established.
[0068] Optionally, the processing module 202 is also used to mark the flow table as pending when a subordinate flow table exists in the flow table; to record the second flow table item of the subordinate flow table of the flow table on the flow table to find the subordinate flow table of the flow table; and to save the flow table into the total flow table.
[0069] Optionally, the processing module 202 is also used to determine whether the flow table exists in the downstream table when the flow table is a header flow table and there is no lower-level flow table, and the downstream table includes the flow table sent to the forwarding chip; the flow table processing device 200 also includes a sending module 204, which is used to send the flow table to the forwarding chip when the flow table does not exist in the downstream table; the processing module 202 is also used to save the flow table to the downstream table and the total flow table.
[0070] Optionally, the sending module 204 is also used to send the merged flow table to the forwarding chip; the processing module 202 is also used to save the merged flow table to a downstream table, wherein the downstream table includes the flow table sent to the forwarding chip; and save the flow table to be merged to the total flow table.
[0071] The specific functional implementation of the flow table processing device 200 can be found in Figure 1 The corresponding method steps will not be repeated here.
[0072] See also Figure 3 , is a schematic diagram of the composition of an electronic device provided in an embodiment of the present application. It may include: a processor 110, a memory 120; wherein the processor 110, the memory 120 and the communication interface 130 are connected via a bus 140, the memory 120 is used to store instructions, and the processor 110 is used to execute the instructions stored in the memory 120 to implement the above Figure 1The corresponding method steps.
[0073] The processor 110 is used to execute the instructions stored in the memory 120 to control the communication interface 130 to receive and send signals and complete the steps in the above method. The memory 120 can be integrated in the processor 110 or can be set separately from the processor 110.
[0074] As an implementation, the function of the communication interface 130 may be implemented by a transceiver circuit or a dedicated transceiver chip. The processor 110 may be implemented by a dedicated processing chip, a processing circuit, a processor or a general-purpose chip.
[0075] As another implementation method, it is possible to use a general-purpose computer to implement the electronic device provided in the embodiment of the present application. That is, the program code that implements the functions of the processor 110 and the communication interface 130 is stored in the memory 120, and the general-purpose processor implements the functions of the processor 110 and the communication interface 130 by executing the code in the memory 120.
[0076] For the concepts, explanations, detailed descriptions and other steps involved in the electronic device and related to the technical solutions provided in the embodiments of the present application, please refer to the description of the method steps executed by the device in the aforementioned method or other embodiments, which will not be repeated here.
[0077] As another implementation of this embodiment, a computer-readable storage medium is provided, on which instructions are stored. When the instructions are executed, the method in the above method embodiment is executed.
[0078] As another implementation of this embodiment, a computer program product including instructions is provided, and when the instructions are executed, the method in the above method embodiment is performed.
[0079] Those skilled in the art will appreciate that for ease of description, Figure 3 Only one memory and processor are shown. In an actual electronic device or server, there may be multiple processors and memories. The memory may also be referred to as a storage medium or a storage device, etc., which is not limited in the embodiments of the present application.
[0080] It should be understood that in the embodiments of the present application, the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
[0081] It should also be understood that the memory mentioned in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (Direct Rambus RAM, DR RAM).
[0082] It should be noted that when the processor is a general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, the memory (storage module) is integrated in the processor.
[0083] It should be noted that the memory described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0084] In addition to the data bus, the bus may also include a power bus, a control bus, a status signal bus, etc. However, for the sake of clarity, various buses are marked as buses in the figure.
[0085] It should also be understood that the first, second, third, fourth and various numerical numbers involved in this document are only distinctions made for the convenience of description and are not intended to limit the scope of the present application.
[0086] It should be understood that the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0087] In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software. The steps of the method disclosed in conjunction with the embodiment of the present application can be directly embodied as a hardware processor for execution, or a combination of hardware and software modules in a processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory and completes the steps of the above method in conjunction with its hardware. To avoid repetition, it is not described in detail here.
[0088] In various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0089] Those skilled in the art will appreciate that the various illustrative logical blocks (ILBs) and steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or in a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0090] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0091] The units described as separate components may or may not be physically separated, and the components shown 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.
[0092] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0093] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.
[0094] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for processing a flow table, It is characterized in that In the case where there are multiple levels of flow tables, the method includes: receiving a flow table, wherein the flow table includes a plurality of flow table entries; Determine whether the flow table is a flow table to be merged; the flow table to be merged is a tail flow table in a multi-level flow table corresponding to the flow; In the case where the flow table is a flow table to be merged, querying and saving one or more upper-level flow tables of the flow table to be merged in the total flow table to a pending list, wherein the total flow table includes received flow tables that have not yet been processed; Merging the preset flow table items of each flow table in the to-be-processed list to obtain a merged flow table, specifically: traversing each flow table in the to-be-processed list, merging the preset flow table items in each flow table to obtain a merged flow table including the preset flow table items of each flow table in the to-be-processed list; The determining whether the flow table is a flow table to be merged includes: Determining whether the flow table is a flow table for which tracking has been established according to a first flow table entry in the flow table entry; In the case where the flow table is a flow table for which tracking has been established, judging whether the flow table is a header flow table according to the second flow table item in the flow table item, and judging whether the flow table has a lower-level flow table according to the third flow table item in the flow table item; If the flow table is not a header flow table and there is no lower-level flow table, the flow table is a flow table to be merged.
2. The method according to claim 1, It is characterized in that The preset flow table entry includes a Key value and an Action, wherein the Key value is used to determine the flow table, and the Action is used to indicate an action performed on the flow table.
3. The method according to claim 2, It is characterized in that The method further comprises: In the case that the flow table is a flow table for which tracking has been established, the fourth flow table entry in the flow table is extracted, and a callback function is registered with the kernel.
4. The method according to claim 3, It is characterized in that The method further comprises: If the flow table has a lower-level flow table, marking the flow table with a pending flag; Recording a second flow table entry of a subordinate flow table of the flow table on the flow table, so as to be used for finding the subordinate flow table of the flow table; The flow table is saved in the total flow table.
5. The method according to claim 3, It is characterized in that The method further comprises: In a case where the flow table is a header flow table and there is no lower-level flow table, determining whether the flow table exists in a lower-level flow table, wherein the lower-level flow table includes a flow table sent to a forwarding chip; If the flow table does not exist in the downstream table, sending the flow table to the forwarding chip; The flow table is saved to the downstream table and the total flow table.
6. The method according to any one of claims 1 to 5, It is characterized in that The method further comprises: Sending the merged flow table to a forwarding chip; Saving the merged flow table to a downstream table, wherein the downstream table includes a flow table sent to the forwarding chip; The flow table to be merged is saved to the total flow table.
7. A flow table processing device, It is characterized in that In the case where there are multiple levels of flow tables, the device includes: A receiving module, used for receiving a flow table, wherein the flow table includes a plurality of flow table entries; A processing module, used for judging whether the flow table is a flow table to be merged according to the flow table item; the flow table to be merged is a tail flow table in a multi-level flow table corresponding to the flow; used for querying and saving one or more upper-level flow tables of the flow table to be merged in the total flow table to a pending list when the flow table is a flow table to be merged, wherein the total flow table includes received flow tables that have not been processed; and used for merging the preset flow table items of each flow table in the pending list to obtain a merged flow table, specifically: traversing each flow table in the pending list, merging the preset flow table items in each flow table to obtain a merged flow table including the preset flow table items of each flow table in the pending list; The determining whether the flow table is a flow table to be merged includes: Determining whether the flow table is a flow table for which tracking has been established according to a first flow table entry in the flow table entry; In the case where the flow table is a flow table for which tracking has been established, judging whether the flow table is a header flow table according to the second flow table item in the flow table item, and judging whether the flow table has a lower-level flow table according to the third flow table item in the flow table item; If the flow table is not a header flow table and there is no lower-level flow table, the flow table is a flow table to be merged.
8. An electronic device, It is characterized in that including a processor and memory, The processor and the memory are connected to each other, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1-6.
9. A computer readable storage medium or a computer program product, It is characterized in that The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method as described in any one of claims 1 to 6; or, the computer program product includes program instructions, which when executed by a processor, causes the processor to execute the method as described in any one of claims 1 to 6.
