Method and apparatus for forwarding MPLS data packet
A method and an apparatus for forwarding an MPLS data packet are provided, which are used in an environment of hybrid networking of an SR network and a non-SR network. The method is as follows: when obtaining a to-be-sent MPLS data packet, a first SR router in an SR network determines whether a next-hop router supports an SR characteristic; the first SR router encapsulates the MPLS data packet into an IP tunnel when determining that the next-hop router does not support the SR characteristic, and sends an encapsulated MPLS data packet to the next-hop router to enable the encapsulated MPLS data packet to be forwarded, based on an IP routing table, to a second SR router. In this way, correct forwarding of an MPLS data packet is completed in an environment of hybrid networking of an SR router and a non-SR router.
1. A method for forwarding a multiprotocol label switching (MPLS) data packet, comprising:
receiving, by a first segment routing (SR) router in an SR network, the MPLS data packet, wherein the first SR router has an MPLS forwarding capability;
encapsulating, by the first SR router, the MPLS data packet into an IP tunnel when a next-hop router is a non-SR router, wherein the non-SR router does not have an MPLS forwarding capability, and
sending an encapsulated MPLS data packet to the next-hop router to enable the encapsulated MPLS data packet to be forwarded to a second SR router.
2. The method according to claim 1 , wherein encapsulating the MPLS data packet into the IP tunnel comprises:
filling in, by the first SR router, a source address of the IP tunnel with an IP address of the first SR router, and filling in a destination address of the IP tunnel with an IP address of the second SR router.
3. The method according to claim 2 , further comprising:
determining, by the first SR router, the IP address of the second SR router according to a node segment label at the top of a label stack of the MPLS data packet, wherein the node segment label at the top of the label stack of the MPLS data packet is a node segment label of the second SR router.
4. The method according to claim 3 , wherein the node segment label is a global label, and before encapsulating the MPLS data packet into the IP tunnel, the method further comprises:
performing, by the first SR router, a pop operation on the global label when a penultimate hop pop (PHP) operation needs to be performed.
5. The method according to claim 3 , wherein the node segment label is a local label, and before encapsulating the MPLS data packet into the IP tunnel, the method further comprises:
performing, by the first SR router, a pop operation on the local label.
6. The method according to claim 1 , wherein before encapsulating the MPLS data packet into the IP tunnel, the method further comprises:
determining, by the first SR router according to a tunnel encapsulation capability advertisement sent by the second SR router, an IP tunnel encapsulation type that is used when the MPLS data packet is encapsulated into the IP tunnel.
7. A first segment routing (SR) router, comprising:
a receiver configured to cooperate with a processor to receive a multiprotocol label switching (MPLS) data packet;
the processor configured to encapsulate the MPLS data packet into an IP tunnel when a next-hop router is a non-SR router, wherein the first SR router has an MPLS forwarding capability, the non-SR router does not have an MPLS forwarding capability;
a transmitter configured to cooperate with the processor to send an encapsulated MPLS data packet to the next-hop router to enable the encapsulated MPLS data packet to be forwarded to a second SR router.
8. The first SR router according to claim 7 , wherein the processor is further configured to:
fill in a source address of the IP tunnel with an IP address of the first SR router, and fill in a destination address of the IP tunnel with an IP address of the second SR router.
9. The first SR router according to claim 8 , wherein the processor is further configured to:
determine the IP address of the second SR router according to a node segment label at the top of a label stack of the MPLS data packet, wherein the node segment label at the top of the label stack of the MPLS data packet is a node segment label of the second SR router.
10. The first SR router according to claim 9 , wherein the node segment label is a global label, and before encapsulate the MPLS data packet into the IP tunnel, the processor is configured to:
perform a pop operation on the global label when a penultimate hop pop (PHP) operation needs to be performed.
11. The first SR router according to claim 9 , wherein the node segment label is a local label, and before encapsulate the MPLS data packet into the IP tunnel, the processor is configured to:
perform a pop operation on the local label.
12. The first SR router according to claim 7 , wherein before encapsulate the MPLS data packet into the IP tunnel, the processor is further configured to:
determine, according to a tunnel encapsulation capability advertisement sent by the second SR router, an IP tunnel encapsulation type that is used when the MPLS data packet is encapsulated into the IP tunnel.
13. A non-transitory computer readable medium, comprising processor-executable instructions which when executed by a processor of a first segment routing (SR) router in an SR network, causes the first SR router to implement the following method for forwarding a multiprotocol label switching (MPLS) data packet, the method comprising:
receiving the MPLS data packet, wherein the first SR router has an MPLS forwarding capability;
encapsulating the MPLS data packet into an IP tunnel when a next-hop router is a non-SR router, wherein the non-SR router does not have an MPLS forwarding capability, and
sending an encapsulated MPLS data packet to the next-hop router to enable the encapsulated MPLS data packet to be forwarded to a second SR router.
14. The non-transitory computer readable medium according to claim 13 , wherein encapsulating the MPLS data packet into the IP tunnel comprises:
filling in, a source address of the IP tunnel with an IP address of the first SR router, and filling in a destination address of the IP tunnel with an IP address of the second SR router.
15. The non-transitory computer readable medium according to claim 14 , wherein the method further comprises:
determining, the IP address of the second SR router according to a node segment label at the top of a label stack of the MPLS data packet, wherein the node segment label at the top of the label stack of the MPLS data packet is a node segment label of the second SR router.
16. The non-transitory computer readable medium according to claim 15 , wherein the node segment label is a global label, and before the encapsulating the MPLS data packet into the IP tunnel, the method further comprises:
performing, a pop operation on the global label when a penultimate hop pop (PHP) operation needs to be performed.
17. The non-transitory computer readable medium according to claim 15 , wherein the node segment label is a local label, before encapsulating the MPLS data packet into the IP tunnel, the method further comprises:
performing, a pop operation on the local label.
18. The non-transitory computer readable medium according to claim 13 , wherein before encapsulating the MPLS data packet into the IP tunnel, the method further comprises:
determining, according to a tunnel encapsulation capability advertisement sent by the second SR router, an IP tunnel encapsulation type that is used when the MPLS data packet is encapsulated into the IP tunnel.