A method and apparatus for storing configuration information
By using a storage rule management structure and traversal mechanism, the problem of low backup efficiency of rule table configuration information in network devices under abnormal conditions is solved, achieving efficient configuration information storage and backup, and improving device performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU DPTECH INFORMATION TECH CO LTD
- Filing Date
- 2023-05-31
- Publication Date
- 2026-06-23
AI Technical Summary
Existing technologies are inefficient at backing up rule table configuration information in abnormal situations such as network device restarts and hot-swapping. Furthermore, traditional methods incur significant system overhead during high-frequency configuration updates, failing to meet device performance requirements.
A rule management structure is adopted to maintain the configuration information of existing but not yet stored rule entries, and the information is persisted by traversing the structure to avoid traversing invalid rule entry configuration information, thereby improving backup efficiency.
It reduces invalid operations, improves the efficiency of backing up rule table entry configuration information, reduces system overhead, and enhances user experience.
Smart Images

Figure CN116647452B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of communication technology, and in particular to a method and apparatus for storing configuration information. Background Technology
[0002] To prevent configuration loss in abnormal situations such as network device restarts and hot-swapping, network devices need to store rule table configuration information for backup. Rule tables refer to ACLs (Access Control Lists), which are entries that filter network packets based on rules. However, with a large volume of important and frequently updated rule table configuration information, the traditional backup method of real-time storage of configuration information when the network device distributes configuration information incurs significant system overhead. This results in the inability to distribute the latest configuration information in a timely manner, thus failing to meet user performance requirements for configuration information distribution.
[0003] In related technologies, network devices typically separate the configuration information distribution process from the backup and storage process, using a bitmap to record whether all rule table entry configuration information has been updated. Then, during the backup process, the bitmap is used to determine which rule table entry configuration information needs to be backed up. However, every update to a rule table entry configuration information requires traversing and confirming it from the bitmap, resulting in low backup efficiency. Summary of the Invention
[0004] In view of this, this specification provides a method and apparatus for storing configuration information to address the shortcomings of related technologies.
[0005] Specifically, this specification is implemented through the following technical solution:
[0006] According to a first aspect of the embodiments of this specification, a method for storing configuration information is provided, the method comprising:
[0007] Read the configuration information of the rule entries to be stored recorded in the rule management structure to be stored. The rule management structure to be stored maintains the configuration information of the rule entries that exist but are not stored. The configuration information of the rule entries to be stored is the configuration information of the rule entries to be stored in the global rule management structure. The global rule management structure maintains the configuration information of the rule entries that already exist.
[0008] Traverse the configuration information of the rule entries to be stored recorded in the rule management structure to be stored, and persist the configuration information of the traversed rule entries to be stored.
[0009] According to a second aspect of the embodiments of this specification, a storage device for configuration information is provided, the device comprising:
[0010] The configuration information reading unit is used to read the configuration information of the rule entries to be stored recorded in the rule management structure to be stored. The rule management structure to be stored maintains existing but not stored rule entry configuration information. The rule entry configuration information to be stored is the rule entry configuration information to be stored in the global rule management structure. The global rule management structure maintains existing rule entry configuration information.
[0011] The configuration information storage unit is used to traverse the configuration information of the rule entries to be stored recorded in the rule management structure to be stored, and to persist the configuration information of the traversed rule entries to be stored.
[0012] According to a third aspect of the embodiments of this specification, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect.
[0013] According to a fourth aspect of the embodiments of this specification, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the method described in the first aspect.
[0014] The technical solution provided in this specification uses a rule management structure to maintain existing but unstored rule entry configuration information, and persists the rule entry configuration information traversed in the rule management structure. Compared to identifying updated rule entry configuration information from a large number of rule entry configuration information by traversing a bitmap, the aforementioned rule management structure, by recording the rule entry configuration information to be stored, eliminates the need for subsequent storage processes to focus on rule entry configuration information that has not been updated, effectively reducing invalid operations and improving the backup efficiency of rule entry configuration information.
[0015] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings.
[0017] Figure 1 This is a schematic diagram of a configuration file shown in an exemplary embodiment of this specification;
[0018] Figure 2This is a schematic diagram illustrating the global rule management structure and the rule management structure to be stored, as shown in an exemplary embodiment of this specification.
[0019] Figure 3 This is a flowchart illustrating an exemplary embodiment of a method for storing configuration information.
[0020] Figure 4 This is a schematic diagram illustrating an exemplary embodiment of the present specification of an execution configuration file storage thread;
[0021] Figure 5 This is a schematic flowchart illustrating a device restart process according to an exemplary embodiment of this specification;
[0022] Figure 6 This is a schematic structural diagram of an electronic device shown in an exemplary embodiment of this specification;
[0023] Figure 7 This is a schematic diagram illustrating the structure of a configuration information storage device according to an exemplary embodiment of this specification. Detailed Implementation
[0024] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this specification.
[0025] It should be noted that in other embodiments, the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification. In some other embodiments, the methods may include more or fewer steps than those described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; and multiple steps described in this specification may be combined into a single step in other embodiments. It should be understood that although the terms first, second, third, etc., may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0026] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.
[0027] In related technologies, binary encoding is typically used to store and back up the rule table configuration information in network devices based on file storage. With the fixed size of binary files and the ability to quickly locate the location of a specific configuration information in the configuration file below, the overall speed of reading and writing rule table configuration information is greatly improved.
[0028] The following is combined with Figure 1 The configuration file used to record rule entry configuration information is explained as follows: During the process of the network device issuing rule entry configuration information to make it effective, the network device will set the bitmap information of the rule entry configuration information (which can be regarded as the recording position information below). This bitmap information can be used to represent the recording position of the rule entry configuration information in the corresponding configuration file. Figure 1 For example, when rule entry configuration information A is stored in the configuration file, assuming the configuration file can only store four rule entry configuration entries, and rule entry configuration information A is written to the position of the third rule entry configuration entry in the configuration file, then the bitmap information of the configuration file (i.e. Figure 1The record position information (from the 5th to the 8th bit) can be represented as "0010", indicating that the position of the third rule entry configuration information in the configuration file contains a corresponding rule entry configuration information A (the 3rd bit in the record position information is set to "1"), while the other addresses do not contain rule entry configuration information (the 1st, 2nd, and 4th bits in the record position information are set to "0"). Of course, the above record position information can be used to quickly and accurately calculate the corresponding actual address parameters in the configuration file using a preset algorithm. Since the calculation method and principle are basically disclosed in related technologies, this specification will not elaborate on this. When the storage thread finds that no new rule entry configuration information has been issued within a certain period, the rule entry configuration information and bitmap information can be centrally stored in the corresponding configuration file. Of course, in order to reduce the duplication of storing the original, unchanged rule table entry configuration information or bitmap information, a second bitmap can be introduced to record whether each configuration file is about to be updated (for example, when the rule table entry configuration information is updated, the corresponding configuration file is located at position 1; after the rule table entry configuration information and bitmap information are successfully persisted to the configuration file, the corresponding configuration file is located at position 0), so that the above storage thread can determine the configuration file involving the updated rule table entry configuration information by traversing the second bitmap.
[0029] Compared with the traditional method of "storing the rule table entry configuration information in real time after issuing the rule table entry configuration information", the above storage method does have higher storage efficiency and has a lower impact on the performance of the issuance process. However, in actual use scenarios, there are at least the following defects: (1) The storage conditions of the above storage thread are limited by the issuance interval of the rule table entry configuration information. That is, the network device will not issue new rule table entry configuration information for a certain period of time before persisting the original rule table entry configuration information that is waiting to be backed up. If the user performs configuration operations intermittently (i.e., writes rule table entry configuration information into the configuration file), and the interval between each write operation is shorter than the above issuance interval, the thread will wait until the user finally stops the configuration operation and then persists the rule table entry configuration information for a period of time. This results in the backlog of rule table entry configuration information to be stored, and the time point for completing the backup operation is delayed, affecting the user experience. (2) The above thread needs to traverse the second bitmap to determine the configuration file that needs to be updated. Therefore, even if a small amount of rule table configuration information is updated, the entire contents of the second bitmap need to be traversed, resulting in a large time cost and reducing the overall backup efficiency. This problem is particularly obvious when there are a large number of configuration files. (3) When the user performs a configuration clear restart (e.g., restores factory settings) on the device, the device theoretically does not need to save the rule configuration. However, the storage thread in the above method will still perform the backup operation of all rule table configuration information before restarting, thus wasting unnecessary time costs.
[0030] The following technical solutions are proposed in this specification to solve the above problems.
[0031] Figure 2 This is a schematic diagram illustrating the global rule management structure and the rule management structure to be stored, as shown in an exemplary embodiment of this specification. Figure 2 As shown, the above method may include the following steps:
[0032] S201, Read the configuration information of the rule entries to be stored recorded in the rule management structure to be stored. The rule management structure to be stored maintains existing but not stored rule entry configuration information. The rule entry configuration information to be stored is the rule entry configuration information to be stored in the global rule management structure. The global rule management structure maintains existing rule entry configuration information.
[0033] The aforementioned rule management structure can record the configuration information of rule entries to be stored. This allows the corresponding network device to quickly determine the rule entry configuration information that needs to be stored, avoiding the need to traverse all configuration files containing different rule entry configuration information, as described in the second bitmap above, to finally determine the rule entry configuration information that needs to be stored. Of course, to further explain the global rule management structure and the rule management structure to be stored, as well as the relationship between the two, the following section will discuss... Figure 3 To explain, Figure 3 This is a schematic diagram illustrating the global rule management structure and the rule management structure to be stored, as shown in an exemplary embodiment of this specification. Figure 3 As mentioned above, a global management structure corresponding to each rule type can be created in the device's memory. As described earlier, the aforementioned rule entries are a type of entry for filtering network packets based on rules. Therefore, their filtering conditions can include parameters such as the packet's source IP (Internet Protocol) address, destination IP address, packet port, and packet protocol. Furthermore, the rule type can be determined based on the network protocol version, such as IPv4 (Internet Protocol version 4) and IPv6 (Internet Protocol version 6), or customized based on other parameters in the packet. This specification does not impose any limitations on this. Both the aforementioned rule management structure to be stored and the aforementioned global management structure can contain corresponding hash lists, and each node in the hash list can record corresponding rule entry configuration information. The difference lies only in that the rule management structure to be stored only records the configuration information of existing but not yet stored rule entries, while the global rule management structure can record the configuration information of all existing (regardless of whether they are stored) rule entries. This also allows the configuration information of rule entries to be stored in the rule management structure to overlap with the configuration information of rule entries in the global rule management structure. For example, a network device has global rule management structures A, B...X corresponding to different rule types, where global rule management structure A records n (n is a positive integer) rule entry configuration information (i.e., ..., ...). Figure 3 The rule table entry configuration information A1~An), and the global rule management structure B records m (m is a positive integer) rule table entry configuration information (i.e. Figure 3Assuming that all rule entry configuration information except for rule entry configuration information A1, A3, and Bm in all global rule management structures has been stored, the rule management structure to be stored can record the rule entry configuration information A1, A3, and Bm corresponding to the aforementioned rule entry configuration information A1, A3, and Bm, respectively. The rule entry configuration information recorded in the rule management structure to be stored and the corresponding rule entry configuration information recorded in the global rule management structure can be shared (e.g., the aforementioned rule entry configuration information A1 and the rule entry configuration information to be stored A1 are the same object), or they can be independent and have a mapping relationship (e.g., the aforementioned rule entry configuration information A1 and the rule entry configuration information to be stored A1 are not the same, and they establish a corresponding mapping relationship based on a preset mapping table). Of course, the global rule management structure can also add information such as the record location information, quantity, and mutex locks that already contain rule entry configuration information to facilitate the implementation of the embodiments below; this specification will not elaborate further here.
[0034] Furthermore, the aforementioned global rule management structure and the rule management structure to be stored can be deployed in different memory addresses. At the operating system level, the aforementioned global rule management structure and the rule management structure to be stored can also run in kernel mode or user mode respectively according to actual functional requirements. This specification does not impose any restrictions on this.
[0035] S202, traverse the configuration information of the rule entries to be stored recorded in the rule management structure to be stored, and persist the configuration information of the traversed rule entries to be stored.
[0036] After reading the configuration information of the rule entries to be stored, the read information can be traversed to persist the existing but not yet stored configuration information of the rule entries to be stored, thus completing the backup. The traversal method of the configuration information of the rule entries to be stored can be adjusted according to the specific storage structure and application requirements. For example, when the configuration information of the rule entries to be stored is recorded in the form of a hash linked list in the rule management structure, the traversal operation can be performed sequentially along the hash linked list from the configuration information of the rule entries to be stored corresponding to the head node to the tail node. This specification does not impose any restrictions on this.
[0037] The configuration information of rule entries in the aforementioned global rule management structure can be determined by the received configuration instructions. These configuration instructions can be addition, modification, or deletion instructions for the target rule entry configuration information.
[0038] In one embodiment, upon receiving an add or modify instruction, the target rule entry configuration information can be added to the global rule management structure; upon receiving a delete instruction, the target rule entry configuration information can be deleted from the global rule management structure. For example, the storage rule management structure and the global rule management structure contain corresponding hash lists. When a user needs to add a rule, an add instruction can be sent to the network device to retrieve an empty node from the idle rule cache list, store the relevant rule content in that node, and add it to the hash list of the global rule management structure to send the corresponding rule entry configuration information to the underlying chip. Alternatively, when a user needs to delete an existing rule, a delete instruction can be sent to the network device to find the corresponding node in the hash list of the global rule management structure, remove it from the existing rule list, add it to the idle rule cache list, and delete the corresponding configuration from the underlying chip.
[0039] When the configuration information of rule entries in the global rule management structure is updated, the configuration information of rule entries to be stored in the rule management structure to be stored can be updated accordingly. The global rule management structure can maintain a storage identifier to identify the rule entry configuration information to be stored, so that the corresponding network device can determine the rule entry configuration information to be stored and add it to the rule management structure to be stored.
[0040] In one embodiment, if the target rule entry configuration information is successfully added to the global rule management structure, a storage identifier for the rule entry configuration information can be added to the global rule management structure, and the rule entry configuration information can be added to the storage rule management structure. Alternatively, if the target rule entry configuration information is successfully deleted from the global rule management structure, and there is no rule entry configuration information in the storage rule management structure, no operation is performed on the storage rule management structure. Alternatively, if the target rule is successfully deleted from the global rule management structure, and there is rule entry configuration information in the storage rule management structure, the storage identifier for the rule entry configuration information is deleted from the global rule management structure, and the rule entry configuration information is deleted from the storage rule management structure. The first scenario refers to the normal situation after the rule entry configuration information is recorded by the global rule management structure through add or modify instructions. The second and third scenarios are similar, both occurring after receiving a delete instruction. The difference is that in the former, the rule entry configuration information to be deleted has already been backed up and stored, so it is not in the rule management structure to be stored, and no operation needs to be performed on the rule management structure to be stored. In the latter, the rule entry configuration information to be deleted has not yet been backed up and stored, so the rule management structure to be stored still records the rule entry configuration information to be deleted. The to-be-stored identifier for the rule entry configuration information to be deleted is removed from the global rule management structure, and the rule entry configuration information is then deleted from the rule management structure to be stored.
[0041] Combination Figure 1 It can be seen that the rule entry configuration information stored in each configuration file is actually divided into two parts: one is the rule content of the corresponding rule contained in the rule entry configuration information, and the other is the record location information maintained in the global rule management structure. This record location information can be used to characterize the record location of the rule content of each rule entry configuration information in the corresponding configuration file. Therefore, the process of persisting the rule entry configuration information to be traversed can be subdivided into the persistence of rule content and the persistence of record location information.
[0042] In one embodiment, the rule content of the traversed rule entry configuration information to be stored can be persisted to a configuration file; and if no rule entry configuration information to be stored exists in the rule management structure, the record position information in the global rule management structure can be persisted to a configuration file. The storage efficiency of the rule content can be improved by reducing the traversal interval. For example, after the rule content of the traversed rule entry configuration information n is persisted to the configuration file, the next round of traversal can be performed immediately, so that the rule content of the subsequently traversed rule entry configuration information n+1 can be persisted to the configuration file in a timely manner. Compared to the method of storing rule entry configuration information only after the time elapsed since the nearest rule entry configuration information was issued exceeds a preset threshold, the above storage method is more suitable for scenarios with high-frequency issuance of rule entry configuration information. In addition, if no rule entry configuration information exists in the rule management structure to be stored, the system can wait for a preset time before performing the next traversal. This is to avoid additional system overhead caused by the lack of rule entry configuration information for a long time. The preset time can be a preset fixed value, or it can be increased in a step-like manner, or it can be adjusted in real time according to factors such as time period. This specification does not impose any restrictions on this.
[0043] Those skilled in the art will understand that the existing but not stored rule entry configuration information maintained by the rule management structure has certain limitations; that is, it cannot record the configuration information of rule entries that need to be deleted. Furthermore, in the process of storing the configuration information of deleted rule entries, it is not necessary to clear or reset the corresponding rule content; only the corresponding record location information needs to be re-stored. Figure 1 For example, suppose the configuration file can only record 4 rule table configuration information, and rule table configuration information A and B are already stored in the positions of the second and third rule table configuration information respectively. At the same time, the record position information of the configuration file can be presented as "0110". When the user needs to delete rule table configuration information A, there is no need to delete the rule content in the position of the second rule table configuration information. Instead, the record position information can be directly changed from "0110" to "0010".
[0044] In other words, the traversal scope of the aforementioned rule management structure to be stored is all rule table entry configuration information that is neither stored nor deleted. Therefore, to promptly obtain the configuration file after the corresponding rule table entry configuration information has been deleted, the global rule management structure can be marked to indicate whether the rule table entry configuration information has changed. This allows the record location information of the marked global rule management structure to be persisted to the configuration file.
[0045] In one embodiment, the global rule management structure also maintains an update identifier, which indicates whether the configuration information of any rule entry in the global rule management structure has changed. The network device can traverse all global rule management structures, and if the update identifier of the traversed global rule management structure indicates that the configuration information of the corresponding rule entry has changed, the device will persist the record location information of the traversed global rule management structure to the configuration file.
[0046] The execution process of the above configuration instructions and the traversal process of the above rule management structure both involve reading and writing the rule management structure. Mutex locks can be configured on the rule entries of the rule management structure to prevent concurrent access caused by the two processes.
[0047] The following is combined with Figure 4 The process of executing the configuration file storage thread is explained, where the configuration file storage thread can be regarded as the direct object of the persistence operation of recording location information and rule content within the operating system of the aforementioned network device. This process includes the following steps:
[0048] S401, Start the configuration file storage thread.
[0049] In one embodiment, the operating system of the network device can create a configuration file storage thread in kernel mode during initialization, so that it periodically reads the hash chain list used to record the configuration information of the rule entries to be stored in the rule management structure. When the network device starts up, the above-mentioned configuration file storage thread can also be started.
[0050] S402 determines whether an irreversible reboot process has begun.
[0051] In one embodiment, the network device can prioritize whether the operating system has entered an irreversible restart process. If so, it executes S403; otherwise, it executes S404.
[0052] S403 disables the configuration files pointed to by the file pointers of each global rule management structure.
[0053] S404, Determine whether the storage status flag g_static_file_abort_flag is set to 1.
[0054] In one embodiment, it can be determined whether the corresponding device is currently in the clear configuration restart process based on the cancellation storage status indicator below. If so, S4155 is executed; otherwise, S405 is executed.
[0055] The restart procedures involved in S402 to S404 can be found in the following section. Figure 5 The explanations will be discussed in detail elsewhere, and will not be repeated here.
[0056] S405 locks the linked list of the rules management structure to be stored.
[0057] In one embodiment, during each traversal, the configuration file storage thread can first add a mutex lock g_static_file_list_lock to the linked list of the rule management structure to be stored (hereinafter named g_static_file_list) to avoid interference from configuration instructions and corresponding configuration operations.
[0058] S406, determine if the linked list is empty.
[0059] In one embodiment, when the configuration file storage thread determines that the linked list is empty, it means that there are no unstored and added / modified rule entry configuration information in the rule management structure to be stored. Therefore, S410 can be executed directly to enter the storage process for recording location information. When the configuration file storage thread determines that the linked list is not empty, it can then execute...
[0060] S407 is used to store the rule content in the linked list node.
[0061] S407: Remove a node from the linked list and decrement rule_count by 1.
[0062] In one embodiment, the rule management structure to be stored also maintains the remaining quantity information of the rule table entry configuration information to be stored, `rule_count`. The value of `rule_count` can be increased when the system receives an add or modify instruction. When there are still nodes in `g_static_file_list`, the head node of the linked list of `g_static_file_list` can be extracted, and `rule_count` can be decremented by 1 to indicate that the number of nodes in `g_static_file_list` has decreased by one.
[0063] S408 unlocks the linked list of the rule management structure to be stored.
[0064] S409 persists the obtained node rule content to the corresponding configuration file.
[0065] In one embodiment, the rule content of the rule entries to be traversed (i.e., the nodes extracted above) can be persisted to a configuration file. Then, S402 is executed immediately to facilitate entering the next round of traversal as quickly as possible.
[0066] S410 unlocks the linked list of the rule management structure to be stored.
[0067] S411, set the global record location information recording status flag g_static_file_bitmap_state to 1.
[0068] S412, traverse each global rule management structure, and persist the record location information of the global rule management structure with need_save set to 1 to the configuration file.
[0069] In one embodiment, each global rule management structure can maintain an update identifier need_save, which indicates whether the configuration information of any rule entry in the corresponding global rule management structure has changed. Therefore, in the process of storing record location information, the global rule management structure whose rule entry configuration information has changed can be determined according to need_save of each global rule management structure, thereby persisting the record location information in the rule management structure to be stored to the configuration file.
[0070] S413, set the global record location information recording status flag g_static_file_bitmap_state to 0.
[0071] Among them, the global recording location information recording status flags involved in S411 to S413 can be referred to in conjunction with the following text regarding... Figure 5 The explanations will be discussed in detail elsewhere, and will not be repeated here.
[0072] S414, sleep for a period of time.
[0073] In one embodiment, unlike persisting rule content, persisting location information means that there is no configuration information for the rule entries to be stored in the rule management structure to be stored. Therefore, the system can be put to sleep for a period of time to reduce the system's additional overhead.
[0074] The technical solutions in this manual can also avoid meaningless storage operations on configuration information during the configuration clearing and restart process.
[0075] In one embodiment, a preset cancellation storage status flag can be determined, wherein the cancellation storage status flag is used to indicate whether the current process is in the configuration clearing and restart process; and if the storage status flag indicates that the current process is in the configuration clearing and restart process, the persistence is cancelled.
[0076] Of course, in any restart process (clear configuration restart process or normal restart process), it can first determine whether the corresponding device is storing the above-mentioned record location information. If so, the user can be shown the corresponding prompt information and the estimated completion time. After waiting for a period of time (e.g., 1 second), it can be re-determined whether the corresponding device is storing the above-mentioned record location information, and the same strategy is executed. If not, the process proceeds to the subsequent restart stage. The storage status of the above-mentioned record location information can be represented by parameters such as status identifiers, which are not limited in this specification. In addition, the number of configuration information entries to be stored in the rule management structure can be determined. If the number is not zero, it means that the device still needs to back up the rule content of the corresponding rule entry configuration information. At this time, the user can be shown the corresponding prompt information and the remaining number of rule entry configuration information entries to be stored. After waiting for a period of time, the remaining number can be re-determined. If the rule content is still being backed up, the remaining number is updated and displayed. If the rule content and record location information have been persisted, the process proceeds to the subsequent restart stage. The corresponding operation interface can provide a cancel restart option, allowing the user to interrupt the waiting and cancel the restart process at any time.
[0077] The subsequent restart phase described above may also include logical checks to cancel the storage status identifier.
[0078] In one embodiment, a global restart flag can be pre-created. When the device passes a pre-restart check or enters an irreversible restart process (killing all processes, closing ports, unmounting storage card partitions, etc.) during any restart process, this global restart flag can be set to 1. During the traversal of the aforementioned rule management structure to be stored (or before or after each traversal), it can be determined whether the global restart flag is set to 1. If so, the open configuration files recorded in the file pointers of each global management structure can be directly closed, and the threads executing the traversal operation can be stopped. It can also be determined whether the aforementioned cancel storage status flag is set to 1. If so, the next traversal can be started after a certain period of time, without persisting the rule content or record location information.
[0079] The following is combined with Figure 5 The device restart process will be explained further, and it includes the following steps:
[0080] S501 allows users to perform a restart operation through the user interface.
[0081] In one embodiment, a user can select to perform a restart operation on a network device through the user interface of the device.
[0082] S502, determine whether the process is in the configuration clearing and restart process. S503.
[0083] In one embodiment, after receiving a reboot operation, the operating system of the network device can determine whether the reboot process corresponding to the operation is a configuration clear reboot process or a normal reboot process. If it is a configuration clear reboot process, then S503 is executed; otherwise, S504 is executed.
[0084] S503 sets the storage status flag g_static_file_abort_flag to 1.
[0085] In one embodiment, a global unstorage status flag g_static_file_abort_flag can be created in the kernel mode of the above operating system. Its initial value is 0. During the configuration clearing and restart process, the global unstorage status flag can be set to 1, indicating that the configuration file does not need to be stored again.
[0086] S504, retrieve the storage status of the configuration file.
[0087] In one embodiment, the operating system can create a global record location information recording status flag, `g_static_file_bitmap_state`. This flag can be used to record the storage status of the record location information for persistent rule entry configuration information to be stored. A value of 1 indicates that the record location information is being stored, while a value of 0 indicates that it is not being stored. Simultaneously, the system can access and read the rule entry configuration information recorded in the rule management structure to be stored and determine the corresponding quantity.
[0088] S505, determine whether record location information is being stored.
[0089] In one embodiment, it can be determined whether the target device is storing record location information based on the above g_static_file_bitmap_state. If so, S506 is executed; otherwise, S507 is executed.
[0090] S506 displays a prompt message and cancels the restart option.
[0091] In one embodiment, the user interface can display "Saving rule configuration information, X seconds remaining, please wait", and the user interface can also provide a cancel restart button to help the user manually select to interrupt the wait and cancel the restart.
[0092] S507, determine whether rule content is being stored.
[0093] In one embodiment, it can be determined whether rule content is being stored based on the quantity in the configuration information of the rule entries to be stored. If the quantity is 0, it means that no rule content is being stored, and S50 can be executed; if the quantity is greater than 0, it means that there is rule content being stored, and S507 can be executed.
[0094] This manual does not restrict the execution order of S505 and S506; they can be adjusted according to actual needs.
[0095] S508 displays a prompt message and cancels the restart option.
[0096] In one embodiment, the user interface can display "Saving rule configuration information, X rules remaining, please wait", and can also provide a cancel restart button to help users manually select interruption and wait and cancel restart.
[0097] S509 determines whether other pre-reboot detection processes have passed.
[0098] In one embodiment, besides the storage state of the configuration file, there may be other interfering factors (such as damaged device components or system malfunctions) that cause the pre-reboot detection process to fail. Therefore, if it is determined that other pre-reboot detection processes have passed, only S510 needs to be executed; otherwise, S515 is executed.
[0099] S510 has entered an irreversible reboot process.
[0100] S511, global reboot flag g_rebooting_flag is set to 1.
[0101] S512, perform device restart operation.
[0102] In one embodiment, after determining that an irreversible reboot process has been entered, the operating system can set g_rebooting_flag to 1 to ensure that the device performs a normal reboot operation.
[0103] S513 determines whether the user chooses to cancel the restart.
[0104] In one embodiment, the operating system can determine whether the user has triggered the cancel restart button. If so, S515 is executed; otherwise, S514 is executed.
[0105] S514, waiting for a while.
[0106] In one embodiment, the prompt information in S506 or S508 may need to be displayed for a relatively long time. In this case, if the user does not cancel the restart, the content of the prompt information can be updated after a certain period of time to improve the user's interactive experience during the waiting process.
[0107] S515 sets the storage status flag g_static_file_abort_flag to 0.
[0108] S516, cancel restart.
[0109] In one embodiment, since the pre-reboot detection process failed or the user actively canceled the reboot operation, the current cancel storage status flag has become invalid. The cancel storage status flag g_static_file_abort_flag can be set to 0, and the reboot can be canceled.
[0110] As can be seen from the above embodiments, this specification adds newly added or modified rule entries to the storage rule management structure and removes deleted rule entries from the storage rule management structure in real time. This ensures that the configuration file storage thread only needs to perform necessary traversals. Furthermore, by immediately performing the next traversal after storing the rule content, it avoids the backlog of rule entry configuration information to be stored, ensuring timely completion of backup operations and improving user experience. In addition, the use of global restart flags and cancellation storage status flags avoids additional system overhead when the device performs a configuration clear restart. It is worth mentioning that users can decide whether to wait for storage to complete or cancel the wait during the storage of rule content or recorded location information.
[0111] Figure 6 This is a schematic structural diagram of an electronic device according to an exemplary embodiment. Please refer to... Figure 6 At the hardware level, the electronic device includes a processor, internal bus, network interface, memory, and non-volatile memory, and may also include other necessary hardware. The processor reads the corresponding computer program from the non-volatile memory into memory and then runs it, forming a storage device for configuration information at the logical level. Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the following processing flow is not limited to individual logic units, but can also be hardware or logic devices.
[0112] Corresponding to the embodiments of the configuration information storage method described above, this specification also provides embodiments of a configuration information storage device.
[0113] Please refer to Figure 7 , Figure 7 This is a schematic diagram illustrating the structure of a configuration information storage device according to an exemplary embodiment. For example... Figure 7 As shown, in a software implementation, the device may include:
[0114] The configuration information reading unit 701 is used to read the configuration information of the rule entries to be stored recorded in the rule management structure to be stored. The rule management structure to be stored maintains existing but not stored rule entry configuration information. The rule entry configuration information to be stored is the rule entry configuration information to be stored in the global rule management structure. The global rule management structure maintains existing rule entry configuration information.
[0115] The configuration information storage unit 702 is used to traverse the configuration information of the rule entries to be stored recorded in the rule management structure to be stored, and to persist the configuration information of the traversed rule entries to be stored.
[0116] Optionally, the rule management structure to be stored and the global rule management structure include corresponding hash linked lists, and each node in the hash linked list records the corresponding rule entry configuration information; the rule entry configuration information recorded in the rule management structure to be stored and the corresponding rule entry configuration information recorded in the global rule management structure are shared with each other, or are independent of each other and have a mapping relationship.
[0117] Optionally, the rule entry configuration information includes the rule content of the corresponding rule; the global rule management structure also maintains record location information, which is used to characterize the record location of the rule content of each rule entry configuration information in the corresponding configuration file; the configuration information storage unit 702 is specifically used for:
[0118] Traverse all global rule management structures;
[0119] When the update identifier of the traversed global rule management structure indicates that the configuration information of the corresponding rule table entry has changed, the record location information of the traversed global rule management structure is persisted to the configuration file.
[0120] Optionally, the rule entry configuration information in the global rule management structure is determined by the received configuration instructions, wherein the configuration instructions are addition, modification, or deletion instructions for the target rule entry configuration information; the device includes:
[0121] The first instruction execution unit 703 is used to add the target rule entry configuration information to the global rule management structure when the add instruction or modify instruction is received.
[0122] Upon receiving the deletion instruction, the configuration information of the target rule entry in the global rule management structure is deleted.
[0123] Optionally, the device includes:
[0124] The second instruction execution unit 704 is configured to, upon successful addition of the target rule entry configuration information to the global rule management structure, add a storage identifier for the rule entry configuration information to the global rule management structure, and add the rule entry configuration information to the storage rule management structure; or...
[0125] If the target rule entry configuration information is successfully deleted from the global rule management structure, and the rule entry configuration information does not exist in the rule management structure to be stored, no operation is performed on the rule management structure to be stored; or,
[0126] If the target rule is successfully deleted from the global rule management structure, and the rule entry configuration information exists in the rule management structure to be stored, the storage identifier for the rule entry configuration information is deleted from the global rule management structure, and the rule entry configuration information is deleted from the rule management structure to be stored.
[0127] Optionally, the device includes:
[0128] The storage unit 705 is used to determine a preset storage cancellation status flag, which indicates whether the current process is in the configuration clearing and restart process.
[0129] If the storage status indicator indicates that the system is currently in a configuration clearing and restart process, then persistence is cancelled.
[0130] The specific implementation process of the functions and roles of each unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0131] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0132] The embodiments of the subject matter and functional operation described in this specification can be implemented in the following ways: digital electronic circuits, tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or combinations thereof. Embodiments of the subject matter described in this specification can be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible, non-transitory program carrier for execution by a data processing apparatus or for controlling the operation of a data processing apparatus. Alternatively or additionally, the program instructions may be encoded on artificially generated propagation signals, such as machine-generated electrical, optical, or electromagnetic signals, which are generated to encode information and transmit it to a suitable receiving device for execution by the data processing apparatus. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or combinations thereof.
[0133] The processing and logic flow described in this specification can be executed by one or more programmable computers that execute one or more computer programs to perform corresponding functions by operating on input data and generating output. The processing and logic flow can also be executed by dedicated logic circuitry—such as FPGAs (Field-Programmable Gate Arrays) or ASICs (Application-Specific Integrated Circuits), and the device can also be implemented as dedicated logic circuitry.
[0134] Suitable computers for executing computer programs include, for example, general-purpose and / or special-purpose microprocessors, or any other type of central processing unit. Typically, the central processing unit receives instructions and data from read-only memory and / or random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Typically, a computer will also include one or more mass storage devices for storing data, such as disks, magneto-optical disks, or optical disks, or the computer will be operatively coupled to such mass storage devices to receive data from or transfer data to them, or both. However, a computer is not required to have such devices. Furthermore, a computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, to name a few.
[0135] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, such as semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD-ROM and DVD-ROM disks. Processors and memory may be supplemented by or incorporated into dedicated logic circuitry.
[0136] While this specification contains numerous specific implementation details, these should not be construed as limiting the scope of any invention or the scope of the claims, but rather are primarily intended to describe features of specific embodiments of a particular invention. Certain features described in the various embodiments herein may also be implemented in combination in a single embodiment. Conversely, various features described in a single embodiment may also be implemented separately in various embodiments or in any suitable sub-combination. Furthermore, while features may function in certain combinations as described above and even initially claimed in this way, one or more features from a claimed combination may be removed from that combination in some cases, and a claimed combination may refer to a sub-combination or a variation thereof.
[0137] Similarly, although the operations are depicted in a specific order in the accompanying drawings, this should not be construed as requiring these operations to be performed in the specific order shown or sequentially, or requiring all illustrated operations to be performed to achieve the desired result. In some cases, multitasking and parallel processing may be advantageous. Furthermore, the separation of various system modules and components in the above embodiments should not be construed as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.
[0138] Therefore, specific embodiments of the subject matter have been described. Furthermore, the processes depicted in the figures are not necessarily shown in a specific order or sequence to achieve the desired result. In some implementations, multitasking and parallel processing may be advantageous.
[0139] The above description is merely a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of protection of this specification.
Claims
1. A method for storing configuration information, characterized in that, The method includes: The system reads the configuration information of rule entries to be stored from the rule management structure to be stored. The rule management structure to be stored maintains existing but not yet stored rule entry configuration information. The rule entry configuration information to be stored is the configuration information of rule entries to be stored in the global rule management structure. The global rule management structure maintains existing rule entry configuration information and record position information. The rule entry configuration information contains the rule content of the corresponding rule. The record position information is used to represent the record position of the rule content of each rule entry configuration information in the corresponding configuration file. Traverse the configuration information of the rule entries to be stored recorded in the rule management structure to be stored, and persist the configuration information of the traversed rule entries to be stored. The persistence of the configuration information of the rule entries to be traversed includes: The rule content of the rule entries to be traversed and stored is persisted to the configuration file; If no rule entry configuration information exists in the rule management structure to be stored, the record location information in the global rule management structure will be persisted to the configuration file.
2. The method according to claim 1, characterized in that, The rule management structure to be stored and the global rule management structure contain corresponding hash linked lists. Each node in the hash linked list records the corresponding rule entry configuration information. The rule entry configuration information recorded in the rule management structure to be stored and the corresponding rule entry configuration information recorded in the global rule management structure are shared with each other, or are independent of each other and have a mapping relationship.
3. The method according to claim 1, characterized in that, The global rule management structure also maintains an update identifier, which is used to indicate whether the configuration information of any rule entry in the global rule management structure has changed. The step of persisting the record location information in the global rule management structure to the configuration file includes: Traverse all global rule management structures; When the update identifier of the traversed global rule management structure indicates that the configuration information of the corresponding rule table entry has changed, the record location information of the traversed global rule management structure is persisted to the configuration file.
4. The method according to claim 1, characterized in that, The rule entry configuration information in the global rule management structure is determined by the received configuration instructions, which are addition, modification, or deletion instructions for the target rule entry configuration information; the method further includes: Upon receiving the add or modify instruction, the target rule entry configuration information is added to the global rule management structure; Upon receiving the deletion instruction, the configuration information of the target rule entry in the global rule management structure is deleted.
5. The method according to claim 4, characterized in that, The global rule management structure maintains a pending storage identifier, which is used to identify the rule table entry configuration information to be stored in the global rule management structure; the method further includes: If the target rule entry configuration information is successfully added to the global rule management structure, a storage identifier for the rule entry configuration information is added to the global rule management structure, and the rule entry configuration information is added to the storage rule management structure; or... If the target rule entry configuration information is successfully deleted from the global rule management structure, and the rule entry configuration information does not exist in the rule management structure to be stored, no operation is performed on the rule management structure to be stored; or, If the target rule is successfully deleted from the global rule management structure, and the rule entry configuration information exists in the rule management structure to be stored, the storage identifier for the rule entry configuration information is deleted from the global rule management structure, and the rule entry configuration information to be stored is deleted from the rule management structure to be stored.
6. The method according to claim 1, characterized in that, The method further includes: Determine the preset cancellation storage status flag, which is used to indicate whether the current process is in the configuration clearing and restart process; If the storage status indicator indicates that the system is currently in a configuration clearing and restart process, then persistence is cancelled.
7. A storage device for configuration information, characterized in that, The device includes: The configuration information reading unit is used to read the configuration information of rule entries to be stored recorded in the rule management structure to be stored. The rule management structure to be stored maintains existing but not yet stored rule entry configuration information. The configuration information of rule entries to be stored is the configuration information of rule entries to be stored in the global rule management structure. The global rule management structure maintains existing rule entry configuration information and record position information. The rule entry configuration information contains the rule content of the corresponding rule. The record position information is used to represent the record position of the rule content of each rule entry configuration information in the corresponding configuration file. A configuration information storage unit is used to traverse the configuration information of the rule entries to be stored recorded in the rule management structure to be stored, and to persist the configuration information of the traversed rule entries to be stored. The configuration information storage unit is specifically used for: The rule content of the rule entries to be traversed and stored is persisted to the configuration file; If no rule entry configuration information exists in the rule management structure to be stored, the record location information in the global rule management structure will be persisted to the configuration file.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the method as described in any one of claims 1 to 6.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method as described in any one of claims 1 to 6.