Packet hardware forwarding method and network device
By configuring the switching chip in proxy mode and the processor port in stacking mode in SRv6 network devices, hardware forwarding of packets is achieved, which solves the problem of excessive CPU load and improves forwarding performance.
Patent Information
- Application Number
- CN202510078729.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-01-17
AI Technical Summary
In SRv6 technology, excessive CPU load during packet forwarding affects forwarding performance.
By configuring the switching chip in proxy mode and configuring the port connecting the processor and the switching chip in stacking mode, the processor is made to simulate another switching chip. The switching chip is responsible for hardware forwarding of packets. After the processor adds a stack header, the switching chip obtains the next-hop information according to the hardware table and forwards the packets.
This effectively reduces the processor load and improves packet forwarding performance.
Smart Images

Figure CN119922120B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data communication technology, and more specifically, to a message hardware forwarding method and network device. Background Technology
[0002] Source routing is a network routing strategy that allows the sender of a data packet to specify the path the packet takes as it travels through the network, including some or all of the routers along the way. This differs from traditional routing, where each router in the network independently determines the next hop for a data packet based on its own routing table, without considering the packet's final source or destination.
[0003] SRv6 (Segment Routing IPv6) is a segmented routing network architecture implemented based on the IPv6 data plane. It is designed based on the source routing concept and supports inserting forwarding instructions into the header node to guide data packet forwarding.
[0004] The core idea of SR technology is to divide the packet forwarding path into different segments and insert segment information into the packet at the beginning of the path. Intermediate nodes only need to forward the packet according to the segment information carried in the packet. It is identified by SID (SegmentIdentifier).
[0005] Based on the IPv6 forwarding plane, SR technology adds an SRH (Segment Routing Header) to the IPv6 routing extension header. This SRH stores IPv6 Segment List information. The Segment List is a forwarding path obtained by arranging segments and network nodes in an ordered manner. During packet forwarding, the SegmentsLeft and Segment List fields jointly determine the IPv6 destination address information, thereby guiding the packet forwarding path and behavior.
[0006] In the current SRV6 technology, after a message is handed over to the CPU (Central Processing Unit) for processing, the CPU needs to look up the software table to determine the output port for message forwarding and edit the message. This will place a heavy burden on the CPU and affect the message forwarding performance. Summary of the Invention
[0007] In view of this, the purpose of the present invention is to provide a packet hardware forwarding method and network device that can reduce processor load and improve packet forwarding performance.
[0008] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows:
[0009] In a first aspect, the present invention provides a packet hardware forwarding method applied to a network device, the network device including a processor and a switching chip; the port of the switching chip connected to the processor is configured in a stacking mode, and the switching chip is configured in a proxy mode, the method comprising:
[0010] The processor adds a stacking header to the original message to obtain the message to be forwarded;
[0011] After receiving the packet to be forwarded, the switching chip looks up the next hop information in the hardware table according to the stack header;
[0012] The switching chip edits the message to be forwarded based on the next-hop information and then forwards it.
[0013] In an optional implementation, the processor adds a stacking header to the original message to obtain a message to be forwarded, including:
[0014] When the original packet does not contain a Segmented Routing Header (SRH), or when the original packet contains the SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is not 0, the processor adds a basic header and an egress edit header to the original packet, fills the destination port in the basic header with the specified destination port and sets the number of extension headers to 1, and sets the value of the next hop field in the egress edit header to the specified identifier, thus obtaining the packet to be forwarded;
[0015] When the original packet contains the SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is 0, the processor adds the base header to the original packet, sets the destination port in the base header to the proxy port and sets the number of extension headers to 0, and sets the ingress interface in the base header to the specified ingress interface, thus obtaining the packet to be forwarded.
[0016] In an optional implementation, the hardware table includes a hardware routing table and a hardware next-hop table; after receiving the packet to be forwarded, the switching chip retrieves the next-hop information from the hardware table based on the stack header, including:
[0017] When the destination port in the base header is a proxy port, the switching chip determines the forwarding domain corresponding to the packet to be forwarded based on the ingress interface in the base header;
[0018] The switching chip looks up the hardware routing table based on the forwarding domain corresponding to the packet to be forwarded and the destination IP address of the packet to be forwarded, and obtains the next-hop identifier corresponding to the packet to be forwarded.
[0019] The switching chip looks up the hardware next-hop table based on the next-hop identifier corresponding to the packet to be forwarded, and obtains the next-hop information corresponding to the packet to be forwarded.
[0020] In an optional implementation, the hardware table includes a hardware next-hop table; after receiving the packet to be forwarded, the switching chip retrieves the next-hop information by looking up the hardware table according to the stack header, including:
[0021] When the destination port in the base header is not a proxy port and the number of extension headers is 1, the switching chip obtains the specified identifier from the export edit extension header;
[0022] The switching chip looks up the hardware next-hop table according to the specified identifier to obtain the next-hop information corresponding to the packet to be forwarded.
[0023] In an optional implementation, the switching chip edits the packet to be forwarded according to the next-hop information and then forwards it, including:
[0024] The switching chip removes the stack header and updates the source MAC address, destination MAC address, and VLAN in the packet to be forwarded to the source MAC address, destination MAC address, and VLAN in the next-hop information;
[0025] The switching chip forwards the edited message to be forwarded through the output port in the next-hop information.
[0026] In an optional implementation, the method further includes:
[0027] When the original packet does not contain a Segmented Routing Extension Header (SRH), the processor looks up the software routing table based on the destination IP address of the original packet to generate a new SRH, and adds the new SRH to the original packet.
[0028] When the original message contains the SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is not 0, the processor deletes the IP address of this device from the segment list in the SRH, updates the remaining number of segments, and sets the next-hop IP address in the segment list to the destination address of the IPv6 header.
[0029] When the SRH exists in the original message, and the segment list in the SRH records the IP address of this device, and the remaining number of segments in the SRH is 0, the processor deletes the SRH from the original message.
[0030] In a second aspect, the present invention provides a network device, including a processor and a switching chip, wherein the port of the switching chip connected to the processor is configured in a stacking mode, and the switching chip is configured in a proxy mode;
[0031] The processor is used to add a stacking header to the original message to obtain a message to be forwarded;
[0032] The switching chip is used to obtain the next-hop information by looking up the hardware table according to the stack header after receiving the message to be forwarded.
[0033] The switching chip is used to edit the message to be forwarded according to the next-hop information and then forward it.
[0034] In an optional implementation, when the original packet does not contain a Segmented Routing Header (SRH), or when the original packet contains the SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is not 0, the processor is used to add a base header and an egress edit header to the original packet, fill the destination port in the base header with a specified destination port and set the number of extension headers to 1, and set the value of the next hop field in the egress edit header to a specified identifier, thereby obtaining the packet to be forwarded;
[0035] When the original packet contains the SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is 0, the processor adds the base header to the original packet, sets the destination port in the base header to the proxy port and sets the number of extension headers to 0, sets the ingress interface in the base header to the specified ingress interface, and obtains the packet to be forwarded.
[0036] In an optional implementation, the hardware table includes a hardware routing table and a hardware next-hop table;
[0037] When the destination port in the base header is a proxy port, the switching chip is used to determine the forwarding domain corresponding to the packet to be forwarded based on the ingress interface in the base header;
[0038] The switching chip is used to look up the hardware routing table based on the forwarding domain corresponding to the packet to be forwarded and the destination IP address of the packet to be forwarded, and obtain the next hop identifier corresponding to the packet to be forwarded.
[0039] The switching chip is used to look up the hardware next-hop table according to the next-hop identifier corresponding to the packet to be forwarded, and obtain the next-hop information corresponding to the packet to be forwarded.
[0040] In an optional implementation, the hardware table includes a hardware next-hop table;
[0041] When the destination port in the base header is not a proxy port and the number of extension headers is 1, the switching chip is used to obtain the specified identifier from the export edit extension header;
[0042] The switching chip is used to look up the hardware next-hop table according to the specified identifier to obtain the next-hop information corresponding to the packet to be forwarded.
[0043] Compared to existing technologies, the packet hardware forwarding method and network device provided in this invention are applied to a network device, which includes a processor and a switching chip. Configuring the switching chip in proxy mode effectively reduces processor load. Configuring the port connecting the switching chip and the processor in stacking mode simulates the processor as another switching chip. The processor adds a stacking header to the original packet to obtain the packet to be forwarded. After receiving the packet to be forwarded, the switching chip looks up the next-hop information in the hardware table based on the stacking header, edits the packet to be forwarded based on the next-hop information, and then forwards it. This achieves hardware forwarding of packets, reduces processor load, and improves packet forwarding performance.
[0044] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0045] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 This diagram illustrates a flowchart of a message hardware forwarding method provided in an embodiment of the present invention.
[0047] Figure 2 This diagram illustrates another flowchart of the message hardware forwarding method provided in an embodiment of the present invention.
[0048] Figure 3 This diagram illustrates another flowchart of the message hardware forwarding method provided in an embodiment of the present invention.
[0049] Figure 4 A block diagram of a network device provided in an embodiment of the present invention is shown.
[0050] Icons: 400 - Network device; 401 - Processor; 402 - Switching chip. Detailed Implementation
[0051] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0052] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0053] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0054] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0055] Please refer to Figure 1 , Figure 1 This diagram illustrates a flowchart of a packet hardware forwarding method provided in an embodiment of the present invention. The method is applied to a network device, which includes a processor and a switching chip. The port connecting the switching chip to the processor is configured in a stacking mode, and the switching chip is configured in a proxy mode. The method includes the following steps:
[0056] In step S10, the processor adds a stacking header to the original message to obtain the message to be forwarded.
[0057] In this embodiment of the invention, before implementing packet hardware forwarding, it is necessary to enable proxy mode on the switching chip and create a next hop based on the service scenario. The processor generates a software routing table based on the next hop, issues hardware routing table entries to the switching chip, specifies the next hop, and generates the hardware routing table.
[0058] After configuring the port connecting the switching chip and the processor into stacking mode, the processor is simulated as another switching chip. The switching chip sends the received raw packets to the processor, which processes the raw packets and adds a stacking header to the processed packets to obtain the packets to be forwarded.
[0059] In step S20, after receiving the message to be forwarded, the switching chip looks up the next hop information in the hardware table according to the stack header.
[0060] The next-hop information typically includes the source MAC address, destination MAC address, VLAN (Virtual Local Area Network), and the outgoing port.
[0061] In step S30, the switching chip edits the message to be forwarded based on the next-hop information and then forwards it.
[0062] In this embodiment of the invention, the switching chip parses the stack header from the packet to be forwarded, looks up the hardware table based on the fields in the stack header, obtains the next-hop information corresponding to the packet to be forwarded, and edits and forwards the packet to be forwarded based on the next-hop information.
[0063] In summary, the packet hardware forwarding method provided in this embodiment of the invention configures the switching chip in proxy mode, which can effectively reduce the processor load. The port connecting the switching chip and the processor is configured in stacking mode, simulating the processor as another switching chip. The processor adds a stacking header to the original packet to obtain the packet to be forwarded; after receiving the packet to be forwarded, the switching chip looks up the next-hop information in the hardware table according to the stacking header, edits the packet to be forwarded according to the next-hop information, and then forwards it. This achieves hardware forwarding of packets, reduces the processor load, and improves packet forwarding performance.
[0064] Optionally, regarding how to generate a message to be forwarded based on the original message, the following is a possible implementation method. Please refer to... Figure 2 , Figure 1 The sub-steps of step S10 may include:
[0065] Step S104: When the original packet does not contain a Segmented Routing Extension Header (SRH), or when the original packet contains an SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is not 0, the processor adds a base header and an egress edit extension header to the original packet, fills the destination port in the base header with the specified destination port and sets the number of extension headers to 1, and sets the value of the next hop field in the egress edit extension header to the specified identifier, thus obtaining the packet to be forwarded.
[0066] In this embodiment of the invention, after receiving the original packet, the processor parses the original packet to obtain the SRH. If the original packet received by this device does not contain an SRH, it indicates that this device is the head node in the forwarding path of the original packet. The processor then looks up the software routing table to obtain the specified next hop and uses the specified next hop identifier as the specified identifier.
[0067] If an SRH (Segment List) exists in the original packet, the processor reads the segment list (i.e., the Segment List field) and the remaining segment count (i.e., the SL (Segments Left) field) from the SRH. The processor obtains the IP address of the local device and checks whether the IP address of the local device is recorded in the segment list. If the IP address of the local device is recorded in the segment list and the remaining segment count is not 0, it means that the local device is an intermediate node in the forwarding path of the original packet. The processor looks up the software routing table to obtain the specified next hop and uses the specified next hop identifier as the specified identifier.
[0068] The processor creates a base header and an egress edit extension header. The destination port in the base header is filled with the specified destination port, and the number of extension headers is set to 1. The next-hop field in the egress edit extension header is set to the specified identifier. The processor combines the base header and the egress edit extension header into a stack header, and uses the stack header to encapsulate the processed message to obtain the message to be forwarded. The processor sends the message to be forwarded to the switching chip. The specified destination port in this step can be any panel port.
[0069] Step S105: When the original packet contains an SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is 0, the processor adds a basic header to the original packet, sets the destination port in the basic header to the proxy port and sets the number of extension headers to 0, sets the ingress interface in the basic header to the specified ingress interface, and obtains the packet to be forwarded.
[0070] In this embodiment of the invention, if the original packet contains an SRH, the processor obtains the segment list and the remaining number of segments from the SRH. If the segment list records the IP address of this device and the remaining number of segments is 0, it indicates that this device is the end node in the forwarding path of the original packet. The processor looks up the software routing table according to the destination IP address of the original packet to obtain the specified ingress interface corresponding to the original packet.
[0071] The processor creates a base header in the stack header, sets the destination port field in the base header to the proxy port (e.g., 0xFE), sets the number of extended headers to 0, and sets the ingress interface field in the base header to the specified ingress interface (e.g., the specified ingress interface ID). The processor encapsulates the processed packet using the stack header to obtain the packet to be forwarded. The processor then sends the packet to be forwarded to the switching chip.
[0072] It is worth mentioning that the present invention applies the proxy mode of the switching chip to the SRv6 scenario, which can meet the various needs of packet forwarding in the SRv6 scenario. The switching chip can use a specified identifier to look up the hardware next-hop table to realize packet hardware forwarding, or use a specified ingress interface to look up the hardware routing table and hardware next-hop table to realize packet hardware forwarding, which can effectively reduce the service load of the processor and reduce packet forwarding latency.
[0073] Optionally, the hardware table includes a hardware routing table and a hardware next-hop table. The following is a possible implementation method for how to use the hardware routing table and the hardware next-hop table to obtain next-hop information.
[0074] Please refer to Figure 2 , Figure 1 The sub-steps of step S20 may include:
[0075] Step S201: When the destination port in the base header is a proxy port, the switching chip determines the forwarding domain corresponding to the packet to be forwarded based on the ingress interface in the base header.
[0076] In this embodiment of the invention, when the processor adds a basic header to the original message, the number of extension headers in the basic header is 0 by default. When specifying the identifier of the next hop, the processor sets the number of extension headers to 1.
[0077] After receiving a packet to be forwarded, the switching chip parses it to obtain the basic header. If the switching chip determines that the number of extended headers in the basic header is 0 and the value of the destination port field in the basic header is a proxy port (e.g., 0xFE), it means that it needs to look up the next-hop information corresponding to the packet to be forwarded in the hardware routing table. The switching chip reads the value of the interface field from the basic header to obtain the specified interface, and then obtains the corresponding forwarding domain based on the specified interface.
[0078] In step S202, the switching chip looks up the hardware routing table based on the forwarding domain corresponding to the packet to be forwarded and the destination IP address of the packet to be forwarded, and obtains the next-hop identifier corresponding to the packet to be forwarded.
[0079] In this embodiment of the invention, the switching chip records a hardware routing table, which contains multiple routing entries. Each routing entry includes a forwarding domain, a destination IP address, and a next-hop identifier. The switching chip searches the hardware routing table based on the forwarding domain and the destination IP address of the packet to be forwarded to find a matching routing entry, and then retrieves the next-hop identifier corresponding to the packet to be forwarded from the matching routing entry.
[0080] In step S203, the switching chip looks up the hardware next-hop table based on the next-hop identifier corresponding to the packet to be forwarded, and obtains the next-hop information corresponding to the packet to be forwarded.
[0081] In this embodiment of the invention, the switching chip also records a hardware next-hop table, which contains multiple next-hop entries used to record next-hop information. When a new next hop is created, the next-hop entry corresponding to the new next hop is added to the hardware next-hop table.
[0082] The switching chip looks up the hardware next-hop table based on the next-hop identifier of the packet to be forwarded, obtains the corresponding next-hop table entry, and reads the next-hop information corresponding to the next-hop identifier from the matching next-hop table entry to obtain the next-hop information corresponding to the packet to be forwarded.
[0083] As can be seen, the embodiments of the present invention utilize the switching chip to quickly obtain next-hop information by looking up the hardware routing table and the hardware next-hop table, effectively reducing the processor load and improving the performance of packet forwarding.
[0084] Optionally, regarding how to utilize a hardware next-hop table to obtain next-hop information, the following is a possible implementation method. Please refer to... Figure 2 , Figure 1 The sub-steps of step S20 may include:
[0085] Step S204: When the destination port in the base header is not a proxy port and the number of extension headers is 1, the switching chip obtains the specified identifier from the export editing extension header.
[0086] In step S205, the switching chip searches the hardware next-hop table according to the specified identifier to obtain the next-hop information corresponding to the packet to be forwarded.
[0087] In this embodiment of the invention, when the switching chip receives the packet to be forwarded, it parses the packet to be forwarded to obtain the basic header. The switching chip determines whether the destination port in the basic header is a proxy port and whether the number of extension headers is 1. If the destination port is not a proxy port and the number of extension headers is 1, the switching chip parses the packet to be forwarded to obtain the egress edit extension header and reads the value of the next hop field from the egress edit extension header to obtain the specified identifier.
[0088] The switching chip looks up the hardware next-hop table based on the specified identifier, obtains the next-hop table entry for the specified identifier, and reads the next-hop information corresponding to the specified identifier from the next-hop table entry, thereby quickly obtaining the next-hop information corresponding to the packet to be forwarded and effectively improving the packet forwarding performance.
[0089] Optionally, regarding how to utilize next-hop information to forward packets, the following is a possible implementation method. Please refer to... Figure 2 , Figure 1 The sub-steps of step S30 may include:
[0090] Step S301: The switching chip removes the stack header and updates the source MAC address, destination MAC address, and VLAN in the packet to be forwarded to the source MAC address, destination MAC address, and VLAN in the next-hop information.
[0091] In step S302, the switching chip forwards the edited message to be forwarded through the output port in the next-hop information.
[0092] In this embodiment of the invention, after obtaining the next-hop information corresponding to the packet to be forwarded, the switching chip begins to edit the packet. The switching chip removes the stack header from the packet, updates the source MAC address in the packet to the source MAC address in the next-hop information, updates the destination MAC address in the packet to the destination MAC address in the next-hop information, updates the VLAN in the packet to the VLAN in the next-hop information, and finally forwards the edited packet through the outgoing port in the next-hop information, thus achieving segmented routing forwarding.
[0093] Alternatively, please refer to Figure 3 ,exist Figure 2 Before step S104, the message hardware forwarding method also includes the following steps:
[0094] Step S101: When the original packet does not contain a Segmented Routing Extension Header (SRH), the processor looks up the software routing table based on the destination IP address of the original packet to generate a new SRH, and adds the new SRH to the original packet.
[0095] In this embodiment of the invention, if the original packet received by this device does not contain an SRH, it indicates that this device is the head node in the forwarding path of the original packet. The head node encapsulates the SRv6 path information in the SRH through the processor. The processor obtains the SRv6 path information of the original packet from the software routing table, generates the SRH, and adds the newly generated SRH to the original packet.
[0096] Step S102: When the original message contains an SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is not 0, the processor deletes the IP address of this device from the segment list in the SRH, updates the remaining number of segments, and sets the next-hop IP address in the segment list to the destination address of the IPv6 header.
[0097] In this embodiment of the invention, if the original packet received by this device contains an SRH (Segment Redirection), the segment list and the remaining segment count are read from the SRH. If the segment list records the IP address of this device and the remaining segment count is greater than 0, it indicates that this device is an intermediate node in the forwarding path of the original packet. The processor deletes the IP address of this device from the segment list, copies the last IP address in the segment list (i.e., the next-hop IP address) to the destination address field in the IPv6 header, and decrements the remaining segment count by 1.
[0098] Step S103: When the original message contains an SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is 0, the processor deletes the SRH from the original message.
[0099] In this embodiment of the invention, if the original packet received by this device contains an SRH (Segment Hash), the segment list and the remaining segment count are read from the SRH. If the segment list records the IP address of this device and the remaining segment count is 0, it indicates that this device is the final node in the forwarding path of the original packet. To ensure network security, efficiency, and correct processing, the SRH in the original SRv6 packet needs to be removed after it reaches the final node.
[0100] To more clearly illustrate the message hardware forwarding method provided in the embodiments of the present invention, the following examples are used for explanation.
[0101] Assume the hardware next-hop table contains nexthop information for nexthop1 and nexthop2. Nexthop1's next-hop information includes: source MAC address 1.1.1, destination MAC address 2.2.2, VLAN 100, and outgoing port port 1. Nexthop2's next-hop information includes: source MAC address 3.3.3, destination MAC address 4.4.4, VLAN 200, and outgoing port port 2. The network device's routing port has an interface ID of 1 and a forwarding domain of 0. The hardware routing table records a next-hop identifier of nexthop1 with a forwarding domain of 0, a destination IP address of 2024:88, and the destination IP address being 2024:88.
[0102] In one possible implementation, the switching chip sends the original packet to the processor. When the original packet contains an SRH and the segment list in the SRH records the IP address of the local device and the remaining number of segments in the SRH is 0, the processor removes the SRH from the original packet, adds a basic header to the original packet, sets the value of the destination port field in the basic header to the proxy port (e.g., 0xFE), and sets the value of the ingress interface field in the basic header (e.g., srcVlanPtr) to 4097, i.e., 4096+1 (1 is the interface ID of the routing port of the network device), thus obtaining the packet to be forwarded, and sends the packet to be forwarded to the switching chip.
[0103] After receiving a packet to be forwarded, the switching chip parses the packet to obtain the basic header. Based on the fact that the number of extension headers in the basic header is 0 and the value of the destination port is the proxy port (e.g., 0xFE), it determines that the next-hop identifier corresponding to the packet to be forwarded needs to be obtained by looking up the hardware routing table.
[0104] The switching chip obtains the interface ID of the routing port as 1 based on the value of the ingress interface field (4097) in the base header, and then obtains the forwarding domain (0) based on the interface ID. Assuming the destination IP address of the packet to be forwarded is 2024:88, the switching chip looks up the hardware routing table based on the forwarding domain (0) and the destination IP address (2024:88) to obtain the next-hop identifier nexthop1. The switching chip then looks up the hardware next-hop table based on nexthop1 to obtain the corresponding next-hop information. Based on this next-hop information, it updates the source MAC address of the packet to be forwarded to 1.1.1, the destination MAC address to 2.2.2, and the VLAN to 100, and then forwards the edited packet through port 1.
[0105] As another possible implementation, the switching chip sends the original packet to the processor. When the original packet does not contain an SRH, the processor adds the SRH to the original packet according to the software routing table. When the original packet contains an SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is not 0, the processor updates the SRH in the original packet.
[0106] Assuming the next-hop identifier corresponding to the original message is nexthop2, the processor adds a basic header and an egress edit extension header to the updated message. The destination port in the basic header is filled with the specified port and the number of extension headers is set to 1. The value of the next-hop field (e.g., nexthopPtr) in the egress edit extension header is set to nexthop2, thus obtaining the message to be forwarded, and then sending the message to be forwarded to the switching chip.
[0107] After receiving a packet to be forwarded, the switching chip parses the packet to obtain the basic header and determines whether the destination port is a proxy port and whether the number of extension headers is 1. If the destination port is not a proxy port and the number of extension headers is 1, it is determined that there is no need to look up the hardware routing table, and the next-hop information corresponding to the packet to be forwarded is obtained directly by looking up the hardware next-hop table.
[0108] The switching chip looks up the hardware next-hop table according to nexthop2 to obtain the next-hop information corresponding to nexthop2. Based on the next-hop information, it updates the source MAC address of the packet to be forwarded to 3.3.3, the destination MAC address to 4.4.4, and the VLAN to 200, and forwards the edited packet to be forwarded through port 2.
[0109] Please refer to Figure 4 , Figure 4 This is a block diagram of a network device 400 provided for an embodiment of the present invention. The network device 400 includes a processor 401 and a switching chip 402; the port connecting the switching chip 402 to the processor 401 is configured in a stacked mode, and the switching chip 402 is configured in a proxy mode.
[0110] Processor 401 is used to add a stacking header to the original message to obtain the message to be forwarded.
[0111] After receiving the message to be forwarded, the switching chip 402 looks up the next hop information in the hardware table according to the stack header.
[0112] The switching chip 402 is used to edit the message to be forwarded based on the next-hop information and then forward it.
[0113] In summary, the network device provided in this embodiment of the invention includes a processor and a switching chip. Configuring the switching chip in proxy mode effectively reduces the processor load. Configuring the port connecting the switching chip and the processor in stacking mode simulates the processor as another switching chip. The processor adds a stacking header to the original packet to obtain the packet to be forwarded; the switching chip looks up the next-hop information in the hardware table based on the stacking header, edits the packet to be forwarded based on the next-hop information, and then forwards it, thereby realizing hardware forwarding of packets, reducing the processor load, and improving packet forwarding performance.
[0114] Optionally, when the original packet does not contain a Segmentation Routing Extension Header (SRH), or when the original packet contains an SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is not 0, the processor 401 adds a base header and an egress edit extension header to the original packet, fills the destination port in the base header with the specified destination port and sets the number of extension headers to 1, and sets the value of the next hop field in the egress edit extension header to the specified identifier, thus obtaining the packet to be forwarded.
[0115] When the original packet contains an SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is 0, the processor 401 adds a basic header to the original packet, sets the destination port in the basic header to the proxy port and sets the number of extension headers to 0, sets the ingress interface in the basic header to the specified ingress interface, and obtains the packet to be forwarded.
[0116] Optionally, the hardware table includes a hardware routing table and a hardware next-hop table; when the number of extension headers in the base header is 0 and the destination port in the base header is a proxy port, the switching chip 402 is used to determine the forwarding domain corresponding to the packet to be forwarded based on the ingress interface in the base header.
[0117] The switching chip 402 is used to look up the hardware routing table based on the forwarding domain and the destination IP address of the packet to be forwarded, and obtain the next-hop identifier of the packet to be forwarded.
[0118] The switching chip 402 is used to look up the hardware next-hop table based on the next-hop identifier of the packet to be forwarded, and obtain the next-hop information corresponding to the packet to be forwarded. The next-hop information includes the source MAC address, destination MAC address, VLAN, and egress port.
[0119] Optionally, the hardware table includes a hardware next-hop table; when the destination port in the base header is not a proxy port and the number of extension headers is 1, the switch chip 402 is used to obtain a specified identifier from the egress edit extension header;
[0120] The switching chip 402 is used to look up the hardware next-hop table according to the specified identifier and obtain the next-hop information corresponding to the packet to be forwarded.
[0121] Optionally, the switching chip 402 is used to remove the stack header and update the source MAC address, destination MAC address and VLAN in the packet to be forwarded to the source MAC address, destination MAC address and VLAN in the next-hop information.
[0122] The switching chip 402 is used to forward the edited message to be forwarded through the output port in the next-hop information.
[0123] Optionally, when the original packet does not contain a Segmented Routing Extension Header (SRH), the processor 401 uses the destination IP address of the original packet to look up the software routing table to generate a new SRH and adds the new SRH to the original packet.
[0124] When the original message contains an SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is not 0, the processor 401 is used to delete the IP address of this device from the segment list in the SRH, update the remaining number of segments, and set the next-hop IP address in the segment list to the destination address of the IPv6 header.
[0125] When the original message contains an SRH and the segment list of the SRH contains the IP address of this device and the remaining number of segments is 0, the processor 401 deletes the SRH from the original message.
[0126] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0127] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0128] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A message hardware forwarding method, characterized in that, Applied to network devices, the network devices including processors and switching chips; the ports of the switching chip connected to the processor are configured in a stacking mode, and the switching chip is configured in a proxy mode, the method includes: The processor adds a stacking header to the original message to obtain the message to be forwarded; After receiving the packet to be forwarded, the switching chip looks up the next hop information in the hardware table according to the stack header; The switching chip edits the message to be forwarded according to the next-hop information and then forwards it. The processor adds a stacking header to the original message to obtain the message to be forwarded, including: When the original packet does not contain a Segmented Routing Header (SRH), or when the original packet contains the SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is not 0, the processor adds a basic header and an egress edit header to the original packet, fills the destination port in the basic header with the specified destination port and sets the number of extension headers to 1, and sets the value of the next hop field in the egress edit header to the specified identifier, thus obtaining the packet to be forwarded; When the original packet contains the SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is 0, the processor adds the base header to the original packet, sets the destination port in the base header to the proxy port and sets the number of extension headers to 0, and sets the ingress interface in the base header to the specified ingress interface, thus obtaining the packet to be forwarded.
2. The message hardware forwarding method according to claim 1, characterized in that, The hardware table includes a hardware routing table and a hardware next-hop table; After receiving the packet to be forwarded, the switching chip retrieves the next-hop information by looking up the hardware table in the stack header, including: When the destination port in the base header is a proxy port, the switching chip determines the forwarding domain corresponding to the packet to be forwarded based on the ingress interface in the base header; The switching chip looks up the hardware routing table based on the forwarding domain corresponding to the packet to be forwarded and the destination IP address of the packet to be forwarded, and obtains the next-hop identifier corresponding to the packet to be forwarded. The switching chip looks up the hardware next-hop table based on the next-hop identifier corresponding to the packet to be forwarded, and obtains the next-hop information corresponding to the packet to be forwarded.
3. The message hardware forwarding method according to claim 1, characterized in that, The hardware table includes a hardware next-hop table; After receiving the packet to be forwarded, the switching chip retrieves the next-hop information by looking up the hardware table in the stack header, including: When the destination port in the base header is not a proxy port and the number of extension headers is 1, the switching chip obtains the specified identifier from the export edit extension header; The switching chip looks up the hardware next-hop table according to the specified identifier to obtain the next-hop information corresponding to the packet to be forwarded.
4. The message hardware forwarding method according to claim 1, characterized in that, The switching chip edits the packet to be forwarded according to the next-hop information and then forwards it, including: The switching chip removes the stack header and updates the source MAC address, destination MAC address, and VLAN in the packet to be forwarded to the source MAC address, destination MAC address, and VLAN in the next-hop information; The switching chip forwards the edited message to be forwarded through the output port in the next-hop information.
5. The message hardware forwarding method according to claim 1, characterized in that, The method further includes: When the original packet does not contain a Segmented Routing Extension Header (SRH), the processor looks up the software routing table based on the destination IP address of the original packet to generate a new SRH, and adds the new SRH to the original packet. When the original message contains the SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is not 0, the processor deletes the IP address of this device from the segment list in the SRH, updates the remaining number of segments, and sets the next-hop IP address in the segment list to the destination address of the IPv6 header. When the SRH exists in the original message, and the segment list in the SRH records the IP address of this device, and the remaining number of segments in the SRH is 0, the processor deletes the SRH from the original message.
6. A network device, characterized in that, It includes a processor and a switching chip, wherein the ports of the switching chip connected to the processor are configured in a stacked mode, and the switching chip is configured in a proxy mode; The processor is used to add a stacking header to the original message to obtain a message to be forwarded; The switching chip is used to obtain the next-hop information by looking up the hardware table according to the stack header after receiving the message to be forwarded. The switching chip is used to edit the message to be forwarded according to the next-hop information and then forward it. Wherein, when the original packet does not contain a Segmented Routing Header (SRH), or when the original packet contains the SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is not 0, the processor is used to add a base header and an egress edit header to the original packet, fill the destination port in the base header with a specified destination port and set the number of extension headers to 1, and set the value of the next hop field in the egress edit header to a specified identifier, thereby obtaining the packet to be forwarded; When the original packet contains the SRH and the segment list in the SRH records the IP address of this device and the remaining number of segments in the SRH is 0, the processor adds the base header to the original packet, sets the destination port in the base header to the proxy port and sets the number of extension headers to 0, sets the ingress interface in the base header to the specified ingress interface, and obtains the packet to be forwarded.
7. The network device according to claim 6, characterized in that, The hardware table includes a hardware routing table and a hardware next-hop table; When the destination port in the base header is a proxy port, the switching chip is used to determine the forwarding domain corresponding to the packet to be forwarded based on the ingress interface in the base header; The switching chip is used to look up the hardware routing table based on the forwarding domain corresponding to the packet to be forwarded and the destination IP address of the packet to be forwarded, and obtain the next hop identifier corresponding to the packet to be forwarded. The switching chip is used to look up the hardware next-hop table according to the next-hop identifier corresponding to the packet to be forwarded, and obtain the next-hop information corresponding to the packet to be forwarded.
8. The network device according to claim 6, characterized in that, The hardware table includes a hardware next-hop table; When the destination port in the base header is not a proxy port and the number of extension headers is 1, the switching chip is used to obtain the specified identifier from the export edit extension header; The switching chip is used to look up the hardware next-hop table according to the specified identifier to obtain the next-hop information corresponding to the packet to be forwarded.
Citation Information
Patent Citations
Interchanger stacking system, slave unit, switching chip and method for processing protocol message
CN106685826A
Cross-network slice segment routing forwarding method and device
CN110266594A