Forwarding path switching methods, devices, network equipment and storage media
By building a neighbor information table in network devices and pre-generating backup ARP entries, the problem of mismatch between Layer 2 and Layer 3 convergence speed when STP and VRRP are combined is solved, realizing synchronous switching between Layer 2 and Layer 3 in network devices and reducing traffic interruption and packet loss.
Patent Information
- Application Number
- CN202611538687.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-30
- Publication Date
- 2026-11-17
AI Technical Summary
In existing technologies, when STP and VRRP are used together, the convergence speeds of Layer 2 and Layer 3 are mismatched, leading to traffic interruptions and packet loss during network redundancy switching. Existing solutions cannot effectively solve the problem of slow ARP switching speed.
By constructing a neighbor information table and updating it based on port events, backup ARP entries corresponding to the primary backup ports are pre-generated or updated and written into the hardware forwarding table, configured as pending activation. When a port status change is detected, the hardware chip determines and activates the backup ARP entries, achieving synchronous switching between Layer 3 and Layer 2.
It achieves synchronous convergence of Layer 2 and Layer 3, reduces or even eliminates packet loss during network failures, and compresses service interruption time to the microsecond level.
Smart Images

Figure CN123123312A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and more specifically, to a forwarding path switching method, apparatus, network device, and storage medium. Background Technology
[0002] Currently, with the rapid development of emerging application scenarios such as 5G, edge computing, cloud interconnection, and network slicing, multi-path redundancy designs are commonly used in campus network environments to improve network reliability. STP (Spanning Tree Protocol) / MSTP (Multiple Spanning Tree Protocol) is used to eliminate loops in Layer 2 networks by blocking redundant ports to build a loop-free tree topology; VRRP (Virtual Router Redundancy Protocol) is used to provide gateway-level redundancy backup. The combination of the two is one of the most mainstream redundancy solutions for enterprise campus networks and financial data centers. However, when using STP in conjunction with VRRP to achieve network redundancy, there is a significant technical problem: STP can complete the Layer 2 MAC address table switching within milliseconds when a link failure is detected, but because ARP (Address Resolution Protocol) entries rely on an active request and response mechanism for learning, its updates take several seconds or even longer. This mismatch in convergence speed between Layer 2 and Layer 3 causes traffic to still point to the old forwarding path after the spanning tree converges, resulting in traffic interruption and packet loss, which seriously affects the application experience of high-reliability services.
[0003] Existing solutions include: passively waiting for ARP timeouts (slow), script-triggered refresh (still requires interruptions lasting seconds), static ARP configuration (difficult to maintain), and BFD (Bidirectional Forwarding Detection) fast detection + ARP relearning (still relies on triggering after a fault, with a delay of tens to hundreds of milliseconds). All of these solutions belong to the "fault response" mode and cannot fundamentally eliminate the ARP learning latency during the handover process.
[0004] In existing network topologies, RSTP (Rapid Spanning Tree Protocol) / MSTP can complete Layer 2 convergence within tens to hundreds of milliseconds, while updating ARP entries still takes at least one second (requiring an ARP request to be sent and a response to be waited for), and in passive aging scenarios, it can even take several minutes to tens of minutes. This order-of-magnitude convergence time difference between Layer 2 and Layer 3 is the root cause of traffic interruptions and packet loss during redundancy switching in campus networks. Summary of the Invention
[0005] The purpose of this application is to provide a forwarding path switching method, apparatus, network device, and storage medium that can solve the problem of traffic interruption caused by the ARP switching speed being slower than the spanning tree convergence speed in the prior art, realize the synchronous switching of the Layer 3 forwarding path and the Layer 2 spanning tree convergence, and significantly reduce or even eliminate data packet loss during network failures.
[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, embodiments of this application provide a forwarding path switching method, applied to a network device, the method comprising: Build a neighbor information table and update it based on the monitored port events; Select the primary backup port that meets the set conditions from all the blocked ports corresponding to each forwarding port, and generate or update the backup address resolution protocol (ARP) table entry for the forwarding path corresponding to the primary backup port according to the neighbor information table. Write the generated or updated backup ARP entry into the hardware forwarding table and configure the backup ARP entry to be in an inactive state; When the primary backup port is detected to have switched from a blocked state to a forwarding state, a state update command is sent to the hardware chip. The hardware chip determines whether the backup ARP entry meets the preset activation conditions. If it does, the backup ARP entry is switched from the pending activation state to the active state.
[0007] Optionally, the step of constructing the neighbor information table and updating it based on the monitored port events includes: After the network device is powered on, it collects device information of neighboring devices by sending a first extended LLDP message and receiving a first extended LLDP message sent by neighboring devices, and constructs the neighbor information table. During the operation of the network device, the neighbor information table is updated based on its own port Down event or by receiving a second extended LLDP message triggered by a neighbor device based on a Spanning Tree Protocol (STP) port role change event or port Up event. The neighbor information table includes the IP address, MAC address, port role, and status of neighboring devices.
[0008] Optionally, the step of selecting a primary backup port that meets the set conditions from all blocked ports corresponding to each forwarding port, and generating or updating the backup address resolution protocol (ARP) entry for the forwarding path corresponding to the primary backup port according to the neighbor information table, includes: After the neighbor information table is initially constructed, among all the blocked ports corresponding to each forwarding port, the optimal port is selected based on the path cost to the root bridge and the port priority, and it is determined as the primary backup port of that forwarding port. Based on the neighbor information table, generate a backup ARP entry for the path corresponding to the primary backup port; After updating the neighbor information table based on port events, update the backup ARP entry.
[0009] Optionally, writing the generated or updated backup ARP entry into the hardware forwarding table includes: Check whether the number of existing backup ARP entries in the hardware forwarding table exceeds a preset threshold; If so, stop writing to the backup ARP entry and issue an alarm, and delete the existing backup ARP entry with the lowest priority in the hardware forwarding table; If not, the backup ARP entry generated this time will be written to the hardware forwarding table.
[0010] Optionally, writing the generated backup ARP entry into the hardware forwarding table further includes: After writing the backup ARP entry into the hardware forwarding table, a live timer is associated with the backup ARP entry. If the forwarding path corresponding to the backup ARP entry is detected to be invalid or the liveness timer expires, the backup ARP entry is deleted.
[0011] Optionally, the hardware chip determines whether the backup ARP entry meets a preset activation condition. If it does, the backup ARP entry is switched from the pending activation state to the activated state, including: After receiving the status update instruction, the hardware chip verifies the validity of the backup ARP entry. If the validity verification of the entry passes, the hardware chip determines that the backup ARP entry meets the preset activation condition and switches the backup ARP entry from the pending activation state to the activated state. If the validity verification of the entry fails, the hardware chip determines that the backup ARP entry does not meet the preset activation conditions and notifies the network device to start the ARP learning process.
[0012] Secondly, embodiments of this application provide a forwarding path switching device, applied to a network device, the device comprising: The build update module is used to build the neighbor information table and update it based on the monitored port events; The execution module is used to select a primary backup port that meets set conditions from all blocked ports corresponding to each forwarding port; generate or update the backup Address Resolution Protocol (ARP) entry for the forwarding path corresponding to the primary backup port according to the neighbor information table; write the generated or updated backup ARP entry into the hardware forwarding table and configure the backup ARP entry to be in an inactive state; when the primary backup port is detected to switch from a blocked state to a forwarding state, a state update command is sent to the hardware chip; the hardware chip determines whether the backup ARP entry meets the preset activation conditions; if it does, the backup ARP entry is switched from the inactive state to the active state.
[0013] Optionally, the build update module is specifically used to, after the network device is powered on, collect device information of neighboring devices by sending a first extended link layer discovery protocol (LLDP) message and receiving a first extended LLDP message sent by neighboring devices, and build the neighbor information table. During the operation of the network device, the neighbor information table is updated based on its own port Down event or by receiving a second extended LLDP message triggered by a neighbor device based on a Spanning Tree Protocol (STP) port role change event or port Up event. The neighbor information table includes the IP address, MAC address, port role, and status of neighboring devices.
[0014] Thirdly, embodiments of this application provide a network device including a processor and a memory, wherein the memory is used to store a program, and the processor is used to implement the forwarding path switching method in the first aspect above when executing the program.
[0015] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the forwarding path switching method described in the first aspect above.
[0016] Compared to existing technologies, the forwarding path switching method, apparatus, network device, and storage medium provided in this application first construct a neighbor information table and update it based on monitored port events. Then, among all blocked ports corresponding to each forwarding port, a primary backup port that meets set conditions is selected. Based on the neighbor information table, a backup ARP entry for the forwarding path corresponding to the primary backup port is generated or updated. The backup ARP entry is written to the hardware forwarding table and configured to be in an active state. When the primary backup port is detected to switch from a blocked state to a forwarding state, a state update command is sent to the hardware chip. The hardware chip determines whether the backup ARP entry meets the preset activation conditions. If it does, the backup ARP entry is switched from an active state to an active state. In this way, the backup path is predicted based on the role of the STP blocked port before a fault occurs, and the backup ARP entry is written to the hardware chip and marked as active in advance. When a fault actually occurs, only a microsecond-level state flip is needed to complete the Layer 3 switch, thereby breaking the protocol isolation between Layer 2 STP and Layer 3 ARP, achieving true synchronous convergence between Layer 2 and Layer 3, and compressing the service interruption time to the microsecond level. Attached Figure Description
[0017] Figure 1 A flowchart illustrating a forwarding path switching method provided in an embodiment of this application is shown.
[0018] Figure 2 The diagram illustrates an application scenario example provided by an embodiment of this application.
[0019] Figure 3 A block diagram of a forwarding path switching device provided in an embodiment of this application is shown.
[0020] Figure 4 A block diagram of a network device provided in an embodiment of this application is shown.
[0021] Icons: 100-Forwarding path switching device; 101-Build and update module; 102-Execution module; 10-Network device; 11-Processor; 12-Memory; 13-Bus. Detailed Implementation
[0022] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0023] The forwarding path switching method provided in this application is applied to network devices in a campus spanning tree scenario. The network devices can be switches, such as SONiC (Software for Open Networking in the Cloud) switches, or other gateway devices that support STP / MSTP protocols.
[0024] Network equipment hardware includes processors and hardware chips, which can be switching chips or ASIC (Application-Specific Integrated Circuit) chips. The processor runs a control plane, performing topology awareness, path deduction, and policy decision-making. The hardware chip handles high-speed packet forwarding and has built-in hardware resources such as TCAM (Ternary Content-Addressable Memory) for storing hardware forwarding tables such as ACL (Access Control List), routing tables, and MAC (Media Access Control Address) address tables. The processor and hardware chip interact through SAI (Switch Abstraction Interface).
[0025] The control plane includes a hardware link detection module and an STP protocol stack. The hardware link detection module monitors hardware link status events, specifically changes in the physical port's Up (connected) / Down (disconnected) status, with a response latency of less than 1 microsecond. The STP protocol stack monitors STP port role change events, that is, it parses BPDU (Bridge Protocol Data Unit) messages to identify changes in port role (root port / designated port / standby port) and status (blocked / forwarding), with a response latency of approximately 2~20 milliseconds (ms).
[0026] In practical applications, after the network device is powered on, it first sends an extended LLDP (Link Layer Discovery Protocol) message to neighboring devices to build a neighbor information table. For example, the initial construction is completed after the first LLDP cycle ends, and the primary and backup ports that meet the set conditions (such as STP port election conditions) among all the blocked ports of the network device are identified. Then, the corresponding backup ARP entries are generated, written to the hardware forwarding table via the SAI interface and configured to be in an active state, thereby completing the initial configuration of the first backup ARP entries.
[0027] Subsequently, neighbor relationships are kept alive by periodically expanding LLDP messages (e.g., detecting neighbor offline). Simultaneously, upon receiving any port event (hardware link status event, STP protocol port role change event), a neighbor information table update and backup ARP entry pre-configuration process are triggered. The pre-configured backup ARP entries include not only the complete backup ARP entry for the primary backup port of this device, but also the reverse backup ARP entry on the neighbor device, as detailed below.
[0028] Subsequently, if the processor detects that the actual status of the primary backup port has changed from blocked to forwarding, or detects that the primary link of the neighboring device has failed, or receives an STP topology change notification from the neighboring device, the processor sends a status update command to the hardware chip through the SAI interface. After receiving the command, the hardware chip determines whether the corresponding backup ARP entry meets the preset activation conditions. If it does, the corresponding backup ARP entry's status is switched from pending activation to active.
[0029] In this way, by predicting the backup path based on the role of the STP blocking port before a fault occurs, the backup ARP entry is written into the hardware chip in advance and marked as to be activated. When the fault actually occurs, only a microsecond-level state flip is needed to complete the Layer 3 switch, thereby breaking the protocol isolation between Layer 2 STP and Layer 3 ARP, realizing true synchronous convergence between Layer 2 and Layer 3, and compressing the service interruption time to the microsecond level.
[0030] The following is a detailed introduction.
[0031] Please refer to Figure 1 , Figure 1 This illustration shows a flowchart of a forwarding path switching method provided in an embodiment of this application, applied to a network device, and may include the following steps: S101, Build a neighbor information table and update it based on the monitored port events; S102, Select the primary backup port that meets the set conditions from all the blocked ports corresponding to each forwarding port, and generate or update the backup address resolution protocol (ARP) table entry for the forwarding path corresponding to the primary backup port according to the neighbor information table. S103, write the generated or updated backup ARP entry into the hardware forwarding table, and configure the backup ARP entry to be in an inactive state; S104 When the primary backup port is detected to have switched from a blocked state to a forwarding state, a status update command is sent to the hardware chip. The hardware chip determines whether the backup ARP entry meets the preset activation conditions. If it does, the backup ARP entry is switched from the pending activation state to the active state.
[0032] In this embodiment, port events include hardware link status events (Up or Down) or STP port role change events. Hardware link status events have the highest priority and a response latency of less than 1 microsecond. STP port role change events are triggered by BPDU message reception, with a response latency of approximately 2-20ms. Upon receiving any of the above events, the control plane does not passively wait for periodic LLDP messages (e.g., at 30-second intervals), but immediately performs incremental updates to neighbor information to ensure that subsequent preset entries are based on the latest network topology, avoiding information lag caused by the 30-second LLDP cycle.
[0033] The neighbor information table is constructed by the control plane after the network device powers on, collecting device information from directly connected neighbor devices through the initial extended LLDP message sent. It characterizes the connection relationship and key forwarding information between the current device and its directly connected neighbors. The neighbor information table includes the MAC address-IP address mapping of neighbor devices' ports, and the STP role and status of each port. It may also include critical ARP information and backup path declaration information, and is subsequently updated incrementally based on received port events, and kept alive and fully refreshed based on periodic LLDP messages.
[0034] Unlike standard LLDP messages, the extended LLDP messages sent and received by the device in this application are LLDP messages extended by the LLDP protocol, containing a variety of newly added TLVs (Type-Length-Value), such as spanning tree status TLV, critical ARP information TLV, backup path declaration TLV, and checksum TLV (such as CRC32 checksum TLV).
[0035] Specifically, the Spanning Tree State TLV carries the current STP role (root port / designated port / standby port) and status (blocking / forwarding) of a port. The Critical ARP Information TLV transmits important ARP entries in the network, such as the IP address and MAC address mapping relationships of gateways, core servers, and critical hosts. Each entry includes an IP address, MAC address, VLAN ID, and flags. The Backup Path Declaration TLV proactively announces the backup path information pre-configured on the device. The Checksum TLV calculates a checksum based on the above TLV contents. The receiver compares the checksum to determine if the neighbor's ARP table or topology status has changed, thereby triggering incremental updates and reducing invalid processing.
[0036] In this embodiment, the extended LLDP messages are divided into two categories according to the timing of transmission: The first type is periodic LLDP messages, which are extended LLDP messages sent by the control plane to directly connected neighbor devices at fixed intervals (e.g., 30 seconds). These messages carry the complete extended TLV of the device and are used for the initial construction of the neighbor information table, neighbor keep-alive (e.g., detecting offline neighbors), and periodic full backup refresh.
[0037] The second type is event-triggered LLDP messages. These are extended LLDP messages sent immediately by the control plane to directly connected neighbor devices when a port event occurs on the local device and the port is still physically connected (such as an STP port role change event or a port up event). These messages carry an extended TLV related to the port event type and are used to trigger incremental updates to the neighbor information table and a pre-defined process for backing up ARP entries. Specifically: the event-triggered LLDP message corresponding to an STP port role change event carries a spanning tree state TLV and a critical ARP information TLV. The event-triggered LLDP message corresponding to a port up event carries a backup path declaration TLV and a critical ARP information TLV. The checksum TLV is carried along with the extended LLDP message.
[0038] For port down events, since the physical link of the port is interrupted, it is impossible to send an event-triggered LLDP message. This device directly updates the neighbor information table based on the blocked port status awareness. The peer device synchronously senses its own port down and updates itself. Changes in the status of the backup path between this device and the affected neighbor device are announced and kept alive through topology change notifications in STP protocol BPDU messages and extended LLDP messages in other ports of this device that are still in physical connectivity (such as backup ports in a blocked state).
[0039] Optionally, the sorting of blocked ports among all blocked ports in the network device is obtained by the processor using the path cost and port priority of each blocked port to the root bridge obtained during the STP calculation process, and by comprehensively sorting all ports in the blocked state. A higher sorting indicates lower switching cost and higher priority.
[0040] Meanwhile, the setting condition can be the top-ranked blocked port. That is, if a blocked port is in a blocked state and ranks first among all blocked ports (lowest switching cost, highest priority), it is designated as the preferred port, and a complete backup ARP entry is pre-configured for it. If a blocked port is in a blocked state and is not ranked first among all blocked ports, a complete backup ARP entry is not pre-configured for it; only directly connected neighbor information is recorded. In other words, only the top-ranked (i.e., lowest switching cost, highest priority) blocked port (i.e., the primary / backup port) undergoes complete path deduction and hardware configuration; for other backup ports, only ARP information of directly connected neighbors or delay configuration is pre-configured to strictly control hardware resource consumption.
[0041] Subsequently, based on the updated neighbor information table, backup ARP entries are generated or updated for the forwarding path corresponding to the primary backup port after it switches from blocked to forwarding state. Backup ARP entries are generated based on pre-stored critical ARP information of directly connected neighbors in the neighbor information table, and may include IP address, corresponding MAC address, VLAN identifier, and necessary flag bits.
[0042] Next, the generated or updated backup ARP entries are written to the hardware forwarding table and configured to be in an inactive state. For example, their weight is set to 0 in the next-hop group of the hardware chip, or the valid bit is set to invalid, so that they occupy TCAM resources but do not participate in actual traffic forwarding. In this way, the backup path is predicted based on the STP blocking port role before a failure occurs, and the backup ARP entries are written to the hardware and marked as inactive in advance.
[0043] When the primary / backup port is detected to have switched from a blocked state to a forwarding state, the control plane sends a state update command to the hardware chip. This command can change the weight of the corresponding entry from 0 to 1, or set the valid bit from invalid to valid. Upon receiving the state update command, the hardware chip checks if the backup ARP entry meets the preset activation conditions. If so, it performs an atomic activation operation, completing the pointer switch within microseconds, making the preset entry instantly effective. Thus, when a fault actually occurs, a three-layer switch can be completed with only a microsecond-level state flip, achieving true synchronous convergence between layers two and three, and compressing service interruption time to the microsecond level.
[0044] The above describes the process of pre-setting a backup ARP entry when the blocking port corresponding to a port event is in a blocked state and ranks first among all blocked ports of the corresponding forwarding port (i.e., the primary backup port). In practical applications, when the local port corresponding to a port event is not in a blocked state, although a complete backup ARP entry will not be pre-set for it, it may be necessary to pre-set a reverse backup ARP entry for neighboring devices.
[0045] When a failure is detected in the primary link of a neighboring device, or when an STP topology change notification is received from a neighboring device, the control plane sends a status update command to the hardware chip. After receiving the command, the hardware chip determines whether the backup ARP entry meets the preset activation conditions. If it does, it performs an atomic activation operation, completing the pointer switch within microseconds, so that the preset entry takes effect instantly.
[0046] In one possible implementation, the process of constructing the neighbor information table and updating it based on the listened port events in step S101 may include: S1011 After the network device is powered on, it collects the device information of the neighboring devices by sending the first extended LLDP message and receiving the first extended LLDP message sent by the neighboring devices, and builds the neighbor information table. S1012, during the operation of the network device, updates the neighbor information table based on its own port Down event or the second extended LLDP message triggered by the neighbor device based on the STP port role change event or port Up event; The neighbor information table includes the IP address, MAC address, port role, and status of neighboring devices.
[0047] In this embodiment, after the network device is powered on, the initialization process is started. The control plane periodically sends first extended LLDP messages to directly connected neighbors to announce the device information, and receives first extended LLDP messages from neighbors to extract the MAC address and IP address mapping relationship of directly connected devices, and gradually builds a global neighbor information table.
[0048] The neighbor information table is not completed all at once, but is initially formed after the first sending cycle and continuously supplemented and improved in subsequent sending cycles. It should be noted that the periodic sending of the first extended LLDP message is used for the initial construction of the neighbor information table and keep-alive refresh, and does not trigger incremental updates or subsequent pre-configured processes.
[0049] In other words, during the operation of a network device, a port down event will occur, and it will receive a second extended LLDP message triggered by a neighboring device based on an STP port role change event or a port up event. It will also receive a periodic first extended LLDP message (e.g., at 30-second intervals). Only the port down event and the second extended LLDP message may trigger an incremental update or subsequent preset process.
[0050] In one possible implementation, step S102, which involves selecting a primary backup port that meets set conditions from all blocked ports corresponding to each forwarding port and generating or updating a backup ARP entry for the forwarding path corresponding to the primary backup port based on the neighbor information table, may include: S1021 After the neighbor information table is initially constructed, among all the blocked ports corresponding to each forwarding port, the optimal port is selected based on the path cost to the root bridge and the port priority, and it is determined as the primary backup port of that forwarding port. S1022, Generate backup ARP entries for the paths corresponding to the primary backup ports based on the neighbor information table; S1023, after updating the neighbor information table based on port events, update the backup ARP table entries.
[0051] In this embodiment, after the neighbor information table is initially constructed, the control plane performs the initial preset table entry operation. Specifically, among all the blocked ports corresponding to each forwarding port, the optimal primary backup port (e.g., the lowest path cost and the highest port priority) is selected based on the path cost to the root bridge and the port priority.
[0052] Subsequently, based on the virtual topology after the primary backup port switches from the blocking state to the forwarding state, and combined with the existing critical ARP information of directly connected neighbors in the neighbor information table, a backup ARP entry corresponding to the primary backup port is generated.
[0053] Meanwhile, during subsequent network device operation, based on its own port down event or the second extended LLDP message triggered by the neighbor device based on the STP port role change event or port up event, it updates the neighbor information table and then updates the backup ARP table entries.
[0054] It should be understood that if the backup ARP entry is written to the hardware forwarding table as soon as it is generated, it may lead to the exhaustion of TCAM resources and affect other forwarding functions. Therefore, in one possible implementation, the process of writing the generated or updated backup ARP entry to the hardware forwarding table in step S103 may include: S1031, Check if the number of existing backup ARP entries in the hardware forwarding table exceeds the preset threshold; S1032, if so, stop writing to the backup ARP table entry and issue an alarm, and delete the existing backup ARP table entry with the lowest priority in the hardware forwarding table; S1033, if not, write the generated backup ARP entry to the hardware forwarding table.
[0055] In this embodiment, after a new backup ARP entry is generated, the system first checks whether the number of existing backup ARP entries in the current hardware forwarding table exceeds a preset threshold (e.g., 5% of the TCAM capacity). If the preset threshold is exceeded, writing to the newly generated backup ARP entry stops, an alarm is issued, and the lowest-priority existing backup ARP entry in the hardware forwarding table is deleted. The criteria for determining the lowest-priority existing backup ARP entry may include the switching cost of the corresponding backup path, historical failure frequency, and the criticality level of neighboring devices, ensuring that backup paths with low switching costs and high priority are retained. If the preset threshold is not exceeded, the newly generated backup ARP entry is directly written to the hardware forwarding table and configured to be in an inactive state. This ensures both the pre-configuration of low-cost, high-priority backup paths and prevents TCAM resource exhaustion from affecting other forwarding functions.
[0056] Correspondingly, if backup ARP entries are retained in the hardware forwarding table for an extended period, TCAM resources will be wasted, and accidental activation may occur. Therefore, in another possible implementation, the process of writing the generated or updated backup ARP entries into the hardware forwarding table in step S103 may also include: S1034: After writing the backup ARP entry into the hardware forwarding table, associate a live timer with the backup ARP entry. S1035 If the forwarding path corresponding to the backup ARP entry is detected to be invalid or the live timer expires, the backup ARP entry is deleted.
[0057] In this embodiment, after the backup ARP entry is written to the hardware forwarding table, a live timer is immediately associated with the backup ARP entry. The timer is used to dynamically maintain the validity of the preset entries and ensure that the backup ARP entry is always consistent with the current network topology.
[0058] If the forwarding path corresponding to a backup ARP entry is detected to be invalid—for example, due to root bridge migration, port path cost changes causing the backup path to fail, or the liveness timer expires—the backup ARP entry is deleted, releasing the TCAM resources it occupies. This ensures that pre-configured entries do not remain in the hardware forwarding table for extended periods, avoiding waste of TCAM resources and accidental activation.
[0059] In one possible implementation, the process of the hardware chip determining whether the backup ARP entry meets the preset activation conditions in step S104, and if so, switching the backup ARP entry from the pending activation state to the active state, may include: S1041, after receiving the status update instruction, the hardware chip verifies the validity of the backup ARP entries; S1042, If the validity verification of the table entry passes, the hardware chip determines that the backup ARP table entry meets the preset activation conditions and switches the backup ARP table entry from the pending activation state to the activated state. S1043 If the validity verification of the table entry fails, the hardware chip determines that the backup ARP table entry does not meet the preset activation conditions and notifies the network device to start the ARP learning process.
[0060] In this embodiment, after receiving the status update command, the hardware chip does not directly activate the preset backup ARP entry. Instead, it first verifies the validity of the backup ARP entry. This validity verification may include, but is not limited to, outgoing interface verification, next-hop MAC verification, VLAN verification, and keep-alive flag verification. Outgoing interface verification refers to directly reading the port register to verify whether the outgoing interface corresponding to the entry is still in physical UP state and the STP state is forwarding state. Next-hop MAC verification refers to querying the MAC table at the nanosecond level to verify whether the next-hop MAC exists in the hardware MAC address table and matches the outgoing port. VLAN verification refers to verifying whether the VLAN in the entry is a member on the outgoing port. Keep-alive flag verification refers to verifying whether the keep-alive timer has not expired.
[0061] If the above entry validity verification passes, the hardware chip confirms that the backup ARP entry meets the preset activation conditions and switches it from the pending activation state to the active state. For example, in the next hop group, the weight of the corresponding entry is changed from 0 to 1, or the valid bit is changed from invalid to valid. The whole process is completed in microseconds without software intervention.
[0062] If the validity verification of the above entries fails, for example, if the outgoing interface is down or the neighbor does not respond with an LLD, the hardware chip confirms that the backup ARP entry does not meet the preset activation conditions, refuses to activate the preset entry, and immediately notifies the network device to start the traditional ARP learning process, that is, to construct and send an ARP request packet, wait for the target device to respond (about 100ms), and then update the hardware entry. Although the switching time is extended to about 150ms, the forwarding correctness is ensured, which is suitable for abnormal scenarios such as root bridge drift and link intermittent failure.
[0063] In practical applications, the control plane needs to determine whether there has been a substantial change after receiving a port event before performing an incremental update of the neighbor information table to avoid meaningless duplicate processing. Therefore, in one possible implementation, the process of updating the neighbor information table in sub-step S1012 based on its own port Down event or receiving a second extended LLDP message triggered by a neighbor device based on an STP port role change event or port Up event can include: S10121, parse the extended TLV and checksum TLV carried in the second extended LLDP message. The extended TLV includes at least one of the spanning tree state TLV, critical ARP information TLV, and backup path declaration TLV. S10122, compare the checksum TLV with the checksum value stored locally to see if they are consistent; S10123, if so, then update the corresponding port information in the neighbor information table based on the extended TLV, and update the checksum value to the checksum TLV; S10124, if not, then the neighbor information table will not be updated.
[0064] In this embodiment, upon receiving a Down event on its own port or a second extended LLDP message triggered by a neighboring device based on an STP port role change event or a port Up event, the extended TLV and checksum TLV carried in the second extended LLDP message are first parsed. The extended TLV includes at least one of a Spanning Tree State TLV, a Critical ARP Information TLV, and a Backup Path Declaration TLV. The Spanning Tree State TLV carries the port's current STP role (root port / designated port / standby port) and status (blocked or forwarding). The Critical ARP Information TLV transmits important ARP entries in the network, such as the IP address and MAC address mapping relationship of gateways, core servers, and critical hosts; each entry includes an IP address, MAC address, VLAN ID, and a flag. The Backup Path Declaration TLV actively announces the backup path information pre-configured on this end. The checksum TLV can be a CRC32 checksum TLV, which is used to calculate the checksum of the extended TLV content.
[0065] Optionally, the extended TLV is based on the IEEE 802.1AB standard and is defined under vendor-defined TLV type 127, as follows: Subtype 1 (Spanning Tree State TLV): Length 2 bytes. The 0th byte represents the port role (0=root port, 1=designated port, 2=standby port); the 1st byte represents the port status (0=blocked, 1=forwarding).
[0066] Subtype 2 (Critical ARP Information TLV): Variable length. Format: IP address (4 bytes), MAC address (6 bytes), VLAN ID (2 bytes), flag bits (1 byte, bit0 = gateway, bit1 = server).
[0067] Subtype 3 (Backup Path Declaration TLV): Length 1 byte, 0 = Request peer preset, 1 = Confirm preset.
[0068] Subtype 4 (CRC32 checksum TLV): 4 bytes in length, covering the Value portion of all the above TLVs, used for integrity verification.
[0069] Subsequently, the checksum TLV is compared with the previous checksum value stored locally. If the comparison result is consistent, it indicates that the ARP table or topology status of the neighboring device has not changed, and no update to the neighbor information table is triggered. If the comparison result is inconsistent, the corresponding port information in the neighbor information table is updated based on the extended TLV, and the checksum value stored locally is synchronously updated to the checksum TLV received this time. In this way, incremental updates are only performed when there is a substantial change, which avoids information lag caused by the default 30-second cycle of LLDP and prevents meaningless duplicate processing.
[0070] To better understand this solution, the following example from a practical application will illustrate the forwarding path switching method provided in this application.
[0071] like Figure 2 As shown, after the Spanning Tree Protocol (STP) is configured, port if1 of device 1 is set as a backup port and enters the Discarding state, while port if2 is in the Forwarding state. Device 1 reaches the server directly from device 3 via port if2, and this path is the primary path. Ports if3 and if4 of device 2 are both in the Forwarding state, and the path from device 1 to device 3 via port if1 and device 2 (ports if3 and if4) is the redundant forwarding path.
[0072] Device 1 sends LLDP packets (first extended LLDP packets) to Device 2 through the blocking port if1 according to the set sending period. The packets carry Device 1's IP address (e.g., 192.168.1.1), MAC address (e.g., 00:11:22:33:44:55), spanning tree state TLV (blocking state), and backup path declaration TLV (request peer preset).
[0073] Device 2 sends LLDP packets (first extended LLDP packets) to Device 1 through port if3 according to the set sending period, carrying Device 2's IP address (e.g., 192.168.1.2), MAC address (e.g., 00:aa:bb:cc:dd:ee) and Spanning Tree Status (TLV, forwarding status).
[0074] Device 3 sends LLDP packets (first extended LLDP packets) to Device 2 through the port connected to Device 2 according to the set sending period. The packets carry Device 3's IP address, MAC address, spanning tree state TLV (forwarding state), and key ARP information TLV (the mapping relationship between the IP address and MAC address of server 192.168.1.100).
[0075] Device 1 receives the first extended LLDP message from Device 2, parses the MAC address and IP address mapping relationship, and confirms that port if1 is a blocked port and is ranked first among all blocked ports (i.e., the primary backup port). At this time, Device 1 pre-sets a complete backup ARP entry pointing to Device 2 and writes the backup ARP entry into the next-hop group of the hardware forwarding table, sets the weight to 0, and sets the status to pending activation.
[0076] Device 2 receives the Backup Path Declaration (TLV) from Device 1, learning that Device 1 has designated it as a backup path. It then confirms, based on its neighbor information table, that its port if3 connects to Device 1's port if1, and its port if4 connects to Device 3. Furthermore, Device 3's critical ARP information TLV indicates that the server is reachable via Device 3. Therefore, Device 2 is one of the redundant forwarding paths from Device 1 to the server's network segment. Since traffic did not pass through Device 2 before the failure, its hardware forwarding table does not contain an ARP entry for the server. To avoid delays caused by ARP learning after the failure, Device 2 pre-sets a backup ARP entry pointing to Device 3 (server IP address and MAC address mapping, outgoing interface if4) based on Device 3's critical ARP information TLV, writes it to its hardware forwarding table, sets its weight to 0, and sets its status to pending activation.
[0077] When port if2 (primary link) of device 1 fails, the STP protocol detects the link interruption and switches port if1 of device 1 from a blocked state to a forwarding state. Upon hearing this state change, the control plane of device 1 immediately sends a state update command to the hardware chip. Upon receiving the command, the hardware chip verifies the validity of the pre-set backup ARP entry (pointing to device 2). If the verification is successful, it switches the entry from a pending state to an active state (e.g., changing the next-hop group weight from 0 to 1). The hardware chip completes the pointer switch within microseconds. For device 2, although neither port if3 nor if4 experiences a link interruption, upon receiving the STP topology change notification from device 1, it sends a state update command to the hardware chip. After successful verification, the hardware chip switches the pre-set backup ARP entry pointing to device 3 from a pending state to an active state. Traffic then immediately forwards through port if1 of device 1 to device 2, and then from device 2 through port if4 to device 3, finally reaching the server.
[0078] At this time, the STP of device 1 has completed the refresh of the Layer 2 MAC address table (the backup ARP entry is activated, which is equivalent to migrating the MAC entry on the original if2 port to port if1). The MAC address table of device 3, which contains the MAC address table of device 1 (after the backup ARP entry is activated), has also been migrated from the port connected to device 1 to the port connected to device 2. Combined with the activated Layer 3 ARP entry in this embodiment, a complete end-to-end path switching can be achieved.
[0079] Compared with the prior art, the forwarding path switching method provided in this application has the following advantages: First, it solves the problem of mismatched switching speeds between Layer 2 and Layer 3. By identifying the role of STP blocked ports, it proactively pre-configures backup ARP entries before a fault occurs. When a fault triggers a port state flip, only one instruction is needed to activate the hardware entry, taking only 1-3 microseconds. Compared to traditional solutions that rely on ARP relearning, resulting in interruptions lasting seconds or even minutes, this embodiment compresses service interruption time to the microsecond level, completely eliminating packet loss caused by ARP incompetence. This improves the experience of high-reliability services sensitive to packet loss, such as financial transactions, remote medical surgery, and industrial control. It avoids TCP window sway and retransmission timeouts, achieving zero interruption and zero packet loss during fault switching.
[0080] Secondly, in response to the long-held belief among those skilled in the art that ARP entries should be passively learned or actively detected after a failure, and that proactive pre-setting is considered a "waste of resources" or "may point to the wrong path," this embodiment overcomes the prejudice that "layer 2 and layer 3 protocols should be handled independently" by introducing entry validity verification and utilizing the characteristics of event-driven and LLDP that can still learn neighbor information during STP blocking. This provides a novel and non-obvious solution for the field.
[0081] In order to perform the corresponding steps in the above method embodiments and various possible implementations, an implementation of a forwarding path switching device is given below.
[0082] Please refer to Figure 3 , Figure 3 A block diagram of a forwarding path switching device 100 provided in an embodiment of this application is shown. The forwarding path switching device 100 is applied to a network device and includes: a build update module 101 and an execution module 102.
[0083] The update module 101 is used to build the neighbor information table and update it based on the monitored port events.
[0084] The execution module 102 is used to select a primary backup port that meets the set conditions from all the blocked ports corresponding to each forwarding port, generate or update the backup address resolution protocol (ARP) table entry for the forwarding path corresponding to the primary backup port according to the neighbor information table, write the generated or updated backup ARP table entry into the hardware forwarding table, and configure the backup ARP table entry to be in an active state. When the primary backup port is detected to switch from a blocked state to a forwarding state, a status update command is sent to the hardware chip. The hardware chip determines whether the backup ARP table entry meets the preset activation conditions. If it does, the backup ARP table entry is switched from an active state to an active state.
[0085] Optionally, the update module 101 is specifically used to: after the network device is powered on, collect device information of neighboring devices by sending a first extended LLDP message and receiving a first extended LLDP message sent by neighboring devices, and build a neighbor information table; during the operation of the network device, update the neighbor information table according to its own port Down event or by receiving a second extended LLDP message triggered by a neighboring device based on an STP port role change event or a port Up event; wherein, the neighbor information table includes the IP address, MAC address, port role and status of the neighboring device's port.
[0086] Optionally, the execution module 102 performs the following: selecting a primary backup port that meets set conditions from all blocked ports corresponding to each forwarding port; and generating or updating the backup Address Resolution Protocol (ARP) entry for the forwarding path corresponding to the primary backup port based on the neighbor information table. This includes: after the neighbor information table is initially constructed, selecting the optimal port from all blocked ports corresponding to each forwarding port based on the path cost to the root bridge and port priority, and determining it as the primary backup port for that forwarding port; generating the backup ARP entry for the path corresponding to the primary backup port based on the neighbor information table; and updating the backup ARP entry after updating the neighbor information table based on port events.
[0087] Optionally, the execution module 102 executes a method for writing the generated or updated backup ARP entries into the hardware forwarding table, including: checking whether the number of existing backup ARP entries in the hardware forwarding table exceeds a preset threshold; if so, stopping the writing of backup ARP entries and issuing an alarm, and deleting the existing backup ARP entries with the lowest priority in the hardware forwarding table; if not, writing the generated backup ARP entries into the hardware forwarding table.
[0088] Optionally, the execution module 102 executes the method of writing the generated or updated backup ARP entry into the hardware forwarding table, which further includes: after writing the backup ARP entry into the hardware forwarding table, associating a liveness timer with the backup ARP entry; if the forwarding path corresponding to the backup ARP entry is detected to be invalid or the liveness timer expires, then the backup ARP entry is deleted.
[0089] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the forwarding path switching device 100 described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0090] Please refer to Figure 4 , Figure 4 A block diagram of a network device 10 provided in an embodiment of this application is shown. The network device 10 includes a processor 11, a memory 12, and a bus 13. The processor 11 is connected to the memory 12 via the bus 13.
[0091] The memory 12 is used to store programs. After receiving an execution instruction, the processor 11 executes the programs to implement the forwarding path switching method disclosed in the above embodiments.
[0092] The memory 12 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0093] Processor 11 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed through integrated logic circuits in the hardware of processor 11 or through software instructions. Processor 11 can be a general-purpose processor, including a Central Processing Unit (CPU), a Microcontroller Unit (MCU), a Complex Programmable Logic Device (CPLD), a Field Programmable Gate Array (FPGA), embedded ARM chips, etc.
[0094] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by the processor 11, implements the forwarding path switching method disclosed in the above embodiments.
[0095] In summary, the forwarding path switching method, apparatus, network device, and storage medium provided in this application first construct a neighbor information table and update it based on monitored port events. Then, among all blocked ports corresponding to each forwarding port, a primary backup port that meets set conditions is selected. Based on the neighbor information table, a backup ARP entry for the forwarding path corresponding to the primary backup port is generated or updated. The backup ARP entry is written to the hardware forwarding table and configured to be in an active state. When the primary backup port is detected to switch from a blocked state to a forwarding state, a state update command is sent to the hardware chip. The hardware chip determines whether the backup ARP entry meets the preset activation conditions. If it does, the backup ARP entry is switched from an active state to an active state. Thus, by predicting the backup path based on the role of the STP blocked port before a fault occurs, and writing the backup ARP entry to the hardware chip and marking it as active in advance, only a microsecond-level state flip is needed to complete the Layer 3 switch when a fault actually occurs. This breaks the protocol isolation between Layer 2 STP and Layer 3 ARP, achieving true synchronous convergence between Layer 2 and Layer 3, and compressing service interruption time to the microsecond level.
[0096] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A forwarding path switching method, characterized in that, Applied to network devices, the method includes: Build a neighbor information table and update it based on the monitored port events; Select the primary backup port that meets the set conditions from all the blocked ports corresponding to each forwarding port, and generate or update the backup address resolution protocol (ARP) table entry for the forwarding path corresponding to the primary backup port according to the neighbor information table. Write the generated or updated backup ARP entry into the hardware forwarding table and configure the backup ARP entry to be in an inactive state; When the primary backup port is detected to have switched from a blocked state to a forwarding state, a state update command is sent to the hardware chip. The hardware chip determines whether the backup ARP entry meets the preset activation conditions. If it does, the backup ARP entry is switched from the pending activation state to the active state.
2. The forwarding path switching method as described in claim 1, characterized in that, The process of constructing the neighbor information table and updating it based on the monitored port events includes: After the network device is powered on, it collects device information of neighboring devices and constructs the neighbor information table by sending first extended link layer discovery protocol (LLDP) messages and receiving first extended LLDP messages sent by neighboring devices. During the operation of the network device, the neighbor information table is updated based on its own port Down event or by receiving a second extended LLDP message triggered by a neighbor device based on a Spanning Tree Protocol (STP) port role change event or port Up event. The neighbor information table includes the IP address, MAC address, port role, and status of neighboring devices.
3. The forwarding path switching method as described in claim 2, characterized in that, The step of selecting a primary backup port that meets set conditions from all blocked ports corresponding to each forwarding port, and generating or updating the backup address resolution protocol (ARP) table entry for the forwarding path corresponding to the primary backup port based on the neighbor information table, includes: After the neighbor information table is initially constructed, among all the blocked ports corresponding to each forwarding port, the optimal port is selected based on the path cost to the root bridge and the port priority, and it is determined as the primary backup port of that forwarding port. Based on the neighbor information table, generate a backup ARP entry for the path corresponding to the primary backup port; After updating the neighbor information table based on port events, update the backup ARP entry.
4. The forwarding path switching method as described in claim 1, characterized in that, The step of writing the generated or updated backup ARP entry into the hardware forwarding table includes: Check whether the number of existing backup ARP entries in the hardware forwarding table exceeds a preset threshold; If so, stop writing to the backup ARP entry and issue an alarm, and delete the existing backup ARP entry with the lowest priority in the hardware forwarding table; If not, the backup ARP entry generated this time will be written to the hardware forwarding table.
5. The forwarding path switching method as described in claim 4, characterized in that, The step of writing the generated backup ARP entry into the hardware forwarding table further includes: After writing the backup ARP entry into the hardware forwarding table, a live timer is associated with the backup ARP entry. If the forwarding path corresponding to the backup ARP entry is detected to be invalid or the liveness timer expires, the backup ARP entry is deleted.
6. The forwarding path switching method as described in claim 1, characterized in that, The hardware chip determines whether the backup ARP entry meets the preset activation conditions. If it does, the backup ARP entry is switched from the pending activation state to the activated state, including: After receiving the status update instruction, the hardware chip verifies the validity of the backup ARP entry. If the validity verification of the entry passes, the hardware chip determines that the backup ARP entry meets the preset activation condition and switches the backup ARP entry from the pending activation state to the activated state. If the validity verification of the entry fails, the hardware chip determines that the backup ARP entry does not meet the preset activation conditions and notifies the network device to start the ARP learning process.
7. A forwarding path switching device, characterized in that, Applied to network devices, the device includes: The build update module is used to build the neighbor information table and update it based on the monitored port events; The execution module is used to select a primary backup port that meets set conditions from all blocked ports corresponding to each forwarding port; generate or update the backup Address Resolution Protocol (ARP) entry for the forwarding path corresponding to the primary backup port according to the neighbor information table; write the generated or updated backup ARP entry into the hardware forwarding table and configure the backup ARP entry to be in an inactive state; when the primary backup port is detected to switch from a blocked state to a forwarding state, a state update command is sent to the hardware chip; the hardware chip determines whether the backup ARP entry meets the preset activation conditions; if it does, the backup ARP entry is switched from the inactive state to the active state.
8. The forwarding path switching device as described in claim 7, characterized in that, The construction and update module is specifically used to collect device information of neighboring devices and construct the neighbor information table after the network device is powered on by sending a first extended link layer discovery protocol (LLDP) message and receiving a first extended LLDP message sent by neighboring devices. During the operation of the network device, the neighbor information table is updated based on its own port Down event or by receiving a second extended LLDP message triggered by a neighbor device based on a Spanning Tree Protocol (STP) port role change event or port Up event. The neighbor information table includes the IP address, MAC address, port role, and status of neighboring devices.
9. A network device, characterized in that, It includes a processor and a memory, the memory being used to store a program, and the processor being used to implement the forwarding path switching method as described in any one of claims 1-6 when executing the program.
10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the forwarding path switching method as described in any one of claims 1-6.
