Patent Description:
In a network, when a fault occurs on a path, traffic on the path may be switched to another path for transmission. For example, traffic is transmitted from a source node to a destination node along a path A. When all links to the destination node that include an intermediate node on the path A become faulty, the source node switches the traffic to a path B for transmission. The path B no longer includes the intermediate node. However, in a path switching process, a severe traffic packet loss is likely to occur. Consequently, network transmission reliability is reduced.

Further, <CIT> refers to a segment routing identifier (SID) allocation method and segment routing (SR) node, the method comprising: an SR management node learns the address information of the SR nodes in the network and allocates SID information to the SR nodes; the SR management node transmits the allocated SID information to each SR node in the network by multicasting internal gateway protocol (IGP) packets or by the extending of configuration management packets.

Further, <CIT> refers to methods and devices for constructing a label and forwarding a label packet. A node receives a message which carries a segment list and a segment list Identifier (ID) for identifying the segment list. The node constructs a label forwarding table according to the segment list and the segment list ID, and performs forwarding according to the label forwarding table; and/or the node maintains a mapping relationship between the segment list and the segment list ID.

Further, the document "<NPL>and, refers to different segment routing use cases.

Based on this, embodiments of this application provide a method and a first network device for processing link state information, to reduce a traffic packet loss in a path switching process, thereby improving network transmission reliability. The above mentioned problem is solved by the subject matter of the independent claims. Further implementation forms are provided in the dependent claims.

To describe the technical solutions in the embodiments of this application more clearly, the following briefly describes the accompanying drawings required for describing the embodiments. Apparently, the accompanying drawings in the following description show merely some embodiments of this application, and an ordinary person skilled in the art may derive other drawings from these accompanying drawings.

For example, in a scenario example shown in <FIG>, when a link between an ASG (English: aggregation site gateway, ASG for short) <NUM> and a provider (English: provider, P for short) device <NUM> and/or a link between the ASG <NUM> and an ASG <NUM> are/is not faulty, a path from the ASG <NUM> to a CSG <NUM> is reachable, and traffic is transmitted through a segment routing (English: segment routing, SR for short) tunnel A from a cell site gateway (English: Cell site gateway, CSG for short) <NUM> to the CSG <NUM>. Nodes along the SR tunnel A include the CSG <NUM>, the ASG <NUM>, the P device <NUM>, an ASG <NUM>, and the CSG <NUM>. When both the link between the ASG <NUM> and the P device <NUM> and the link between the ASG <NUM> and the ASG <NUM> are faulty, the path from the ASG <NUM> to the CSG <NUM> is unreachable, and the CSG <NUM> may switch the traffic from the SR tunnel A to an SR tunnel B for transmission. Nodes along the SR tunnel B include the CSG <NUM>, a CSG <NUM>, the ASG <NUM>, a P <NUM>, an ASG <NUM>, and the CSG <NUM>. In addition, after the CSG <NUM> switches the traffic from the SR tunnel A to the SR tunnel B for transmission, if the link between the ASG <NUM> and the P device <NUM> and/or the link between the ASG <NUM> and the ASG <NUM> recover/recovers from a faulty state, the path from the ASG <NUM> to the CSG <NUM> is reachable, and the CSG <NUM> may switch the traffic from the SR tunnel B back to the SR tunnel A for transmission.

In some cases, for example, the open shortest path first (English: Open Shortest Path First, OSPF for short) protocol is used in a network, when both the link between the ASG <NUM> and the P device <NUM> and the link between the ASG <NUM> and the ASG <NUM> are faulty, the ASG <NUM> sends two different types of link state information to the CSG <NUM>, to indicate the CSG <NUM> to no longer use the SR tunnel A to send traffic to the CSG <NUM>. One type of link state information, that is, link state information A, is used to indicate the CSG <NUM> to delete link state information E previously received from the ASG <NUM>. The link state information E carries a SID of the CSG <NUM>. The link state information A may be carried in an opaque (English: opaque) link-state advertisement (English: link state advertisement, LSA for short) defined according to the OSPF, and sent through the opaque LSA. The other type of link state information, that is, link state information B, is used to indicate the CSG <NUM> to delete link state information F previously received from the ASG <NUM>. The link state information B carries information for computing a route to the CSG <NUM>. The link state information B may be carried in a network summary LSA (English: network summary LSA) or another type of LSA defined according to the OSPF, and sent through the network summary LSA or the another type of LSA. Similarly, when the link between the ASG <NUM> and the P device <NUM> and/or the link between the ASG <NUM> and the ASG <NUM> recover/recovers from a faulty state, the ASG <NUM> also sends two different types of link state information to the CSG <NUM>, to indicate the CSG <NUM> to use the SR tunnel A again to send traffic to the CSG <NUM>. One type of link state information, that is, link state information C, carries the SID of the CSG <NUM>, and is used to indicate the CSG <NUM> to provide the SID of the CSG <NUM> for the route to the CSG <NUM> based on the link state information C. The link state information C may be carried in an opaque LSA defined according to the OSPF. The other type of link state information, that is, link state information D, carries the information for computing the route to the CSG <NUM>, and is used to indicate the CSG <NUM> to update a route to the CSG <NUM> based on the link state information D. The link state information D may be carried in a network summary LSA or another type of LSA defined according to the OSPF.

Because the link state information A and the link state information B are carried in different packets for transmission, in-order transmission of the link state information A and the link state information B cannot be ensured. Therefore, when both the link between the ASG <NUM> and the P device <NUM> and the link between the ASG <NUM> and the ASG <NUM> are faulty, the CSG <NUM> may receive the link state information A before the link state information B, or may receive the link state information B before the link state information A.

When receiving the link state information A, the CSG <NUM> deletes, from a link state database (English: link state database, LSDB for short) of the CSG <NUM>, the link state information E previously received from the ASG <NUM>, where the link state information E carries the SID of the CSG <NUM>. However, if the CSG <NUM> has not received the link state information B at this time, the LSDB of the CSG <NUM> also stores the link state information F previously received from the ASG <NUM>, where the link state information F carries the information for computing the route to the CSG <NUM>. When the link state information F is not deleted from the LSDB, the CSG <NUM> does not delete the route that is to the CSG <NUM> through the ASG <NUM> and that is computed based on the link state information F. The CSG <NUM> does not recompute, based on link state information that is recorded in the LSDB and that is sent by the ASG <NUM>, the route to the CSG <NUM> through the ASG <NUM>, either. Therefore, the CSG <NUM> does not switch the traffic from the SR tunnel A to the SR tunnel B for forwarding. When the link state information E is deleted from the LSDB, the CSG <NUM> deletes the SID of the CSG <NUM> that corresponds to the route to the CSG <NUM> through the ASG <NUM>. Therefore, the CSG <NUM> can no longer use the SR tunnel A to perform traffic forwarding. The CSG <NUM> does not delete the link state information F from the LSDB of the CSG <NUM> until the CSG <NUM> receives the link state information B. After the link state information F is deleted from the LSDB, the CSG <NUM> deletes the route that is to the CSG <NUM> through the ASG <NUM> and that is computed based on the link state information F. Then, the CSG <NUM> computes the route to the CSG <NUM> through the ASG <NUM> based on the link state information sent by the ASG <NUM>, to switch the traffic from the SR tunnel A to the SR tunnel B for forwarding. It can be learned from above that, because the in-order transmission of the link state information A and the link state information B cannot be ensured, if the CSG <NUM> receives the link state information A before the link state information B, during a time period in which the CSG <NUM> receives the link state information A but has not received the link state information B, the CSG <NUM> can no longer use the SR tunnel A to perform traffic forwarding, and cannot switch the traffic from the SR tunnel A to the SR tunnel B for forwarding, either. Consequently, a traffic packet loss is caused.

Further, because the link state information C and the link state information D are also carried in different packets for transmission, in-order transmission of the link state information C and the link state information D cannot be ensured. Therefore, when the link between the ASG <NUM> and the P device <NUM> and/or the link between the ASG <NUM> and the ASG <NUM> recover/recovers from a faulty state, the CSG <NUM> may receive the link state information C before the link state information D, or may receive the link state information D before the link state information C.

When receiving the link state information D, the CSG <NUM> records the link state information D in the LSDB of the CSG <NUM>. When the link state information D has been recorded in the LSDB, the CSG <NUM> computes, based on the link state information D, the route to the CSG <NUM> through the ASG <NUM>, and updates the route to the CSG <NUM> through the ASG <NUM> to the route from the ASG <NUM> to the CSG <NUM>. In this way, the CSG <NUM> no longer uses the SR tunnel B to perform traffic forwarding. However, if the CSG <NUM> has not received the link state information C at this time, the link state information C is not recorded in the LSDB of the CSG <NUM>. In this case, the CSG <NUM> cannot provide, based on the link state information C, the SID of the CSG <NUM> for the route to the CSG <NUM> through the ASG <NUM>. Therefore, the CSG <NUM> cannot use the SR tunnel A to perform traffic forwarding, either. The CSG <NUM> records the link state information C in the LSDB of the CSG <NUM> only after receiving the link state information C. The CSG <NUM> can provide, based on the link state information C, the SID of the CSG <NUM> for the route to the CSG <NUM> through the ASG <NUM> only when the link state information C has been recorded in the LSDB. Therefore, the CSG <NUM> can use the SR tunnel A to perform traffic forwarding. It can be learned from above that, because the in-order transmission of the link state information C and the link state information D cannot be ensured, if the CSG <NUM> receives the link state information D before the link state information C, during a time period in which the CSG <NUM> receives the link state information D but has not received the link state information C, the CSG <NUM> can no longer use the SR tunnel B to perform traffic forwarding, and cannot switch the traffic from the SR tunnel B back to the SR tunnel A for forwarding, either. Consequently, a traffic packet loss is caused.

To avoid the traffic packet loss that is caused because the link state information A is received before the link state information B, the CSG <NUM> may delete the link state information E and the link state information F from the LSDB of the CSG <NUM> when receiving the link state information A. In this way, even if the CSG <NUM> has not received the link state information B at this time, both the link state information E and the link state information F in the LSDB of the CSG <NUM> may be deleted. Therefore, the CSG <NUM> not only deletes the SID of the CSG <NUM> that is provided for the route to the CSG <NUM> through the ASG <NUM>, but also deletes the route to the CSG <NUM> through the ASG <NUM>. This avoids a case in which the CSG <NUM> continues to use the SR tunnel A to perform traffic forwarding when a link between the ASG <NUM> and the CSG <NUM> is faulty, thereby avoiding a traffic packet loss. Further, the CSG <NUM> computes, based on the link state information that is sent by the ASG <NUM> and that is recorded in the LSDB, the route to the CSG <NUM> through the ASG <NUM>, and provides the SID of the CSG <NUM> for the route to the CSG <NUM> through the ASG <NUM>. In this way, the CSG <NUM> can switch the traffic from the SR tunnel A to the SR tunnel B for forwarding. It can be learned from above that, when the in-order transmission of the link state information A and the link state information B cannot be ensured, even if the CSG <NUM> receives the link state information A before the link state information B, during the time period in which the CSG <NUM> receives the link state information A but has not received the link state information B, the CSG <NUM> can switch the traffic from the SR tunnel A to the SR tunnel B for forwarding, thereby avoiding the traffic packet loss.

To avoid the packet loss problem that is caused because the link state information D is received before the link state information C, after receiving the link state information D, the CSG <NUM> may determine whether the link state information C has been recorded in the LSDB of the CSG <NUM>. If the CSG <NUM> has received the link state information C at this time, and the link state information C has been recorded in the LSDB of the CSG <NUM>, the CSG <NUM> may record the link state information D in the LSDB of the CSG <NUM>. If the CSG <NUM> has not received the link state information C at this time, the CSG <NUM> records the link state information D in the LSDB of the CSG <NUM> after the link state information C has been recorded in the LSDB of the CSG <NUM>. In this way, even if the CSG <NUM> receives the link state information D before the link state information C, the link state information D is recorded in the LSDB of the CSG <NUM> after the link state information C has been recorded. Therefore, when updating the route based on the LSDB, the CSG <NUM> not only can update the route to the CSG <NUM> to the route to the CSG <NUM> through the ASG <NUM> based on the link state information D, but also can provide the SID of the CSG <NUM> for the route to the CSG <NUM> through the ASG <NUM> based on the link state information C. In this way, the CSG <NUM> can switch the traffic back to the SR tunnel A for forwarding. Therefore, when the in-order transmission of the link state information C and the link state information D cannot be ensured, even if the CSG <NUM> receives the link state information D before the link state information C, during the time period in which the CSG <NUM> receives the link state information D but has not received the link state information C, the CSG <NUM> can continue to use the SR tunnel B to perform traffic forwarding, thereby avoiding the traffic packet loss.

It should be noted that the network shown in <FIG> may be an OSPF network. For example, the ASG <NUM> and the ASG <NUM> may be devices at a boundary between two OSPF areas (English: area). For example, the CSG <NUM>, the CSG <NUM>, the ASG <NUM>, and the ASG <NUM> are included in an area <NUM>, and the ASG <NUM>, the ASG <NUM>, the P <NUM>, the P <NUM>, the ASG <NUM>, and the ASG <NUM> are included in an area <NUM>. For another example, the ASG <NUM> and the ASG <NUM> may be devices at a boundary between two OSPF processes (English: process). For example, the CSG <NUM>, the CSG <NUM>, the ASG <NUM>, and the ASG <NUM> are included in an OSPF process <NUM>, and the ASG <NUM>, the ASG <NUM>, the P <NUM>, the P <NUM>, the ASG <NUM>, and the ASG <NUM> are included in an OSPF process <NUM>. In addition, the network shown in <FIG> may be an intermediate system to intermediate system (English: intermediate system to intermediate system, IS-IS for short) network.

It can be understood that the foregoing scenario is merely a scenario example provided in this embodiment of this application, and this embodiment of this application is not limited to this scenario.

With reference to the scenario shown in <FIG>, an embodiment of this application provides a method <NUM> for processing link state information. As shown in <FIG>, the method <NUM> may include the following steps.

<NUM>: The CSG <NUM> receives link state information sent by the ASG <NUM>.

In an SR network, when a link from the ASG <NUM> to the CSG <NUM> is faulty, the ASG <NUM> may send, to the CSG <NUM>, link state information A used to indicate the CSG <NUM> to delete link state information E, and the ASG <NUM> also sends link state information B used to indicate the CSG <NUM> to delete link state information F. The link state information E and the link state information F are sent by the ASG <NUM> to the CSG <NUM>, and have been recorded in an LSDB of the CSG <NUM>. The link state information E carries a SID of the CSG <NUM>, and the link state information F carries information for computing a route to the CSG <NUM>. The information for computing the route to the CSG <NUM> may include a device identifier of the CSG <NUM>, a device identifier of the ASG <NUM>, and the like. The device identifier of the CSG <NUM> may be an Internet Protocol (English: Internet Protocol, IP for short) address of the CSG <NUM>. The device identifier of the ASG <NUM> may be an IP address of the ASG <NUM>.

When the fault of the link from the ASG <NUM> to the CSG <NUM> is rectified, the ASG <NUM> may send, to the CSG <NUM>, link state information C carrying the SID of the CSG <NUM>, and may also send, to the CSG <NUM>, link state information D used to indicate the CSG <NUM> to update a route to the CSG <NUM>. The link state information D carries information for computing the route to the CSG <NUM>. The information for computing the route to the CSG <NUM> may include a device identifier of the CSG <NUM>, a device identifier of the ASG <NUM>, and the like. The device identifier of the CSG <NUM> may be an IP address of the CSG <NUM>, and the device identifier of the ASG <NUM> may be an IP address of the ASG <NUM>.

It can be understood that, because the link state information A and the link state information B are carried in two different packets and sent through the packets, in-order transmission of the link state information A and the link state information B cannot be ensured. The ASG <NUM> may send the link state information A and the link state information B at the same time, may send the link state information A before the link state information B, or may send the link state information B before the link state information A. The CSG <NUM> may receive the link state information A and the link state information B at the same time, may receive the link state information A before the link state information B, or may receive the link state information B before the link state information A. In addition, because the link state information C and the link state information D are carried in two different packets and sent through the packets, in-order transmission of the link state information C and the link state information D cannot be ensured. The ASG <NUM> may send the link state information C and the link state information D at the same time, may send the link state information C before the link state information D, or may send the link state information D before the link state information C. The CSG <NUM> may receive the link state information C and the link state information D at the same time, may receive the link state information C before the link state information D, or may receive the link state information D before the link state information C.

For example, a network in which the CSG <NUM> and the ASG <NUM> are located may be an OSPF network, and the link state information sent by the ASG <NUM> to the CSG <NUM> may be carried in an LSA defined according to the OSPF protocol. Specifically, the link state information A, the link state information C, and the link state information E may be carried in an opaque LSA and sent by the ASG <NUM> to the CSG <NUM>. The link state information B, the link state information D, and the link state information F may be carried in a router LSA (English: router LSA), a network LSA (English: network LSA), a network summary LSA, an autonomous system boundary router (English: autonomous system boundary router, ASBR for short) summary LSA (English: ASBR summary LSA), an autonomous system (English: autonomous system, AS for short) external LSA (English: AS external LSA), or a not-so-stubby area (English: not so stubby area, NSSA for short) LSA, and sent by the ASG <NUM> to the CSG <NUM>.

In some implementations, if the network in which the CSG <NUM> and the ASG <NUM> are located is an OSPF network, the ASG <NUM> may be a device at a boundary between two OSPF areas or a device at a boundary between two OSPF processes. For example, both the CSG <NUM> and the ASG <NUM> are located in an OSPF area <NUM>, and the ASG <NUM> is also located in an OSPF area <NUM>. The ASG <NUM> receives, from the OSPF area <NUM>, traffic sent by the CSG <NUM>, and sends the traffic to the OSPF area <NUM>, so that the traffic is transmitted to the CSG <NUM>. For another example, both the CSG <NUM> and the ASG <NUM> exist in an OSPF process <NUM>, and the ASG <NUM> also exists in an OSPF process <NUM>. The ASG <NUM> receives, from the OSPF process <NUM>, traffic sent by the CSG <NUM>, and sends the traffic to the OSPF process <NUM>, so that the traffic is transmitted to the CSG <NUM>.

In addition, the network in which the CSG <NUM> and the ASG <NUM> are located may alternatively be an IS-IS network. In this case, the link state information sent by the ASG <NUM> to the CSG <NUM> may be carried in a link state packet (English: Link State PDU, LSP for short) defined according to the IS-IS protocol.

<NUM>: If the link state information is the link state information A, the CSG <NUM> deletes the link state information E and the link state information F from the LSDB based on the link state information A.

When the LSDB of the CSG <NUM> stores the link state information F, a route <NUM> to the CSG <NUM> through the ASG <NUM> is recorded in a routing table of the CSG <NUM>. When the LSDB of the CSG <NUM> stores the link state information E, a SID of the CSG <NUM> is recorded for the route <NUM> in the routing table of the CSG <NUM>, and a forwarding entry <NUM> is recorded in a forwarding table of the CSG <NUM>. The forwarding entry <NUM> includes the SID of the CSG <NUM> and a next-hop network device of the CSG <NUM> in the route <NUM>. In this way, the CSG <NUM> can use the SR tunnel A to perform traffic forwarding.

When receiving the link state information A, the CSG <NUM> may delete the link state information E and the link state information F from the LSDB of the CSG <NUM>. The link state information A may be used to indicate the CSG <NUM> to delete link state information about the CSG <NUM> that is stored in the CSG <NUM>, that is, the link state information E and the link state information F. In this case, the link state information A may be considered as link state information of the CSG <NUM>. In this way, even if the CSG <NUM> has not received the link state information B at this time, both the link state information E and the link state information F may be deleted from the LSDB of the CSG <NUM>. When the link state information E is deleted from the LSDB of the CSG <NUM>, the SID of the CSG <NUM> recorded for the route <NUM> is deleted from the routing table of the CSG <NUM>. When no SID of the CSG <NUM> is recorded for the route <NUM>, the forwarding entry <NUM> is also deleted from the forwarding table of the CSG <NUM>. In this way, the CSG <NUM> no longer uses the SR tunnel A to perform traffic forwarding. When the link state information F is deleted from the LSDB of the CSG <NUM>, the route <NUM> is deleted from the routing table of the CSG <NUM>. Then, the CSG <NUM> computes a route <NUM> to the CSG <NUM> through the ASG <NUM> based on link state information that is sent by the ASG <NUM> and that is recorded in the LSDB, records the route <NUM> in the routing table, records a SID of the CSG <NUM> for the route <NUM> in the routing table, and creates a forwarding entry <NUM> in the forwarding table. The SID of the CSG <NUM> and a next hop of the CSG <NUM> in the route <NUM> are recorded in the forwarding entry <NUM>. In this way, the CSG <NUM> can use the SR tunnel B to perform traffic forwarding. It can be learned from above that, when the in-order transmission of the link state information A and the link state information B cannot be ensured, even if the CSG <NUM> receives the link state information A before the link state information B, during a time period in which the CSG <NUM> receives the link state information A but has not received the link state information B, the CSG <NUM> can switch traffic from the SR tunnel A to the SR tunnel B for forwarding, thereby avoiding a traffic packet loss.

In some implementations, the link state information A may carry a first indication identifier, to indicate the CSG <NUM> to delete the link state information F from the LSDB. After the CSG <NUM> receives the link state information A, if the CSG <NUM> reads the first indication identifier from the link state information A, the CSG <NUM> may delete the link state information E from the LSDB of the CSG <NUM> based on the link state information A, and may also delete the link state information F from the LSDB of the CSG <NUM> based on the first indication identifier in the link state information A. If the CSG <NUM> cannot read the first indication identifier from the link state information A, the CSG <NUM> may delete the link state information E from the LSDB of the CSG <NUM> based on the link state information A, without deleting the link state information F from the LSDB of the CSG <NUM> based on the link state information A. It can be learned from above that, by adding the first indication identifier to the link state information A, the ASG <NUM> may indicate, to the CSG <NUM>, whether the CSG <NUM> is to synchronously delete the link state information E and the link state information F. In this way, a processing manner of route withdrawal can be more flexibly configured.

If the link state information A is carried in a first LSA defined according to the OSPF protocol and sent through the first LSA, the first indication identifier may be carried in an LSA header (English: header) of the first LSA. With reference to a description in Internet Engineering Task Force (English: Internet Engineering Task Force, IETF for short) Request for Comments (English: Request For Comments, RFC for short) <NUM>, the first LSA may use an LSA header shown in <FIG>. The first indication identifier may be carried in an options (English: options) field in the LSA header. With reference to a description in IETF RFC <NUM>, the options field in the LSA header of the first LSA may use a structure shown in <FIG>. An external attributes bit (English: external attributes bit, EA bit for short) has been explicitly deprecated. Therefore, in the options field in the LSA header of the first LSA, an EA bit may be replaced by an SR bit, and the SR bit is used to carry the first indication identifier. Specifically, if the SR bit in the first LSA is set, the link state information A carries the first indication identifier. If the SR bit in the first LSA is not set, the link state information A does not carry the first indication identifier.

It should be noted that the LSA header shown in <FIG> includes a link state age (English: LS age) field, an options field, a link state type (English: LS type), a link state identifier (English: a link state ID) field, an advertising router (English: advertising router) field, a link state sequence number (English: LS sequence number), a link state checksum (English: LS checksum), and a length (English: length) field. The options field shown in <FIG> includes a DN bit (used to prevent a loop), an O bit (used to identify whether an opaque LSA is to be received), an EA bit (used to identify whether an external attributes LSA is to be received), a DC bit (used to identify a circuit for router processing), and an N/P bit (used to identify an LSA whose processing type is <NUM>), an MC bit (used to identify whether a multicast packet is to be forwarded), an E bit (used to identify an LSA flooding mode), and an MT bit (used to identify a multi-topology capability).

<NUM>: If the link state information is the link state information B, the CSG <NUM> deletes the link state information F from the LSDB based on the link state information B.

When receiving the link state information B, the CSG <NUM> may delete the link state information F from the LSDB of the CSG <NUM>. When the link state information F is deleted from the LSDB, the route <NUM> is deleted from the routing table of the CSG <NUM>. Then, the CSG <NUM> computes the route <NUM> based on the link state information that is sent by the ASG <NUM> and that is recorded in the LSDB, records the route <NUM> in the routing table, records the SID of the CSG <NUM> for the route <NUM> in the routing table, and creates the forwarding entry <NUM> in the forwarding table. In this way, the CSG <NUM> can use the SR tunnel B to perform traffic forwarding. It can be learned from above that, when the in-order transmission of the link state information A and the link state information B cannot be ensured, even if the CSG <NUM> receives the link state information B before the link state information A, during a time period in which the CSG <NUM> receives the link state information B but has not received the link state information A, the CSG <NUM> can switch the traffic from the SR tunnel A to the SR tunnel B for forwarding, thereby avoiding a traffic packet loss.

In some implementations, the link state information B may carry a second indication identifier, to indicate the CSG <NUM> to delete the link state information E from the LSDB. After the CSG <NUM> receives the link state information B, if the CSG <NUM> reads the second indication identifier from the link state information B, the CSG <NUM> may delete the link state information F from the LSDB of the CSG <NUM> based on the link state information B, and may also delete the link state information E from the LSDB of the CSG <NUM> based on the second indication identifier in the link state information B. Alternatively, the CSG <NUM> may ignore the second indication identifier to avoid deleting the link state information E from the LSDB of the CSG <NUM> based on the second indication identifier in the link state information B. If the CSG <NUM> cannot read the second indication identifier from the link state information B, the CSG <NUM> may delete the link state information F from the LSDB of the CSG <NUM> based on the link state information B, without deleting the link state information E from the LSDB of the CSG <NUM> based on the link state information B. It can be learned from above that, by adding the second indication identifier to the link state information B, the ASG <NUM> may indicate, to the CSG <NUM>, whether the CSG <NUM> is to synchronously delete the link state information E and the link state information F. In this way, a processing manner of route withdrawal can be more flexibly configured.

If the link state information B is carried in a second LSA defined according to the OSPF protocol, the second indication identifier may be carried in an LSA header of the second LSA. With reference to the description in IETF RFC <NUM>, the second LSA may use the LSA header shown in <FIG>. The second indication identifier may be carried in an options field in the LSA header of the second LSA. With reference to the description in IETF RFC <NUM>, the options field in the LSA header of the second LSA may use the structure shown in <FIG>. The EA bit has been explicitly deprecated. Therefore, in the options field in the LSA header of the second LSA, an EA bit may be replaced by an SR bit, and the SR bit is used to carry the second indication identifier. Specifically, if the SR bit in the second LSA is set, the link state information B carries the second indication identifier. If the SR bit in the second LSA is not set, the link state information B does not carry the second indication identifier.

<NUM>: If the link state information is the link state information C, the CSG <NUM> records the link state information C in the LSDB of the CSG <NUM>.

When receiving the link state information C, the CSG <NUM> may record the link state information C in the LSDB of the CSG <NUM>. If the CSG <NUM> has not received the link state information D at this time, the CSG <NUM> does not update the route <NUM> computed based on the link state information D to the routing table, and therefore does not delete the route <NUM> and the SID of the CSG <NUM> from the routing table nor delete the forwarding entry <NUM> from the forwarding table. In this way, the CSG <NUM> continues to use the SR tunnel B to perform traffic forwarding. It can be learned from above that, when the in-order transmission of the link state information C and the link state information D cannot be ensured, even if the CSG <NUM> receives the link state information C before the link state information D, during a time period in which the CSG <NUM> receives the link state information C but has not received the link state information D, the CSG <NUM> continues to use the SR tunnel B to perform traffic forwarding, thereby avoiding a traffic packet loss.

In some implementations, the link state information C may carry a third indication identifier, to indicate the CSG <NUM> to synchronously record the link state information C and the link state information D in the LSDB. After the CSG <NUM> receives the link state information C, if the CSG <NUM> reads the third indication identifier from the link state information C, the CSG <NUM> may synchronously record, based on the third indication identifier in the link state information C, the link state information C and the link state information D in the LSDB when both the link state information C and the link state information D are received. Alternatively, the CSG <NUM> may ignore the third indication identifier, and record the link state information C in the LSDB of the CSG <NUM>, without determining whether the link state information D has been received at this time and ensuring that both the link state information C and the link state information D are recorded in the LSDB of the CSG <NUM>. If the CSG <NUM> cannot read the third indication identifier from the link state information C, the CSG <NUM> may record the link state information C in the LSDB of the CSG <NUM>, without ensuring that both the link state information C and the link state information D are recorded in the LSDB of the CSG <NUM>. It can be learned from above that, by adding the third indication identifier to the link state information C, the ASG <NUM> may indicate, to the CSG <NUM>, whether the CSG <NUM> is to synchronously update the link state information C and the link state information D. In this way, a processing manner of route updating can be more flexibly configured.

If the link state information C is carried in a third LSA defined according to the OSPF protocol, the third indication identifier may be carried in an LSA header of the third LSA. With reference to the description in IETF RFC <NUM>, the third LSA may use the LSA header shown in <FIG>. The third indication identifier may be carried in an options field in the LSA header of the third LSA. With reference to the description in IETF RFC <NUM>, the options field in the LSA header of the third LSA may use the structure shown in <FIG>. The EA bit has been explicitly deprecated. Therefore, in the options field in the LSA header of the third LSA, an EA bit may be replaced by an SR bit, and the SR bit is used to carry the third indication identifier. Specifically, if the SR bit in the third LSA is set, the link state information C carries the third indication identifier. If the SR bit in the third LSA is not set, the link state information C does not carry the third indication identifier.

<NUM>: If the link state information is the link state information D, the CSG <NUM> records the link state information D in the LSDB of the CSG <NUM> when the link state information C has been recorded in the LSDB of the CSG <NUM>.

When receiving the link state information D, the CSG <NUM> may determine whether the link state information C has been recorded in the LSDB of the CSG <NUM>. If the CSG <NUM> has received the link state information C at this time, and the link state information C has been recorded in the LSDB of the CSG <NUM>, the CSG <NUM> may record the link state information D in the LSDB of the CSG <NUM>. If the CSG <NUM> has not received the link state information C at this time, the CSG <NUM> records the link state information D in the LSDB of the CSG <NUM> after the link state information C has been recorded in the LSDB of the CSG <NUM>. In this way, even if the CSG <NUM> receives the link state information D before the link state information C, the link state information D is recorded in the LSDB of the CSG <NUM> when the link state information C has been recorded. When the link state information D is recorded in the LSDB, the CSG <NUM> may compute the route <NUM> based on the link state information D, replace the route <NUM> in the routing table by the route <NUM>, and delete the forwarding entry <NUM> from the forwarding table. In this way, the CSG <NUM> no longer uses the SR tunnel B to perform traffic forwarding. When the link state information C is recorded in the LSDB, the CSG <NUM> may record, based on the link state information C, the SID of the CSG <NUM> for the route <NUM> in the routing table when the route <NUM> has been recorded in the routing table. In this way, the CSG <NUM> can use the SR tunnel A to perform traffic forwarding. Therefore, when the in-order transmission of the link state information C and the link state information D cannot be ensured, even if the CSG <NUM> receives the link state information D before the link state information C, during a time period in which the CSG <NUM> receives the link state information D but has not received the link state information C, the CSG <NUM> can continue to use the SR tunnel B to perform traffic forwarding; and after receiving the link state information C and the link state information D, the CSG <NUM> can switch the traffic from the SR tunnel B back to the SR tunnel A for forwarding, thereby avoiding a traffic packet loss. In specific implementation, when the CSG <NUM> receives the link state information D, the CSG <NUM> may determine whether the link state information C is recorded in the CSG <NUM> LSDB. If the link state information C has been recorded in the LSDB of the CSG <NUM>, the CSG <NUM> may also record the link state information D in the LSDB of the CSG <NUM>, so that the CSG <NUM> may update the route to the CSG <NUM> based on the link state information D in the LSDB. If the link state information C is not recorded in the LSDB of the CSG <NUM>, the CSG <NUM> may start a timer (English: timer), and wait for a preset time. For example, the timer expires and is restarted every one second, and the preset time is reached when the timer expires after being restarted twice, or in other words, the preset time is three seconds. Within the preset time controlled by using the timer, if the CSG <NUM> receives the link state information C, and records the link state information C in the LSDB of the CSG <NUM>, the CSG <NUM> may also record the link state information D in the LSDB of the CSG <NUM>. If the CSG <NUM> has not received the link state information C after the preset time controlled by using the timer, and the link state information C has not been recorded in the LSDB of the CSG <NUM>, the CSG <NUM> may discard the link state information D.

In some implementations, the link state information D may carry a fourth indication identifier, to indicate the CSG <NUM> to synchronously record the link state information C and the link state information D in the LSDB. After the CSG <NUM> receives the link state information D, if the CSG <NUM> reads the fourth indication identifier from the link state information D, the CSG <NUM> may record, based on the fourth indication identifier in the link state information D, the link state information D in the LSDB of the CSG <NUM> after having received the link state information C and recorded the link state information C in the LSDB of the CSG <NUM>. If the CSG <NUM> cannot read the fourth indication identifier from the link state information D, the CSG <NUM> may record the link state information D in the LSDB of the CSG <NUM>, without ensuring that the link state information D is recorded in the LSDB when the link state information C has been recorded in the LSDB. It can be learned from above that, by adding the fourth indication identifier to the link state information D, the ASG <NUM> may indicate, to the CSG <NUM>, whether the CSG <NUM> is to synchronously update the link state information C and the link state information D. In this way, a processing manner of route updating can be more flexibly configured.

If the link state information D is carried in a fourth LSA defined according to the OSPF protocol, the fourth indication identifier may be carried in an LSA header of the fourth LSA. With reference to the description in IETF RFC <NUM>, the fourth LSA may use the LSA header shown in <FIG>. The fourth indication identifier may be carried in an options field in an LSA header of the fourth LSA. With reference to the description in IETF RFC <NUM>, the options field in the LSA header of the fourth LSA may use the structure shown in <FIG>. The EA bit has been explicitly deprecated. Therefore, in the options field in the LSA header of the fourth LSA, an EA bit may be replaced by an SR bit, and the SR bit is used to carry the fourth indication identifier. Specifically, if the SR bit in the fourth LSA is set, the link state information D carries the fourth indication identifier. If the SR bit in the fourth LSA is not set, the link state information D does not carry the fourth indication identifier.

In this embodiment, when the in-order transmission of the link state information A and the link state information B cannot be ensured, regardless of whether the CSG <NUM> receives the link state information A but has not received the link state information B, or the CSG <NUM> receives the link state information B but has not received the link state information A, the CSG <NUM> can switch the traffic from the SR tunnel A to the SR tunnel B for forwarding, thereby avoiding the traffic packet loss. In addition, when the in-order transmission of the link state information C and the link state information D cannot be ensured, regardless of whether the CSG <NUM> receives the link state information C but has not received the link state information D, or the CSG <NUM> receives the link state information D but has not received the link state information C, the CSG <NUM> can continue to use the SR tunnel B to perform traffic forwarding; and after receiving the link state information C and the link state information D, the CSG <NUM> can switch the traffic from the SR tunnel B back to the SR tunnel A for forwarding, thereby avoiding the traffic packet loss.

<FIG> is a schematic flowchart of a method for processing link state information according to an embodiment of this application. The method <NUM> may include the following steps.

<NUM>: A first network device receives first link state information sent by a second network device, where the first link state information is information about a third network device.

<NUM>: In response to receiving the first link state information, the first network device deletes second link state information that is received by the first network device from the second network device, where the second link state information carries a segment identifier of the third network device.

<NUM>: The first network device deletes, based on the first link state information, third link state information received from the second network device, where the third link state information carries link state information for computing a route to the third network device.

It can be understood that the first link state information may be used to indicate the first network device to delete link state information that is about the third network device and that is stored in the first network device, that is, the second link state information and the third link state information. In this case, the first link state information can be considered as information about the third network device.

In some implementations, the first link state information carries an indication identifier, and the indication identifier is used to indicate the network device that receives the first link state information, to delete the third link state information.

In some implementations, that the first network device deletes, based on the first link state information, third link state information received from the second network device includes: The first network device deletes the third link state information when determining that the first link state information carries the indication identifier.

In some implementations, the first link state information is carried in a link-state advertisement (LSA) defined according to the open shortest path first (OSPF) protocol, and the indication identifier is carried in an options options field in an LSA header corresponding to the link state information.

It should be noted that the first network device mentioned in the method <NUM> may be the CSG <NUM> mentioned in the method <NUM>. The second network device mentioned in the method <NUM> may be the ASG <NUM> mentioned in the method <NUM>. The third network device mentioned in the method <NUM> may be the CSG <NUM> mentioned in the method <NUM>. The first link state information mentioned in the method <NUM> may be the link state information A mentioned in the method <NUM>. The second link state information mentioned in the method <NUM> may be the link state information E mentioned in the method <NUM>. The third link state information mentioned in the method <NUM> may be the link state information F mentioned in the method <NUM>. The indication identifier mentioned in the method <NUM> may be the first indication identifier mentioned in the method <NUM>. Therefore, for various specific implementations of the method <NUM>, refer to related descriptions of the method <NUM>. Details are not described again in this embodiment.

<NUM>: A first network device receives first link state information sent by a second network device, where the first link state information carries information for computing a route to a third network device.

<NUM>: The first network device determines, based on the first link state information, whether the first network device stores second link state information received from the second network device, where the second link state information carries a segment identifier of the third network device.

<NUM>: When determining that the first network device stores the second link state information, the first network device updates a route to the third network device based on the first link state information.

The method <NUM> further includes: The first network device starts a timer when the first network device determines that the first network device does not store the second link state information; and determines, during timing of the timer, whether the first network device receives the second link state information sent by the second network device.

The method <NUM> further includes: When determining that the first network device receives the second link state information before the timer expires, the first network device updates the route to the third network device based on the first link state information.

The method <NUM> further includes: When determining that the first network device does not receive the second link state information even after the timer expires, the first network device skips updating the route to the third network device based on the first link state information.

In some implementations, the first link state information carries an indication identifier, and the indication identifier is used to indicate the network device that receives the first link state information, to determine, when updating the route to the third network device based on the first link state information, whether the network device stores the second link state information.

In some implementations, that the first network device determines, based on the first link state information, whether the first network device stores second link state information received from the second network device includes: when determining that the first link state information carries the indication identifier, the first network device determines whether the first network device stores the second link state information.

In some implementations, the first link state information is carried in a link-state advertisement (LSA) defined according to the OSPF protocol, and the indication identifier is carried in an options options field in an LSA header of the LSA.

It should be noted that the first network device mentioned in the method <NUM> may be the CSG <NUM> mentioned in the method <NUM>. The second network device mentioned in the method <NUM> may be the ASG <NUM> mentioned in the method <NUM>. The third network device mentioned in the method <NUM> may be the CSG <NUM> mentioned in the method <NUM>. The first link state information mentioned in the method <NUM> may be the link state information D mentioned in the method <NUM>. The second link state information mentioned in the method <NUM> may be the link state information C mentioned in the method <NUM>. The indication identifier mentioned in the method <NUM> may be the fourth indication identifier mentioned in the method <NUM>. Therefore, for various specific implementations of the method <NUM>, refer to related descriptions of the method <NUM>. Details are not described again in this embodiment.

<FIG> is a schematic structural diagram of an apparatus for processing link state information according to an embodiment of this application. The apparatus <NUM> is a first network device, and includes:.

In some implementations, the processing unit <NUM> is specifically configured to delete the third link state information when it is determined that the first link state information carries the indication identifier.

In some implementations, the first link state information is carried in a link-state advertisement (LSA) defined according to the open shortest path first (OSPF) protocol, and the indication identifier is carried in an options options field in an LSA header of the LSA.

It can be understood that the apparatus <NUM> shown in <FIG> may be the CSG <NUM> mentioned in the method <NUM> shown in <FIG>. Therefore, for various specific implementations of the apparatus <NUM>, refer to related descriptions of the method <NUM>. Details are not described again in this embodiment.

In some implementations,
the processing unit <NUM> is further configured to: when the determining unit <NUM> determines that the first network device receives the second link state information before the timer expires, update the route to the third network device based on the first link state information.

In some implementations,
the processing unit <NUM> is further configured to: when the determining unit <NUM> determines that the first network device does not receive the second link state information even after the timer expires, not update the route to the third network device based on the first link state information.

In some implementations, the determining unit <NUM> is specifically configured to: when determining that the first link state information carries the indication identifier, determine whether the first network device stores the second link state information.

<FIG> is a schematic structural diagram of a network device according to an embodiment of this application. The network device <NUM> includes a memory <NUM>, a processor <NUM>, and a communications interface <NUM>. The memory <NUM> is configured to store program code. The processor <NUM> is configured to run instructions in the program code to enable the network device <NUM> to perform the method according to any implementation of the method <NUM>. The communications interface <NUM> is configured to send information to another network device or receive information sent by another network device.

In addition, an embodiment of this application further provides a computer program product. When the computer program product is run on a computer, the computer is enabled to perform the method according to any implementation of the method <NUM> or the method according to any implementation of the method <NUM>.

In addition, an embodiment of this application further provides a computer-readable storage medium. The computer-readable storage medium stores instructions. When the instructions are run on a computer or a processor, the computer or the processor is enabled to perform the method according to any implementation of the method <NUM> or the method according to any implementation of the method <NUM>.

"First" in terms such as "first link state information" and "first network device" mentioned in the embodiments of this application is merely used for name identification, and does not represent the first in order. This rule is also applicable to "second" and the like.

From the foregoing descriptions of the implementations, a person skilled in the art may clearly understand that some or all steps of the methods in the embodiments may be implemented by software in addition to a universal hardware platform. Based on such an understanding, the technical solutions of this application may be implemented in a form of a software product. The software product may be stored in a storage medium, such as a read-only memory (English: read-only memory, ROM)/RAM, a magnetic disk, or an optical disc, and includes several instructions for instructing a computer device (which may be a personal computer, a server, or a network communications device such as a router) to perform the methods described in the embodiments or some parts of the embodiments of this application.

Claim 1:
A method for processing link state information performed by a first network device, the method comprising the steps of:
• receiving (S <NUM>) first link state information from a second network device, wherein the first link state information carries information for computing a route to a third network device, the route being a route from the first network device to the third network device via the second network device, the first, second, and third network devices being different network devices;
• determining (S <NUM>), based on the first link state information, whether the first network device stores second link state information received from the second network device, wherein the second link state information carries a segment identifier of the third network device:
∘ when determining that the first network device stores the second link state information, updating (S <NUM>) a route from the first network device to the third network device based on the first link state information,
o when determining that the first network device does not store the second link state information, starting a timer, and determining, during timing of the timer, whether the first network device receives the second link state information from the second network device:
▪ when determining that the first network device receives the second link state information before the timer expires, updating (S <NUM>) the route from the first network device to the third network device based on the first link state information, and
▪ when determining that the first network device does not receive the second link state information even after the timer expires, skipping updating the route from the first network device to the third network device based on the first link state information.