A message forwarding method and apparatus

By configuring BFD sessions in network devices to generate BFD packets to detect and forward link status, the problem of link failures in the network environment that cannot be detected in a timely manner in the existing technology is solved, and reliable forwarding of data packets is achieved.

CN121000655BActive Publication Date: 2026-01-30格创通信(浙江)有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511529346.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-24
Publication Date
2026-01-30
Estimated Expiration
2045-10-24

AI Technical Summary

Technical Problem

Existing failover technologies cannot detect link interruptions caused by non-routing device failures or logical layer failures in the network environment in a timely manner, resulting in data packet forwarding failures.

Method used

By configuring a bidirectional forwarding detection (BFD) session in the network device, BFD packets are generated to perform link detection on the forwarding link, identify the link status corresponding to the interface, and reselect the interface for data packet forwarding when the link status is Down.

Benefits of technology

It enables timely detection of link failures in the network environment, avoiding data packet forwarding failures caused by the inability to detect non-routing device failures, and ensuring service continuity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121000655B_ABST
    Figure CN121000655B_ABST
Patent Text Reader

Abstract

This application discloses a message forwarding method and apparatus, relating to the field of communication technology. The method comprises: receiving a data packet; identifying the outgoing interface of the data packet; if the outgoing interface is fault-free, identifying the link status of the forwarding link corresponding to the outgoing interface, wherein the link status is obtained by performing link detection on the forwarding link based on BFD messages generated by the BFD session when the outgoing interface is configured with a BFD session for detecting the link status of the forwarding link corresponding to the outgoing interface; if the link status is UP, forwarding the data packet using the outgoing interface; if the link status is Down, reselecting the outgoing interface for forwarding the data packet. Thus, data packet forwarding is achieved when link faults in the network environment are detected in a timely manner.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of communication technology, in particular to a message forwarding method and device. BACKGROUND

[0002] In the field of network communication, aggregation ports and equal-cost multi-path routing technology are widely used to achieve link redundancy, increase bandwidth, and load balancing. When a physical fault occurs in an aggregation port of a network device or a member port of equal-cost multi-path routing in a network environment, i.e., the interface state of the aforementioned member port changes from up to down, the existing failover method can quickly locate the fault by identifying the interface state before the controller of the network device refreshes the hardware table items to isolate the faulty member port, and reselect other member ports for data forwarding, thereby reducing packet loss and ensuring the continuity of network services.

[0003] However, with the increasing complexity of network topology, there are many situations in the actual network environment that existing technologies cannot handle. On the one hand, when two routing devices are not directly connected, there are non-routing devices (also known as intermediate devices) such as switches or other transmission devices between them. If a physical interface of an intermediate device fails, the failure will not directly affect the interface state of the aggregation port or the member port of equal-cost multi-path routing in the routing device, resulting in the failover technology based on the current interface state detection being unable to perceive such a failure and thus unable to perform link switching and service recovery in a timely manner.

[0004] On the other hand, even if the physical state of the interface is normal, there may still be conditions that cause the failure of layer 2 and layer 3 forwarding, such as network configuration errors, routing protocol abnormalities, and other reasons. Similarly, the existing failover technology simply relies on interface state detection and cannot perceive such logical level failures, making it unable to respond in a timely manner when the service is interrupted.

[0005] Therefore, how to timely perceive link failures in a network environment and perform message forwarding is one of the technical problems worth considering. SUMMARY

[0006] Embodiments of the present application provide a message forwarding method and device for timely perceiving link failures in a network environment and performing message forwarding.

[0007] In one aspect, the present application provides a message forwarding method applied in a network device, the method comprising:

[0008] receiving a data message;

[0009] identifying an out-interface of the data message;

[0010] if the out interface is fault-free, identifying a link state of a forwarding link corresponding to the out interface, wherein the link state is obtained by performing link detection on the forwarding link based on a BFD message generated by a BFD session configured on the out interface for detecting the link state of the forwarding link corresponding to the out interface;

[0011] if the link state is a fault-free UP state, forwarding the data message by using the out interface;

[0012] if the link state is a faulty Down state, reselecting an out interface for forwarding the data message.

[0013] In another aspect, an embodiment of the present application further provides a message forwarding device applied to a network device, the device comprising:

[0014] a receiving unit configured to receive a data message;

[0015] a first identifying unit configured to identify an out interface of the data message;

[0016] a second identifying unit configured to, if the out interface is fault-free, identify a link state of a forwarding link corresponding to the out interface, wherein the link state is obtained by performing link detection on the forwarding link based on a BFD message generated by a BFD session configured on the out interface for detecting the link state of the forwarding link corresponding to the out interface;

[0017] a forwarding unit configured to, if the second identifying unit identifies that the link state is a fault-free UP state, forward the data message by using the out interface;

[0018] a processing unit configured to, if the second identifying unit identifies that the link state is a faulty Down state, reselect an out interface for forwarding the data message.

[0019] The present application has the following advantages:

[0020] In the message forwarding method and device, the network device receives a data message and identifies an out interface of the data message; if the out interface is not faulty, the network device identifies a link state of a forwarding link corresponding to the out interface; if the link state is an UP state, the network device forwards the data message by using the out interface; and if the link state is a Down state, the network device reselects an out interface for forwarding the data message. By using the message forwarding method, after the network device determines the out interface of the data message, the network device identifies the link state of the forwarding link corresponding to the out interface in addition to identifying the state of the out interface itself. In this way, the network device can timely perceive the link state of the network in which the network device is located, and then successfully forwards the data message when the link state is UP. In addition, the link state is obtained by using BFD messages generated based on a BFD session configured on the out interface to perform pre-link detection on the forwarding link. The forwarding link can pass through a routing device or a non-routing device. By using the BFD messages to perform pre-link detection on the forwarding link, the network device can timely perceive whether each routing device or non-routing device in the forwarding link is faulty, thereby avoiding the failure of forwarding the data message due to the inability to perceive the state of the non-routing device, and further avoiding the interruption of services.

[0021] Other features and advantages of the present application will be set forth in the following description, and in part will be apparent from the description, or can be learned by practice of the present application. The objects and other advantages of the present application will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings. BRIEF DESCRIPTION OF DRAWINGS

[0022] The accompanying drawings, which are included to provide a further understanding of the present application and are incorporated in and constitute a part of this application, illustrate embodiments of the present application and together with the description serve to explain the present application. In the drawings:

[0023] Figure 1 A flowchart of a message forwarding method provided by an embodiment of the present application;

[0024] Figure 2 A flowchart of a fault detection method provided by an embodiment of the present application;

[0025] Figure 3 A format diagram of a BFD header provided by an embodiment of the present application;

[0026] Figure 4 A format diagram of a state table provided by an embodiment of the present application;

[0027] Figure 5 is a network architecture diagram provided by an embodiment of the present application;

[0028] Figure 6 is another network architecture diagram provided by an embodiment of the present application;

[0029] Figure 7 is a structure diagram of a routing device provided by an embodiment of the present application;

[0030] Figure 8 is a structure diagram of a message forwarding device provided by an embodiment of the present application;

[0031] Figure 9 is a structure diagram of a computing device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0032] The message forwarding method and device provided by the embodiments of the present application can timely perceive the link fault in the network environment to ensure message forwarding.

[0033] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application. The embodiments in the present application and the features in the embodiments can be combined with each other arbitrarily without conflict. Moreover, although the logical order is shown in the flowchart, in some cases, the steps shown or described can be performed in an order different from that here.

[0034] The terms "first" and "second" in the specification and claims and drawings of the present application are used to distinguish different objects, and are not used to describe a specific order. In addition, the term "comprising" and any variations thereof are intended to cover non-exclusive protection. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, product or device.

[0035] In order to timely perceive the link fault in the network environment and perform message forwarding, the embodiments of the present application provide a message forwarding method, which refers to Figure 1The flowchart shows that the packet forwarding method can be applied to a network device, which can be but is not limited to a device supporting three-layer forwarding. The network device can be any device supporting three-layer forwarding in a network. When implementing the method, the network device can include the following steps:

[0036] S101, receiving a data packet.

[0037] S102, identifying an out-interface of the data packet.

[0038] In this step, after receiving the data packet sent by the previous network device, if the network device is not the last-hop network device, the network device needs to forward the data packet to the next-hop network device. Before sending the data packet to the next-hop network device, the network device needs to determine the out-interface of the data packet, i.e., after determining the out-interface, the network device can send the data packet to the next-hop network device through the out-interface.

[0039] On this basis, when determining the out-interface, the network device can identify the out-interface by searching the setting table. Specifically, different protocols correspond to different setting tables. For example, when the data packet supports a two-layer protocol, the setting table can be a media access control table (MAC table); when the data packet supports a three-layer protocol, the setting table can be a forwarding information base table (FIB table). On this basis, when the data packet is a data packet supporting a two-layer protocol, the network device can determine the in-interface through which the data packet enters the network device, and then query the MAC table by using the VLAN (Virtual Local Area Network) to which the in-interface belongs and the destination MAC address of the data packet, so as to identify the out-interface of the data packet. When the data packet is a data packet supporting a three-layer protocol, after determining the in-interface, the network device can query the FIB table by using the VPN (Virtual Private Network) / VRF (Virtual Routing and Forwarding) to which the in-interface belongs and the destination IP address of the data packet, so as to identify the out-interface of the data packet.

[0040] Optionally, when the out interface found based on the MAC table or the FIB table is an aggregation port or an equal-cost route port, a member port of the aggregation port or the equal-cost route port can be selected as the out interface of the identified data packet according to a hash value calculated by a preset hash algorithm. When the hash algorithm is calculated, for example, the hash calculation can be performed according to the five-tuple of the data packet, and the number of member ports is taken as a modulus, so as to determine the out interface of the data packet.

[0041] S103, if the out interface is fault-free, identifying a link state of a forwarding link corresponding to the out interface.

[0042] The link state is obtained by performing link detection on the forwarding link based on a BFD (Bidirectional Forwarding Detection) packet generated by a BFD session configured on the out interface for detecting the link state of the forwarding link corresponding to the out interface.

[0043] In this step, the network device performs fault detection processing on each out interface on the network device, and therefore, after the out interface is determined, the fault detection result of the out interface is obtained. If it is identified that the out interface is fault-free, in order to ensure that the data packet is successfully forwarded to a next-hop network device, the embodiment further proposes identifying a link state of a forwarding link of the out interface, and the forwarding link is a link that will be used to forward the data packet.

[0044] If it is identified that the out interface is faulty, it indicates that the data packet cannot be forwarded based on the out interface at present, and therefore, an out interface that can forward the data packet can be reselected at this time.

[0045] It should be noted that the link state of the forwarding link is obtained by pre-detection. Specifically, the network device can configure a BFD session for a physical interface whose link state needs to be detected, and the physical interface can be any interface in the network device. In this way, for any physical interface, the network device can obtain the BFD session of the physical interface, and then identify whether the BFD session is a session for detecting the link state of the forwarding link of the physical interface. When it is identified that the BFD session is a session for detecting the link state of the forwarding link of the physical interface, the network device can generate a BFD packet based on the BFD session, and then forward the BFD packet through the physical interface, so as to detect the link state of the forwarding link. Further, the network device can obtain the link state of the forwarding link of the physical interface based on the detection result of the BFD packet. The link state can be an UP state or a Down state, wherein the UP state indicates that the forwarding link is currently fault-free and can normally provide data packet transmission service, and the Down state indicates that the forwarding link is faulty and cannot provide data packet transmission service.

[0046] Specifically, when the network device comprises a control plane, a driver and a forwarding plane, the interaction flow between the modules in the network device when performing the above link state detection is as follows: the control plane can obtain the BFD session of the physical interface and perform state machine negotiation, and after the state machine negotiation is completed, the state of the BFD session is switched from down to up. On this basis, the control plane can issue the session information of the BFD session to the driver. After receiving the BFD session, the driver can forward the timing packet sending and timeout detection functions of the BFD session to the forwarding plane. In this way, after receiving the BFD session, the forwarding plane can generate a BFD packet and start the BFD detection function, which can generally include the functions of periodic packet sending, periodic packet scanning, counting whether there is an increase, timeout notification to the host, etc. Based on the above BFD detection function, the above BFD packet can be periodically sent, and the response of the BFD packet based on the above BFD detection function can be used to obtain the link state of the forwarding link of the physical interface.

[0047] It should be noted that when the outgoing interface is fault-free and the outgoing interface is not configured with a BFD session for detecting the link state of the forwarding link corresponding to the outgoing interface, the data packet can be directly forwarded from the outgoing interface.

[0048] S104, if the link state is an UP state, the data packet is forwarded using the outgoing interface.

[0049] In this step, when the link state of the forwarding link of the outgoing interface obtained based on step 103 is an UP state, it indicates that the current forwarding link can be used to provide data packet transmission service, and at this time the data packet can be forwarded.

[0050] S105, if the link state is a Down state, an outgoing interface for forwarding the data packet is reselected.

[0051] In this step, when the link state of the forwarding link of the outgoing interface obtained based on step 103 is a Down state, it indicates that the current forwarding link cannot provide data packet transmission service, and at this time the network device needs to reselect an outgoing interface.

[0052] When reselecting the outgoing interface, for example, an outgoing interface can be randomly selected, and then the steps of step 103 are re-executed until the data packet is successfully forwarded. For example, when reselecting the outgoing interface, different strategies can be adopted to reselect the outgoing interface according to different link types.

[0053] When the packet forwarding method is used, after receiving a data packet, the network device identifies an out interface of the data packet; if it is found that the out interface is not faulty, the network device identifies a link state of a forwarding link corresponding to the out interface; if the link state is an UP state, the network device forwards the data packet by using the out interface; if the link state is a Down state, the network device reselects an out interface for forwarding the data packet. In this way, after determining the out interface of the data packet, the network device identifies the link state of the forwarding link corresponding to the out interface in addition to identifying the state of the out interface itself. In this way, the network device can timely perceive the link state of the network in which the network device is located, and then successfully forwards the data packet when the link state is UP. In addition, the link state is obtained by using a BFD session configured on the out interface to detect the link state of the forwarding link corresponding to the out interface, and the forwarding link can pass through a routing device or a non-routing device. By using the BFD packet to pre-link detect the forwarding link, the network device can timely perceive whether each routing device or non-routing device in the forwarding link is faulty, thereby avoiding the failure of forwarding the data packet due to the inability to perceive the device state of the non-routing device, and avoiding the interruption of the service.

[0054] Optionally, when the network device includes a control plane, a driver, and a forwarding plane, the steps S101-S105 are performed by the forwarding plane. The control plane and the driver are responsible for controlling the forwarding plane to perform the detection of the link state of the forwarding link.

[0055] Optionally, based on the foregoing embodiment, in this embodiment, the step of identifying the link state of the forwarding link corresponding to the out interface can be performed according to the following process: if the out interface is marked with the first mark, it is identified that the link state of the forwarding link corresponding to the out interface is an UP state; if the out interface is marked with the second mark, it is identified that the link state of the forwarding link corresponding to the out interface is a Down state.

[0056] Specifically, when the network device confirms that the out interface is configured with the BFD session for detecting the link state of the corresponding forwarding link, the network device can identify the link state of the forwarding link corresponding to the out interface based on the BFD packet generated by the BFD session. After identifying the link state, the network device can perform marking processing on the out interface. For example, when the identified link state of the forwarding link is UP state, the network device performs first marking on the out interface; and when the identified link state of the forwarding link is Down state, the network device performs second marking on the out interface. In this way, the network device can acquire the marking performed on the out interface. If the network device finds that the first marking is performed on the out interface, it means that the link state of the forwarding link corresponding to the out interface is UP state, and further means that the forwarding link corresponding to the out interface is not faulty. If the network device finds that the second marking is performed on the out interface, it means that the link state of the forwarding link corresponding to the out interface is Down state, and further means that the forwarding link corresponding to the out interface is faulty.

[0057] Specifically, when the network device includes the control plane, the driver and the forwarding plane, the forwarding plane identifies the link state of the forwarding link corresponding to the out interface according to the description of the embodiment.

[0058] Optionally, the out interface being configured with the BFD session for detecting the link state of the forwarding link corresponding to the out interface can be determined according to the following method: querying an attribute table of the out interface; and if a first field in the attribute table has a first value, it is determined that the out interface is configured with the BFD session for detecting the link state of the forwarding link corresponding to the out interface.

[0059] Specifically, in actual application, not all out interfaces are subjected to the link detection of the forwarding link. In order to facilitate identification of whether the forwarding link of a certain out interface is subjected to detection, the embodiment proposes that a first field included in an attribute table of the out interface is set to have a value. When the first field is set to have a first value, it means that the out interface is configured with the BFD session for detecting the link state of the forwarding link corresponding to the out interface. When the first field is set to have a second value, it means that the out interface is not configured with the BFD session for detecting the link state of the forwarding link corresponding to the out interface. In this way, it can be quickly confirmed whether the forwarding link of a certain out interface is subjected to fault detection.

[0060] On this basis, the network device can obtain the attribute table corresponding to the out interface after identifying the out interface corresponding to the data packet this time, and then query the value of the first field in the attribute table. When the value of the first field is identified as the first value, it can be determined that the out interface is configured with a BFD session for detecting the link state of the forwarding link corresponding to the out interface. When the value of the first field is identified as the second value, it can be determined that the out interface is not configured with a BFD session for detecting the link state of the forwarding link corresponding to the out interface.

[0061] Optionally, when the network device includes a control plane, a driver, and a forwarding plane, the BFD session is pre-configured for the out interface, and the session information of the BFD session is issued by the control plane to the forwarding plane through the driver, and the forwarding plane performs the determination of whether the out interface is configured with a BFD session for detecting the link state of the forwarding link corresponding to the out interface.

[0062] It should be noted that in actual application, the BFD detection function can also be used for other purposes, for example, detecting tunnel, detecting routing protocol, detecting IP address, and the like. In this application, in order to distinguish the function of detecting the link state of the forwarding link of the interface from other detection functions, the session information of the BFD session can be used for the distinction. Different values of the application type in the session information are set to represent different detection functions of the BFD session. In this way, the control plane can distribute the corresponding relationship between the values of the above-mentioned application type and the detection functions to the driver. On this basis, for a certain interface, when the management personnel wants to detect the link state of the forwarding link corresponding to the interface, the control plane can obtain the session information of the BFD session of the interface, so that the session information of the BFD session includes the value of the application type for detecting the link state of the forwarding link corresponding to the interface. Further, the control plane can distribute the session information of the BFD session to the driver, and the driver can identify the detection function represented by the application type in the session information based on the above-mentioned corresponding relationship after receiving the session information of the BFD session. When it is identified that the value of the application type is used to represent the function of detecting the link state of the forwarding link corresponding to the interface, the attribute table corresponding to the interface can be added with a first field, the value of the first field is set to a first numerical value, and the attribute table of the interface is distributed to the forwarding plane. When the attribute table corresponding to the interface is received, the forwarding plane can generate the BFD packet corresponding to the interface, use the BFD packet to detect the link state of the forwarding link corresponding to the interface, and perform corresponding marking processing on the interface based on the link detection result. If the link detection result determines that the forwarding link corresponding to the interface is not faulty, the first marking processing is performed on the interface, and the first marking is used to indicate that the link state of the target forwarding link is UP state. If the link detection result determines that the forwarding link corresponding to the interface is faulty, the second marking processing is performed on the interface, and the first marking is used to indicate that the link state of the target forwarding link is Down state.

[0063] Optionally, the first field can be but is not limited to a BFD_enable field, and the bit width of the BFD_enable field can be but is not limited to 1 bit. When the BFD_enable field occupies 1 bit, the first numerical value can be 1, and the second numerical value can be 0.

[0064] Further, the interface can be identified as being marked with the first marking or the second marking according to the following process: the interface is identified as being marked with the first marking or the second marking according to the value of the second field in the attribute table of the interface.

[0065] Specifically, the attribute table of the out-interface can further include a second field, and the second field can be used to indicate that the out-interface is executed with the first mark or the second mark.

[0066] In an embodiment, the value of the second field can be directly used to indicate that the out-interface is executed with the first mark or the second mark. For example, if the value of the second field is a first set value, it can be determined that the out-interface is executed with the first mark; if the value of the second field is a second set value, it can be determined that the out-interface is executed with the second mark.

[0067] In another possible embodiment, in actual application, the bit width occupied by the second field is determined according to the specification of the BFD session corresponding to the out-interface, and the specification size of the attribute table of the out-interface is limited, therefore, in order to avoid the specification of the attribute table being too large, the second field of the attribute table includes the index value of the BFD session configured for the out-interface; on this basis, the value of the out-interface being executed with the first mark or the second mark is identified according to the value of the second field by using the index value of the BFD session configured for the out-interface to find the value of the position indicated by the index value in the pre-configured state table; if the value of the position is a first mark value, it is identified that the out-interface is executed with the first mark; if the value of the position is a second mark value, it is identified that the out-interface is executed with the second mark.

[0068] Specifically, the above index value is assigned to the BFD session for detecting the link state of the forwarding link of the out-interface after the BFD session is configured for the out-interface, different BFD sessions correspond to different index values, and correspondingly, different physical interfaces correspond to different index values. On this basis, after the above BFD session is configured for the out-interface, a second field is added in the attribute table of the out-interface, and then the index value is written into the second field. In addition, the network device is pre-configured with a state table, which records the link state of the forwarding link of the out-interface that needs to be detected, and then points to the position in the state table for indicating the link state of the forwarding link of the corresponding out-interface by using the index value.

[0069] On this basis, the network device can obtain the index value included in the second field from the attribute table of the out-interface, and then use the index value to find the position indicated by the index value in the state table, and identify the value of the position; if the value of the position is a first mark value, it is identified that the out-interface is executed with the first mark; if the value of the position is a second mark value, it is identified that the out-interface is executed with the second mark.

[0070] Optionally, when the network device comprises a control plane, a driver and a forwarding plane, after the attribute table writes the session information of the BFD session of the out interface based on the control plane and identifies that the BFD session is used to detect the link state of the forwarding link of the out interface, the attribute table of the out interface is updated by adding a second field in the attribute table in addition to writing the first value into the first field, and then the index value of the BFD session corresponding to the out interface is written into the second field; wherein the index value of the BFD session corresponding to the out interface is assigned by the control plane and delivered to the driver; after the driver writes the index value, the attribute table of the out interface can be delivered to the forwarding plane; after the forwarding plane detects the link of the out interface based on the attribute table of the out interface and the foregoing description, the link detection result is written into the position indicated by the index value in the state table.

[0071] On this basis, when the forwarding plane identifies that the out interface is configured with the BFD session used for detecting the link state of the forwarding link during data packet forwarding, the index value in the second field of the attribute table of the out interface is read, and the value of the position indicated by the index value in the state table is found, and then it is identified that the out interface is executed with the first mark or the second mark.

[0072] Optionally, the second field can be but is not limited to a BFD_index field, and correspondingly, the bit width of the field can be determined according to the specification of the BFD session of the out interface. For example, if the specification of the BFD session of the out interface assigned by the control plane for detecting the link state of the corresponding forwarding link is 2K, the bit width of the BFD_index field is 11 bits.

[0073] Optionally, based on any of the foregoing embodiments, when it is identified that the forwarding link corresponding to the interface fails, the present embodiment proposes that the step of reselecting the out interface for forwarding the data packet can be performed according to the following process: when the out interface is an aggregation port, the standby member port of the out interface is used as the out interface for forwarding the data packet; when the out interface is an equal-cost routing port, any other member port constituting equal-cost routing with the out interface is used as the out interface for forwarding the data packet.

[0074] Specifically, the aggregation port refers to a logical interface composed of multiple physical interfaces, each physical interface being an aggregation member port, and the packet is forwarded through the aggregation port, which not only improves the bandwidth but also enhances the reliability of packet transmission, and at the same time realizes load balancing. The foregoing equal-cost routing refers to the existence of multiple equal-cost paths to the same destination network, and the data packet sent to the destination network can be load balanced among the multiple physical interfaces of the equal-cost paths, which also improves the bandwidth and enhances the reliability of packet transmission.

[0075] On this basis, when the out interface is an aggregation port, a backup member port can be configured for each aggregation member port in advance, so that when it is identified that the interface belongs to the aggregation port, the backup member port corresponding to the out interface can be obtained when the forwarding link of the out interface fails; when it is determined that the out interface has only one backup member port, the backup member port is the out interface for forwarding data packets; and when there are multiple backup member ports, one of the backup member ports can be randomly selected as the out interface for forwarding data packets. It should be noted that after the backup member port is selected, the backup member port can continue to execute the processes of steps S103-S105.

[0076] When the out interface is an equal-cost routing port, based on the principle of equal-cost routing, there can be multiple equal-cost paths to the same destination network, and then the forwarding link (forwarding path) corresponding to the out interface is removed from the multiple equal-cost paths to obtain the remaining equal-cost paths, and then a member port of the network device on a random equal-cost path is selected as the out interface for forwarding data packets. It should be noted that after the member port is selected, the member port can continue to execute the processes of steps S103-S105. In order to better understand the embodiment, an example of equal-cost routing including three out interfaces corresponding to physical interface 1-physical interface 3 can be used for illustration. If the out interface of the identified data packet is physical interface 2, then according to the process of Figure 1 , when physical interface 2 fails, physical interface 1 or physical interface 3 can be selected as the out interface for forwarding data packets.

[0077] Alternatively, when the out interface is an aggregation member port, the embodiment proposes that the backup member port of the out interface can be determined according to the following method: obtaining a fault switching table of the out interface, the fault switching table including interface information of other aggregation member ports of the aggregation port to which the out interface belongs; and selecting one of the aggregation member ports as the backup member port based on the interface information of the other aggregation member ports.

[0078] Specifically, the above-mentioned failover table (also referred to as a failover table) is generated when the aggregation port is created. Each aggregation member port corresponds to a failover table, and the failover table includes interface information and the number of interfaces of other aggregation member ports under the aggregation port except the aggregation member port. For example, an aggregation port RAGG1 is composed of four physical interfaces, namely, a physical interface A, a physical interface B, a physical interface C, and a physical interface D. On this basis, the failover table of the physical interface A includes interface information of the physical interface B, the physical interface C, and the physical interface D, and the number of interfaces is 3; correspondingly, the failover table of the physical interface B includes interface information of the physical interface A, the physical interface C, and the physical interface D, and the number of interfaces is 3; the failover table of the physical interface C includes interface information of the physical interface A, the physical interface B, and the physical interface D, and the number of interfaces is 3; and the failover table of the physical interface D includes interface information of the physical interface A, the physical interface B, and the physical interface C, and the number of interfaces is 3.

[0079] Further, when the network device identifies that the interface is the physical interface A and the forwarding link corresponding to the physical interface A fails, the failover table of the physical interface A can be obtained, and then the interface information of other aggregation member ports, i.e., the interface information of the physical interface B, the physical interface C, and the physical interface D, is obtained, and then an aggregation member port is selected as the backup member port based on the interface information, i.e., one of the physical interface B, the physical interface C, and the physical interface D is selected as the backup member port. It should be noted that when the failover table includes interface information of multiple aggregation member ports, a hash algorithm can be used to select one aggregation member port as the backup member port.

[0080] Optionally, when the network device includes a control plane, a driver, and a forwarding plane, the implementation process of each embodiment of the foregoing reselection of the out-interface for forwarding the data packet is performed by the forwarding plane.

[0081] Further, the aggregation port is created by the control plane, and then the related information of the aggregation port is sent to the driver, and the driver creates a failover table for each aggregation member port in the aggregation port. Then, the driver sends the failover table of each aggregation member port to the forwarding plane, and then the forwarding plane performs the step of determining the backup member port of the out-interface based on the failover table.

[0082] At this point, the introduction of the data packet forwarding process is completed, and next, the detection process of the link state of the forwarding link corresponding to the physical interface is introduced, and the flowchart of the fault detection method is shown in FIG. 1. Figure 2 The detection process of the link state of the forwarding link corresponding to the physical interface can include the following steps:

[0083] S201, a target BFD session is identified.

[0084] In this step, when the network device comprises a control plane, a driver and a forwarding plane, for a target interface, when link detection is to be performed on a forwarding link of the target interface, the control plane can obtain a BFD session for performing link detection that is previously created for the target interface. It is worth noting that the target interface can be any physical interface in the network device, which can be an ingress interface or an egress interface. After obtaining the target BFD session, the control plane performs a state machine negotiation process, and after the negotiation is completed, the state of the target BFD session is switched from the down state to the up state. Then, the control plane sends session information of the target BFD session to the driver, which can include interface information of the target interface.

[0085] In addition, the session information further includes an application type, which is used to represent the function of the target BFD session. Specifically, BFD probes can be used for multiple purposes, such as the above-mentioned probe tunnel case, probe routing protocol, probe IP address, and the like. In order to facilitate the driver to identify the detection function of the received BFD session, the control plane can pre-configure a correspondence between the detection function and the value of the application type, and then send the correspondence to the driver. In this way, after receiving the session information of the target BFD session, the driver can identify the detection function of the target BFD session based on the value of the application type in the session information and the above-mentioned correspondence.

[0086] S202, if the target BFD session is identified as a session for detecting the link state of the target forwarding link corresponding to the target interface, set the value of the first field in the attribute table corresponding to the target interface to the first value.

[0087] The first value is used to indicate that the target interface is configured with the target BFD session.

[0088] Specifically, when the driver identifies the above-mentioned target BFD session as a session for detecting the link state of the target forwarding link corresponding to the target interface, a first field can be added to the attribute table corresponding to the target interface, and the value of the first field is set to the first value, which is used to indicate that the target interface is configured with the target BFD session. After generating the above-mentioned attribute table, the driver can send the attribute table of the target interface to the forwarding plane, and send the session information of the target BFD session to the forwarding plane.

[0089] Optionally, each interface corresponds to an attribute table, which can include the above-mentioned first field, and can further include whether the interface is valid, interface identification, bandwidth, whether to enable routing function, whether to enable egress direction configuration, whether to associate with an aggregation port, aggregation port identification, whether to enable port mirroring, and the like.

[0090] S203, based on the target BFD session, sending a target BFD packet through a target forwarding link corresponding to the target interface to perform link detection on the target forwarding link.

[0091] Specifically, when the forwarding plane receives the attribute table and finds that the value of the first field is the first numerical value, it indicates that the target BFD session is used to detect the link state of the target forwarding link corresponding to the target interface, and the link state detection of the target forwarding link of the target interface can be started. For example, the forwarding plane generates a target BFD packet based on the target BFD session, and then periodically sends the BFD packet through the target forwarding link corresponding to the target interface and scans the receiving situation of the response packet of the target BFD packet through the customizer, and further obtains the link detection result of the target forwarding link.

[0092] Further, for the convenience of understanding, taking IPv4 protocol as an example, the basic encapsulation format and bit of the target BFD packet are as follows: Eth II (14B) + IPv4 (20B) + UDP (8B) + BFD (24B), wherein the destination MAC address of the two-layer Ethernet encapsulation Eth II is the multicast MAC address, specifically: 01-00-5E-00-00-B8; the destination IP address of the IPv4 protocol is the multicast IP address, specifically: 224.0.0.184; the destination port number of the UDP is 3784, and the format of the BFD header is referred to Figure 3 , wherein, Figure 3 , wherein, Vers is the version field, that is, the BFD protocol version number; Diag is the diagnostic code field, used to indicate the reason for the change of the session state; Sta is the state field, indicating the local BFD session state; P is the parameter field; F is the response flag field; C is the control plane independent field; A is the authentication field; D is the query mode field; M is the reserved field; Detect Mult is the detection multiple field; Length is the length field; My Discriminator is the unique identifier of the local session, that is, "my discriminator", to distinguish multiple sessions of the network device; Your Discriminator is the remote session identifier, that is, "your discriminator"; Desired Min TX Interval is the minimum packet sending interval supported by the local, that is, "desired minimum sending interval"; Desired Min RX Interval is the minimum packet receiving interval supported by the local, that is, "desired minimum receiving interval"; Required Min Echo RX Interval is the minimum Echo packet receiving interval supported by the local, that is, "required minimum Echo packet receiving interval".

[0093] S204, if it is determined that the target forwarding link is not faulty based on the link detection result of the target BFD packet, performing first marking processing on the target interface.

[0094] The first marking is used to indicate that the link state of the target forwarding link is UP state.

[0095] Specifically, after obtaining the link detection result of the target forwarding link based on step S203, the forwarding plane can identify whether the target forwarding link is faulty; when identifying that the target forwarding link is not faulty, the first marking processing can be performed on the target interface to indicate that the link state of the target forwarding link is UP state, for facilitating data packet forwarding.

[0096] S205, if it is determined that the target forwarding link is faulty based on the link detection result of the target BFD packet, performing second marking processing on the target interface.

[0097] The second marking is used to indicate that the link state of the target forwarding link is Down state.

[0098] Specifically, when identifying that the target forwarding link is faulty based on step S203, the second marking processing can be performed on the target interface to indicate that the link state of the target forwarding link is Down state, so as to facilitate link switching in time during data packet forwarding, thereby ensuring successful data packet forwarding.

[0099] By providing the above fault detection method, whether the forwarding link corresponding to the physical interface is faulty can be sensed in time. In addition, the forwarding link can pass through a routing device or a non-routing device. By using the BFD packet to pre-detect the link of the forwarding link, whether each routing device or non-routing device in the forwarding link is faulty can be sensed in time, thereby avoiding the situation of data packet forwarding failure caused by the inability to sense the device condition of the non-routing device, and further avoiding the situation of service interruption.

[0100] Optionally, the first field can be but is not limited to a BFD_enable field; the bit width of the BFD_enable field can be but is not limited to 1 bit. When the BFD_enable field occupies 1 bit, the first value can be 1 and the second value can be 0.

[0101] Optionally, the attribute table corresponding to the target interface further includes a second field, the second field includes a set indication value, and the set indication value is used to indicate that the target interface has been executed the first marking or the second marking.

[0102] Specifically, in an embodiment, the value of the second field can be directly used to indicate that the target interface is executed with the first mark or the second mark. For example, if the set indication value is the first set value, it can be determined that the target interface is executed with the first mark; if the set indication value is the second set value, it can be determined that the target interface is executed with the second mark.

[0103] In another embodiment, the set indication value is an index value of a target BFD session corresponding to the target interface, which is allocated when the target BFD session is created for the target interface; different BFD sessions correspond to different index values, and correspondingly, different physical interfaces correspond to different index values.

[0104] Specifically, after the state machine negotiation is completed, the control plane dynamically applies an index value for the target BFD session of the target interface from a resource pool, which is used to uniquely represent the BFD session of the target interface for detecting the link state of the forwarding link corresponding to the target interface. The resource pool is an index pool at the software level, which is used to manage the application and release of index values within the set range. The range of the resource pool is related to the specification of the BFD session. If the total specification of the BFD session allowed by the network device is 2K, the value range of the index value can be [0, 2K-1]. On this basis, the control plane includes the index value allocated for the target BFD session in the session information of the target BFD session when the session information is issued. Further, the driver obtains the index value from the session information after receiving the session information, then adds a second field in the attribute table of the target interface, and sets the value of the second field as the index value, that is, the set indication value is the index value, which is used to indicate that the target interface is executed with the first mark or the second mark.

[0105] Optionally, the second field can be but is not limited to a BFD_index field, and correspondingly, the bit width occupied by the field can be determined according to the specification of the BFD session of the out-interface. For example, if the specification of the BFD session allocated by the control plane for the out-interface for detecting the link state of the corresponding forwarding link is 2K, the bit width of the BFD_index field is 11 bits.

[0106] On this basis, the process of executing the first mark processing on the target interface in step S204 if it is determined based on the link detection result of the target BFD packet that the target forwarding link is fault-free can be performed according to the following process: if it is determined based on the link detection result of the target BFD packet that the target forwarding link is fault-free, the value at the position indicated by the index value in the pre-configured state table is set as the first mark value.

[0107] And, if it is determined that the target forwarding link is faulty based on the link detection result of the target BFD packet, a second marking process is performed on the target interface, that is, the value at the position indicated by the index value in the preconfigured state table is set to a second marking value.

[0108] Specifically, the index value allocated by the control plane for the physical interface can be represented by bfd_index. The above-mentioned state table is a hardware table item maintained by the forwarding plane. Based on this, the forwarding plane reads the index value bfd_index in the BFD_index field from the attribute table of the target interface after obtaining the attribute table of the target interface from the driver, and then sets the value at the position indicated by the index value bfd_index in the state table according to the link detection result of the target forwarding link.

[0109] Alternatively, the above-mentioned state table can be denoted as bfd_state table, which is stored in the form of bitmap, and each BFD session occupies 1 bit, and 0 and 1 are used to represent the link state obtained by performing forwarding link detection based on the BFD session, for example, 0 represents Down state and 1 represents UP state. In addition, when the network device needs to manage a large number of BFD sessions, the maintenance of the above-mentioned state table can significantly save memory resources.

[0110] Taking a 2K-specification BFD session as an example, the state table occupies 2K bits, and the format of the state table can be referred to as shown in Figure 4 Each row is 32 bits, a total of 64 rows, and a total of 2048 bits, for example, the first row index value bfd_index0~index value bfd_index31, and so on. On this basis, when the control plane obtains the target BFD session created in advance for the target interface to detect the link state of the forwarding link of the target interface, after obtaining the link detection result of the target forwarding link, when writing the first marking value or the second marking value to the state table, the corresponding target row can be found based on the index value of the target interface, and then the position of the offset of the index value in the target row is found, and then the first marking value or the second marking value is written at the found position; for example, if the target forwarding link is not faulty, the first marking value is written at the found position, and if the target forwarding link is faulty, the second marking value is written at the found position. Alternatively, the first marking value can be 1 and the second marking value can be 0.

[0111] To better understand the embodiment, it is assumed that the index value bfd_index applied for the target BFD session of the target interface is 10, and after negotiation based on the state machine of the target BFD session is completed, the interface state of the target interface is up, and then the state table is issued to the forwarding plane by the driver. Further, after the forwarding plane obtains the link detection result of the target forwarding link according to the foregoing description, the value at the position indicated by the index value 10 in the state table can be set, for example, if the link detection result indicates that the target forwarding link is fault-free, the value at the position indicated by the index value 10 is set to 1, and if the link detection result indicates that the target forwarding link is faulty, the value at the position indicated by the index value 10 is set to 0.

[0112] Optionally, based on any of the foregoing embodiments, the embodiment further provides a process as shown below: obtaining a session deletion indication; if the session deletion indication is used to indicate that the target BFD session of the target interface is deleted, setting the value of the first field in the attribute table corresponding to the target interface to a second value, the second value being used to indicate that the target interface is not configured with a BFD session; and performing the step of performing second marking processing on the target interface.

[0113] Specifically, the session deletion indication can be issued by the control plane after detecting that the forwarding link is deleted or disconnected, or can be issued by the control plane after receiving a deletion command triggered by the administrator through a command line or the like. In this way, after receiving the session deletion indication, one of the processing modes of the driver is that the session deletion indication carries session information, and the session information carries an application type; on this basis, the driver extracts the application type from the session information, and when identifying that the application type is used to represent a BFD session for detecting the link state of the forwarding link of the target interface, the interface information (identifier) of the target interface included in the session information is used to find the information related to the target interface stored locally, and then the deletion processing is performed; at the same time, the driver also issues a deletion indication to the forwarding plane, and the deletion indication can carry the interface information of the target interface, and then the forwarding plane can set the value of the BFD_enable field in the attribute table corresponding to the target interface to a second value 0 based on the deletion indication, to indicate that the target interface is not configured with a BFD session. Another processing mode of the driver is that the session deletion indication carries the interface information (identifier) of the target interface, so that the driver can directly find the information related to the target interface stored locally based on the interface information of the target interface, and then perform the deletion processing; at the same time, the driver also issues a deletion indication to the forwarding plane, and the deletion indication can carry the interface information of the target interface, and then the forwarding plane can set the value of the BFD_enable field in the attribute table corresponding to the target interface to a second value 0 based on the deletion indication, to indicate that the target interface is not configured with a BFD session.

[0114] Further, when the setting indication value of the second field is the index value of the target BFD session corresponding to the target interface, the embodiment further provides the following process: setting the value of the position indicated by the index value in the pre-configured state table to the second mark value; and clearing the index value in the second field in the attribute table corresponding to the target interface.

[0115] Specifically, after receiving the aforementioned deletion indication, the forwarding plane further sets the value of the position indicated by the index value of the target BFD session in the state table to the second mark value 0, to indicate that the link state of the target forwarding link of the target interface is in the Down state; meanwhile, the forwarding plane further clears the index value in the BFD_index field in the attribute table. Further, the forwarding plane closes the detection function of the BFD session for detecting the link state of the target interface.

[0116] So far, the process of the fault detection method is introduced. By providing the aforementioned fault detection method, it is realized that the network device can timely perceive the link state of the network in which the network device is located; and the fault perception is more comprehensive; in addition, the aforementioned link state is obtained by pre-link detection of the forwarding link by the BFD session based on the BFD packet generated by the BFD session when the BFD session for detecting the link state of the forwarding link corresponding to the out interface is configured on the out interface, and the forwarding link can pass through a routing device or a non-routing device. By using the BFD packet to pre-link detect the forwarding link, it can be timely perceived whether each routing device or non-routing device in the forwarding link is faulty, so as to avoid the situation that the data packet forwarding fails due to the inability to perceive the device condition of the non-routing device, and further avoid the situation that the service is interrupted.

[0117] In order to better understand the packet forwarding method provided by the present application, the present application respectively provides Figure 5 the networking architecture diagram of the out interface being an equal-cost routing port, Figure 6 the networking architecture diagram of the out interface being an aggregation port, and the following will be described respectively with the two networking architecture diagrams.

[0118] Figure 5In the shown networking architecture diagram, CE1 and CE2 are customer edge devices, network device A, network device D, network device C1 to network device C3 are routing devices, and network device B1 to network device B3 are non-three-layer devices (non-routing devices), which can be switching devices or transmission devices, etc. Under this networking, portA1, portA2 and portA3 of network device A belong to three equal routing interfaces, respectively corresponding to three equal routing links, which are equal routing link 1, equal routing link 2 and equal routing link 3, wherein: equal routing link 1 is network device A-network device B1-network device C1-network device D; equal routing link 2 is network device A-network device B2-network device C2-network device D; and equal routing link 3 is network device A-network device B3-network device C3-network device D. In addition, Figure 5 PortC1 of network device C1 belongs to an interface of a routing device; similarly, portC2 of network device C2 and portC3 of network device C3 also respectively belong to interfaces of routing devices.

[0119] On this basis, when the data packet arrives at network device A, network device A can select an equivalent route link from the three equivalent route links to send the data packet when CE1 sends the data packet to CE2, and finally network device D sends the data packet to CE2. In order to ensure the successful forwarding of the data packet, the routing devices (network device A, network device C1, network device C2, network device C3) in the networking architecture diagram can detect the link state of the forwarding link of the interface according to the related embodiments of the fault detection method of the present application. For example, for any one of the member ports portA1, portA2 and portA3 of the three equivalent routes of network device A, network device A can configure a BFD session for detecting the link state of the forwarding link corresponding to the member port. Since there may be BFD sessions for detecting different functions during fault detection, the BFD session of the member port can be identified first. If the BFD session is identified as a session for detecting the link state of the forwarding link corresponding to the member port, the value of the first field in the attribute table corresponding to the member port is set to a first value, and the first value is used to indicate that the member port is configured with a BFD session. On this basis, based on the BFD session, the BFD packet is sent through the forwarding link corresponding to the member port to perform link detection on the forwarding link corresponding to the member port. If it is determined based on the link detection result of the BFD packet that the forwarding link is not faulty, the first marking process is performed on the member port to indicate that the link state of the forwarding link corresponding to the member port is UP. If it is determined based on the link detection result of the BFD packet that the forwarding link is faulty, the second marking process is performed on the member port to indicate that the link state of the forwarding link corresponding to the member port is Down.

[0120] Network device A can implement each step of the fault detection process according to any of the above related embodiments, which will not be described in detail here.

[0121] On this basis, when the network device A receives the data message sent from the CE1, the network device A can perform forwarding processing according to the message forwarding method provided in the embodiment, which is roughly as follows: the network device A identifies the out interface of the data message, for example, the identified out interface is the member port portA1, then the network device A can further identify whether the member port portA1 is faulty; if the member port portA1 is not faulty, the network device A identifies the link state of the forwarding link corresponding to the member port portA1, wherein the link state of the forwarding link of the member port portA1 is detected by the network device A based on the foregoing fault detection method; if the identified link state is UP state, that is, the equivalent routing link corresponding to the member port portA1 is not faulty, the network device A forwards the data message by using the member port portA1; if the link state is Down state, that is, the equivalent routing link corresponding to the member port portA1 is faulty due to the unavailability of two-layer or three-layer forwarding, the network device A reselects the out interface for forwarding the data message.

[0122] The network device A can perform each step of the message forwarding process according to any of the foregoing embodiments, which will not be described in detail here.

[0123] Therefore, the link fault in the equivalent routing networking environment is sensed in time and the message forwarding is performed; moreover, the non-routing device (the network device B1, the network device B2 or the network device B3) in the equivalent routing networking environment can sense whether each routing device or non-routing device in the forwarding link is faulty in time by using the BFD message to perform link detection in advance, thereby avoiding the failure of data message forwarding due to the inability to sense the device status of the non-routing device, and further avoiding the interruption of the service.

[0124] Figure 6 In the networking architecture shown in the figure, the CE1 and the CE2 are user edge devices, the network device A and the network device C are routing devices, and the network device B is a non-three-layer device (non-routing device), which can be a switching device or a transmission device, etc. In this networking, the portA1, the portA2 and the portA3 of the network device A form an aggregation port, and the portA1, the portA2 and the portA3 are aggregation member ports respectively. The network device B is a non-three-layer device (also referred to as a non-routing device), which can be a switching device or a transmission device, etc. The portC1, the portC2 and the portC3 of the network device C also form an aggregation port, and the portC1, the portC2 and the portC3 are aggregation member ports respectively.

[0125] On this basis, when the data packet arrives at the network device A, the network device A can select an aggregation member port from the aggregation port to send the data packet to the network device B, and the network device B sends the data packet to the aggregation member port of the network device C, and the network device C receives the data packet through the aggregation member port and then sends it to the CE2 when the CE1 sends the data packet to the CE2.

[0126] In order to ensure the successful forwarding of the data packet, the network device A and the network device C can detect the link state of the forwarding link of the interface according to the related embodiments of the fault detection method of the present application. For the convenience of understanding, the network device A is taken as an example for illustration. For any one of the three aggregation member ports portA1, portA2 and portA3 in the network device A, the network device A can configure a BFD session for detecting the link state of the forwarding link corresponding to the member port. Since there may be BFD sessions for detecting different functions when performing fault detection, the BFD session of the member port can be identified first. If the BFD session is identified as a session for detecting the link state of the forwarding link corresponding to the member port, the value of the first field in the attribute table corresponding to the member port is set to a first value, and the first value is used to indicate that the member port is configured with a BFD session. On this basis, based on the BFD session, the BFD packet is sent through the forwarding link corresponding to the member port to perform link detection on the forwarding link corresponding to the member port. If it is determined based on the link detection result of the BFD packet that the forwarding link is not faulty, the first marking process is performed on the member port to indicate that the link state of the forwarding link corresponding to the member port is UP. If it is determined based on the link detection result of the BFD packet that the forwarding link is faulty, the second marking process is performed on the member port to indicate that the link state of the forwarding link corresponding to the member port is Down.

[0127] The network device A can perform each step of the fault detection process according to any one of the above-mentioned embodiments, which will not be described in detail here.

[0128] Based on this, when network device A receives a data packet sent from CE1, network device A can perform forwarding processing according to the packet forwarding method provided in this embodiment. The general process is as follows: Network device A identifies the outgoing interface of the data packet. For example, if the identified outgoing interface is member port A1, network device A can further identify whether member port A1 is faulty. If member port A1 is not faulty, the link status of the forwarding link corresponding to member port A1 is identified. The link status of the forwarding link of member port A1 is obtained by network device A based on the fault detection method described above. If the identified link status is UP, meaning the forwarding link corresponding to member port A1 is not faulty, then member port A1 is used to forward the data packet. If the link status is Down, meaning the forwarding link corresponding to member port A1 may be faulty due to Layer 2 or Layer 3 forwarding failure, then a new outgoing interface is selected for forwarding the data packet.

[0129] When network device A performs each step of the packet forwarding process, it can be implemented according to any of the aforementioned related embodiments, which will not be described in detail here.

[0130] This enables timely detection of link failures in the aggregated network environment and timely packet forwarding. Moreover, since the aggregated network involves non-routing devices (network device B), by using BFD messages to perform link detection on the forwarding links in advance, it is possible to detect whether each routing device and non-routing device in the forwarding links is faulty in a timely manner. This avoids the situation where data packet forwarding fails due to the inability to detect the device status of non-routing devices, and thus avoids the interruption of services.

[0131] against Figure 5 or Figure 6 Any routing device in the network, comprising various components, interacts with each other to implement the fault detection and packet forwarding processes provided in this application. The structure of the routing device can be referenced from... Figure 7 As shown, the routing device includes a host CPU and a forwarding chip. The host CPU can logically be divided into a management plane, a control plane, and a hardware abstraction layer, which includes drivers and a chip SDK. The forwarding chip can logically be divided into a BFD processing engine, an entry management module, and a forwarding engine. At the logical level, the general process for fault detection is as follows:

[0132] Step 1: The management plane in the host CPU receives a configuration instruction, which may include session information of the BFD session configured for the interface to be detected; the management plane parses the configuration instruction to extract the session information of the BFD session; and passes the session information of the BFD session to the control plane.

[0133] It should be noted that the above configuration indication can be entered by the administrator through the command line, or can be issued by the administrator through the management plane of the network management software. Specifically, when the administrator wants to detect the link state of the forwarding link of the interface, the configuration indication can be directly sent to the routing device through the command line; or, the network management software for managing the network devices in the network is set in the present application, based on which the administrator can issue the configuration indication to the routing device through the network management software.

[0134] Step 2, the control plane performs state machine negotiation based on the received session information of the BFD session, and after the negotiation is completed, the session information is issued to the driver in the hardware abstraction layer.

[0135] It is worth noting that when the control plane performs state machine negotiation, if the state machine negotiation cannot be completed, it indicates that the BFD session cannot take effect, then the control plane can identify the reason, for example, whether there is a configuration error or a routing protocol exception, so that the administrator can timely handle the fault in the network.

[0136] Step 3, the driver identifies the BFD session after receiving the session information, and when identifying the BFD session as being used to detect the link state of the forwarding link of the interface, sets the value of the BFD_enable field in the attribute table of the interface to 1 to indicate that the interface is configured with the aforementioned BFD session; at the same time, writes the index value of the interface into the BFD_index field in the attribute table.

[0137] Step 4, the driver sends the session information of the BFD session and the attribute table of the interface to the forwarding chip through the chip SDK.

[0138] Step 5, after the bfd processing engine in the forwarding chip receives the session information issued by the driver and the attribute table of the interface, generates a BFD packet and performs detection on the forwarding link of the interface.

[0139] Specifically, the bfd processing engine is responsible for maintaining the timing packet sending and timeout detection functions of the BFD session. For example, periodically scan the packet counter, if the counter does not increase within the timeout time, identify the forwarding link failure; otherwise, identify that the forwarding link has no failure.

[0140] Optionally, the above periodic action can be triggered by the hardware timer of the chip, or can be triggered by the risc-v core integrated in the disk, that is, the above bfd processing engine can be a risc-v core. Specifically, the bfd processing engine maintains the session information of the BFD session, such as packet sending interval, detection interval, timeout time, index value of the interface, packet encapsulation, etc.

[0141] Step 6, after the BFD processing engine performs the link detection of the forwarding link of the interface based on the foregoing BFD packet, if it is determined based on the link detection result that the forwarding link is not faulty, the BFD processing engine looks up the position indicated by the index value of the interface in the preconfigured bfd_state table based on the index value of the interface, and sets the value of the looked-up position to 1; if it is determined that the forwarding link is faulty, the value of the looked-up position is set to 0.

[0142] Step 7, when the BFD processing engine detects that the forwarding link of the interface is faulty, in addition to updating the foregoing bfd_state table, the BFD processing engine also reports the fault information of the forwarding link of the interface to the hardware abstraction layer of the host CPU, and the fault information includes BFD session information, and the session information can include the fault condition.

[0143] Step 8, the hardware abstraction layer receives the foregoing fault information through an interrupt, and performs analysis processing on the fault information, then extracts the foregoing session information, and performs format conversion processing on the session information according to a format recognizable by the control plane, and sends the session information to the control plane.

[0144] Step 9, after the control plane receives the session information, the control plane extracts the fault condition from the session information; and after analysis and calculation processing, the control plane updates the software table items of the aggregation port or the equal-cost multi-path member port, and refreshes the hardware table items stored in the forwarding chip according to the updated software table items.

[0145] It is worth noting that most of the hardware table items are stored in the table item management module of the forwarding chip, and the foregoing hardware table items can include but are not limited to MAC table and FIB table; the foregoing table item management module can also store packet receiving counter related information, bfd_state table, and attribute table of the interface, and the like.

[0146] It should be noted that the implementation of the foregoing fault detection process and the packet forwarding process has no sequence, and the routing device can perform the two processes synchronously.

[0147] After the foregoing fault detection process performed by the routing device is introduced, the packet forwarding process performed by the routing device based on the logic structure shown in FIG. 2 is introduced, and the process is as follows: Figure 7

[0148] Step 1, when a data packet enters the routing device from a physical interface of the routing device, the data packet reaches a forwarding engine in a forwarding chip of the routing device after passing through a series of preceding modules. The forwarding engine performs identification processing on the data packet.

[0149] ​Specifically, the forwarding engine identifies whether to perform Layer 2 forwarding or Layer 3 forwarding on the data packet, and if it is identified that Layer 2 forwarding is performed on the data packet, the MAC table in the table entry management module is queried to identify the out interface of the data packet; if it is identified that Layer 3 forwarding is performed on the data packet, the FIB table in the table entry management module is queried to identify the out interface of the data packet.

[0150] Step 2, when the out interface of the data packet is identified as an equal-cost routing port or an aggregation port, one of the member ports is selected to perform forwarding of the data packet according to a preset hash algorithm.

[0151] Step 3, the forwarding engine performs state query processing on the selected member port before performing forwarding of the data packet; if the state of the member port is queried as down, a failover network redundancy strategy is used to reselect a member port to perform forwarding of the data packet.

[0152] Step 4, if the state of the member port is queried as up, the forwarding engine can obtain the attribute table of the member port from the table entry management module in order to further ensure successful forwarding of the data packet.

[0153] Step 5, the forwarding engine queries whether the value of the BFD_enable field in the attribute table is 1, and if it is not 1, it indicates that the member port is not subjected to link detection of the corresponding forwarding link, and the data packet is directly forwarded through the member port at this time; if it is 1, it indicates that the member port is subjected to link detection of the corresponding forwarding link, and then the forwarding engine obtains the bfd_state table from the table entry management module, and obtains the index value of the member port from the BFD_index field in the attribute table, and queries the value at the position indicated by the index value in the bfd_state table.

[0154] Step 6, if the value at the position indicated by the index value is queried as 1, it indicates that the forwarding link corresponding to the member port is normal, and the data packet is directly forwarded using the member port, thereby ensuring successful forwarding of the data packet; if the value at the position indicated by the index value is queried as 0, it indicates that the forwarding link corresponding to the member port is faulty, and at this time a member port can be reselected to perform forwarding of the data packet, thereby timely sensing the failure of the forwarding link in the network, and switching the forwarding link when the failure of the forwarding link is sensed.

[0155] Thus, by providing the packet forwarding method, the fault awareness is more comprehensive, and the fault response speed is faster, without waiting for the calculation and entry update of the complete protocol stack control plane. In addition, in the packet forwarding method provided by the application, the hardware and software level of the network device is changed less, so that the network device can be normally connected with a network device that does not support the packet forwarding method provided by the application, and the compatibility is good.

[0156] Based on the same inventive concept, the application also provides a packet forwarding device, as shown in Figure 8 The device can be applied in a network device, and the device comprises:

[0157] The receiving unit 801 is configured to receive a data packet.

[0158] The first identification unit 802 is configured to identify an out interface of the data packet.

[0159] The second identification unit 803 is configured to identify a link state of a forwarding link corresponding to the out interface if the out interface is fault-free, wherein the link state is obtained by performing link detection on the forwarding link based on a BFD packet generated by a BFD session configured on the out interface for detecting the link state of the forwarding link corresponding to the out interface.

[0160] The forwarding unit 804 is configured to forward the data packet by using the out interface if the second identification unit 803 identifies that the link state is an UP state.

[0161] The processing unit 805 is configured to reselect an out interface for forwarding the data packet if the second identification unit 803 identifies that the link state is a Down state.

[0162] Thus, after determining the out interface of the data packet, in addition to identifying the state of the out interface itself, the link state of the forwarding link corresponding to the out interface is further identified if the out interface is fault-free, so that the link state of the network device in the networking can be timely perceived, and the forwarding of the data packet is successfully realized when the link state is UP. In addition, the above-mentioned link state is obtained by performing link detection on the forwarding link based on a BFD packet generated by a BFD session configured on the out interface for detecting the link state of the forwarding link corresponding to the out interface, and the forwarding link can pass through a routing device or a non-routing device. By using the BFD packet to perform link detection on the forwarding link in advance, whether each routing device or non-routing device in the forwarding link is faulty can be timely perceived, so that the failure of the forwarding of the data packet caused by the inability to perceive the device state of the non-routing device is avoided, and the interruption of the service is avoided.

[0163] Optionally, the second identifying unit 803 is specifically configured to identify that the link state of the forwarding link corresponding to the out interface is in an UP state if the first mark is performed on the out interface, and identify that the link state of the forwarding link corresponding to the out interface is in a Down state if the second mark is performed on the out interface.

[0164] Optionally, the packet forwarding device provided in the embodiment further comprises:

[0165] The determining unit is configured to determine that the out interface is configured with the BFD session for detecting the link state of the forwarding link corresponding to the out interface according to the following method: querying an attribute table of the out interface; and determining that the out interface is configured with the BFD session for detecting the link state of the forwarding link corresponding to the out interface if the value of a first field in the attribute table is a first value.

[0166] Optionally, the second identifying unit 803 is specifically configured to identify that the out interface is performed with the first mark or the second mark according to the following method: identifying that the out interface is performed with the first mark or the second mark according to the value of a second field in the attribute table of the out interface.

[0167] Further, the second field comprises an index value of the BFD session configured for the out interface, and the index values corresponding to different BFD sessions are different; on this basis, the second identifying unit 803 is specifically configured to find the value of a position indicated by the index value of the BFD session configured for the out interface in a preconfigured state table; identify that the out interface is performed with the first mark if the value of the position is a first mark value; and identify that the out interface is performed with the second mark if the value of the position is a second mark value.

[0168] Optionally, based on any of the above embodiments, in the embodiment, the processing unit 805 is specifically configured to take a backup member port of the out interface as the out interface for forwarding the data packet when the out interface is an aggregation port, and take any other member port constituting equal-cost multi-path with the out interface as the out interface for forwarding the data packet when the out interface is an equal-cost multi-path port.

[0169] Further, the processing unit 805 is specifically configured to determine the backup member port of the out interface according to the following method: obtaining a fault switching table of the out interface, the fault switching table comprising interface information of other aggregation member ports of an aggregation port to which the out interface belongs; and selecting one aggregation member port as the backup member port based on the interface information of the other aggregation member ports.

[0170] Optionally, based on any of the above embodiments, the packet forwarding device provided in the embodiment further includes:

[0171] a third identification unit configured to identify a target BFD session;

[0172] a setting unit configured to, if the third identification unit identifies the target BFD session as a session for detecting a link state of a target forwarding link corresponding to a target interface, set a value of a first field in an attribute table corresponding to the target interface to a first numerical value, the first numerical value being used to indicate that the target interface is configured with the target BFD session;

[0173] a sending unit configured to send a target BFD packet through the target forwarding link corresponding to the target interface based on the target BFD session, so as to perform link detection on the target forwarding link;

[0174] an execution unit configured to, if it is determined based on a link detection result of the target BFD packet that the target forwarding link is not faulty, perform first marking processing on the target interface, the first marking being used to indicate that a link state of the target forwarding link is an UP state;

[0175] the execution unit is further configured to, if it is determined based on the link detection result of the target BFD packet that the target forwarding link is faulty, perform second marking processing on the target interface, the second marking being used to indicate that the link state of the target forwarding link is a Down state.

[0176] Further, the attribute table corresponding to the target interface further includes a second field, the second field including a set indication value, the set indication value being used to indicate that the target interface is executed with the first marking or the second marking.

[0177] Further, the set indication value is an index value of the target BFD session corresponding to the target interface, the index value being allocated when the target BFD session is created for the target interface; different BFD sessions correspond to different index values; on this basis, the execution unit is specifically configured to, if it is determined based on the link detection result of the target BFD packet that the target forwarding link is not faulty, set a value of a position indicated by the index value in a preconfigured state table to a first marking value; if it is determined based on the link detection result of the target BFD packet that the target forwarding link is faulty, set the value of the position indicated by the index value in the preconfigured state table to a second marking value.

[0178] Optionally, the packet forwarding device provided in the embodiment further includes:

[0179] an acquisition unit configured to acquire a session deletion indication;

[0180] The setting unit is further configured to set a value of a first field in the attribute table corresponding to the target interface to a second value if the session deletion instruction is used to instruct to delete the target BFD session of the target interface, and the second value is used to indicate that the target interface is not configured with a BFD session.

[0181] The execution unit is specifically configured to execute the step of performing the second marking processing on the target interface.

[0182] Further, the attribute table corresponding to the target interface further includes a second field, and the second field includes a set indication value, and the set indication value is used to indicate that the target interface is executed with the first marking or the second marking.

[0183] On this basis, the execution unit is further configured to set a value of a position indicated by the index value in a pre-configured state table to a second marking value when the set indication value is the index value of the target BFD session corresponding to the target interface.

[0184] The setting unit is further configured to clear the index value in the second field in the attribute table corresponding to the target interface.

[0185] After introducing the packet forwarding method and device of the example embodiments of the present application, next, the computing device according to another example embodiment of the present application is introduced. The computing device can be a computer device, and the computer device can be the network device described above.

[0186] Those skilled in the art can understand that each aspect of the present application can be implemented as a system, a method or a program product. Therefore, each aspect of the present application can be specifically implemented as follows: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation combining hardware and software aspects, which can be collectively referred to as "circuitry", "module" or "system" here.

[0187] In some possible implementations, the computing device according to the present application can include at least one processor and at least one memory. The memory stores program code which, when executed by the processor, causes the processor to perform the steps in the packet forwarding method and the fault detection method according to various example embodiments of the present application described above in the specification. For example, the processor can perform the packet forwarding process in steps S101-S105 as shown in Figure 1 , and can perform the fault detection process in steps S201-S205 as shown in Figure 2 .

[0188] The following refers to the accompanying drawings. Figure 9The computing device 90 according to an embodiment of the present application is described in more detail below. Figure 9 The computing device 90 shown is only one example of a computing device and should not be taken to limit the scope of embodiments of the present application to the functionality or use of the particular machine shown.

[0189] As shown Figure 9 The computing device 90 is shown in the form of a general-purpose computing device. The components of computing device 90 can include, but are not limited to, at least one processor 91, at least one memory 92, and a bus 93 that couples various system components including the memory 92 and the processor 91.

[0190] The bus 93 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, and a local bus using any of a variety of bus architectures.

[0191] The memory 92 can include read-only memory (ROM) 923 in the form of flash-based or other types of nonvolatile memory, and can further include random access memory (RAM) 921 in the form of synchronous dynamic RAM (SDRAM) and / or cache memory 922.

[0192] The memory 92 can include a program / utility 925 having a set of program modules 924, including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which can include an implementation of a networking environment, or a portion thereof. In particular, the program modules 924 can include a program module for implementing the functionality of the present application.

[0193] The computing device 90 can also communicate with one or more external devices 94 such as a keyboard or a pointing device, through an I / O interface 95. Additionally, the computing device 90 can communicate with one or more devices that enable a user to interact with the computing device 90, and / or one or more devices that enable the computing device 90 to communicate with one or more other computing devices. Such communication can be via an I / O interface 95. The computing device 90 can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or the Internet) through a network adapter 96. As shown, the network adapter 96 communicates with the other components of the computing device 90 via the bus 93. It should be understood that although not shown, other hardware and / or software components that can be used in conjunction with the computing device 90 can include, but are not limited to, microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems, etc.

[0194] Based on the same inventive concept, the embodiment of the present application further provides a computer readable medium storing processor executable instructions for executing the packet forwarding method provided by the present application.

[0195] Those skilled in the art will appreciate that embodiments of the present application can be supplied as a method, a system, or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage, etc.) embodying computer usable program code.

[0196] Obviously, various modifications and changes can be made to the present application by those skilled in the art without departing from the spirit and scope of the present application. Thus, it is intended that the present application embrace all such modifications and changes and, accordingly, the application is not to be construed as limited to the embodiments described herein.

Claims

1. A packet forwarding method, characterized by, The method is applied to a network device, and comprises the following steps: receiving a data packet; identifying an out interface of the data packet; if the out interface is not faulty, identifying a link state of a forwarding link corresponding to the out interface, wherein the link state is obtained by performing link detection on the forwarding link based on a BFD packet generated by a BFD session configured for detecting the link state of the forwarding link corresponding to the out interface; if the link state is an up state, forwarding the data packet by using the out interface; if the link state is a down state, reselecting an out interface for forwarding the data packet, comprising: when the out interface is an aggregation port, selecting a backup member port of the out interface as the out interface for forwarding the data packet; and when the out interface is an equal-cost multi-path port, selecting any other member port constituting an equal-cost multi-path with the out interface as the out interface for forwarding the data packet; wherein the backup member port of the out interface is determined by the following method: obtaining a fault switching table of the out interface, wherein the fault switching table comprises interface information of other aggregation member ports of an aggregation port to which the out interface belongs; based on the interface information of the other aggregation member ports, selecting one aggregation member port as the backup member port.

2. The method of claim 1, wherein, identifying the link state of the forwarding link corresponding to the out interface, comprising: if the out interface is marked with a first mark, identifying the link state of the forwarding link corresponding to the out interface as an up state; if the out interface is marked with a second mark, identifying the link state of the forwarding link corresponding to the out interface as a down state.

3. The method of claim 1, wherein, determining that the out interface is configured with the BFD session for detecting the link state of the forwarding link corresponding to the out interface by the following method: inquiring an attribute table of the out interface; if a first field in the attribute table has a first value, determining that the out interface is configured with the BFD session for detecting the link state of the forwarding link corresponding to the out interface.

4. The method of claim 2, wherein, identifying that the out interface is marked with the first mark or the second mark by the following method: identifying that the out interface is marked with the first mark or the second mark according to a value of a second field in the attribute table of the out interface.

5. The method of claim 4, wherein, the second field comprises an index value of a BFD session configured for the out interface, and different BFD sessions correspond to different index values; identifying that the out interface is marked with the first mark or the second mark according to the value of the second field, comprising: finding a value at a position indicated by the index value of the BFD session configured for the out interface in a preconfigured state table; if the value at the position is a first mark value, identifying that the out interface is marked with the first mark; if the value at the position is a second mark value, identifying that the out interface is marked with the second mark.

6. The method of claim 3 or 4, wherein, further comprising: identifying a target BFD session; If the target BFD session is identified as a session for detecting a link state of a target forwarding link corresponding to the target interface, a value of a first field in an attribute table corresponding to the target interface is set as a first numerical value, and the first numerical value is used to indicate that the target interface is configured with the target BFD session. Based on the target BFD session, a target BFD packet is sent through the target forwarding link corresponding to the target interface, so as to perform link detection on the target forwarding link. If it is determined that the target forwarding link is fault-free based on a link detection result of the target BFD packet, first marking processing is performed on the target interface, and the first marking is used to indicate that the link state of the target forwarding link is an UP state. If it is determined that the target forwarding link is faulty based on the link detection result of the target BFD packet, second marking processing is performed on the target interface, and the second marking is used to indicate that the link state of the target forwarding link is a Down state.

7. The method of claim 6, wherein, The attribute table corresponding to the target interface further includes a second field, and the second field includes a set indication value, and the set indication value is used to indicate that the target interface is executed with the first marking or the second marking. If it is determined that the target forwarding link is fault-free based on the link detection result of the target BFD packet, first marking processing is performed on the target interface, and the first marking is used to indicate that the link state of the target forwarding link is an UP state. When the set indication value is an index value of a target BFD session corresponding to the target interface, if it is determined that the target forwarding link is fault-free based on the link detection result of the target BFD packet, a value of a position indicated by the index value in a preconfigured state table is set as a first marking value. If it is determined that the target forwarding link is faulty based on the link detection result of the target BFD packet, second marking processing is performed on the target interface, and the second marking is used to indicate that the link state of the target forwarding link is a Down state. When the set indication value is an index value of the target interface, if it is determined that the target forwarding link is faulty based on the link detection result of the target BFD packet, a value of a position indicated by the index value in a preconfigured state table is set as a second marking value. The index value of the target BFD session is allocated when the target BFD session is created for the target interface, and index values corresponding to different BFD sessions are different.

8. The method of claim 6, wherein, The method further includes: An session deletion indication is acquired. If the session deletion indication is used to indicate that the target BFD session of the target interface is deleted, a value of a first field in an attribute table corresponding to the target interface is set as a second numerical value, the second numerical value is used to indicate that the target interface is not configured with a BFD session, and The step of performing second marking processing on the target interface is executed. The attribute table corresponding to the target interface further includes a second field, and the second field includes a set indication value, and the set indication value is used to indicate that the target interface is executed with the first marking or the second marking. When the set indication value is an index value of a target BFD session corresponding to the target interface, a value of a position indicated by the index value in a preconfigured state table is set as a second marking value. Clear the index value in the second field in the attribute table corresponding to the target interface.

9. A packet forwarding device, characterized by, The device is applied to a network device and includes: A receiving unit configured to receive a data packet; A first identifying unit configured to identify an out-interface of the data packet; A second identifying unit configured to identify a link state of a forwarding link corresponding to the out-interface if the out-interface is fault-free, wherein the link state is obtained by performing link detection on the forwarding link based on a BFD packet generated by a BFD session configured for detecting the link state of the forwarding link corresponding to the out-interface; A forwarding unit configured to forward the data packet by using the out-interface if the second identifying unit identifies that the link state is an UP state; A processing unit configured to reselect an out-interface for forwarding the data packet if the second identifying unit identifies that the link state is a Down state; The processing unit is specifically configured to select a backup member interface of the out-interface as the out-interface for forwarding the data packet when the out-interface is an aggregation interface, or select any other member interface constituting equal-cost multi-path with the out-interface as the out-interface for forwarding the data packet when the out-interface is an equal-cost multi-path interface. The processing unit is specifically configured to determine the backup member interface of the out-interface by the following method: obtaining a fault switching table of the out-interface, wherein the fault switching table includes interface information of other aggregation member interfaces of an aggregation interface to which the out-interface belongs; and selecting one aggregation member interface as the backup member interface based on the interface information of the other aggregation member interfaces.

Citation Information

Patent Citations

  • Path state notification method, path switching method, forwarding equipment and system

    CN110113259A

  • Message processing method and device

    CN111478851A