MAC table item updating method and device, storage medium and electronic device
By introducing a clear register on the routing device, the fresh bit of the MAC table entry can be directly located and cleared, which solves the problem of low update efficiency of MAC table entries in VLAN bridges, improves update efficiency and flexibility, and optimizes the performance of VLAN bridges.
Patent Information
- Application Number
- CN202510871945.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-26
- Publication Date
- 2025-11-18
AI Technical Summary
In existing technologies, the MAC table update efficiency of VLAN bridges is low, resulting in network latency, packet loss, and insufficient bandwidth, which affects data transmission real-time performance and network efficiency.
By introducing a clear register on the routing device, the fresh bit of the MAC table entry can be directly located and cleared, transforming software operations into hardware operations and improving update efficiency and flexibility.
It improves the efficiency and flexibility of MAC table entries updates, reduces MAC table maintenance latency, ensures the accuracy of MAC table aging operations, and optimizes the performance of VLAN bridges.
Smart Images

Figure CN120979999A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network technology, and more specifically, to a method and apparatus for updating MAC entries, a storage medium, and an electronic device. Background Technology
[0002] In related technologies, with the rapid development of network technology, VLAN (Virtual Local Area Network) has become an indispensable part of modern network architecture. VLAN technology improves network flexibility and security by dividing a physical network into multiple logical networks. However, with the increase in the number of users and the surge in data traffic, the performance bottleneck of traditional VLAN bridges has gradually become apparent, affecting the overall network efficiency and user experience. In existing technologies, the updating of VLAN bridge MAC (Media Access Control) addresses is mainly performed by software. However, as the network scales up, VLAN bridges may experience problems such as latency, packet loss, and insufficient bandwidth when handling large amounts of data streams. These problems not only affect the real-time performance of data transmission but may also lead to network congestion, thereby affecting application performance.
[0003] In related technologies, updating the dynamic MAC address entries of a VLAN bridge requires software control. The process involves hardware searching the MAC table to find a match for the destination MAC address. The software then retrieves the destination PORT from the MAC table, forwards the data, and updates the update bit in the MAC table by clearing it to zero. This flag is identified during the MAC table aging process. If the update bit is 0, the table is considered in use during the aging period and will not be deleted. The process of setting the update bit to 0 mainly involves MAC table lookup, setting the update bit to 0, and writing back the MAC table. Both the lookup and write-back operations require several register operations and three polling cycles, consuming significant CPU resources.
[0004] There are currently no effective solutions to the aforementioned problems in the relevant technologies. Summary of the Invention
[0005] This invention provides a method and apparatus for updating MAC entries, a storage medium, and an electronic device.
[0006] According to an embodiment of the present invention, a method for updating a MAC table entry is provided, comprising: receiving a routing data packet on a routing device, wherein the routing device stores a source MAC table; invoking a configuration value in a clear register according to the routing data packet, wherein the routing device includes the clear register, and the configuration value is used to indicate the bit position of the fresh bit in the MAC table entry of the MAC table on the routing device; updating the source entry in the source MAC table to a target entry using the configuration value; and writing the target entry back to the routing device.
[0007] Optionally, calling the configuration value in the clear register according to the routing data packet includes: calling the Direct Memory Access Controller (DMAC) of the routing device to read the source MAC table on the routing device, wherein the routing device includes the DMAC; extracting the source MAC address from the routing data packet; determining whether the source MAC table matches the source MAC address; if the source MAC table matches the source MAC address, calling the configuration value in the clear register.
[0008] Optionally, updating the source entry in the source MAC table to the target entry using the configuration value includes: extracting the source MAC address from the routing data packet; searching the source MAC table for a source entry that matches the source MAC address; and updating the source entry in the source MAC table using the configuration value to obtain the target entry.
[0009] Optionally, updating the source entry in the source MAC table using the configuration value includes: parsing the bit position of the fresh bit to be cleared in the source entry in the source MAC table based on the configuration value; and performing a clearing operation on the bit position of the source entry in the source MAC table to update the source entry.
[0010] Optionally, updating the source entry in the source MAC table using the configuration value includes: inverting the configuration value to obtain a transformed value; and performing a bitwise AND operation between the transformed value and the bit data of the source entry in the source MAC table to update the source entry.
[0011] Optionally, before calling the configuration value in the clear register according to the routed data packet, the method further includes: generating the configuration value; and initializing the clear register with the configuration value.
[0012] Optionally, generating the configuration value includes: reading the version information of the source MAC table, wherein the version information is used to indicate the position of the fresh bit of each entry in the MAC table; and configuring the value of the configuration value according to the version information.
[0013] According to another embodiment of the present invention, a MAC entry update apparatus is provided, comprising: a receiving module for receiving routing data packets on a routing device, wherein the routing device stores a source MAC table; a calling module for calling a configuration value in a clear register according to the routing data packets, wherein the routing device includes the clear register, and the configuration value is used to indicate the bit position of the fresh bit in the MAC entry of the MAC table on the routing device; an updating module for updating a source entry in the source MAC table to a target entry using the configuration value; and a write-back module for writing the target entry back to the routing device.
[0014] Optionally, the calling module includes: a reading unit, used to call the Direct Memory Access Controller (DMAC) of the routing device to read the source MAC table on the routing device, wherein the routing device includes the DMAC; an extraction unit, used to extract the source MAC address from the routing data packet; a judgment unit, used to judge whether the source MAC table matches the source MAC address; and a calling unit, used to call the configuration value in the clear register if the source MAC table matches the source MAC address.
[0015] Optionally, the update module includes: an extraction unit for extracting the source MAC address from the routing data packet; a lookup unit for searching for a source entry in the source MAC table that matches the source MAC address; and an update unit for updating the source entry in the source MAC table using the configuration value to obtain the target entry.
[0016] Optionally, the update unit includes: a parsing subunit, configured to parse the bit position of the fresh bit to be cleared in the source entry of the source MAC table based on the configuration value; and a first update subunit, configured to perform a clearing operation on the bit position of the source entry in the source MAC table to update the source entry.
[0017] Optionally, the update unit includes: a processing subunit, configured to invert the configuration value to obtain a transformed value; and a second update subunit, configured to perform a bitwise AND operation between the transformed value and the bit data of the source entry in the source MAC table to update the source entry.
[0018] Optionally, the apparatus further includes: a generation module, configured to generate the configuration value before the calling module calls the configuration value in the clear register according to the routing data packet; and an initialization module, configured to initialize the clear register with the configuration value.
[0019] Optionally, the generation module includes: a reading unit for reading version information of the source MAC table, wherein the version information is used to indicate the position of the fresh bit of each entry in the MAC table; and a configuration unit for configuring the value of the configuration value according to the version information.
[0020] According to yet another embodiment of the present invention, a storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
[0021] According to yet another embodiment of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0022] This invention involves receiving routing data packets on a routing device, wherein the routing device stores a source MAC table; calling a configuration value in a clear register according to the routing data packet, wherein the routing device includes the clear register, and the configuration value is used to indicate the bit position of the fresh bit in the MAC table entry on the routing device; updating the source entry in the source MAC table to a target entry using the configuration value; and writing the target entry back to the routing device. By introducing a clear register, the fresh bit of the MAC table entry can be directly located and cleared, solving the low efficiency problem of updating MAC table entries in related technologies, improving the update efficiency and flexibility of MAC table entries, making MAC table maintenance more accurate in terms of latency, and more accurate during MAC table aging operations. Attached Figure Description
[0023] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0024] Figure 1 This is a hardware structure block diagram of a MAC entry update switch according to an embodiment of the present invention.
[0025] Figure 2 This is a flowchart illustrating a method for updating a MAC entry according to an embodiment of the present invention;
[0026] Figure 3 This is a flowchart of hardware updating the MAC table in an embodiment of the present invention;
[0027] Figure 4 This is a schematic diagram illustrating the principle of clearing the register in an embodiment of the present invention;
[0028] Figure 5 This is a structural block diagram of a MAC entry updating device according to an embodiment of the present invention. Detailed Implementation
[0029] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all of them. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present application. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of the present application can be combined with each other.
[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0031] Example 1
[0032] The method embodiment provided in Embodiment 1 of this application can be executed in a processor, router, switch, vehicle, computer, or similar electronic terminal. Taking its operation on a switch as an example, Figure 1 This is a hardware structure block diagram of a switch for updating MAC entries according to an embodiment of the present invention. Figure 1 As shown, a switch may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. Optionally, the switch may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the switch described above. For example, the switch may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0033] The memory 104 can be used to store switch programs, such as application software programs and modules, like the switch program corresponding to a MAC entry update method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the switch program stored in the memory 104, thus implementing the aforementioned method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the switch via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. In this embodiment, the processor 104 is used to respond to human-computer interaction instructions and system instructions, and to execute code analysis tasks. The memory 104 is used to store configuration information, script information, etc.
[0034] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the switch's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0035] Optionally, the input / output device 108 also includes a human-computer interaction screen for obtaining human-computer interaction instructions through the human-computer interaction interface and for presenting the human-computer interaction interface;
[0036] This embodiment provides a method for updating MAC entries. Figure 2 This is a flowchart illustrating a method for updating a MAC entry according to an embodiment of the present invention, as shown below. Figure 2 As shown, the process includes the following steps:
[0037] Step S202: Receive routing data packets on the routing device, wherein the routing device stores a source MAC table;
[0038] Optionally, the routing device can be a router, switch, or other routing gateway device. The storage space of the routing device can store multiple MAC tables (MAC address tables), and each MAC table can store several MAC table entries (simply referred to as entries).
[0039] Step S204: Call the configuration value in the clear register according to the routing data packet, wherein the routing device includes the clear register, and the configuration value is used to indicate the bit position of the fresh bit in the MAC table entry of the MAC table on the routing device;
[0040] In this embodiment, the clear register is the MAC_ENTRY_FRESH_BIT_CLEAR register. The clear register is used to store the bit position of the fresh bit in the MAC table entry of the routing device.
[0041] Step S206: Update the source entry in the source MAC table to the target entry using the configuration value;
[0042] In this embodiment, the MAC entry is a record table in the routing device used to store the mapping relationship between MAC addresses and switch ports, guiding the switch on how to forward data frames. A MAC entry contains the following key information: MAC Address: This is a 48-bit unique identifier used to identify the physical interface of the network device. Each network interface has a unique MAC address. Port Number: Indicates which port on the routing device, such as the switch, is associated with this MAC address, and thus forwards data frames based on this port number. VLAN ID (Optional): If the switch supports VLANs (Virtual Local Area Networks), the entry will also contain a VLAN ID to distinguish MAC addresses in different VLANs. Aging Time: Each entry has an aging time to record the "freshness" of the entry. If no data frames associated with the entry are received within the aging time, the switch will delete the entry. Dynamic / Static Flag: The entry can be dynamic (dynamically learned) or static (manually configured). Dynamic entries are automatically learned by the switch, while static entries are manually configured by the administrator.
[0043] In this embodiment, the update target is the aging time in the MAC table entry, which is stored in the MAC table entry through a fresh bit at a specified position.
[0044] Step S208: Write the target entry back to the routing device;
[0045] Through the steps described above in this embodiment, routing data packets are received on the routing device, wherein the routing device stores a source MAC table; the configuration value in the clear register is called according to the routing data packet, wherein the routing device includes the clear register, and the configuration value is used to indicate the bit position of the fresh bit in the MAC table entry of the MAC table on the routing device; the source table entry in the source MAC table is updated to the target table entry using the configuration value; the target table entry is written back to the routing device. By introducing the clear register, the fresh bit of the MAC table entry can be directly located and cleared, solving the low efficiency problem of updating MAC table entries in related technologies, improving the update efficiency and flexibility of MAC table entries, making the maintenance of the MAC table more accurate in terms of latency, and making it more accurate during MAC table aging operations.
[0046] In this embodiment, calling the configuration value in the clear register according to the routing data packet includes: calling the Direct Memory Access Controller (DMAC) of the routing device to read the source MAC table on the routing device, wherein the routing device includes the DMAC; extracting the source MAC address from the routing data packet; determining whether the source MAC table matches the source MAC address; if the source MAC table matches the source MAC address, calling the configuration value in the clear register.
[0047] The routing packet is a packet to be forwarded, which includes at least the source MAC address and the destination MAC address. If the source MAC table matches the source MAC address of the routing packet, then the clear register is read.
[0048] In one embodiment of this example, updating a source entry in the source MAC table to a target entry using the configuration value includes: extracting the source MAC address from the routing data packet; searching the source MAC table for a source entry that matches the source MAC address; and updating the source entry in the source MAC table using the configuration value to obtain the target entry.
[0049] Since the source MAC table may contain multiple entries, it is necessary to find the source entry that matches the source MAC address of the current routed packet, and then update the value of the fresh bit of that source entry.
[0050] In one example, updating the source entry in the source MAC table using the configuration value includes: parsing the bit position of the fresh bit to be cleared in the source entry of the source MAC table based on the configuration value; and performing a clearing operation on the bit position of the source entry in the source MAC table to update the source entry.
[0051] For example, if the configuration value of the clear register is 0x00100000, and this configuration value indicates that the 20th bit of each MAC entry (such as the source entry) in the source MAC table is a fresh bit, then the 20th bit in the MAC entry will be cleared. The corresponding clear operation is performed according to the refresh rule of the fresh bit in the MAC entry. The cleared fresh bit indicates that the MAC entry is still in its normal lifecycle, is in a "fresh" state, has not aged, and does not need to be deleted. The fresh bit acts as a flag, and can be 0 or 1 to identify different states. For example, 0 represents a "fresh" state, and 1 represents an "aged" state. If a "fresh" state entry is never cleared, it will eventually transition to an "aged" state.
[0052] The fresh bit can also be bound to an aging timer. The aging timer is set to an aging duration, such as 300 seconds (5 minutes). If the clearing operation is not performed within 300 seconds after the new entry is created, it means that the entry has entered the "aging" state and will be automatically set to 1 and deleted. If the clearing operation is performed, the current timing duration of the aging timer will be cleared to zero and the timing will start again.
[0053] In one example, updating the source entry in the source MAC table using the configuration value includes: inverting the configuration value to obtain a transformed value; and performing a bitwise AND operation between the transformed value and the bit data of the source entry in the source MAC table to update the source entry.
[0054] Taking the configuration value of the clear register as 0x00100000 as an example, the operation is to invert 0x00100000 to 0xffe00000, and then perform a bitwise AND operation with the bit data of the MAC table entry to achieve the operation of clearing the MAC table entry fresh bit according to the configuration value of the clear register.
[0055] In this embodiment, before calling the configuration value in the clear register according to the routing data packet, the method further includes: generating the configuration value; and initializing the clear register with the configuration value.
[0056] The MAC table clearing register provided in this proposal only needs to be configured once during system initialization. During the routing packet processing, the software does not need to operate, and the hardware automatically completes the MAC table update operation, thereby improving the update efficiency of the MAC table.
[0057] Optionally, generating the configuration value includes: reading the version information of the source MAC table, wherein the version information is used to indicate the position of the fresh bit of each entry in the MAC table; and configuring the value of the configuration value according to the version information.
[0058] For example, in version 1, the software design places the fresh bit of the MAC entry at bit 20, so the clear register should be configured to 0x00100000. In version 2, the software design places the fresh bit of the MAC entry at bit 30, so the clear register should be configured to 0x40000000 during initialization. Without changing the hardware design, different software versions and different MAC entry designs can be flexibly adapted simply by modifying the configuration value of the clear register, thus improving flexibility.
[0059] This ensures that even if the position of the update bit changes after the MAC table design is updated, the new MAC table design can be adapted simply by reconfiguring this register during system software initialization.
[0060] This embodiment provides a novel method for optimizing VLAN bridge performance, which can improve data forwarding efficiency, reduce latency, and effectively manage network traffic without significantly increasing network complexity. This optimization scheme should be adaptable to network environments of different sizes and possess good scalability and compatibility to meet the needs of future network development.
[0061] Figure 3 This is a flowchart of hardware updating the MAC table in an embodiment of the present invention. Figure 4 This is a schematic diagram illustrating the principle of clearing the register in this embodiment of the invention. A new hardware—the clear register—has been added, and the hardware update process includes:
[0062] Step 1: After receiving a data packet (routing data packet), the hardware will start a MAC table lookup, which is the normal process for processing data packets;
[0063] Step 2: If the MAC table matches the source MAC address, the hardware reads the clear register and clears the corresponding fresh bit in the MAC table to 0 according to the configuration value of the clear register.
[0064] For example, if the 20th bit of the MAC table entry is the fresh bit, and the clear register is configured with 0x00100000, then the 20th bit of the MAC table entry will be cleared to 0. The specific hardware operation is to invert 0x00100000 to 0xffe00000 and then perform a bitwise AND operation on the MAC table entry to achieve the operation of clearing the fresh bit of the MAC table entry according to the configuration value of the clear register.
[0065] Step 3: The hardware writes the MAC table entry with the fresh bit cleared back to the MAC table's storage space.
[0066] Using the scheme in this embodiment, the MAC table update operation only requires the software to configure a register clearing once during system initialization; all other actions are performed by hardware. The added overhead of this scheme is the addition of a 32-bit register in hardware, as well as hardware read-from-the-register and hardware write-back operations for the MAC table. In implementation, the MAC table address found in step 1 can be used for direct write-back, so the actual overhead is limited to steps 2 and 3.
[0067] This embodiment transforms the software operation of updating the MAC table into a hardware operation, enabling rapid clearing of the fresh bit in MAC table entries via hardware. The required hardware addition is a new clear register, configured in software, which indicates which bit in the MAC table entry is the fresh bit and needs to be cleared before being written back to the MAC table entry storage space. The purpose of setting up the clear register is to improve the flexibility of the MAC table. Based on this design, the hardware can clear any bit in the MAC table according to the software settings. This function still works normally after the MAC table design is optimized and updated. In multi-core systems, it reduces the probability of read / write MAC table conflicts by approximately 50%, and provides more precise latency control for MAC table maintenance, especially during MAC table aging operations.
[0068] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0069] Example 2
[0070] This embodiment also provides a MAC entry updating device for implementing 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 device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0071] Figure 5 This is a structural block diagram of a MAC entry updating device according to an embodiment of the present invention, such as... Figure 5As shown, the device includes: a receiving module 50, a calling module 52, an updating module 54, and a write-back module 56, wherein...
[0072] The receiving module 50 is used to receive routing data packets on the routing device, wherein the routing device stores a source MAC table;
[0073] Calling module 52 is used to call the configuration value in the clear register according to the routing data packet, wherein the routing device includes the clear register, and the configuration value is used to indicate the bit position of the fresh bit in the MAC table entry of the MAC table on the routing device;
[0074] Update module 54 is used to update the source entry in the source MAC table to the target entry using the configuration value;
[0075] The write-back module 56 is used to write back the target entry to the routing device.
[0076] Optionally, the calling module includes: a reading unit, used to call the Direct Memory Access Controller (DMAC) of the routing device to read the source MAC table on the routing device, wherein the routing device includes the DMAC; an extraction unit, used to extract the source MAC address from the routing data packet; a judgment unit, used to judge whether the source MAC table matches the source MAC address; and a calling unit, used to call the configuration value in the clear register if the source MAC table matches the source MAC address.
[0077] Optionally, the update module includes: an extraction unit for extracting the source MAC address from the routing data packet; a lookup unit for searching for a source entry in the source MAC table that matches the source MAC address; and an update unit for updating the source entry in the source MAC table using the configuration value to obtain the target entry.
[0078] Optionally, the update unit includes: a parsing subunit, configured to parse the bit position of the fresh bit to be cleared in the source entry of the source MAC table based on the configuration value; and a first update subunit, configured to perform a clearing operation on the bit position of the source entry in the source MAC table to update the source entry.
[0079] Optionally, the update unit includes: a processing subunit, configured to invert the configuration value to obtain a transformed value; and a second update subunit, configured to perform a bitwise AND operation between the transformed value and the bit data of the source entry in the source MAC table to update the source entry.
[0080] Optionally, the apparatus further includes: a generation module, configured to generate the configuration value before the calling module calls the configuration value in the clear register according to the routing data packet; and an initialization module, configured to initialize the clear register with the configuration value.
[0081] Optionally, the generation module includes: a reading unit for reading version information of the source MAC table, wherein the version information is used to indicate the position of the fresh bit of each entry in the MAC table; and a configuration unit for configuring the value of the configuration value according to the version information.
[0082] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0083] Example 3
[0084] Embodiments of the present invention also provide a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
[0085] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0086] S1, receiving routing data packets on a routing device, wherein the routing device stores a source MAC table;
[0087] S2, call the configuration value in the clear register according to the routing data packet, wherein the routing device includes the clear register, and the configuration value is used to indicate the bit position of the fresh bit in the MAC table entry of the MAC table on the routing device;
[0088] S3, update the source entry in the source MAC table to the target entry using the configuration value;
[0089] S4, Write the target entry back to the routing device.
[0090] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0091] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0092] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0093] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0094] S1, receiving routing data packets on a routing device, wherein the routing device stores a source MAC table;
[0095] S2, call the configuration value in the clear register according to the routing data packet, wherein the routing device includes the clear register, and the configuration value is used to indicate the bit position of the fresh bit in the MAC table entry of the MAC table on the routing device;
[0096] S3, update the source entry in the source MAC table to the target entry using the configuration value;
[0097] S4, Write the target entry back to the routing device.
[0098] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0099] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0100] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0101] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0102] The units described as separate components may or may not be physically separate. 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 units can be selected to achieve the purpose of this embodiment according to actual needs.
[0103] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0104] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0105] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for updating MAC entries, characterized in that, include: Receiving routing data packets on a routing device, wherein the routing device stores a source MAC table; The configuration value in the clear register is invoked according to the routed data packet, wherein the routing device includes the clear register, and the configuration value is used to indicate the bit position of the fresh bit in the MAC table entry of the MAC table on the routing device; The source entry in the source MAC table is updated to the target entry using the configuration value; Write the target entry back to the routing device.
2. The method according to claim 1, characterized in that, The configuration value in the clear register is invoked based on the routed data packet, including: The direct memory access controller (DMAC) of the routing device is invoked to read the source MAC table on the routing device, wherein the routing device includes the DMAC. Extract the source MAC address from the routed data packets; Determine whether the source MAC address is matched in the source MAC table; If the source MAC table matches the source MAC address, the configuration value in the clear register is called.
3. The method according to claim 1, characterized in that, Updating the source entry in the source MAC table to the target entry using the configuration value includes: Extract the source MAC address from the routed data packets; Search the source MAC table for a source entry that matches the source MAC address; The source entry in the source MAC table is updated using the configuration value to obtain the target entry.
4. The method according to claim 3, characterized in that, Updating the source table entry in the source MAC table using the configuration value includes: Based on the configuration value, the bit position of the fresh bit to be cleared in the source table entry of the source MAC table is parsed. A zeroing operation is performed on the bit position of the source entry in the source MAC table to update the source entry.
5. The method according to claim 4, characterized in that, Updating the source table entry in the source MAC table using the configuration value includes: The configuration value is inverted to obtain the transformed value; The transformed value is bitwise ANDed with the bit data of the source entry in the source MAC table to update the source entry.
6. The method according to claim 1, characterized in that, Before clearing the configuration value in the register based on the routed data packet, the method further includes: Generate the configuration value; The clear register is initialized using the configuration value.
7. The method according to claim 6, characterized in that, Generating the configuration value includes: Read the version information of the source MAC table, wherein the version information is used to indicate the position of the fresh bit of each entry in the MAC table; Configure the value of the configuration based on the version information.
8. A device for updating MAC entries, characterized in that, include: A receiving module is used to receive routing data packets on a routing device, wherein the routing device stores a source MAC table; The calling module is used to call the configuration value in the clear register according to the routing data packet, wherein the routing device includes the clear register, and the configuration value is used to indicate the bit position of the fresh bit in the MAC table entry of the MAC table on the routing device; The update module is used to update the source entry in the source MAC table to the target entry using the configuration value; The write-back module is used to write back the target entry to the routing device.
9. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the method described in any one of claims 1 to 7 when it is run.
10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method as described in any one of claims 1 to 7.