Method and system for synchronizing arp forwarding table, storage medium and electronic device
Patent Information
- Application Number
- CN202311049712.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-18
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-08-18
AI Technical Summary
[0008]本发明实施例提供了一种ARP转发表的同步方法及系统、存储介质及电子装置,以至少解决堆叠系统中不同交换机的ARP转发表难以统一的问题
[0020]根据本发明实施例的又一方面,还提供了一种电子装置,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,上述处理器通过计算机程序执行上述ARP转发表的同步方法。
Smart Images

Figure CN117118991B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communications, and more specifically, to a method and system for synchronizing an ARP forwarding table, a storage medium, and an electronic device. Background Technology
[0002] Stacking systems, as a network switch virtualization technology, can logically virtualize multiple switch devices into a single switch device, aggregating the hardware resources of multiple switches for unified management, thereby achieving higher performance, reliability, and scalability.
[0003] The main advantage of stacking systems is that they can easily expand switching capacity and increase port access capabilities as business needs grow, while the initial investment can continue to be effective and is less likely to be wasted. They are often used at the network edge where access needs are constantly growing.
[0004] Within a stacked system, each stack member needs a defined role in order to collaborate as a logical whole and participate in network operations, such as... Figure 1 As shown, all individual switches in a stacked system are called member switches, each with a unique switch ID (switchID). Based on their functions, individual switches in a stacked system can be divided into three roles: Master Switch: The master switch manages and controls the entire stack. There is only one master switch in a stacked system. Standby Switch: The standby switch is a backup switch for the master switch. There is only one standby switch in a stacked system. Besides backing up network information, the standby switch also participates in service forwarding. When the master switch fails, the standby switch takes over all the services of the original master switch and becomes the new master switch. Follower Switch: The follower switch is used for service forwarding. There can be multiple follower switches in a stacked system. The more follower switches there are, the greater the forwarding bandwidth of the stacked system. Besides the master and standby switches, all other member switches in the stack are follower switches. Because a standby switch can be promptly promoted to master when the master switch fails, the robustness of the system is ensured.
[0005] The ARP protocol running on a stacked system needs to virtualize multiple devices into a single logical node to interact with the outside world and learn the ARP entries of access users. The learned ARP forwarding entries need to guide forwarding on different switches within the stacked system. However, implementing the ARP network protocol within a stacked system is much more complex than implementing it on a single machine, making it difficult to unify the ARP forwarding tables of different switches in the stacked system.
[0006] Regarding the issue of unifying ARP forwarding tables across different switches in a stacked system, no effective solution has yet been proposed.
[0007] Therefore, it is necessary to improve the relevant technology to overcome the aforementioned defects. Summary of the Invention
[0008] This invention provides a method and system for synchronizing ARP forwarding tables, a storage medium, and an electronic device to at least solve the problem of difficulty in unifying ARP forwarding tables of different switches in a stacked system.
[0009] According to one aspect of the present invention, an ARP forwarding table synchronization method is provided, applied to a master switch in a stacked system with N switches, comprising: acquiring M Address Resolution Protocol (ARP) response packets through a packet transmission and reception channel between the kernel interface of the master switch and the hardware interface of each of the N switches, wherein the ARP response packets are packets received by the hardware interface of the switches, and the ARP response packets carry at least the Internet Protocol (IP) address and Media Access Control (MAC) address of the terminal device that sent the ARP response packets; the kernel interface of the master switch is a software-simulated interface of the hardware interface of the master switch in the network kernel of the master switch, and M is greater than or equal to N; generating an ARP forwarding table based on the M ARP response packets, wherein the ARP forwarding table records at least the IP address and MAC address of each terminal device connected to the stacked system; and synchronizing the ARP forwarding table to each target switch among the N switches, wherein the target switch is a backup switch or a slave switch in the stacked system.
[0010] In an exemplary embodiment, M Address Resolution Protocol (ARP) response packets are obtained through the packet transceiver channel between the kernel interface of the master switch and the hardware interface of each of the N switches in the stacking system. This includes: obtaining ARP response packets sent by the hardware interface of the master switch through the packet transceiver channel between the kernel interface of the master switch and the hardware interface of the master switch; and obtaining ARP response packets sent by the kernel interface of each target switch through the packet transceiver channel between the kernel interface of the master switch and the kernel interface of each of the N target switches. The ARP response packets sent by the kernel interface of the target switch are ARP response packets obtained by the kernel interface of the target switch through the packet transceiver channel with the hardware interface of the target switch.
[0011] In an exemplary embodiment, synchronizing the ARP forwarding table to each target switch among the N switches includes: storing the ARP forwarding table in the database of the master switch; and synchronizing the ARP forwarding table in the database of the master switch to the database of each target switch among the N switches through a database synchronization mechanism.
[0012] In an exemplary embodiment, after synchronizing the ARP forwarding table to each of the N switches as a target switch, the method further includes: upon detecting that the first switch in the stacking system has left the stacking system, deleting the packet transmission and reception channel between the kernel interface of the master switch and the hardware interface of the first switch, wherein the first switch is a target switch in the stacking system; and deleting the IP address and MAC address of the terminal device connected to the first switch from the ARP forwarding table to obtain an updated ARP forwarding table; and synchronizing the updated ARP forwarding table to each of the N switches except the first switch.
[0013] In an exemplary embodiment, after synchronizing the ARP forwarding table to each target switch among the N switches, the method further includes: upon detecting that a second switch has joined the stacking system, establishing a packet transmission and reception channel between the kernel interface of the master switch and the hardware interface of the second switch; and synchronizing the ARP forwarding table in the database of the master switch to the database of the second switch through a database synchronization mechanism.
[0014] In an exemplary embodiment, after synchronizing the ARP forwarding table to each of the N switches, the method further includes: writing the ARP forwarding table to the hardware chip forwarding table of the master switch.
[0015] According to another aspect of the present invention, an ARP forwarding table synchronization method is also provided, applied to a target switch in a stacking system, wherein the target switch is a backup switch or a slave switch in the stacking system, comprising: sending an ARP response packet obtained by the hardware interface of the target switch to the kernel interface of the master switch through a packet transmission and reception channel between the hardware interface of the target switch and the kernel interface of the master switch in the stacking system, wherein the ARP response packet carries at least the IP address and MAC address of the terminal device that sent the ARP response packet; the kernel interface of the master switch is a software-simulated interface of the hardware interface of the master switch in the network kernel of the master switch; and obtaining an ARP forwarding table synchronized by the master switch, wherein the ARP forwarding table is an ARP forwarding table generated by the master switch based on all obtained ARP response packets, wherein the ARP forwarding table records at least the IP address and MAC address of each terminal device connected to the stacking system.
[0016] In an exemplary embodiment, after obtaining the ARP forwarding table synchronized by the master switch, the method further includes: when the target switch is a backup switch and the target switch detects that it needs to be upgraded to a master switch, establishing a packet transmission and reception channel between the kernel interface of the target switch and the hardware interface of each switch in the stacking system; updating the ARP forwarding table to obtain an updated ARP forwarding table; and synchronizing the updated ARP forwarding table to each target switch in the stacking system except for the new master switch.
[0017] In an exemplary embodiment, after obtaining the ARP forwarding table synchronized by the master switch, the method further includes: writing the ARP forwarding table into the hardware chip forwarding table of the target switch.
[0018] According to another aspect of the present invention, an ARP forwarding table synchronization system is also provided, comprising: a target switch, configured to send an ARP response packet obtained by the hardware interface of the target switch to the kernel interface of the master switch through a packet transmission and reception channel between the hardware interface of the target switch and the kernel interface of the master switch in a stacking system, wherein the ARP response packet carries at least the IP address and MAC address of the terminal device sending the ARP response packet, and the kernel interface of the master switch is a software-simulated interface of the hardware interface of the master switch in the network kernel of the master switch. The switch is either a backup switch or a slave switch in the stacking system; the master switch is used to acquire M ARP response packets and generate an ARP forwarding table based on the M ARP response packets; and synchronize the ARP forwarding table to each of the target switches in the stacking system; wherein, the M ARP response packets include: multiple ARP response packets sent by multiple target switches, and one or more ARP response packets sent from the hardware interface of the master switch to the kernel interface of the master switch; the ARP forwarding table records at least the IP address and MAC address of each terminal device connected to the stacking system.
[0019] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, wherein the computer program is configured to execute the above-described ARP forwarding table synchronization method when running.
[0020] According to another aspect of the present invention, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above-described ARP forwarding table synchronization method through the computer program.
[0021] Through this invention, the master switch obtains M ARP response packets through the packet transmission and reception channel between its own kernel interface and the hardware interface of each switch, and generates an ARP forwarding table based on the M ARP response packets. The ARP forwarding table is then synchronized to each target switch (backup switch or slave switch) among the N switches, thereby achieving the unification of ARP forwarding tables within the stacking system and solving the problem of difficulty in unifying ARP forwarding tables of different switches in the stacking system. Attached Figure Description
[0022] 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 the description thereof, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0023] Figure 1This is a schematic diagram of the components of a stacked system;
[0024] Figure 2 This is a hardware structure block diagram of a computer terminal according to an embodiment of the present invention, which describes a method for synchronizing an ARP forwarding table.
[0025] Figure 3 This is a flowchart of an ARP forwarding table synchronization method according to an embodiment of the present invention;
[0026] Figure 4 This is a flowchart of another method for synchronizing an ARP forwarding table according to an embodiment of the present invention;
[0027] Figure 5 This is a schematic diagram illustrating the establishment of a message transmission and reception channel according to an embodiment of the present invention;
[0028] Figure 6 This is a schematic diagram of a chain-type network of a stacked system according to an embodiment of the present invention;
[0029] Figure 7 This is an overall schematic diagram of a stacked system ARP management method according to an embodiment of the present invention;
[0030] Figure 8 This is a structural block diagram of an ARP forwarding table synchronization system according to an embodiment of the present invention. Detailed Implementation
[0031] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention 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 the invention 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 a non-exclusive inclusion; for example, a process, method, system, 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.
[0033] The methods and embodiments provided in this application can be executed on a computer terminal or similar computing device. Taking running on a computer terminal as an example, Figure 2 This is a hardware structure block diagram of a computer terminal according to an embodiment of the present invention, which describes a method for synchronizing an ARP forwarding table. Figure 2 As shown, a computer terminal may include one or more ( Figure 2 Only one is shown in the diagram. A processor 202 (which may include, but is not limited to, a microprocessor unit (MPU) or a programmable logic device (PLD)) and a memory 204 for storing data are also shown. In one exemplary embodiment, the computer terminal may further include a transmission device 206 for communication functions and an input / output device 208. Those skilled in the art will understand that... Figure 2 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 2 The more or fewer components shown, or having the same Figure 2 Equivalent functions or ratios shown Figure 2 The functions shown have more different configurations.
[0034] The memory 204 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the ARP forwarding table synchronization method in this embodiment of the invention. The processor 202 executes various functional applications and data processing by running the computer programs stored in the memory 204, thereby implementing the aforementioned method. The memory 204 may include high-speed random access memory, and may also include 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 204 may further include memory remotely located relative to the processor 202, and these remote memories can be connected to a computer terminal 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.
[0035] The transmission device 206 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the computer terminal. In one example, the transmission device 206 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 206 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0036] Specifically, this embodiment provides an ARP forwarding table synchronization method, applied to the master switch in a stacked system with N switches. Figure 3 This is a flowchart of an ARP forwarding table synchronization method according to an embodiment of the present invention, the process including the following steps:
[0037] Step S302: Obtain M Address Resolution Protocol (ARP) response packets through the packet transmission and reception channel between the kernel interface of the main switch and the hardware interface of each of the N switches. Each ARP response packet is a packet received by the hardware interface of the switch, and each ARP response packet carries at least the Internet Protocol (IP) address and Media Access Control (MAC) address of the terminal device that sent the ARP response packet. The kernel interface of the main switch is the software-simulated interface of the hardware interface of the main switch within the network kernel of the main switch. M is greater than or equal to N.
[0038] It should be noted that since each switch in the stacked system is connected to one or more end devices, each switch will receive multiple ARP response messages, thus M is greater than or equal to N.
[0039] In an exemplary embodiment, prior to step S302 described above, the following steps S11-S12 are also included:
[0040] Step S11: Establish a message transmission and reception channel between the kernel interface of the main switch and the hardware interface of the main switch;
[0041] Step S12: Establish a message transmission and reception channel between the kernel interface of the master switch and the kernel interface of each of the N target switches, wherein the target switch is a backup switch or a slave switch among the N switches.
[0042] As an alternative example, the message transmission and reception channel between the master switch and the target switch can be a VXLAN tunnel.
[0043] It should be noted that there is no specific order in which steps S11 and S12 are executed; either step S11 or step S12 can be executed first.
[0044] It should be noted that the kernel interface of the target switch is a software-simulated interface of the target switch's hardware interface within the target switch's network kernel. Each target switch, upon startup, establishes a packet transmission and reception channel between its own hardware interface and its own kernel interface.
[0045] It should be noted that after performing the above steps S11-S12, the master switch establishes a message transmission and reception channel between its own kernel interface and the hardware interface of each switch in the stacking system. Thus, the kernel interface of the master switch is a software simulation interface of the hardware interfaces of all switches in the stacking system in the network kernel of the master switch.
[0046] In an exemplary embodiment, step S302 above includes the following steps S21-S22:
[0047] Step S21: Obtain the ARP response message sent by the hardware interface of the main switch through the message transmission and reception channel between the kernel interface and the hardware interface of the main switch;
[0048] It should be noted that after receiving an ARP response packet, the hardware interface of the master switch will forward the ARP response packet to the kernel interface in the master switch.
[0049] Step S22: Obtain the ARP response message sent by the kernel interface of each target switch through the message transmission and reception channel between the kernel interface of the master switch and the kernel interface of each of the N switches;
[0050] It should be noted that there is no specific order in which steps S21 and S22 are executed; either step S21 or step S22 can be executed first.
[0051] It should be noted that the ARP response message sent by the kernel interface of the target switch is the ARP response message obtained by the kernel interface of the target switch through the message transmission and reception channel between the kernel interface and the hardware interface of the target switch.
[0052] In other words, the target switch among N switches will send ARP request packets to the terminal devices connected to it through its hardware interface. Upon receiving the ARP request packet, the corresponding terminal device will send an ARP response packet to the target switch. After receiving the ARP response packet, the target switch's own hardware interface will forward the ARP response packet to its own kernel interface through the packet transmission channel between the target switch and its kernel interface. The target switch's kernel interface will then forward the ARP response packet to the master switch's kernel interface through the packet transmission and reception channel between the master switch and its kernel interface. Thus, the master switch's kernel interface can obtain the ARP response packet from the target switch's kernel interface.
[0053] It should be noted that when the kernel ARP protocol on the main switch's network kernel specifies that a kernel interface sends a packet, it will enter the corresponding VXLAN tunnel (i.e., the packet transmission and reception channel between the kernel interface of the main switch and the kernel interfaces of the backup / slave switches) and be sent to the corresponding kernel interface on the backup / slave switches, and finally sent out from the corresponding hardware interface.
[0054] As an optional example, before the above steps SS302, it is also necessary to establish a database synchronization channel between the master switch and the backup / slave switches. That is, databases are set up on the three types of switches respectively, with the database on the master switch being the master database and the database on the backup / slave switches being the slave database. The data information in the master database will be synchronized to the slave database.
[0055] Step S304: Generate an ARP forwarding table based on M ARP response messages, wherein the ARP forwarding table records at least the IP address and MAC address of each terminal device connected to the stacking system, and M is greater than or equal to N;
[0056] As an optional example, the master switch can generate an ARP forwarding table based on the M ARP response packets using its own ARP module, wherein the master switch's ARP module is located in the master switch's network kernel;
[0057] In other words, all users accessing the master / backup / slave switches interact with the ARP module in the master switch's network kernel via protocol packets. The ARP modules in the backup / slave switches, not receiving user packets, do not learn ARP information. The master switch's ARP module learns the ARP forwarding information of all users accessing the stacking system and generates an ARP forwarding table. The master switch's ARP module also responds to ARP requests from external users on behalf of the stacking system, helping external users learn the stacking system's ARP information.
[0058] It should be noted that, in this field, the ARP module in the network kernel is also called the neighbor module.
[0059] Step S306: Synchronize the ARP forwarding table to each of the N switches, wherein the target switch is a backup switch or a slave switch in the stacking system.
[0060] In an exemplary embodiment, after step S306 above, the method further includes: writing the ARP forwarding table to the hardware chip forwarding table of the master switch.
[0061] The above steps involve the master switch acquiring M ARP response packets through the packet transmission and reception channel between its own kernel interface and the hardware interface of each switch, generating an ARP forwarding table based on the M ARP response packets, and synchronizing the ARP forwarding table to each target switch (backup switch or slave switch) among the N switches. This achieves the unification of the ARP forwarding table within the stacking system, solving the problem of difficulty in unifying the ARP forwarding tables of different switches in the stacking system.
[0062] In an exemplary embodiment, step S306 can be performed by the following steps S31-S32:
[0063] Step S31: Store the ARP forwarding table in the database of the main switch;
[0064] As an alternative example, the master switch can obtain the ARP forwarding table from the ARP module of the master switch through the first management process, and store the ARP forwarding table in the database of the master switch.
[0065] It should be noted that the first management process is the neighbor management process in the network kernel. The neighbor management process running on the switch communicates with the ARP module in the network kernel through the Netlink interface provided by Linux to obtain ARP forwarding table change information from the ARP module. When the ARP module sends an ARP entry addition / deletion notification, the neighbor management process synchronously stores the changed ARP forwarding table data into the database, ensuring that the ARP entry information in the switch's database is consistent with the ARP information cached by the ARP module.
[0066] As an optional example, writing the ARP forwarding table to the hardware chip forwarding table of the master switch includes: subscribing to the ARP forwarding table from the database of the master switch through the second management process of the master switch, and writing the ARP forwarding table to the hardware chip forwarding table of the master switch.
[0067] It should be noted that the second management process is the neighbor assignment process in the network kernel. The neighbor assignment process of the master switch subscribes to database information from the database of the master switch (i.e., the master database) and further writes the ARP forwarding table of the entire stack system into the forwarding table of the hardware chip of this switch.
[0068] Step S32: Synchronize the ARP forwarding table in the database of the master switch to the database of each of the N target switches through the database synchronization mechanism.
[0069] It should be noted that the neighbor distribution process running on the target switch subscribes to the target switch's local slave database information, obtains the ARP forwarding table of the stacking system, and further writes the ARP forwarding table of the entire stacking system into the hardware chip forwarding table of this switch.
[0070] Through the above steps, all member forwarding planes of the stacking system have all ARP forwarding table entries, enabling them to query the ARP forwarding table when forwarding Layer 3 traffic, obtain the corresponding user's Layer 2 address information, and support cross-board ARP entry queries.
[0071] In an exemplary embodiment, after synchronizing the ARP forwarding table to each of the N switches, the method further includes the following steps S41-S43:
[0072] Step S41: If it is detected that the first switch in the stacking system has left the stacking system, delete the message transmission and reception channel between the kernel interface of the master switch and the hardware interface of the first switch, wherein the first switch is the target switch in the stacking system.
[0073] Step S42: Delete the IP address and MAC address of the terminal device connected to the first switch from the ARP forwarding table to obtain an updated ARP forwarding table;
[0074] It should be noted that there is no specific order in which steps S41 and S42 are executed; either step S41 or step S42 can be executed first.
[0075] Step S43: Synchronize the updated ARP forwarding table to each of the N switches except for the first switch.
[0076] In other words, when the master switch detects that a member device has left the stacking system (removed or failed and went down), the master switch needs to delete the message transmission and reception channel between its own kernel interface and the hardware interface of the first switch. (It should be noted that deleting the message transmission and reception channel between the kernel interface of the master switch and the kernel interface of the first switch is equivalent to deleting the message transmission and reception channel between the kernel interface of the master switch and the hardware interface of the first switch.)
[0077] When a member device leaves the stacking system, the terminal devices connected to the stacking system will also leave. Therefore, the ARP module of the master switch needs to update the ARP forwarding table to delete the IP address and MAC address of the departing terminal device. Subsequently, after the neighbor management process of the master switch receives the netlink neighbor deletion message, it updates the master database and synchronizes it to all slave databases. Then, the neighbor distribution processes running on the other backup / slave switches subscribe to the local slave database change information and delete the IP address and MAC address of the deleted terminal device from their own switch hardware chip forwarding table.
[0078] In an exemplary embodiment, after synchronizing the ARP forwarding table to each of the N target switches, the method further includes the following steps S51-S52:
[0079] Step S51: When the addition of the second switch to the stacking system is detected, a message transmission and reception channel is established between the kernel interface of the master switch and the hardware interface of the second switch.
[0080] It should be noted that after the second switch is added to the stacking system, it will establish a message transmission and reception channel between its own kernel interface and its own hardware interface.
[0081] It should be noted that once the main switch establishes a message transmission and reception channel between its own kernel interface and the kernel interface of the second switch, a message transmission and reception channel between the kernel interface of the main switch and the hardware interface of the second switch is also established.
[0082] Step S52: Synchronize the ARP forwarding table in the database of the master switch to the database of the second switch through the database synchronization mechanism.
[0083] It should be noted that the second management process of the second switch will subscribe to the ARP forwarding table from the database of the second switch and write the ARP forwarding table to the forwarding table of the hardware chip of the second switch.
[0084] It should be noted that the execution of steps S51 and S52 above is not sequential; either step S51 or step S52 can be executed first.
[0085] In this embodiment, when the master switch detects that a new switch has joined the stacking system, the master switch needs to establish a message transmission and reception channel with the newly joined switch and set the database of the newly joined switch as a slave database of the master switch's master database. The master switch synchronizes the learned ARP entries to the new switch through the database. The neighbor distribution process running on the new switch subscribes to the local slave database information and writes the ARP information learned by the stacking system into the forwarding table of the switch's hardware chip.
[0086] In addition, the main switch will also send and receive ARP packets through the hardware interfaces of newly added switches, and learn and manage the IP addresses and MAC addresses of mobile terminals accessed through the hardware interfaces of newly added switches.
[0087] This embodiment provides an ARP forwarding table synchronization method, applied to a target switch in a stacked system, where the target switch is either a backup switch or a slave switch in the stacked system. Figure 4 This is a flowchart of another method for synchronizing an ARP forwarding table according to an embodiment of the present invention, the process including the following steps:
[0088] Step S402: Through the packet transmission and reception channel between the hardware interface of the target switch and the kernel interface of the master switch in the stacking system, the ARP response packet obtained by the hardware interface of the target switch is sent to the kernel interface of the master switch. The ARP response packet carries at least the IP address and MAC address of the terminal device that sent the ARP response packet. The kernel interface of the master switch is the software emulation interface of the hardware interface of the master switch in the network kernel of the master switch.
[0089] It should be noted that after the target switch starts up, it establishes a packet transmission and reception channel between its kernel interface and its hardware interface. Then, after receiving an ARP response packet from the terminal device, the target switch's hardware interface forwards the ARP response packet to its own kernel interface through the packet transmission and reception channel with the master switch's kernel interface. The target switch's kernel interface then forwards the ARP response packet to the master switch's kernel interface through the packet transmission and reception channel with the master switch's kernel interface.
[0090] Step S404: Obtain the ARP forwarding table synchronized by the master switch, wherein the ARP forwarding table is generated by the master switch based on all obtained ARP response packets, and wherein the ARP forwarding table records at least the IP address and MAC address of each terminal device connected to the stacking system.
[0091] In an exemplary embodiment, after step S404 above, the target switch will also write the ARP forwarding table to the target switch's hardware chip forwarding table.
[0092] Optionally, the target switch can subscribe to the ARP forwarding table from its own database through its own second management process and write the ARP forwarding table into the target switch's hardware chip forwarding table.
[0093] The above steps involve the target switch sending an ARP response message to the master switch through the packet transmission and reception channel between its own hardware interface and the kernel interface of the master switch, thereby obtaining the synchronized ARP forwarding table of the master switch. This achieves the unification of ARP forwarding tables within the stacking system, solving the problem of the difficulty in unifying ARP forwarding tables of different switches in the stacking system.
[0094] In an exemplary embodiment, step S404 above can be implemented by obtaining the ARP forwarding table from the database of the target switch.
[0095] It should be noted that the ARP forwarding table in the target switch's database is a forwarding table synchronized from the master switch's database through a database synchronization mechanism.
[0096] In an exemplary embodiment, after obtaining the ARP forwarding table from the database of the target switch, the following steps S61-S62 are further performed:
[0097] Step S61: Monitor the changes in the ARP forwarding table in the database of the target switch;
[0098] Step S62: If a change is detected in the ARP forwarding table in the database of the target switch, the changed ARP forwarding table is written to the forwarding table of the target switch's own hardware chip.
[0099] In this embodiment, the above steps enable real-time unification of ARP forwarding tables within the stacked system.
[0100] In an exemplary embodiment, after step S404 above, the method further includes the following steps S71-S72:
[0101] Step S71: When the target switch is a backup switch and the target switch detects that it needs to be upgraded to a master switch, establish a packet transmission and reception channel between the kernel interface of the target switch and the hardware interface of each switch in the stacking system; and update the ARP forwarding table to obtain the updated ARP forwarding table.
[0102] Step S72: Synchronize the updated ARP forwarding table to each target switch in the stacking system except for the new master switch.
[0103] In other words, when the backup switch detects that the master switch has left the stacking system or receives a master-slave reversal command, the backup switch needs to quickly take over the ARP management of the stacking system. The backup switch deletes the previously established packet transmission and reception channel from its local kernel interface to the master switch's kernel interface, upgrades itself to the master switch, rebuilds the packet transmission and reception channel from the new master switch's kernel interface to the hardware interfaces of all stack members, and restores the packet transmission and reception channel from its local hardware interface to its local kernel interface. The new master switch establishes tunnel channels between its own kernel interface and the kernel interfaces of other switches in the stacking system. The new master switch's database is upgraded to the master database, and the databases of other stack members become slave databases of the new master database, subsequently retrieving ARP entries from the new master database. The neighbor management process running on the new master switch reads the ARP information of the stacking system from its own database, notifies the local ARP module to add dynamic ARP via the netlink interface, and restores the ARP information to the kernel.
[0104] After the target switch is upgraded to the master switch, some access users (i.e., terminal devices accessing the stacking system) will leave. The ARP entries of these expired neighbors should be deleted. As a result, the new master switch needs to update the original ARP forwarding table and synchronize the updated ARP forwarding table to every target switch in the stacking system except for the new master switch.
[0105] In an exemplary embodiment, updating the ARP forwarding table can be achieved through the following steps S81-S82:
[0106] Step S81: Send ARP request messages to multiple terminal devices, wherein the ARP forwarding table records the IP address and MAC address of the multiple terminal devices;
[0107] Step S82: If no ARP response message is received from the target terminal device in response to the ARP request message, delete the IP address and MAC address of the target terminal device from the ARP forwarding table.
[0108] It should be noted that if no ARP response message is received from the target terminal device in response to the ARP request message, it means that the target terminal device has left, and the ARP module of the new main switch needs to delete the IP address and MAC address of the target terminal device from the ARP forwarding table.
[0109] In other words, the ARP module of the new master switch will age the neighbor information added by the neighbor management process normally. When the aging time is up, it will send an ARP request packet. If a neighbor responds, it proves that the ARP entry remains valid. If no neighbor responds, the ARP entry will be deleted. This deletion event will be notified to the neighbor management process via a netlink message, and the neighbor management process will delete the neighbor from the master database. After receiving the database notification, the neighbor distribution processes of other switches will delete the neighbor information from their respective switch's hardware chip forwarding table.
[0110] At this point, kernel ARP information on the new master device is restored, and the ARP module in the network kernel continues to work normally to complete the ARP management work of the entire stack system. The hardware chip forwarding tables of all stack members are working normally, the ARP forwarding table entries of departing users are deleted, and the neighbor entries that are always online continue to exist in the data plane.
[0111] Obviously, the embodiments described above are only some embodiments of the present invention, and not all embodiments. To better understand the above-described ARP forwarding table synchronization method, the process is described below with reference to embodiments, but this is not intended to limit the technical solutions of the embodiments of the present invention. Specifically:
[0112] This application proposes a method for ARP neighbor management within a stacked system. This method, based on the Linux kernel ARP module, performs address protocol translation from Layer 3 to Layer 2 addresses for users accessing the stack, thus managing ARP neighbors within the stacked system. Even during special scenarios such as primary / standby failover, offline events, or new member additions, ARP protocol interaction, ARP entry learning, updating, and aging can continue, ensuring ARP table consistency and normal traffic forwarding across all members within the stack. Specifically:
[0113] 1. After startup, stack members join the same stacking system and operate as a virtual logical switch. The stacking system elects a master, backup, or slave switch role for each member, with each role undertaking different responsibilities.
[0114] 2. Once the roles of the stack members are determined, the message transmission and reception channels from the master switch kernel interface to the hardware interfaces of each switch are created.
[0115] like Figure 5 As shown, a) establishes a mapping between the kernel interfaces of the master / standby / slave switches and the hardware interfaces of the switches. The kernel interface is a software simulation of the hardware interface on the network kernel. Packets received by the hardware interface are sent to the corresponding kernel interface for processing in the kernel, and the kernel ARP protocol of the network kernel specifies that packets sent by the kernel interface will ultimately be sent out from the corresponding hardware interface.
[0116] (b) Establish a tunnel between the kernel interfaces of the backup / slave switches and the kernel interface of the master switch. This VXLAN tunnel is established through the kernel, forming a packet path between the kernel interfaces of the backup / slave switches and the master switch. After receiving packets at their hardware interfaces, the backup / slave switches send them to the corresponding kernel interfaces. The kernel interfaces then further tunnel the packets to the master switch's kernel interface for processing, ultimately delivering them to the master switch's kernel ARP module. When the kernel ARP protocol on the master switch's network kernel specifies a kernel interface for packet transmission, the packets enter the corresponding VXLAN tunnel and are sent to the corresponding kernel interfaces on the backup / slave switches, ultimately being sent out from the corresponding hardware interfaces.
[0117] c) Establish a packet transmission and reception path from the main switch kernel interface to the hardware interfaces of all switches in the stack system.
[0118] 3. Establish a data synchronization channel from the master to the backup / slave switch. Start the database on each of the three types of devices. The database on the master device (i.e., the master switch device) is the master database, and the database on the backup / slave device (backup / slave switch device) is the slave database. The data information in the master database will be synchronized to the slave database.
[0119] 4. The ARP module in the network kernel operates. Users accessing the primary, backup, and slave devices all interact with the ARP module in the primary device's kernel via protocol messages. The backup / slave device's ARP module, not receiving user messages at this time, will not learn ARP information. The primary device's kernel ARP module learns the ARP forwarding information of all users accessing the stacked system and generates an ARP forwarding table. The primary device's kernel ARP module also responds to ARP requests from external users on behalf of the stacked system, helping external users learn the stacked system's ARP information.
[0120] 5. The neighbor management process running on the main switch communicates with the ARP module through the Netlink interface provided by Linux to obtain ARP table entry cache change information from the ARP module. When the ARP module sends an ARP entry addition / deletion notification, the neighbor management process synchronously stores the ARP entry changes in the database, ensuring that the ARP entry information in the database is consistent with the ARP information cached by the ARP module.
[0121] 6. The neighbor distribution process running on the main switch subscribes to database information and further writes the ARP information of the entire stack system into the forwarding table of the switch's hardware chip.
[0122] 7. The master database synchronizes ARP entry information from the master database to the slave database through a master-slave synchronization mechanism.
[0123] 8. The neighbor distribution process running on the standby / slave switch subscribes to the local slave database information, obtains the ARP information of the stacking system, and further writes the ARP information of the entire stacking system into the hardware chip forwarding table of this switch.
[0124] 9. At this point, all member forwarding planes of the stacking system have all ARP forwarding table entries, enabling them to query the ARP forwarding table when forwarding Layer 3 traffic to obtain the corresponding user's Layer 2 address information, and supporting cross-board ARP entry queries.
[0125] 10. When a primary / standby switchover or primary device shutdown occurs in the stacking system, the standby device needs to quickly take over the ARP management of the stacking system. In this case, the standby device is promoted to primary device.
[0126] a) Rebuild the packet transmission and reception channels from the new master switch kernel to all stack member hardware interfaces: delete the previously established local to the original master device VXLAN tunnel, restore the packet transmission and reception channels from the local hardware to the local kernel; establish tunnel channels from the backup / from the kernel interfaces of the two types of switches to the kernel interfaces of the new master switch.
[0127] b) The master device database is upgraded to the master database, and other stack member databases are changed to slave databases of the new master database. ARP table entry information will then be obtained from the new master database.
[0128] c) The neighbor management process running on the new master device reads the ARP information of the stacking system from the database, notifies the local kernel ARP module to add dynamic ARP through the netlink interface, and restores the ARP information to the kernel.
[0129] d) During the switchover process, if some access users have already left, the ARP entries for these expired neighbors should be deleted. The method to resolve expired neighbor data remnants during the switchover process is as follows: The kernel ARP module ages the neighbor information added by the neighbor management process normally. When the aging time expires, an ARP request packet is sent. If a neighbor response is received, it proves that the ARP entry remains valid. If no neighbor response is received, the ARP entry is deleted. This deletion event is notified to the neighbor management process via a netlink message, and the neighbor management process deletes the neighbor from the main database. After receiving the database notification, the neighbor distribution processes of all devices delete the neighbor information from the hardware chip forwarding table of their respective switches.
[0130] e) At this point, the kernel ARP information on the new master device is restored, and the kernel ARP module continues to work normally to complete the ARP management work of the entire stack system. The hardware chip forwarding tables of all stack members are working normally. The ARP forwarding table entries of users who have left are deleted, and the entries of neighbors that have been online have always existed in the data plane. During the master-slave switchover process, the ARP entries normally serve to forward traffic.
[0131] 11. When a new device is added to the stacking system:
[0132] a) Establish a message transmission and reception channel between the master device and the new device, and set the database of the newly added device as a slave database of the master database;
[0133] b) The ARP entries learned by the master device are synchronized to the new device through the database. The neighbor distribution process running on the new device subscribes to the local database information and writes the ARP information learned by the stacking system into the forwarding table of the hardware chip of this switch.
[0134] c) The master device sends and receives ARP messages through the new device's hardware interface, and learns and manages the ARP information of users accessing the device through the new device's hardware interface.
[0135] 12. When a member device leaves the stacking system (removed or goes down):
[0136] a) Delete the VXLAN tunnel from the master device to the interface of this device.
[0137] b) The master device kernel normally performs ARP entry aging. When the aging time expires, because no one responds to the sent ARP request packets, the ARP entries of users who have left the device will be cleared. Subsequently, after the master device's neighbor management module receives the netlink neighbor deletion message, it deletes the master database and synchronizes it to all slave databases. The neighbor distribution process running on each device subscribes to the local slave database information changes and deletes the ARP information from the switch's hardware chip forwarding table.
[0138] As an optional example, and for better illustration, the following is an embodiment of implementing ARP table management in a stacked system using the method of this application:
[0139] like Figure 6 As shown, 1. The stacking system has three switch devices. After the devices are started, a stacking link is created, and the Layer 2 / 3 communication between the master / backup / slave devices is established through the stacking link.
[0140] 2. The following roles are determined through a stacked election process: switch1 is the master device, switch2 is the backup device, and switch3 is the slave device.
[0141] 3) Based on the device election results, begin initializing the device's service functions:
[0142] a) All devices create a mapping from their own switch hardware ports to Linux kernel ports, further establishing a VXLAN tunnel between the master device kernel interface and the master / slave device kernel interfaces, ultimately forming a packet transmission channel between the master device kernel interface and the hardware ports of all devices in the stack.
[0143] b) All devices start the database according to the stack role. Switch1 is the master database, and Switch2 and Switch3 are slave databases.
[0144] c) Start the neighbor management process and neighbor assignment process for each device. Figure 7 This describes the state after the business-related modules are started.
[0145] 4. The stacked system has service packets that need to be sent to hosts1-host3, but the ARP entries for hosts1-host3 are missing. This triggers the kernel ARP module to issue an ARP request. The ARP request packet is sent from the kernel interface and eventually reaches the hardware interface. After receiving the ARP request, hosts1-host3 respond. The response packets are sent from the hardware interface to the kernel interface and finally to the kernel ARP module for processing. The ARP module learns the ARP information of the three users.
[0146] 5. The neighbor management process of the master device subscribes to the ARP information of the three corresponding hosts through the netlink message interface. The ARP information is then written to the master database.
[0147] 6. Upon receiving the ARP update notification from the database, the neighbor distribution process of each device writes all three ARP entries into its local forwarding chip. Each device's forwarding plane possesses all ARP information within the stacked system. When traffic from host1 enters the stacked system and needs to be forwarded to host3, the ARP information for host3 can be found in the chip of switch1, the device connected to host1. The ARP outgoing interface is the hardware interface on switch3 (which is connected to host3), so the packet is forwarded to switch3 and finally sent out from the corresponding ARP outgoing interface.
[0148] 7. When a user executes a primary / standby switchover command, the primary device switch1 receives the command and notifies the stacking system of the switchover process. After notification, switch1 restarts. Subsequently, the user can manually remove switch1 for other uses.
[0149] 1) Switch2 detects the primary / standby switchover and performs the standby-to-primary promotion operation:
[0150] a) Create a batch of kernel VXLAN tunnels to connect to the kernel interface of switch3, establishing a message exchange channel from the switch3 hardware interface to the switch3 kernel interface and then to the switch2 kernel interface. Packets received by the switch3 hardware interface will be sent to the switch2 kernel interface for processing.
[0151] b) Delete the kernel VXLAN channel of switch1 that should be restarted and is temporarily offline. Switch2's local hardware interface will send packets to the local kernel interface for processing.
[0152] c) Upgrade the local database to the primary database.
[0153] d) The neighbor management process reads the ARP entries for the three users stored in the main database and writes them back into the ARP module in the Linux network kernel. The ARP information is then restored, and the ARP module performs normal aging of the ARP information.
[0154] e) When the aging timeout expires, after sending an ARP request, host2 and host3 respond normally, but host3 cannot respond because switch1 has been moved. The ARP module deletes host1's ARP entry. After receiving the netlink message indicating host1's ARP deletion, the neighbor management process deletes the corresponding entry in the database. After deleting the ARP entry in the database, master-slave synchronization is performed.
[0155] f) The neighbor distribution process of the online device receives the ARP deletion notification from the local database and deletes host1ARP.
[0156] 2) After the slave device switch3 detects the master-slave switchover, it begins to create a message transmission channel to the new master switch2. It also sets its own database as a slave database of the new master switch2. It then receives table entries from the new master switch2's database for synchronization.
[0157] 8. The ARP information of the kernel ARP module and the local chip remains consistent, except for the ARP information of host2 and host3. The ARP table entries of the stacked system are consistent with the actual situation of users in the external environment. During the switchover process, the ARP entries are also retained in the forwarding table, and traffic forwarding is normal.
[0158] It should be noted that this application proposes an ARP management method for a stacked system. This method is based on the Linux kernel ARP function and supplemented by certain infrastructure modifications to achieve complete ARP functionality within the stacked system. This stacked system can generate user ARP tables, manage ARP neighbors within the stacked system, and continue ARP protocol interaction, ARP table learning, updating, and aging even when stacked system members experience primary / standby failover, offline status, or new additions, ensuring ARP table consistency and normal traffic forwarding across all members within the stack. This significantly reduces the development workload for implementing ARP functionality in the stacked system.
[0159] 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 of the various embodiments of the present invention.
[0160] This embodiment also provides an ARP forwarding table synchronization system for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the systems described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.
[0161] Figure 8 This is a structural block diagram of an ARP forwarding table synchronization system according to an embodiment of the present invention. The system includes:
[0162] The target switch 82 is used to send an ARP response packet obtained by the hardware interface of the target switch 82 to the kernel interface of the master switch 84 in the stacking system through the packet transmission and reception channel between the hardware interface of the target switch 82 and the kernel interface of the master switch 84. The ARP response packet carries at least the IP address and MAC address of the terminal device that sent the ARP response packet. The kernel interface of the master switch 84 is a software emulation interface of the hardware interface of the master switch 84 in the network kernel of the master switch 84. The target switch 82 is a backup switch or a slave switch in the stacking system.
[0163] The master switch 84 is used to acquire M ARP response packets and generate an ARP forwarding table based on the M ARP response packets; and synchronize the ARP forwarding table to each of the target switches 82 in the stacking system; wherein, the M ARP response packets include: multiple ARP response packets sent by multiple target switches, and one or more ARP response packets sent from the hardware interface of the master switch 84 to the kernel interface of the master switch 84; the ARP forwarding table records at least the IP address and MAC address of each terminal device connected to the stacking system.
[0164] In the above system, the master switch 84 obtains M ARP response packets through the packet transmission and reception channel between its own kernel interface and the hardware interface of each switch. Based on the M ARP response packets, it generates an ARP forwarding table and synchronizes the ARP forwarding table to each target switch (backup switch or slave switch) among the N switches. This achieves the unification of ARP forwarding tables within the stacked system and solves the problem of the difficulty in unifying ARP forwarding tables of different switches in the stacked system.
[0165] In an exemplary embodiment, when the target switch 82 is a backup switch, the target switch 82 is further configured to, after obtaining the ARP forwarding table synchronized by the master switch 84, and upon detecting that it is to be upgraded to the master switch 84, establish a packet transmission and reception channel between the kernel interface of the target switch 82 and the hardware interface of each switch in the stacking system; update the ARP forwarding table to obtain an updated ARP forwarding table; and synchronize the updated ARP forwarding table to each target switch in the stacking system except for the new master switch 84.
[0166] In an exemplary embodiment, the target switch 82 is further configured to write the ARP forwarding table synchronized by the master switch 84 into the hardware chip forwarding table of the target switch 82 after obtaining the ARP forwarding table.
[0167] In an exemplary embodiment, the master switch 84 is further configured to: acquire ARP response packets sent by the hardware interface of the master switch 84 through a packet transceiver channel between the kernel interface of the master switch 84 and the hardware interface of the master switch 84; and acquire ARP response packets sent by the kernel interface of each target switch 82 through a packet transceiver channel between the kernel interface of the master switch 84 and the kernel interface of each of the N switches; wherein the ARP response packets sent by the kernel interface of the target switch 82 are ARP response packets acquired by the kernel interface of the target switch 82 through a packet transceiver channel with the hardware interface of the target switch 82.
[0168] In an exemplary embodiment, the master switch 84 is further configured to store the ARP forwarding table in the database of the master switch 84; and synchronize the ARP forwarding table in the database of the master switch 84 to the database of each of the N target switches through a database synchronization mechanism.
[0169] In an exemplary embodiment, the master switch 84 is further configured to, after synchronizing the ARP forwarding table to each target switch among the N switches, delete the packet transmission and reception channel between the kernel interface of the master switch 84 and the hardware interface of the first switch, wherein the first switch is the target switch 82 in the stacking system, upon detecting that the first switch in the stacking system has left the stacking system; and delete the IP address and MAC address of the terminal device connected to the first switch from the ARP forwarding table to obtain an updated ARP forwarding table; and synchronize the updated ARP forwarding table to each target switch among the N switches except the first switch.
[0170] In an exemplary embodiment, the master switch 84 is further configured to, after synchronizing the ARP forwarding table to each target switch among the N switches, establish a packet transmission and reception channel between the kernel interface of the master switch 84 and the hardware interface of the second switch when a second switch is detected joining the stacking system; and synchronize the ARP forwarding table in the database of the master switch 84 to the database of the second switch through a database synchronization mechanism.
[0171] In an exemplary embodiment, the master switch 84 is further configured to write the ARP forwarding table to the hardware chip forwarding table of the master switch 84 after synchronizing the ARP forwarding table to each of the N switches.
[0172] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.
[0173] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0174] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0175] 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.
[0176] In one exemplary embodiment, 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.
[0177] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0178] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0179] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for synchronizing an ARP forwarding table, characterized in that, The master switch used in a stacked system with N switches includes: M Address Resolution Protocol (ARP) response packets are obtained through the packet transmission and reception channel between the kernel interface of the main switch and the hardware interface of each of the N switches. Each ARP response packet is a packet received by the hardware interface of the switch, and each ARP response packet carries at least the Internet Protocol (IP) address and Media Access Control (MAC) address of the terminal device that sent the ARP response packet. The kernel interface of the main switch is a software-simulated interface of the hardware interface of the main switch within the network kernel of the main switch. M is greater than or equal to N. An ARP forwarding table is generated based on M ARP response messages, wherein the ARP forwarding table records at least the IP address and MAC address of each terminal device connected to the stacking system; The ARP forwarding table is synchronized to each of the N switches, wherein the target switch is a backup switch or a slave switch in the stacking system; Specifically, M Address Resolution Protocol (ARP) response messages are obtained through the message transmission and reception channel between the kernel interface of the main switch and the hardware interface of each of the N switches in the stacked system, including: The ARP response packets sent by the hardware interface of the main switch are obtained through the packet transmission and reception channel between the kernel interface and the hardware interface of the main switch; and The ARP response message sent by the kernel interface of each of the N target switches is obtained through the message transmission and reception channel between the kernel interface of the master switch and the kernel interface of each target switch. The ARP response message sent by the kernel interface of the target switch is the ARP response message obtained by the kernel interface of the target switch through the message transmission and reception channel between the kernel interface and the hardware interface of the target switch.
2. The method according to claim 1, characterized in that, Synchronizing the ARP forwarding table to each target switch among the N switches includes: The ARP forwarding table is stored in the database of the main switch; The ARP forwarding table in the database of the master switch is synchronized to the database of each of the N target switches through a database synchronization mechanism.
3. The method according to claim 1, characterized in that, After synchronizing the ARP forwarding table to each of the N target switches, the method further includes: If it is detected that the first switch in the stacking system has left the stacking system, the packet transmission and reception channel between the kernel interface of the master switch and the hardware interface of the first switch is deleted, wherein the first switch is the target switch in the stacking system; and The IP address and MAC address of the terminal device connected to the first switch are deleted from the ARP forwarding table to obtain an updated ARP forwarding table; The updated ARP forwarding table is synchronized to each of the N switches except for the first switch.
4. The method according to claim 1, characterized in that, After synchronizing the ARP forwarding table to each of the N target switches, the method further includes: Upon detecting that a second switch has joined the stacking system, a message transmission and reception channel is established between the kernel interface of the master switch and the hardware interface of the second switch. The ARP forwarding table in the database of the master switch is synchronized to the database of the second switch through a database synchronization mechanism.
5. The method according to any one of claims 1 to 4, characterized in that, After synchronizing the ARP forwarding table to each of the N target switches, the method further includes: The ARP forwarding table is written into the hardware chip forwarding table of the main switch.
6. A method for synchronizing an ARP forwarding table, characterized in that, A target switch applied in a stacking system, wherein the target switch is a backup switch or a slave switch in the stacking system, including: The ARP response message obtained by the hardware interface of the target switch is sent to the kernel interface of the master switch through the message transmission and reception channel between the hardware interface of the target switch and the kernel interface of the master switch in the stacking system. The ARP response message carries at least the IP address and MAC address of the terminal device that sent the ARP response message. The kernel interface of the master switch is the software emulation interface of the hardware interface of the master switch in the network kernel of the master switch. Obtain the ARP forwarding table synchronized by the master switch, wherein the ARP forwarding table is generated by the master switch based on all obtained ARP response packets, and wherein the ARP forwarding table records at least the IP address and MAC address of each terminal device connected to the stacking system; Specifically, the ARP response message obtained by the hardware interface of the target switch is sent to the kernel interface of the master switch through the message transmission and reception channel between the hardware interface of the target switch and the kernel interface of the master switch in the stacking system, including: The ARP response message sent by the hardware interface of the target switch is obtained through the message transmission and reception channel between the kernel interface and the hardware interface of the target switch. The acquired ARP response message is sent to the kernel interface of the main switch through the message transmission and reception channel between the kernel interface of the target switch and the kernel interface of the main switch.
7. The method according to claim 6, characterized in that, After obtaining the ARP forwarding table synchronized by the master switch, the method further includes: When the target switch is a backup switch and the target switch detects that it needs to be upgraded to a master switch, a packet transmission and reception channel is established between the kernel interface of the target switch and the hardware interface of each switch in the stacking system; and the ARP forwarding table is updated to obtain the updated ARP forwarding table. The updated ARP forwarding table is synchronized to each target switch in the stacked system, except for the new master switch.
8. The method according to any one of claims 6 to 7, characterized in that, After obtaining the ARP forwarding table synchronized by the master switch, the method further includes: The ARP forwarding table is written into the hardware chip forwarding table of the target switch.
9. A synchronization system for an ARP forwarding table, characterized in that, include: The target switch is used to send an ARP response packet obtained by the hardware interface of the target switch to the kernel interface of the master switch in the stacking system through the packet transmission and reception channel between the hardware interface of the target switch and the kernel interface of the master switch. The ARP response packet carries at least the IP address and MAC address of the terminal device that sent the ARP response packet. The kernel interface of the master switch is the software emulation interface of the hardware interface of the master switch in the network kernel of the master switch. The target switch is a backup switch or a slave switch in the stacking system. The master switch is configured to acquire M ARP response packets and generate an ARP forwarding table based on the M ARP response packets; and synchronize the ARP forwarding table to each of the target switches in the stacking system; wherein the M ARP response packets include: multiple ARP response packets sent by multiple target switches, and one or more ARP response packets sent from the hardware interface of the master switch to the kernel interface of the master switch; the ARP forwarding table records at least the IP address and MAC address of each terminal device connected to the stacking system; The target switch is further configured to acquire an ARP response message sent by the hardware interface of the target switch through a message transmission and reception channel between the kernel interface of the target switch and the hardware interface of the target switch; and to send the acquired ARP response message to the kernel interface of the master switch through a message transmission and reception channel between the kernel interface of the target switch and the kernel interface of the master switch. The main switch is also used to obtain ARP response packets sent by the hardware interface of the main switch through the packet transmission and reception channel between the kernel interface and the hardware interface of the main switch.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed by a processor, performs the method described in any one of claims 1 to 8.
11. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 8 through the computer program.
Citation Information
Patent Citations
ARP protocol implementation method and system of SDN network and controller
CN110401733A
Method and device for synchronizing MAC (Media Access Control) table entries in multi-switch stacking system
CN115086254A