Flow table management method and apparatus for data packet processing, device, and storage medium
By adopting a flow table management method with cascade ring queue data structure in the SDN network, the flow table management efficiency and cross-NUMA node access problems caused by fast communication speed of virtual switches are solved, and efficient and lock-free flow table allocation and Release improves performance and consistency of flow table management.
Patent Information
- Application Number
- PCT/CN2023/132498
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-09
- Filing Date
- 2023-11-20
- Publication Date
- 2024-11-14
AI Technical Summary
In the SDN network, the creation and aging of virtual switch communication links are fast, which causes the database to process a large number of flow table management requests, resulting in low flow table management efficiency, and the database stores flow table information across NUMA nodes, which reduces performance and consistency.
Adopt a flow table management method based on a cascading ring queue data structure, and allocate and release flow table information without locks through the memory file system, and use multi-level flow table queue priority order to ensure that each thread can be allocated and concurrently and allocated efficiently and concurrently. Release flow table information and maintain the first-in-first-out semantics of flow table information.
It improves the allocation and release speed of stream table information, reduces memory usage, improves memory utilization, ensures the order and predictability of stream table management, and adapts to the high-speed processing needs of virtual switches.
Smart Images

Figure CN2023132498_14112024_PF_FP_ABST
Abstract
Description
Flow table management method, device, equipment and storage medium for data packet processing
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on May 9, 2023, with application number 2023105283913 and entitled “Flow table management method, device, equipment and storage medium for data packet processing”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present invention relates to the field of computer science and in particular to a flow table management method, apparatus, device and storage medium for data packet processing.
[0003] background
[0004] In the Software Defined Network (SDN) architecture, the OpenFlow protocol is used to separate the control and data planes, centralizing control plane operations to the SDN controller. Switches (such as virtual switches and SDN switches) are responsible only for simple, high-speed data plane operations locally. During data plane operations, switches process data packets (such as lookups, modifications, and forwarding) based on flow tables.
[0005] Currently, related technologies primarily use independent databases to store flow table information to implement management operations such as flow table allocation and release. However, in SDN networks, the creation and aging of virtual switch communication links can reach millions per second, meaning the database receives millions of flow table management requests per second. Therefore, to ensure the sequential and consistent nature of flow table management, related technologies primarily use a single thread or lock to control database access, but this approach reduces the efficiency of flow table management. Furthermore, flow table information in the database often resides on a specific Non-Uniform Memory Access (NUMA) node. Consequently, when multiple threads request to allocate or release a flow table, cross-NUMA node access occurs, reducing flow table management efficiency.
[0006] Technical content
[0007] The present invention provides a flow table management method for data packet processing, including:
[0008] Receiving flow table management requests concurrently sent by multiple threads respectively, wherein at least one thread among the multiple threads runs on a NUMA node;
[0009] For each thread, do the following:
[0010] When the flow table management request of the thread is a flow table allocation request, based on the priority order of the flow table queues at each level contained in the flow table information pool in the memory file system, a flow table information is allocated to the thread in a lock-free state; wherein, the flow table queues at each level include at least a first-level flow table queue, a second-level flow table queue and a third-level flow table queue, each of the first-level flow table queues stores flow table information available in the local memory of a thread itself, each of the second-level flow table queues stores flow table information available in the local memory of each thread of the at least one thread running on a NUMA node, and the third-level flow table queue stores flow table information available in the total memory of each NUMA node, the flow table information in the flow table queues at each level does not overlap with each other, the priority of the first-level flow table queue is higher than the priority of the second-level flow table queue, and the priority of the second-level flow table queue is higher than the priority of the third-level flow table queue;
[0011] When the flow table management request of the thread is a flow table release request, an atomic instruction is used to store the flow table information carried in the flow table release request into the third-level flow table queue.
[0012] The present invention also provides a flow table management device for data packet processing, including:
[0013] a request receiving module, configured to respectively receive flow table management requests concurrently sent by multiple threads, wherein at least one thread among the multiple threads runs on a NUMA node;
[0014] A flow table management module is configured to allocate flow table information to each thread in a lock-free manner, when the flow table management request of the thread is a flow table allocation request, based on the priority order of flow table queues at various levels contained in a flow table information pool in an in-memory file system, wherein the flow table queues at various levels include at least a first-level flow table queue, a second-level flow table queue, and a third-level flow table queue; and, when the flow table management request of the thread is a flow table release request, use an atomic instruction to store the flow table information carried in the flow table release request in the third-level flow table queue.
[0015] Among them, each first-level flow table queue stores the flow table information available to a thread itself in the local memory, each second-level flow table queue stores the flow table information available to each thread on a NUMA node in the local memory, and the third-level flow table queue stores the flow table information available to each NUMA node in the total memory. The flow table information in the flow table queues at each level does not overlap with each other, the priority of the first-level flow table queue is higher than the priority of the second-level flow table queue, and the priority of the second-level flow table queue is higher than the priority of the third-level flow table queue.
[0016] An embodiment of the present application provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the steps of the flow table management method for data packet processing are implemented.
[0017] An embodiment of the present application provides a computer-readable storage medium having computer-executable instructions stored thereon. When the computer-executable instructions are executed by an electronic device, the steps of the flow table management method for data packet processing are implemented.
[0018] An embodiment of the present application provides a computer program product, comprising a computer program, which, when executed by an electronic device, implements the steps of the flow table management method for data packet processing.
[0019] Other features and advantages of the present application will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present application. The purposes and other advantages of the present application can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. 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 paying any creative labor.
[0021] FIG1A is a schematic diagram of a flow table management process of a related technology provided by an embodiment of the present application;
[0022] FIG1B is a diagram of an application scenario applicable to an embodiment of the present application;
[0023] FIG1C is another application scenario diagram applicable to the embodiment of the present application;
[0024] FIG2 is a flow chart of a flow table management method for data processing provided by an embodiment of the present application;
[0025] FIG3 is a schematic diagram of a NUMA architecture provided in an embodiment of the present application;
[0026] FIG4 is a schematic diagram of memory occupied by flow table queues at various levels according to an embodiment of the present application;
[0027] FIG5 is a schematic diagram of the initial contents of the third-level flow table queue provided in an embodiment of the present application;
[0028] FIG6 is a flow chart of a method for distributing flow table information provided in an embodiment of the present application;
[0029] FIG7A is a schematic diagram of allocating flow table information from a first-level flow table queue according to an embodiment of the present application;
[0030] FIG7B is a schematic diagram of changes in the head and tail pointers of the first-level flow table queue provided in an embodiment of the present application;
[0031] FIG7C is a schematic diagram of allocating flow table information from a second-level flow table queue according to an embodiment of the present application;
[0032] FIG7D is a schematic diagram showing changes in the head and tail pointers of the second-level flow table queue provided in an embodiment of the present application;
[0033] FIG7E is a schematic diagram of allocating flow table information from a third-level flow table queue according to an embodiment of the present application;
[0034] FIG7F is a schematic diagram showing changes in the head and tail pointers of the third-level flow table queue provided in an embodiment of the present application;
[0035] FIG8A is a schematic diagram of a pointer before storing released flow table information in a third-level flow table queue according to an embodiment of the present application;
[0036] FIG8B is a schematic diagram of a pointer after storing released flow table information in a third-level flow table queue according to an embodiment of the present application;
[0037] FIG9 is a structural diagram of a flow table management device for data processing provided by an embodiment of the present application;
[0038] FIG10 is a structural diagram of a data classification device provided in an embodiment of the present application;
[0039] FIG11 is a structural diagram of an electronic device provided in an embodiment of the present application.
[0040] Implementation Method
[0041] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of the technical solutions of this application, but not all of them. Based on the embodiments described in this application document, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the technical solutions of this application.
[0042] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.
[0043] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form a resource pool for on-demand, flexible and convenient use. Cloud computing technology will become a key support. Backend services of technical network systems, such as video websites, image websites, and more portals, require extensive computing and storage resources. With the rapid development and application of the internet industry, every item will likely have its own unique identification mark, which will need to be transmitted to backend systems for logical processing. Different levels of data will be processed separately. All types of industry data require strong system support, which can only be achieved through cloud computing.
[0044] Cloud computing has developed rapidly with the development of the Internet, real-time data streams, and the diversification of connected devices, as well as the demand for search services, social networks, mobile commerce, and open collaboration.
[0045] Cloud computing refers to the delivery and usage model of IT infrastructure, enabling on-demand, scalable access to required resources over the internet. Broadly speaking, cloud computing refers to the delivery and usage model of services, enabling on-demand, scalable access to required services over the internet. These services can be IT-related, software-related, internet-related, or other services. Cloud computing is the product of the convergence of traditional computer and network technologies, including grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing. Unlike previous parallel and distributed computing approaches, the emergence of cloud computing will fundamentally revolutionize the entire internet model and enterprise management models.
[0046] The following explains some of the terms used in the embodiments of the present application to facilitate understanding by those skilled in the art.
[0047] Switches are used to connect network devices and enable communication across networks. They can forward data packets to designated network devices to help guide network traffic, thereby implementing various networking functions. They usually include virtual switches and physical switches. Among them, virtual switches generally refer to network switches implemented in software, while physical switches have separate hardware.
[0048] A flow table is a table stored in a switch that performs operations such as packet identification, lookup, forwarding, and modification, thereby controlling network traffic. Each flow table consists of multiple flow entries, each representing a packet processing rule. When a packet enters the switch, the switch queries the flow table to determine the destination port for processing the packet.
[0049] The flow table information refers to a unique identifier for marking the identity of traffic within the server, for example, it can be an ID consisting of at least one of numbers, letters, and symbols.
[0050] NUMA is a memory design architecture for multi-processors. In this architecture, memory access time depends on the relative position between the processor and the memory. Generally, the memory relatively close to the processor is called local memory, and the memory relatively far from the processor is called non-local memory.
[0051] Atomic instructions are instructions used to maintain synchronization between multiple CPUs when multiple CPUs solve the same problem through parallel algorithms. They are instructions that cannot be divided into software.
[0052] Lock is a mechanism in a multi-threaded concurrent environment that ensures that only one thread is executed at a time.
[0053] The following is an overview of the design concepts of the embodiments of the present application.
[0054] Currently, related technologies mainly use independent databases to store flow table information to implement management operations such as allocation and release of flow tables. This is generally applicable to single-threaded access. For multi-threaded concurrent access, locks are usually used to prevent the occurrence of dirty data. Dirty data here refers to data that does not meet expectations, is illegal, or invalid, also known as "junk data" or "bad data." Dirty data can appear in various data sources, including files, databases, and network data. For example, a database table stores height information, but the height of one record is mistakenly entered as a negative number. This is dirty data.
[0055] Taking the use of a database to process concurrent flow table management as an example, as shown in FIG1A , thread 0 needs to allocate a flow table, and thus sends a database access request to obtain flow table information. At the same time, thread 1 needs to release a flow table, so it sends a database access request to release a flow table information (ID: 23456); since thread 0's access request to the database arrives at the database first, the management thread responsible for handling the allocation and release of flow table information in the database uses a lock to ensure that this time it will not allocate flow table information (ID: 23456) that has not been released back to the flow table information pool to thread 0, thereby ensuring the order and consistency of the request; after thread 0 obtains the lock, the management thread accesses the flow table information pool that stores flow table information, selects a new flow table information (ID: 12345) and returns it to thread 0; after the flow table information is allocated, the management thread locks again to process thread 1's database access request, and stores the flow table information (ID: 23456) released by thread 1 in the flow table information pool by accessing the flow table information pool, and the flow table information (ID: 23456) newly stored in the flow table information pool can be reallocated and used.
[0056] Using a database for flow table management can ensure the persistence of flow table information. In this way, when the virtual switch is hot upgraded or crashes, the consistency and persistence of flow table information can be guaranteed. At the same time, the database handles the flow table information allocation or release requests of a single thread, and uses locks to handle the flow table information allocation or release requests of multiple threads, which can ensure the sequential management of flow table information and avoid the repeated allocation of the same flow table information or the leakage of flow table information recovery.
[0057] However, using a database for flow table management also has the following problems:
[0058] First, in SDN networks, virtual switch communication links can be created and aged at a rate of millions per second. This means that the database must be accessed millions of times per second to manage flow information allocation and release. However, using a single thread or lock to ensure sequentiality and consistency prevents multiple threads from concurrently allocating and releasing flow information, resulting in low management performance for flow information allocation and release, insufficient to meet the high-speed traffic processing requirements of the virtual switch. Furthermore, to ensure the transactional and persistent nature of flow information allocation and release, the database must first store the allocation and release results on disk before returning them to the virtual switch threads. However, disk read and write performance is relatively low, limiting the database's ability to support flow information allocation and release.
[0059] Second, when storing flow table information, the database also needs to store additional metadata or management information for each flow table to facilitate management. As the number of stored flow tables increases, the additional memory usage increases, reducing effective memory utilization. For example, if storing each flow table requires an additional 8 to 24 bytes, storing 100MB of flow table information would require approximately 800MB to 2.4GB of memory.
[0060] Third, the server architecture currently used by cloud platforms is mostly NUMA. In this architecture, different CPUs have different performance when accessing the memory of different NUMA nodes. The CPU can only achieve maximum access performance when accessing the memory of the NUMA node closest to it. Therefore, to achieve maximum access performance, the threads of the virtual switch may be distributed across multiple NUMA nodes, while the flow table information pool in the database is often only stored in the memory of a specific node. This will cause a thread to request the allocation or release of flow table information across NUMA nodes, which not only reduces the performance of flow table management, but also causes different threads of the virtual switch to observe different network performance results, which in turn affects flow control and causes network congestion. This is not friendly to the NUMA architecture.
[0061] Fourth, the allocation and release of flow table information in the database generally does not guarantee "first-in, first-out" semantics. That is, a flow table information that has just been released may be immediately reallocated, rather than waiting until other unallocated flow table information is allocated. However, "first-in, first-out" semantics are very important for virtual switches, smart network cards, etc. This is because "first-in, first-out" ensures the predictability of flow table information allocation. That is, a flow table information that has just been released will not be reallocated immediately. This provides greater flexibility in the pipeline design of virtual switches, smart network cards, etc., and is more friendly to maintaining high-speed pipeline operation.
[0062] In order to solve the above-mentioned problems existing when using a database for flow table management, an embodiment of the present application provides a flow table management method for data packet processing, which is based on a cascaded ring queue data structure and a memory file system to achieve efficient and lock-free management of flow tables. Through the cascade of multi-level flow table queues, the perception of the NUMA architecture is achieved. When multiple threads concurrently request to allocate or release flow tables, based on the priority order of the flow table queues at each level contained in the flow table information pool in the memory file system, a flow table information can be allocated to each thread from the first-level flow table queue available in the local memory, thereby achieving lock-free and concurrent efficient allocation of flow table information for multiple threads. Only when there is no allocable flow table information in its own first-level flow table queue will it be obtained in sequence from the upper-level flow table queue, thereby ensuring that each thread can be allocated flow table information, and the released flow table information is stored in the third-level flow table queue with the lowest priority, and its position in the third-level flow table queue is determined by maintaining a pointer, thereby achieving the predictability of first-in-first-out flow table information. At the same time, by storing the ring data structure of flow table queues at all levels in the memory file system, the speed of flow table information allocation and release is improved while ensuring data persistence, and no additional information needs to occupy memory, thereby improving the effective utilization of memory space.
[0063] The following describes the embodiments of the present application in conjunction with the drawings in the specification. It should be understood that the embodiments described herein are only used to illustrate and explain the present application and are not used to limit the present application. In addition, the embodiments of the present application and the features in the embodiments can be combined with each other if there is no conflict.
[0064] 1B is a schematic diagram of a possible application scenario in an embodiment of the present application, which includes a server device 100, a switch 200 (specifically, switch 201, switch 202, switch 203, etc.), and a terminal device 300 (specifically, terminal device 301, terminal device 302, etc.).
[0065] In an SDN network, terminal device 301 and terminal device 302 communicate. Terminal device 301 sends a data packet to switch 201 in the network. Switch 201 does not store a flow table for forwarding data packets, so it sends a flow table request to server device 100. After receiving the request, server device 100 allocates a flow table for it. Switch 201 forwards the data packet to switch 202 based on a flow table entry in the flow table. Switch 202 stores a flow table for forwarding data packets, and then forwards the data packet to terminal device 302 based on a flow table entry in the stored flow table. When communication between terminal devices 301 and 302 ends, server device 100 reclaims the flow tables released by switches 201 and 202.
[0066] In another application scenario, unused terminal devices can share a switch. As shown in Figure 1C, in an SDN network, terminal device 301 and terminal device 302 communicate. Terminal device 301 sends a data packet to switch 201 in the network. Switch 201 does not store a flow table for forwarding the data packet, so it sends a flow table request to server device 100. After receiving the request, server device 100 allocates a flow table for it. Switch 201 forwards the data packet to terminal device 302 based on a flow table entry in the flow table. When the communication between terminal devices 301 and 302 ends, the server device reclaims the flow table released by switch 201.
[0067] Among them, in the application scenarios shown in Figures 1B and 1C, the server device 100 allocates a flow table to the switch 201, and when reclaiming the flow table released by the switch 201, the flow table management method provided by this application can be adopted. For details, please refer to the following embodiments.
[0068] In some implementations, the server device 100 and the switch 200 , as well as the switch 200 and the terminal device 300 , can communicate via a wired network or a wireless network.
[0069] Terminal device 300 includes, but is not limited to, personal computers, mobile phones, tablet computers, laptops, e-book readers, smart medical devices, and in-vehicle terminals, among other computer devices with data transceiver capabilities. Furthermore, these computer devices can be installed with various communication clients, which can be software, web pages, or mini-programs.
[0070] Switch 200 includes physical switches and virtual switches, and can be divided into access devices and transmission devices, wherein the access device is a switch directly connected to a service node, virtual machine or terminal device in the SDN network (such as switch 201 and switch 202), and the transmission device is a switch that is not an access device in the SDN network (such as switch 203).
[0071] The server device 100 is a backend server for the communication client, or a server specifically used for data packet forwarding, querying, modifying, etc., which is not specifically limited in this application. The server device 100 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0072] It should be noted that when the following embodiments of this application are applied to specific products or technologies, data managed based on flow tables need to obtain object permission or consent, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0073] 2 is a flowchart of a flow table management method for data packet processing provided in an embodiment of the present application. The process is executed by a server device and mainly includes the following steps:
[0074] S201: The server device receives flow table management requests concurrently sent by multiple threads.
[0075] In a NUMA architecture, among multiple threads on a virtual switch, at least one thread runs on a NUMA node.
[0076] For example, as shown in Figure 3, the server device includes two CPUs, denoted as CPU1 and CPU2, corresponding to local memory 1 and local memory 2, respectively, with the shortest access time. Local memory 2 is CPU1's non-local memory, and local memory 1 is CPU2's non-local memory. Local memory 1 and local memory 2 are both server device memories. CPU1 and local memory 1, as well as CPU2 and local memory 2, are each considered a NUMA node. CPU1 is used to execute threads on virtual switch 1, allocating flow table information to threads 1 and 2 by accessing local memory 1, or storing flow table information released by threads 1 and 2. That is, threads 1 and 2 run on NUMA node 1. CPU2 is used to execute threads on virtual switch 2, allocating flow table information to thread 3 by accessing local memory 2, or receiving flow table information released by thread 3. Thread 3 runs on NUMA node 2.
[0077] In an embodiment of the present application, multiple threads on the virtual switch can concurrently send flow table management requests to the server device, and the flow table management requests sent by different threads can be different.
[0078] In some implementations of the present application, different threads on the same virtual switch may send the same type of flow table management request.
[0079] Still taking FIG. 3 as an example, on virtual switch 1, the flow table management requests sent by thread 1 and thread 2 are both flow table allocation requests, ie, requesting the server device to allocate a flow table information to each of them respectively.
[0080] In some implementations of the present application, different threads on the same virtual switch may send different types of flow table management requests.
[0081] Still taking Figure 3 as an example, on virtual switch 1, the flow table management request sent by thread 1 is a flow table allocation request, that is, requesting the server device to allocate a flow table information for it; the flow table management request sent by thread 2 is a flow table release request, that is, requesting the server device to reclaim the flow table information allocated to it.
[0082] In some implementations of the present application, different threads on different virtual switches may send the same type of flow table management request.
[0083] Still taking Figure 3 as an example, on virtual switch 1, the flow table management request sent by thread 1 is a flow table allocation request, that is, it requests the server device to allocate a flow table information for it; on virtual switch 2, the flow table management request sent by thread 3 is also a flow table allocation request, that is, it requests the server device to also allocate a flow table information for it.
[0084] In some implementations of the present application, different threads on different virtual switches may send different types of flow table management requests.
[0085] Still taking Figure 3 as an example, on virtual switch 1, the flow table management requests sent by thread 1 and thread 2 are both flow table allocation requests, that is, requesting the server device to allocate a flow table information to each of them respectively; on virtual switch 2, the flow table management request sent by thread 3 is a flow table release request, that is, requesting the server device to reclaim the flow table information allocated to it.
[0086] Considering that when multiple threads request to allocate or release flow table information at high speed and concurrently, fierce competition will occur, resulting in errors or failures in the allocation and release of flow table information, and the flow table needs to be re-managed, which reduces the management performance of the flow table; at the same time, placing the flow table information in the memory space of a specific NUMA node cannot avoid the problem of performance degradation due to excessive access across NUMA nodes in the case of high concurrency.
[0087] In order to solve the above problems, the embodiment of the present application provides a cascaded ring queue data structure to store and manage flow table information, and realize the pooled management of flow table information. Specifically, through the ring queue data structure, the flow table information pool regards each flow table information as an independent element, no longer caring about the specific content of each flow table information (such as the specific number of the flow table ID), but only caring about the position of each flow table information in the ring queue. In the ring queue data structure, the flow table information ID at the head of the queue will be allocated first, and the newly released flow table information ID will be placed at the end of the queue, thus forming a ring queue data structure.
[0088] In an embodiment of the present application, a cascaded ring queue data structure is used to store and manage flow table information, and there is no need to rely on additional management information or metadata to assist in allocating, releasing or recovering flow table information. That is, except for the memory required to store the flow table information, there is basically no need to occupy additional memory space. Compared with using a database to store and manage flow table information, memory space is saved. This is crucial for smart network cards because, unlike servers, smart network cards have relatively higher memory usage costs.
[0089] For example, assuming each flow table ID only requires 4 bytes of memory, storing 100 flow table IDs only requires 400MB of memory. Compared to using a database, storing 100MB of flow table ID information can save approximately 800MB to 2.4GB of memory.
[0090] At the same time, the flow table queues at all levels will not increase as the number of stored flow table IDs increases. Compared with the database, the memory space used by the flow table queues at all levels is fixed and generally small.
[0091] For example, assuming that a flow table queue stores 64 flow table IDs, 4 bytes of memory space is required to store each flow table ID. If there are 4 flow table queues in total, the memory space required to store the flow table information is 1 KB.
[0092] In some embodiments of the present application, multiple flow table queues constituting a ring queue data structure have different access priorities.
[0093] In one example, based on the two dimensions of threads and NUMA nodes in the NUMA architecture, the circular queue data structure is divided into three levels, namely the first-level flow table queue, the second-level flow table queue, and the third-level flow table queue, wherein the priority of the first-level flow table queue is higher than the priority of the second-level flow table queue, and the priority of the second-level flow table queue is higher than the priority of the third-level flow table queue. Each first-level flow table queue corresponds to a thread and is used to store the flow table information available in the local memory of the thread itself, that is, each first-level flow table queue is exclusively used by a thread; each second-level flow table queue corresponds to a NUMA node and is used to store the flow table information available in the local memory of each thread running on the NUMA node, that is, all threads of the virtual switch distributed on the NUMA node share a second-level flow table queue; the third-level flow table queue is used to store the flow table information available in the total memory of each NUMA node, and the flow table information in each level of flow table queue does not overlap.
[0094] Still taking Figure 3 as an example, the relationship between the flow table queues at all levels is shown in Figure 4. The server device allocates a memory space on the total memory for pooled management of flow table information, and the total memory space stores the third-level flow table queue; according to the shortest access time, a local memory is allocated for each NUMA node from the total memory, wherein the second-level flow table queue corresponding to NUMA node 1 is stored in the local memory 1 of NUMA node 1, and the second-level flow table queue corresponding to NUMA node 2 is stored in the local memory 2 of NUMA node 2; in the local memory 1 of NUMA node 1, a part of the memory space (local memory 1') is allocated to thread 1 for storing the first-level flow table queue corresponding to thread 1, and at the same time, another part of the memory space (local memory 2') is allocated to thread 2 for storing the first-level flow table queue corresponding to thread 2; in the local memory 2 of NUMA node 2, a part of the memory space (local memory 3') is allocated to thread 3 for storing the first-level flow table queue corresponding to thread 3.
[0095] In an embodiment of the present application, when each virtual switch is started for the first time, the available flow table information is added to the third-level flow table queue in sequence, so that the third-level flow table queue initially stores all available flow table information for subsequent management of flow table allocation and release.
[0096] Taking the flow table information as the flow table ID as an example, the initial third-level flow table queue is shown in Figure 5.
[0097] Based on the flow table queues at each level corresponding to the cascaded ring queue data structure, pooled management of flow table information can be achieved. For details, see steps S202-S203.
[0098] S202: The server device determines the type of flow table management request sent by each thread. If the type is a flow table allocation request, S203 is executed; if the type is a flow table release request, S204 is executed.
[0099] For different types of flow table management requests, the operations on flow table information are different. When the flow table management request is a flow table allocation request, a flow table information needs to be allocated to the thread. When the flow table management request is a flow table release request, a flow table information released by the thread needs to be recovered. Therefore, when performing flow table management, it is necessary to determine the type of flow table management request sent by each thread in advance.
[0100] S203: The server device allocates a flow table information to the thread in a lock-free state based on the priority order of the flow table queues at each level contained in the flow table information pool in the memory file system.
[0101] In an embodiment of the present application, the flow table queues at each level constitute a cascaded ring queue data structure and have different access priority orders, wherein the first-level flow table queue is accessed at a higher priority than the second-level flow table queue, and the second-level flow table queue is accessed at a higher priority than the third-level flow table queue. Therefore, when allocating flow table information to each thread, a flow table information is allocated to it from the first-level flow table queue corresponding to each thread. Since each thread corresponds to a first-level flow table queue, there will be no competition for the same flow table information between the threads, so that flow table information can be allocated to each thread concurrently without locking, and the allocation efficiency is higher; when there is no allocable flow table information in the first-level flow table queue of each thread, atomic instructions are used to allocate flow table information to each thread from the upper-level flow table queue in order of priority. Since atomic instructions are lighter than locks, even if flow table information is allocated from the upper-level flow table queue, the allocation efficiency can still be guaranteed compared to the flow table allocation method using locks.
[0102] The embodiment of the present application maps the memory file to the memory space of the virtual switch by storing the circular queue data structure of the flow table queues of each level in a memory file system (such as the memory file system of an operating system such as Linux, Windows or MAC). This allows the threads of the virtual switch to access the memory file to manage the flow table information as if they were accessing local memory, which improves the access speed compared to accessing ordinary files. At the same time, it can support the rapid recovery of flow table information by remapping the memory file. In this way, in the case of hot upgrade or abnormal crash of the virtual switch, all flow table information can be restored by remapping the memory file. According to data testing, the memory file mapping method can restore tens of millions of flow table information within 10ms.
[0103] The following example uses the allocation of flow table information for a thread as an example. The specific process is shown in Figure 6, which mainly includes the following steps:
[0104] S2031: Determine whether the first-level flow table queue of the thread itself is empty. If not, execute S2032; if so, execute S2033.
[0105] When the thread's own first-level flow table queue is not empty, it indicates that there is available flow table information in its own first-level flow table queue, and a flow table information can be directly allocated to it from the first-level flow table queue. When the thread's own first-level flow table queue is empty, it indicates that there is no available flow table information in its own first-level flow table queue, so a flow table information needs to be allocated to the thread from the upper-level flow table queue.
[0106] S2032: Allocate a flow table information for the thread from the first-level flow table queue.
[0107] For example, as shown in FIG7A , the first-level flow table queue of the thread itself is not empty, and a flow table ID can be directly allocated to it from the first-level flow table queue.
[0108] When using the flow table queue to store flow table information, there is no need to care about the specific content of the flow table information (such as the specific number of the flow table ID). You only need to care about the position of each flow table information in the flow table queue. Therefore, by maintaining the head pointer and the tail pointer, it is possible to achieve multi-threaded concurrent allocation and release of flow table information IDs without using locks and only using atomic instructions. When allocating, the flow table information is always obtained from the position pointed to by the head pointer, thereby realizing the "first in, first out" queue semantics and ensuring the predictability of flow table information allocation. The head pointer refers to the pointer pointing to the head of the queue, and the tail pointer refers to the pointer pointing to the tail of the queue.
[0109] Among them, when allocating a flow table information to the thread from the first-level flow table queue, specifically, obtain the current first head pointer in the first-level flow table queue, allocate the flow table information at the position pointed to by the first head pointer to the thread, and point the first head pointer to the position of the next flow table information.
[0110] For example, as shown in Figure 7B, a flow table ID is directly assigned to thread 1 from its first-level flow table queue. Before the assignment, the first head pointer and the first tail pointer in the current first-level flow table queue both point to the first position in the queue. Therefore, flow table ID 1 at the first position is assigned to thread 1. After the assignment is completed, the first position is empty and cannot be assigned again. At this time, the first head pointer and the second tail pointer can be moved back one position, that is, the first head pointer and the first tail pointer point to the second position. By pointing the first head pointer and the first tail pointer to the same position, a loop in the first-level flow table queue of thread 1 is achieved.
[0111] S2033: Determine whether the second-level flow table queue of the NUMA node where the thread is located is empty. If not, execute S2034; if so, execute S2035.
[0112] When the first-level flow table queue of the thread itself is empty, it is necessary to allocate a flow table information for the thread from the upper-level flow table queue. The upper-level flow table queue contains the second-level flow table queue of the NUMA node on which it runs and the third-level flow table queue of each NUMA node. According to the priority order, the second-level flow table queue needs to be accessed first. Therefore, it is necessary to determine whether the second-level flow table queue is empty.
[0113] S2034: Allocate multiple flow table information from the second-level flow table queue and store them in the first-level flow table queue of the thread itself, and allocate one flow table information from the first-level flow table queue to the thread.
[0114] When the second-level flow table queue of the NUMA node running the thread is not empty, it indicates that a flow table information can be allocated to the thread from the second-level flow table queue without accessing the third-level flow table queue.
[0115] For example, the first-level flow table queue of thread 1 itself is empty, but the second-level flow table queue of the NUMA node on which it runs is not empty. At this time, as shown in Figure 7C, 5 flow table IDs are first allocated from the second-level flow table queue to the first-level flow table queue of thread 1 at a time, and then 1 flow table information is allocated to thread 1 from the first-level flow table queue.
[0116] Among them, when allocating multiple flow table information from the second-level flow table queue to the first-level flow table queue, specifically, obtain the current second head pointer in the second-level flow table queue, store the flow table information at the position pointed to by the second head pointer, and at least one flow table information thereafter, into the first-level flow table queue of the thread itself, and point the second head pointer to the position of the first flow table information in the remaining flow table information.
[0117] For example, as shown in Figure 7D , when a flow table ID is assigned to the second-level flow table queue of the NUMA node running thread 1, before the assignment, the second head pointer and second tail pointer in the current second-level flow table queue both point to the first position in the queue. Therefore, flow table ID 1 at the first position and the four subsequent flow table IDs are assigned to the first-level flow table queue of thread 1. After the assignment is complete, the second head pointer and second tail pointer are shifted backward by five positions, that is, they point to the sixth position. By pointing the second head pointer and second tail pointer to the same position, a loop is implemented in the second-level flow table queue of the NUMA node.
[0118] The process of allocating flow table information from the first level flow table queue to the thread after the second level flow table queue is allocated to the first level flow table queue is referred to in S2032 and will not be repeated here.
[0119] S2035: Allocate multiple flow table information from the third-level flow table queue and store them in the second-level flow table queue of the NUMA node where the thread is located, and allocate multiple flow table information from the second-level flow table queue and store them in the first-level flow table queue of the thread itself, and allocate one flow table information for the thread from the first-level flow table queue.
[0120] When the second-level flow table queue of the NUMA node running the thread is empty, it is necessary to access the third-level flow table queue to allocate a flow table information for it.
[0121] For example, when the first-level flow table queue of thread 1 itself and the second-level flow table queue of the NUMA node on which it runs are both empty, at this time, as shown in Figure 7E, 17 flow table IDs are first allocated from the third-level flow table queue to the second-level flow table queue of the NUMA node where thread 1 is located, and then 5 flow table IDs are allocated from the second-level flow table queue to the first-level flow table queue of thread 1 itself, and finally 1 flow table information is allocated to thread 1 from the first-level flow table queue.
[0122] Among them, when allocating multiple flow table information from the third-level flow table queue to the second-level flow table queue, specifically, obtain the current third head pointer in the third-level flow table queue, store the flow table information at the position pointed to by the third head pointer, and at least one flow table information thereafter, in the second-level flow table queue of the NUMA node where the thread is distributed, and point the third head pointer to the position of the first flow table information in the remaining flow table information.
[0123] For example, as shown in Figure 7F , before allocation, the third head pointer and third tail pointer in the current third-level flow table queue both point to the first position in the queue. Therefore, flow table ID 1 at the first position and the 16 subsequent flow table IDs are allocated to the second-level flow table queue of the NUMA node running thread 1. After allocation, the third head pointer and third tail pointer are shifted backward by 17 positions, that is, the second head pointer and second tail pointer point to the 18th position. By pointing the third head pointer and third tail pointer to the same position, a loop is implemented in the third-level flow table queue.
[0124] In the flow table management method provided by the embodiment of the present application, since each first-level flow table queue is exclusively used by one thread and will not be accessed by other threads, flow table information can be efficiently and concurrently allocated to each thread from each first-level flow table queue without locking or using atomic instructions. Atomic instructions will only be used when the first-level flow table queue is empty and the upper-level flow table queue needs to be accessed for flow table information allocation, and memory access across NUMA nodes may only occur when flow table information is allocated from the third-level flow table. In this way, in the case of high concurrency, the number of memory accesses across NUMA nodes can be minimized to the greatest extent, thereby improving the access performance of the flow table queue.
[0125] For example, taking the allocation of 4096 flow table information from the third-level flow table queue to the second-level flow table queue of a thread's NUMA node at a time, and the allocation of 4096 flow table information from the second-level flow table queue to the first-level flow table queue of a thread as an example, only one-64th of the memory access requires the use of atomic instructions, and on average, one memory access across NUMA nodes is performed for every 256K allocations.
[0126] S204: The server device uses an atomic instruction to store the flow table information carried in the flow table release request into the third-level flow table queue.
[0127] Since each first-level flow table queue is exclusively used by one thread, and the flow table information in the third-level flow table queue can be allocated to the lower-level flow table queue, in order to ensure that the released flow table information can be reallocated to other threads, when the thread's flow table management request is a flow table release request, the flow table information carried by the flow table release request can be stored in the third-level flow table queue with the lowest priority.
[0128] Flow table information is often released during network traffic aging and is generally not part of the critical path affecting virtual switch performance. To ensure first-in, first-out semantics, the server uses atomic instructions to store the released flow table information of each thread in a third-level flow table queue. The release rate of flow table information is slower than the allocation rate of flow table information.
[0129] During specific implementation, the current fourth head pointer in the third-level flow table queue is obtained, the flow table information carried by the flow table release request is stored at the position pointed to by the fourth head pointer, and the fourth head pointer is moved to the next position, thereby ensuring that the released flow table information will be allocated again only after other flow table information before the released flow table information is allocated.
[0130] For example, as shown in FIG8A , before thread 3 releases flow table ID 100, the fourth head pointer and the fourth tail pointer in the current third-level flow table queue both point to the 100th position. This position does not store a flow table ID, that is, the position is empty, so the released flow table ID 100 can be stored at this position. When the server device receives the flow table release request sent by thread 3, it places flow table ID 100 at the current positions pointed to by the fourth head pointer and the fourth tail pointer, and moves the fourth head pointer and the fourth tail pointer backward by one position, as shown in FIG8B .
[0131] As can be seen from Figures 8A and 8B, the third-level flow table queue is different from the first-level flow table queue and the second-level flow table queue. The third-level flow table queue includes two head pointers and two tail pointers, where the third head pointer and the third tail pointer are used to cyclically manage the allocation of flow table information, and the fourth head pointer and the fourth tail pointer are used to cyclically manage the release of flow table information.
[0132] In an embodiment of the present application, by maintaining the head pointer in the flow table queue at each level, when the flow table information is allocated, it is always allocated starting from the position pointed to by the head pointer, and when the flow table information is released, it is always stored at the position pointed to by the head pointer. While minimizing the use of thread competition for flow table information and atomic instructions, the orderliness of flow table information allocation and release is achieved, and the "first in, first out" queue semantics are guaranteed, thereby improving the predictability of flow table information allocation and release, which is more friendly to the pipeline design of virtual switches and smart network cards; and, the tail pointer corresponding to each head pointer is pointed to the same position in the flow table queue, forming a bidirectional ring flow table queue, so that the flow table queue can be recycled.
[0133] In one example, after each thread is assigned a flow table information in a lock-free state, a processing operation is performed on the data packets transmitted by each thread based on the flow table information of each thread, wherein the processing operation includes one of searching, forwarding, modifying and deleting the data packet, and the data packet includes one of an image data packet, a voice data packet, a text data packet and a web page data packet.
[0134] Taking the forwarding operation of a text data packet between the first thread and the second thread as an example, as shown in Figure 9, the first thread packages the text data input by object A through terminal device 1 into a text data packet, and sends the text data packet to the server device based on the first flow table information assigned to it. The server device forwards the text data packet to the second thread based on the second flow table information assigned to the second thread, and after decoding it through terminal device 2, displays it to object B.
[0135] Based on the same technical concept, an embodiment of the present application provides a structural diagram of a flow table management device for data packet processing, which can implement the above-mentioned flow table management method for data packet processing and achieve the same technical effect.
[0136] 10 , the flow table management device includes a request receiving module 1001 and a flow table management module 1002, wherein:
[0137] A request receiving module 1001 is configured to receive flow table management requests concurrently sent by multiple threads, wherein at least one of the multiple threads runs on a NUMA node;
[0138] The flow table management module 1002 is configured to allocate flow table information to each thread in a lock-free manner, based on the priority order of the various levels of flow table queues contained in the flow table information pool in the memory file system, when the thread's flow table management request is a flow table allocation request; wherein the various levels of flow table queues include at least a first-level flow table queue, a second-level flow table queue, and a third-level flow table queue; and, when the thread's flow table management request is a flow table release request, use an atomic instruction to store the flow table information carried in the flow table release request in the third-level flow table queue.
[0139] Among them, in the flow table queues at each level, each first-level flow table queue stores the flow table information available in the local memory of a thread itself, each second-level flow table queue stores the flow table information available in the local memory of each thread of the at least one thread running on a NUMA node, and the third-level flow table queue stores the flow table information available in the total memory of each NUMA node. The flow table information in the flow table queues at each level does not overlap with each other, the priority of the first-level flow table queue is higher than the priority of the second-level flow table queue, and the priority of the second-level flow table queue is higher than the priority of the third-level flow table queue.
[0140] In some embodiments, the flow table management module 1002 is specifically configured to:
[0141] When the first-level flow table queue of the thread itself is not empty, a flow table information is allocated to the thread from the first-level flow table queue;
[0142] When the first-level flow table queue of the thread itself is empty, a flow table information is allocated to the thread from the upper-level flow table queue.
[0143] In some embodiments, the flow table management module 1002 is specifically configured to:
[0144] When the second-level flow table queue of the NUMA node where the thread is located is not empty, multiple flow table information is allocated from the second-level flow table queue and stored in the first-level flow table queue of the thread itself, and a flow table information is allocated to the thread from the first-level flow table queue;
[0145] When the second-level flow table queue of the NUMA node where the thread is located is empty, multiple flow table information is allocated from the third-level flow table queue and stored in the second-level flow table queue of the NUMA node where the thread is located, and multiple flow table information is allocated from the second-level flow table queue and stored in the first-level flow table queue of the thread itself, and a flow table information is allocated to the thread from the first-level flow table queue.
[0146] In some embodiments, the flow table management module 1002 is specifically configured to:
[0147] Get the current third head pointer in the third-level flow table queue, store the flow table information at the position pointed to by the third head pointer, and at least one flow table information thereafter, in the second-level flow table queue of the NUMA node where the thread is located, and point the third head pointer to the position of the first flow table information in the remaining flow table information.
[0148] In some embodiments, the flow table management module 1002 is specifically configured to:
[0149] Get the current second head pointer in the second-level flow table queue, store the flow table information at the position pointed to by the second head pointer, and at least one flow table information thereafter, into the first-level flow table queue of the thread itself, and point the second head pointer to the position of the first flow table information in the remaining flow table information.
[0150] In some embodiments, the flow table management module 1002 is specifically configured to:
[0151] The first head pointer of the current first level flow table queue is obtained, the flow table information at the position pointed by the first head pointer is allocated to the thread, and the first head pointer is pointed to the position of the next flow table information.
[0152] In some embodiments, the flow table management module 1002 is specifically configured to:
[0153] The fourth head pointer in the third-level flow table queue is obtained, the flow table information carried in the flow table release request is stored in the position pointed to by the fourth head pointer, and the fourth head pointer is moved to the next position.
[0154] In some embodiments, the release speed of storing the flow table information carried in the flow table release request in the third-level flow table queue is lower than the allocation speed of allocating flow table information to other threads without lock.
[0155] In some embodiments, a data processing module 1003 is also included for performing processing operations on data packets transmitted by each thread based on the flow table information of each thread, wherein the processing operation includes one of searching, forwarding, modifying and deleting the data packet, and the data packet includes one of an image data packet, a voice data packet, a text data packet and a web page data packet.
[0156] In a flow table management device for data packet processing provided by an embodiment of the present application, a cascaded ring queue data structure is used to store and manage flow tables. Among the flow table queues at each level, each first-level flow table queue stores the flow table information available in the local memory of a thread itself, that is, each first-level flow table queue is exclusively used by a thread and does not compete with other threads for flow table information. Therefore, for each thread requesting flow table allocation, flow table information can be allocated concurrently from the first-level flow table queue corresponding to each thread without lock, thereby improving the efficiency of flow table allocation. When there is no flow table information available to be allocated in the first-level flow table queue, flow table information can be allocated to each thread in sequence from the second-level flow table queue and the third-level flow table queue, thereby ensuring the stability of flow table information allocation for each thread through queue cascading. When the thread's flow table management request is a flow table release request, an atomic instruction is used to store the flow table information carried by the flow table release request in the third-level flow table queue with the lowest priority. At the same time, for each thread requesting to release a flow table, the released flow table information is stored in the third-level flow table queue with the lowest priority. This ensures that after the unallocated flow table information is allocated, the newly released flow table information can be reallocated, thereby improving the utilization of flow table information. Furthermore, the cascaded ring queue data structure is mapped in the in-memory file system to achieve pooled management of flow table information. The in-memory file system can be accessed to allocate or release flow table information as if it were local memory, which improves the management speed of flow table information.
[0157] Based on the same inventive concept as the above-mentioned method embodiment, an electronic device is also provided in an embodiment of the present application. In one embodiment, the electronic device can be a server device or a smart network card. In this embodiment, the structure of the electronic device can be as shown in Figure 11, including a memory 1101, a communication module 1103, and one or more processors 1102.
[0158] The memory 1101 is used to store computer programs executed by the processor 1102. The memory 1101 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and an operating instruction set.
[0159] Memory 1101 may be a volatile memory, such as random-access memory (RAM); a non-volatile memory, such as read-only memory, flash memory, a hard disk drive (HDD), or a solid-state drive (SSD); or any other medium capable of carrying or storing a desired computer program in the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1101 may be a combination of the aforementioned memories.
[0160] The processor 1102 may include one or more central processing units (CPUs) or digital processing units, etc. The processor 1102 is configured to implement the flow table management method for data packet processing when calling the computer program stored in the memory 1101 .
[0161] The communication module 1103 is used to communicate with terminal devices and other servers.
[0162] The specific connection medium between the memory 1101, communication module 1103, and processor 1102 is not limited in the embodiments of the present application. In Figure 11, the embodiment of the present application shows that the memory 1101 and the processor 1102 are connected via a bus 1104. The bus 1104 is depicted in bold in Figure 11. The connection methods between other components are merely schematic and are not intended to be limiting. The bus 1104 can be divided into an address bus, a data bus, a control bus, etc. For ease of description, Figure 11 only uses a single bold line, but does not represent only one bus or one type of bus.
[0163] The memory 1101 stores a computer storage medium, which stores computer executable instructions for implementing the flow table management method for data packet processing according to an embodiment of the present application. The processor 1102 is configured to execute the steps of the flow table management method for data packet processing.
[0164] In some possible implementations, various aspects of the data classification method provided in the present application can also be implemented in the form of a program product, which includes a computer program. When the program product is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the flow table management method for data packet processing according to various exemplary embodiments of the present application described above in this specification. For example, the electronic device can execute the steps shown in Figure 2.
[0165] The program product may utilize any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples of readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical fiber, a portable compact disk read-only memory, an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0166] The program product of the embodiment of the present application may be a portable compact disk read-only memory and include a computer program, and can be run on an electronic device. However, the program product of the present application is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with a command execution system, apparatus, or device.
[0167] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries a readable computer program. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with a command execution system, apparatus, or device.
[0168] The computer program embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0169] The computer program for performing the operations of the present application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, and the like, as well as conventional procedural programming languages such as "C" or similar programming languages. The computer program can be executed entirely on the user computing device, partially on the user computing device, as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device via any type of network, including a local area network or a wide area network, or can be connected to an external computing device.
[0170] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain a computer-usable computer program.
[0171] Although the embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the embodiments and all changes and modifications that fall within the scope of the present application.
[0172] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A flow table management method for data packet processing, executed by a server device, the method comprising: Receiving flow table management requests concurrently sent by multiple threads respectively, wherein at least one thread among the multiple threads runs on a non-uniform memory access NUMA node; For each thread, do the following: When the flow table management request of the thread is a flow table allocation request, based on the priority order of the flow table queues at various levels contained in the flow table information pool in the memory file system, a flow table information is allocated to the thread in a lock-free state; wherein the flow table queues at various levels include at least a first-level flow table queue, a second-level flow table queue and a third-level flow table queue, each of the first-level flow table queues stores flow table information available in the local memory of a thread itself, each of the second-level flow table queues stores flow table information available in the local memory of each thread of the at least one thread running on a non-consistent memory access NUMA node, the third-level flow table queue stores flow table information available in the total memory of each non-consistent memory access NUMA node, the flow table information in the flow table queues at various levels do not overlap with each other, the priority of the first-level flow table queue is higher than the priority of the second-level flow table queue, and the priority of the second-level flow table queue is higher than the priority of the third-level flow table queue; When the flow table management request of the thread is a flow table release request, an atomic instruction is used to store the flow table information carried by the flow table release request in the third-level flow table queue.
2. The method of claim 1, wherein: The priority order of each level of flow table queues contained in the flow table information pool in the memory is based on, and a flow table information is allocated to the thread in a lock-free state, including: When the first-level flow table queue of the thread itself is not empty, allocating a flow table information for the thread from the first-level flow table queue; When the first-level flow table queue of the thread itself is empty, a flow table information is allocated to the thread from the upper-level flow table queue.
3. The method of claim 2, wherein: The allocating a flow table information to the thread from the upper level flow table queue includes: When the second-level flow table queue of the non-uniform memory access NUMA node where the thread is located is not empty, multiple flow table information is allocated from the second-level flow table queue to be stored in the first-level flow table queue of the thread itself, and one flow table information is allocated to the thread from the first-level flow table queue; When the second-level flow table queue of the non-consistent memory access NUMA node where the thread is located is empty, multiple flow table information are allocated from the third-level flow table queue and stored in the second-level flow table queue of the non-consistent memory access NUMA node where the thread is located, and multiple flow table information are allocated from the second-level flow table queue and stored in the first-level flow table queue of the thread itself, and one flow table information is allocated to the thread from the first-level flow table queue.
4. The method of claim 3, wherein: The allocating multiple flow table information from the third-level flow table queue to be stored in the second-level flow table queue of the non-uniform memory access NUMA node where the thread is located includes: Obtain the current third head pointer in the third-level flow table queue, store the flow table information at the position pointed to by the third head pointer, and at least one subsequent flow table information, in the second-level flow table queue of the non-uniform memory access NUMA node where the thread is located, and point the third head pointer to the position of the first flow table information in the remaining flow table information.
5. The method of claim 3, wherein: The allocating a plurality of flow table information from the second-level flow table queue to be stored in the first-level flow table queue of the thread itself includes: Get the current second head pointer in the second-level flow table queue, store the flow table information at the position pointed to by the second head pointer and at least one subsequent flow table information into the first-level flow table queue of the thread itself, and point the second head pointer to the position of the first flow table information in the remaining flow table information.
6. The method according to claim 2 or 3, wherein: The allocating a flow table information to the thread from the first-level flow table queue includes: The first head pointer currently in the first-level flow table queue is obtained, the flow table information at the position pointed to by the first head pointer is allocated to the thread, and the first head pointer is pointed to the position of the next flow table information.
7. The method of claim 1, wherein: The adopting of atomic instructions to store the flow table information carried by the flow table release request in the third-level flow table queue includes: The fourth head pointer currently in the third-level flow table queue is obtained, the flow table information carried in the flow table release request is stored in the position pointed to by the fourth head pointer, and the fourth head pointer is moved to the next position.
8. The method of claim 1, wherein: The release speed of storing the flow table information carried by the flow table release request in the third-level flow table queue is lower than the allocation speed of allocating flow table information to other threads without lock.
9. The method of claim 1, wherein: After allocating a flow table information to each thread in a lock-free state, the method further includes: Based on the flow table information of each thread, processing operations are performed on the data packets transmitted by the threads, wherein the processing operations include one of searching, forwarding, modifying and deleting the data packets, and the data packets include one of image data packets, voice data packets, text data packets and web page data packets.
10. A flow table management device for data packet processing, comprising: A request receiving module, used to receive flow table management requests sent concurrently by multiple threads respectively, wherein at least one thread among the multiple threads runs on a non-uniform memory access non-uniform memory access NUMA node; A flow table management module, for each thread, when the flow table management request of the thread is a flow table allocation request, based on the priority order of the flow table queues at various levels contained in the flow table information pool in the memory file system, allocate a flow table information for the thread in a lock-free state, wherein the flow table queues at various levels include at least a first-level flow table queue, a second-level flow table queue and a third-level flow table queue; and when the flow table management request of the thread is a flow table release request, using an atomic instruction to store the flow table information carried by the flow table release request in the third-level flow table queue; Among them, each first-level flow table queue stores the flow table information available in the local memory of a thread itself, each second-level flow table queue stores the flow table information available in the local memory of each thread of the at least one thread running on a non-consistent memory access NUMA node, and the third-level flow table queue stores the flow table information available in the total memory of each non-consistent memory access NUMA node. The flow table information in the flow table queues at each level does not overlap with each other, the priority of the first-level flow table queue is higher than the priority of the second-level flow table queue, and the priority of the second-level flow table queue is higher than the priority of the third-level flow table queue.
11. The device of claim 10, wherein: The flow table management module is used to: when the first-level flow table queue of the thread itself is not empty, allocate a flow table information for the thread from the first-level flow table queue; when the first-level flow table queue of the thread itself is empty, allocate a flow table information for the thread from the upper-level flow table queue.
12. The device of claim 11, wherein: The flow table management module is used for: When the second-level flow table queue of the non-uniform memory access NUMA node where the thread is located is not empty, multiple flow table information is allocated from the second-level flow table queue to be stored in the first-level flow table queue of the thread itself, and one flow table information is allocated to the thread from the first-level flow table queue; When the second-level flow table queue of the non-consistent memory access NUMA node where the thread is located is empty, multiple flow table information are allocated from the third-level flow table queue and stored in the second-level flow table queue of the non-consistent memory access NUMA node where the thread is located, and multiple flow table information are allocated from the second-level flow table queue and stored in the first-level flow table queue of the thread itself, and one flow table information is allocated to the thread from the first-level flow table queue.
13. The device of claim 12, wherein: The flow table management module is used for: Obtain the current third head pointer in the third-level flow table queue, store the flow table information at the position pointed to by the third head pointer, and at least one subsequent flow table information, in the second-level flow table queue of the non-uniform memory access NUMA node where the thread is located, and point the third head pointer to the position of the first flow table information in the remaining flow table information.
14. The device of claim 12, wherein: The flow table management module is used for: Get the current second head pointer in the second-level flow table queue, store the flow table information at the position pointed to by the second head pointer and at least one subsequent flow table information into the first-level flow table queue of the thread itself, and point the second head pointer to the position of the first flow table information in the remaining flow table information.
15. The device according to claim 11 or 12, wherein: The flow table management module is used for: The first head pointer currently in the first-level flow table queue is obtained, the flow table information at the position pointed to by the first head pointer is allocated to the thread, and the first head pointer is pointed to the position of the next flow table information.
16. The device of claim 10, wherein: The flow table management module is used for: The fourth head pointer currently in the third-level flow table queue is obtained, the flow table information carried in the flow table release request is stored in the position pointed to by the fourth head pointer, and the fourth head pointer is moved to the next position.
17. The device of claim 10, wherein: The release speed of storing the flow table information carried by the flow table release request in the third-level flow table queue is lower than the allocation speed of allocating flow table information to other threads without lock.
18. An electronic device comprising a processor and a memory, wherein: The memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to perform the steps of any one of the methods of claims 1-9.
19. A computer-readable storage medium comprising a computer program, wherein when the computer program is run on an electronic device, the computer program is used to cause the electronic device to execute the steps of the method according to any one of claims 1 to 9.
20. A computer program product, comprising a computer program, wherein the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps of any of the methods described in claims 1-9.
Citation Information
Patent Citations
SDN (Software Defined Networking) controller classifying network flows through DPI (Deep Packet Inspection) data package
CN104394090A
Message control method, flow table updating method and node equipment
CN110708253A
Network monitoring method based on software definition
CN113518043A
Distributed computing communication integrated scheduling method based on SDN (Software Defined Network) and related components
CN115883490A
Flow table management method and device for data packet processing, equipment and storage medium
CN116962311A
