Method, device and equipment for synchronizing flow table entries of virtual switch, and storage medium
By swapping and reading/writing pointer variables in the memory region of the switch process within the virtual switch, the problem of inconsistent flow table updates during hot upgrades is resolved, achieving full synchronization of the flow table and improving system stability and reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA TELECOM CLOUD TECH CO LTD
- Filing Date
- 2025-04-30
- Publication Date
- 2026-06-16
AI Technical Summary
Existing technologies lack a method for handling flow table updates during the hot upgrade process of virtual switches, resulting in inconsistencies in flow tables before and after the upgrade, which affects network traffic forwarding performance.
By obtaining the memory region pointer variables of the first and second processes in the virtual switch, the pointer variables are swapped and read/write operations are performed. Based on the read operation, the modified flow table entries in the first process are obtained and synchronized. At the end of the flow table synchronization process, full synchronization is completed to ensure that the flow table entries of the second process are completely updated.
It achieves full synchronization of flow tables during the hot upgrade process of virtual switches, improves the stability and reliability of the system, prevents flow table updates from not being synchronized to the second process, and ensures network performance.
Smart Images

Figure CN120455361B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of cloud computing technology, specifically to a method, apparatus, device, and storage medium for synchronizing flow table entries of a virtual switch. Background Technology
[0002] With the rapid development of cloud computing technology, virtual switches are playing an increasingly important role in modern cloud network architectures. The efficient operation and continuous service capabilities of virtual switches are crucial for ensuring network stability and reliability. In practical applications, to continuously improve the performance of virtual switches, fix vulnerabilities, or add new functions, upgrades are necessary. However, traditional upgrade methods often require service interruption, causing significant inconvenience to network service assurance. Hot upgrades, on the other hand, can ensure uninterrupted service while minimizing the impact of upgrades on the network.
[0003] Existing hot upgrade solutions include technologies such as dual-process and primary / backup failover. The dual-process solution has received considerable attention due to its advantages in lower resource consumption and flexibility. In the dual-process solution, the first process needs to synchronize configuration information, including flow tables, ports, and controller information, with the second process. To ensure uninterrupted traffic, the old virtual switch remains operational during the hot upgrade process, and its flow tables are likely to be updated during this process. However, there is currently a lack of methods to handle flow table updates during hot upgrades. Summary of the Invention
[0004] In view of this, this disclosure provides a method, apparatus, device, and storage medium for synchronizing flow table entries of a virtual switch to solve the problem of the current lack of a way to handle flow table updates during hot upgrades.
[0005] In a first aspect, this disclosure provides a method for synchronizing flow table entries of a virtual switch, the method comprising:
[0006] Get the first memory region pointed to by the pointer variable of the first process in the virtual switch, and the second memory region pointed to by the pointer variable of the second process in the virtual switch;
[0007] If it is determined that the first process has performed a write operation on the first memory region, the pointer variable of the first process is set to point to the second memory region, the pointer variable of the second process is set to point to the first memory region, and the first process performs a write operation on the second memory region and the second process performs a read operation on the first memory region.
[0008] The target flow table entry that has been modified in the first process is obtained based on the read operation, and the target flow table entry is synchronized to the second process. The first memory area where the read operation was performed is cleared.
[0009] At the end of the flow table synchronization process, the memory regions pointed to by the first and second processes are retrieved again. The second process synchronizes the flow table based on the memory region read results, completes the final flow table update operation, and obtains the full synchronization result of the flow table entries of the second process during the hot upgrade process.
[0010] In this embodiment, the system obtains the first memory region pointed to by the pointer variable of the first process in the virtual switch and the second memory region pointed to by the pointer variable of the second process in the virtual switch. Then, when it is determined that the first process has performed a write operation on the first memory region, the pointer variable of the first process is set to point to the second memory region, and the pointer variable of the second process is set to point to the first memory region. The first process then performs a write operation on the second memory region, and the second process performs a read operation on the first memory region. Based on the read operation, the target flow table entry modified in the first process is obtained, and the target flow table entry is synchronized to the second process. Then, at the end of the flow table synchronization process, the memory regions pointed to by the first and second processes are obtained again. The second process synchronizes the flow table based on the memory region read results, completing the final flow table update operation. This accurately transmits the flow table entry information to be synchronized, achieving full synchronization of the flow table and preventing the updated flow table from not being synchronized to the second process during hot upgrades.
[0011] In one alternative implementation, determining that the first process performed a write operation on the first memory region includes:
[0012] Upon receiving target indication information, the modified target flow table entry is obtained based on the target indication information. The target indication information is used to characterize that the first process has been upgraded and that an identification operation has been inserted into the update action function of the target flow table entry of the first process. The identification operation is used to indicate that the target flow table entry has been modified.
[0013] Obtain the target bit corresponding to the target stream table entry in the first memory region;
[0014] Perform a write operation on the target bit in the first memory region.
[0015] In this embodiment of the disclosure, if the first process updates the flow table, the second process reads the target bit in the first memory region by marking the target bit in the first memory region as dirty, and obtains the target flow table entry based on the target bit, thereby achieving the purpose of synchronizing the target flow table entry.
[0016] In one optional implementation, obtaining the target bit corresponding to the target flow table entry in the first memory region includes:
[0017] Calculate the offset of the target flow table entry in the first memory region;
[0018] The target position is determined based on the offset.
[0019] In this embodiment of the disclosure, the target bit is determined by the offset of the target flow table entry in the first memory region, which facilitates quick and accurate location of the target bit.
[0020] In one alternative implementation, retrieving the target flow table entry that has been modified in the first process based on a read operation includes:
[0021] Read all bit information in the first memory region based on the read operation;
[0022] When the target bit is read, the index information is obtained based on the target bit, where the index information corresponds to the target flow table entry;
[0023] The target flow table entry is obtained by searching the flow table database based on the index information.
[0024] In this embodiment of the disclosure, by obtaining index information through the target bit and then finding the target flow table entry, the flow table labeling and processing during the hot upgrade process of the virtual switch can be effectively realized, thereby improving the stability and reliability of the system.
[0025] In one optional implementation, the execution action corresponding to the update action function includes at least one or more of the following: deletion of a flow table entry, addition of a flow table entry, status update of a flow table entry, and creation of a new flow table entry.
[0026] In one alternative implementation, retrieving the target flow table entry that has been modified in the first process based on a read operation includes:
[0027] Based on the read operation, all bit information in the first memory region is read sequentially;
[0028] After reading all the bit information, obtain all the target stream table entries.
[0029] In this embodiment of the disclosure, after reading all the bit information in the first memory region, all the target flow table entries can be obtained, thereby achieving full synchronization of the flow table.
[0030] Secondly, this disclosure provides a flow table entry synchronization device for a virtual switch, the device comprising:
[0031] The first acquisition module is used to acquire the first memory region pointed to by the pointer variable of the first process in the virtual switch, and the second memory region pointed to by the pointer variable of the second process in the virtual switch.
[0032] The swap module is used to, when it is determined that the first process has performed a write operation on the first memory region, point the pointer variable of the first process to the second memory region, point the pointer variable of the second process to the first memory region, and cause the first process to perform a write operation on the second memory region and the second process to perform a read operation on the first memory region.
[0033] The synchronization module is used to obtain the target flow table entry that has been modified in the first process based on the read operation, synchronize the target flow table entry to the second process, and clear the first memory area where the read operation was performed.
[0034] The second acquisition module is used to acquire the memory regions pointed to by the first process and the second process again when the flow table synchronization process ends. The second process synchronizes the flow table according to the reading result of the memory region, completes the last step of the flow table update operation, and obtains the full synchronization result of the flow table entries of the second process during the hot upgrade process.
[0035] Thirdly, this disclosure provides a computer device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to perform the flow table entry synchronization method of the virtual switch described in the first aspect or any corresponding embodiment.
[0036] Fourthly, this disclosure provides a computer-readable storage medium storing computer instructions for causing a computer to execute the flow table entry synchronization method of a virtual switch according to the first aspect or any corresponding embodiment thereof.
[0037] Fifthly, this disclosure provides a computer program product, including computer instructions for causing a computer to execute the flow table entry synchronization method of a virtual switch according to the first aspect or any corresponding embodiment thereof. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the specific embodiments of this disclosure or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0039] Figure 1 This is a flowchart illustrating a flow table entry synchronization method for a virtual switch according to an embodiment of the present disclosure;
[0040] Figure 2 This is a schematic diagram of flow table entry synchronization of a virtual switch according to another embodiment of the present disclosure;
[0041] Figure 3 This is a schematic diagram of inter-process interaction according to an embodiment of the present disclosure;
[0042] Figure 4 This is a structural block diagram of a flow table entry synchronization device for a virtual switch according to an embodiment of the present disclosure;
[0043] Figure 5 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present disclosure. Detailed Implementation
[0044] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0045] During current hot upgrades of virtual switches, old processes remain active, and their flow tables are likely to be updated during the upgrade process. Complete synchronization of flow tables during a hot upgrade is crucial for network performance. The lack of a mechanism to ensure complete synchronization of flow tables before and after a hot upgrade can lead to inconsistencies, impacting network traffic forwarding performance. Currently, there is a lack of methods to handle flow table updates during hot upgrades.
[0046] To address the aforementioned problems, according to an embodiment of this disclosure, a method for synchronizing flow table entries of a virtual switch is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0047] This embodiment provides a method for synchronizing flow table entries of a virtual switch. Figure 1 This is a flowchart of a flow table entry synchronization method for a virtual switch according to an embodiment of the present disclosure, such as... Figure 1 As shown, this method can be applied to virtual switches, and the method process includes the following steps:
[0048] Step S101: Obtain the first memory region pointed to by the pointer variable of the first process in the virtual switch, and the second memory region pointed to by the pointer variable of the second process in the virtual switch.
[0049] Optionally, the virtual switch in this embodiment of the disclosure adopts a dual-process technical approach in hot upgrades, such as... Figure 2As shown, a virtual switch contains a first process (the old process) and a second process (the new process). When a flow table entry in the first process is updated, the updated flow table entry needs to be synchronized to the second process to implement the flow table synchronization mechanism. Here, a flow table entry refers to the flow table entry information of the switch. Furthermore, the switch flow table mechanism is a key mechanism in the switch used for data forwarding decisions. It consists of a header field (matching field), a counter, and an action. The header field is used to match the packet header content, the counter counts data flow-related information, and the action indicates how the switch should handle the matching packet, such as forwarding, dropping, or modifying the packet content.
[0050] Specifically, a control channel and a data channel are established between the first process and the second process (i.e., the two processes). The control channel is used to transmit configuration information such as ports and controllers, while the data channel is used for flow table synchronization. The data channel is implemented based on shared memory. Additionally, two swap areas are established in the shared memory region of the two processes, namely the first memory region (…). Figure 2 bitmap1 in the second memory region ( Figure 2 bitmap2 in the middle). Figure 2 As shown, in the initial stage, the pointer variable of the first process points to the first memory region, and the pointer variable of the second process in the virtual switch points to the second memory region.
[0051] It should be noted that, in this embodiment of the disclosure, two buffers (i.e., the first memory region and the second memory region) are opened in the large page memory for the flow table to be marked as dirty, and all bits in the memory region are initialized to 0. Then, two long type volatile pointer variables are defined to point to these two buffers. The first memory region is used to perform read operations, and the second memory region is used to perform write operations. The read and write operations of the two memory regions are swapped at appropriate times to achieve complete synchronization of flow table entries.
[0052] Additionally, during a hot upgrade of a virtual switch, "dirty" marking is a mechanism for indicating the state of specific entries in a flow table. When a flow table update is detected during the upgrade process, the relevant flow table entries are marked as "dirty," indicating that these entries need to be synchronized.
[0053] Step S102: If it is determined that the first process has performed a write operation on the first memory region, the pointer variable of the first process is set to point to the second memory region, the pointer variable of the second process is set to point to the first memory region, and the first process performs a write operation on the second memory region and the second process performs a read operation on the first memory region.
[0054] Optionally, if the first process performs a write operation on the first memory region, it means that the flow table entry of the virtual switch has been changed during the hot upgrade process. The bit corresponding to the changed flow table entry in the first memory region will be changed from the initial 0 to 1.
[0055] Then, the positions of the first and second memory regions need to be swapped. Specifically, the pointer variable of the second process is changed from pointing to the second memory region to pointing to the first memory region, and the pointer variable of the first process is changed from pointing to the first memory region to pointing to the second memory region.
[0056] Implement position swapping (see Figure 2 After the "switch" in the memory, the virtual switch then allows the first process to perform a write operation on the second memory region, and the second process to perform a read operation on the first memory region.
[0057] It should be noted that, Figure 2 Whether the operation performed on bitmap1 and bitmap2 in shared memory is a write operation or a read operation depends mainly on the object being accessed. If the object being accessed is the first process, then a write operation is performed; if the object being accessed is the second process, then a write operation is performed.
[0058] Step S103: Obtain the target flow table entry that has been modified in the first process based on the read operation, synchronize the target flow table entry to the second process, and clear the first memory area where the read operation was performed.
[0059] Optionally, the second process can obtain which flow table entry in the first process has been modified based on the read operation, then use this flow table entry as the target flow table entry, and synchronize the target flow table entry to the second process. When the second process reads various flow table entries in the first memory region, the basis for determining which flow table entry has been modified can be by obtaining a certain identifier, which may include, but is not limited to, marking as dirty.
[0060] Then, the bit records in the first memory area where the read operation was performed are cleared. This way, when the flow table synchronization process ends and another position swap is performed, if the first process writes to the first memory area, the bit records in the first memory area will be cleared, thus enabling the final flow table update and synchronization.
[0061] Step S104: When the flow table synchronization process ends, the memory regions pointed to by the first process and the second process are retrieved again. The second process synchronizes the flow table according to the memory region read result, completes the last flow table update operation, and obtains the full synchronization result of the flow table entries of the second process during the hot upgrade process.
[0062] Optionally, in this embodiment of the disclosure, a condition is set for swapping the positions of the first memory region and the second memory region again. For example, when the flow table synchronization process ends (e.g., all flow table entries are transmitted, or a clear end instruction is received), the memory regions pointed to by the first process and the second process are retrieved again, and then the memory region pointed to by the current second process is retrieved, a read operation is performed on it, and the read result is synchronized to the flow table to ensure that no cases where the target flow table entry is not synchronized to the second process are missed.
[0063] It's important to note that this position swap essentially involves exchanging the access objects of the first and second memory regions, or, more accurately, exchanging the objects pointed to by the pointers of the first and second processes. Since the first process performs write operations and the second process performs read operations, real-time synchronization of flow table entries is necessary. Therefore, after the swap, the hierarchical relationship between the first and second memory regions is altered. This hierarchical relationship is essentially the result of the write operation performed by the first process or the read operation performed by the second process.
[0064] In this embodiment, the system obtains the first memory region pointed to by the pointer variable of the first process in the virtual switch and the second memory region pointed to by the pointer variable of the second process in the virtual switch. Then, when it is determined that the first process has performed a write operation on the first memory region, the pointer variable of the first process is set to point to the second memory region, and the pointer variable of the second process is set to point to the first memory region. The first process then performs a write operation on the second memory region, and the second process performs a read operation on the first memory region. Based on the read operation, the target flow table entry modified in the first process is obtained, and the target flow table entry is synchronized to the second process. Then, at the end of the flow table synchronization process, the memory regions pointed to by the first and second processes are obtained again. The second process synchronizes the flow table based on the memory region read results, completing the final flow table update operation. This accurately transmits the flow table entry information to be synchronized, achieving full synchronization of the flow table and preventing the updated flow table from not being synchronized to the second process during hot upgrades.
[0065] In some alternative implementations, determining that the first process performed a write operation on the first memory region includes:
[0066] Upon receiving target indication information, the modified target flow table entry is obtained based on the target indication information. The target indication information is used to characterize that the first process has been upgraded and that a dirty operation has been inserted into the update action function of the target flow table entry of the first process.
[0067] Obtain the target bit corresponding to the target stream table entry in the first memory region;
[0068] Perform a write operation on the target bit in the first memory region.
[0069] Optionally, if the first process of the virtual switch is upgraded and flow table updates occur during the upgrade, a target indication message will be sent to the virtual switch. After receiving the target indication message, the virtual switch considers that the flow table of the first process has been added, deleted, or modified. By accessing the update action function of each flow table entry in the flow table of the first process, the target flow table entry that has been modified can be obtained.
[0070] It should be noted that the indicator that the first process has updated the flow table during the virtual switch upgrade is that a dirty operation is inserted into the update action function of the target flow table entry of the first process. Here, the target flow table entry refers to any flow table entry information that has been modified.
[0071] Since each bit in the first memory region represents whether a certain array item has been modified, and the array items include, but are not limited to, various flow table entries. At the same time, during the initialization phase, the value of each bit is 0, so the target bit corresponding to the target flow table entry in the first memory region can be calculated through the first calculation, and then the target bit can be modified from 0 to 1 and written into the first memory region to achieve the marking of the bits in the first memory region as dirty.
[0072] In this embodiment of the disclosure, if the first process updates the flow table, the second process reads the target bit in the first memory region by marking the target bit in the first memory region as dirty, and obtains the target flow table entry based on the target bit, thereby achieving the purpose of synchronizing the target flow table entry.
[0073] In some optional implementations, obtaining the target bit corresponding to the target flow table entry in the first memory region includes:
[0074] Calculate the offset of the target flow table entry in the first memory region;
[0075] The target position is determined based on the offset.
[0076] Optionally, when the flow table uses contiguous memory allocation, the virtual switch's operating system allocates a contiguous block of memory for the flow table. Then, the starting address of the flow table is determined, and the offset of the target flow table entry relative to the starting address is calculated.
[0077] Then, based on the offset, the corresponding target bit contained in the first memory region can be obtained.
[0078] In this embodiment of the disclosure, the target bit is determined by the offset of the target flow table entry in the first memory region, which facilitates quick and accurate location of the target bit.
[0079] In some alternative implementations, retrieving the target flow table entry that has been modified in the first process based on a read operation includes:
[0080] Read all bit information in the first memory region based on the read operation;
[0081] When the target bit is read, the index information is obtained based on the target bit, where the index information corresponds to the target flow table entry;
[0082] The target flow table entry is obtained by searching the flow table database based on the index information.
[0083] Optionally, during the flow table entry synchronization phase, based on the read operation performed by the second process on the first memory region, all bit information in the first memory region is read, that is, all bit bits. After reading the bit set to 1, it is determined that the target bit has been read. Then, the corresponding index information is obtained based on the target bit, and then the flow table database is searched based on the index information to obtain the target flow table entry.
[0084] It should be noted that each flow table entry in the flow table database corresponds to an index. Therefore, after obtaining the index information corresponding to the target bit, the target flow table entry can be obtained based on that index information.
[0085] In this embodiment of the disclosure, by obtaining index information through the target bit and then finding the target flow table entry, the flow table labeling and processing during the hot upgrade process of the virtual switch can be effectively realized, thereby improving the stability and reliability of the system.
[0086] In some optional implementations, the execution action corresponding to the update action function includes at least one or more of the following: deletion of a flow table entry, addition of a flow table entry, status update of a flow table entry, and creation of a flow table entry.
[0087] Optionally, the criterion for determining whether a flow table has been modified is to check whether a dirty operation has been inserted into the update action function of the flow table entry. Specifically, if one or more of the following occur: deletion of a flow table entry, addition of a flow table entry, state update of a flow table entry, or creation of a flow table entry, the current flow table entry is considered to have been modified, and a dirty operation is inserted into the update action function of the current flow table entry.
[0088] In some alternative implementations, retrieving the target flow table entry that has been modified in the first process based on a read operation includes:
[0089] Based on the read operation, all bit information in the first memory region is read sequentially;
[0090] After reading all the bit information, obtain all the target stream table entries.
[0091] Optionally, in this embodiment of the present disclosure, the triggering condition for swapping the positions of the first memory region and the second memory region is as follows: the second process sequentially reads all bit information in the first memory region based on a read operation; after reading all bit information and obtaining all target flow table entries, all target flow table entries are synchronized to the second process; then, the records of the bits in the first memory region are cleared, and the positions of the first memory region and the second memory region are swapped, thereby achieving the swapping of the corresponding subordinate relationships.
[0092] Another trigger condition for position swapping is: when the target flow table entry is synchronized and the final update is performed, the position swapping operation is performed (as described in the above embodiments, and will not be repeated here).
[0093] In this embodiment of the disclosure, after reading all the bit information in the first memory region, all the target flow table entries can be obtained, thereby achieving full synchronization of the flow table.
[0094] In some alternative implementations, such as Figure 3 As shown, Figure 3 This is a schematic diagram of inter-process interaction according to an embodiment of the present disclosure. The specific process is as follows:
[0095] Synchronize state information between the first process and the second process;
[0096] A control channel and a data channel are established between the first process and the second process to achieve configuration synchronization;
[0097] Flow table synchronization is achieved between the first process and the second process;
[0098] The second process side implements configuration and flow table installation;
[0099] After the flow table update synchronization is completed on the second process side, an exit command is sent to the first process.
[0100] The first process exits, and the second process finishes its upgrade.
[0101] This embodiment also provides a flow table entry synchronization device for a virtual switch, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.
[0102] This embodiment provides a flow table entry synchronization device for a virtual switch, such as... Figure 4 As shown, it includes:
[0103] The first acquisition module 401 is used to acquire the first memory region pointed to by the pointer variable of the first process in the virtual switch, and the second memory region pointed to by the pointer variable of the second process in the virtual switch.
[0104] The switching module 402 is used to, when it is determined that the first process has performed a write operation on the first memory region, point the pointer variable of the first process to the second memory region, point the pointer variable of the second process to the first memory region, and cause the first process to perform a write operation on the second memory region and the second process to perform a read operation on the first memory region.
[0105] Synchronization module 403 is used to obtain the target flow table entry that has been modified in the first process based on the read operation, synchronize the target flow table entry to the second process, and clear the first memory area where the read operation was performed.
[0106] The second acquisition module 404 is used to acquire the memory regions pointed to by the first process and the second process again when the flow table synchronization process ends. The second process synchronizes the flow table according to the memory region read result, completes the last step of flow table update operation, and obtains the full synchronization result of the flow table entries of the second process during the hot upgrade process.
[0107] In some optional implementations, the switching module 402 is configured to, upon receiving target indication information, obtain the modified target flow table entry based on the target indication information, wherein the target indication information is used to indicate that the first process has been upgraded and that a dirty operation has been inserted into the update action function of the target flow table entry of the first process; obtain the target bit corresponding to the target flow table entry in the first memory region; and perform a write operation on the target bit in the first memory region.
[0108] In some alternative implementations, the switching module 402 is used to calculate the offset of the target flow table entry in the first memory region; and determine the target bit based on the offset.
[0109] In some optional implementations, the synchronization module 403 is used to read all bit information in the first memory region based on the read operation; when the target bit is read, index information is obtained based on the target bit, wherein the index information corresponds to the target flow table entry; and the flow table database is searched based on the index information to obtain the target flow table entry.
[0110] In some optional implementations, the execution action corresponding to the update action function includes at least one or more of the following: deletion of a flow table entry, addition of a flow table entry, status update of a flow table entry, and creation of a flow table entry.
[0111] In some optional implementations, the synchronization module 403 is used to read all bit information in the first memory region sequentially based on a read operation before pointing the pointer variable of the first process to the second memory region and before pointing the pointer variable of the second process to the first memory region; after reading all bit information, the subordinate relationship between the first memory region and the second memory region is swapped.
[0112] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0113] In this embodiment, the flow table synchronization device of the virtual switch is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0114] This disclosure also provides a computer device having the above-described features. Figure 4 The virtual switch shown has a flow table entry synchronization device.
[0115] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of this disclosure, such as... Figure 5 As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 5 Take a processor 10 as an example.
[0116] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0117] The memory 20 stores instructions executable by at least one processor 10 to cause at least one processor 10 to perform the method shown in the above embodiments.
[0118] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0119] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0120] The computer device also includes a communication interface 30 for communicating with other devices or communication networks.
[0121] This disclosure also provides a computer-readable storage medium in which the methods described in this disclosure can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code originally stored on a remote storage medium or a non-transitory machine-readable storage medium and subsequently stored on a local storage medium after being downloaded over a network. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium may be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium may also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code that, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0122] A portion of this disclosure can be applied to computer program products, such as computer program instructions, which, when executed by a computer, can invoke or provide methods and / or technical solutions according to this disclosure through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, and installation package files. Accordingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions; the computer compiling the instructions and then executing the corresponding compiled program; the computer reading and executing the instructions; or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0123] Although embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for synchronizing flow table entries of a virtual switch, the method comprising: The method includes: Get the first memory region pointed to by the pointer variable of the first process in the virtual switch, and the second memory region pointed to by the pointer variable of the second process in the virtual switch; If it is determined that the first process has performed a write operation on the first memory region, the pointer variable of the first process is set to point to the second memory region, the pointer variable of the second process is set to point to the first memory region, and the first process performs a write operation on the second memory region, while the second process performs a read operation on the first memory region. Based on the read operation, the target flow table entry that has been modified in the first process is obtained, and the target flow table entry is synchronized to the second process, and the first memory area where the read operation was performed is cleared; When the flow table synchronization process ends, the memory regions pointed to by the first process and the second process are retrieved again. The second process synchronizes the flow table according to the memory region read result, completes the last flow table update operation, and obtains the full synchronization result of the flow table entries of the second process during the hot upgrade process. The step of retrieving the memory regions pointed to by the first process and the second process includes: retrieving the memory regions pointed to by the first process and the second process, setting the pointer variable of the first process to point to the first memory region, and setting the pointer variable of the second process to point to the second memory region.
2. The method of claim 1, wherein, Determining that the first process performed a write operation on the first memory region includes: Upon receiving target indication information, the modified target flow table entry is obtained based on the target indication information, wherein the target indication information is used to characterize that the first process has been upgraded and that a dirty operation has been inserted into the update action function of the target flow table entry of the first process; Obtain the target bit corresponding to the target flow table entry in the first memory region; A write operation is performed on the target bit in the first memory region.
3. The method of claim 2, wherein, The step of obtaining the target bit corresponding to the target flow table entry in the first memory region includes: Calculate the offset of the target flow table entry in the first memory region; The target position is determined based on the offset.
4. The method of claim 3, wherein, The step of obtaining the modified target flow table entry in the first process based on the read operation includes: Based on the read operation, all bit information in the first memory region is read; When the target bit is read, index information is obtained based on the target bit, wherein the index information corresponds to the target flow table entry; The target flow table entry is obtained by searching the flow table database based on the index information.
5. The method of claim 2, wherein, The execution actions corresponding to the update action function include at least one or more of the following: deletion of a flow table entry, addition of a flow table entry, status update of a flow table entry, and creation of a new flow table entry.
6. The method of claim 1, wherein, The step of obtaining the modified target flow table entry in the first process based on the read operation includes: Based on the read operation, all bit information in the first memory region is read sequentially; After reading all the bit information, obtain all the target flow table entries.
7. An apparatus for synchronizing flow table entries of virtual switches, the apparatus comprising: a flow table entry synchronizer configured to synchronize flow table entries of virtual switches. The device includes: The first acquisition module is used to acquire the first memory region pointed to by the pointer variable of the first process in the virtual switch, and the second memory region pointed to by the pointer variable of the second process in the virtual switch. The swapping module is used to, when it is determined that the first process has performed a write operation on the first memory region, point the pointer variable of the first process to the second memory region, point the pointer variable of the second process to the first memory region, and cause the first process to perform a write operation on the second memory region and the second process to perform a read operation on the first memory region. The synchronization module is used to obtain the target flow table entry that has been modified in the first process based on the read operation, synchronize the target flow table entry to the second process, and clear the first memory area where the read operation was performed; The second acquisition module is used to acquire the memory regions pointed to by the first process and the second process again when the flow table synchronization process ends. The second process synchronizes the flow table according to the memory region read result, completes the last step of flow table update operation, and obtains the full synchronization result of the flow table entries of the second process during the hot upgrade process. The step of retrieving the memory regions pointed to by the first process and the second process includes: retrieving the memory regions pointed to by the first process and the second process, setting the pointer variable of the first process to point to the first memory region, and setting the pointer variable of the second process to point to the second memory region.
8. A computer device, comprising: include: A memory and a processor are communicatively connected, the memory storing computer instructions, and the processor executing the computer instructions to perform the flow table entry synchronization method of the virtual switch according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to execute the flow table entry synchronization method of the virtual switch according to any one of claims 1 to 6.
10. A computer program product, characterized in that, Includes computer instructions for causing a computer to perform the flow table entry synchronization method for the virtual switch according to any one of claims 1 to 6.