Routing protocol process processing method and apparatus, device and storage medium
By establishing an inter-process session between the main dashboard protocol process and the backup protocol session process in a network device, backing up the target protocol session information, and when the main dashboard protocol process is interrupted, the backup protocol session process takes over the target protocol session, solving the routing interruption problem caused by the restart of the routing protocol process, and achieving high reliability and low memory consumption protocol process restart processing.
Patent Information
- Application Number
- PCT/CN2024/115303
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-08-31
- Filing Date
- 2024-08-28
- Publication Date
- 2025-03-06
AI Technical Summary
In a data communication network, when the routing protocol process is restarted, it will cause the routing protocol session to be interrupted, affecting the forwarding of user data packets. The existing technology has compatibility problems and high memory consumption.
By pre-establishing an inter-process session between the main dashboard protocol process and the backup protocol session process in the network device, the target protocol session information is backed up, and the backup protocol session process takes over the target protocol session when the main dashboard protocol process is interrupted.
No full protocol process backup is required, which reduces memory consumption and improves the security and reliability of the protocol process interrupted restart process, avoiding compatibility issues and the defect of double memory usage.
Smart Images

Figure CN2024115303_06032025_PF_FP_ABST
Abstract
Description
Routing protocol process processing method, device, equipment and storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on August 31, 2023, with application number 202311113285.5 and invention name “Routing Protocol Process Processing Method, Apparatus, Equipment and Storage Medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0003] The present application relates to the field of communication technology, and in particular to a method, apparatus, device and storage medium for processing a routing protocol process. Background Art
[0004] In data communication networks, Layer 3 packets are forwarded through routing. The Layer 3 routing information used to guide data packet forwarding comes mainly from the following sources:
[0005] 1. The network segment routing of the configured interface.
[0006] 2. Through manually configured static routing.
[0007] 3. Routes dynamically learned through routing protocols.
[0008] Most of the routes are learned dynamically by routing protocols. When the routing protocol software on the network device fails and the routing protocol process is restarted, the routing protocol session will be interrupted, resulting in interruption of Layer 3 routing and affecting the forwarding of user data packets.
[0009] There are currently several solutions to this problem:
[0010] 1) Graceful Restart (GR) at the routing protocol level
[0011] When a routing protocol process is restarted, although the routing protocol session is interrupted, the neighboring devices still maintain routing information. After the process is restarted, the protocol neighbor session is re-established, and the neighboring devices assist the restarting device in restoring routing information until the information is restored to the same level as before the restart.
[0012] 2) Full protocol process backup
[0013] Protection is achieved through a complete hot backup of the routing protocol process. The backup routing protocol process has the same information as the original routing protocol process. When the original routing protocol process is restarted, the backup routing protocol is upgraded to the main routing protocol process to interact with external devices.
[0014] 3) Trigger the master-slave control board to switch to NSR protection
[0015] For devices with master-slave control boards and non-stop routing (NSR) protection, when a routing protocol process on the master control board restarts, it directly triggers the master-slave control board to switch, thereby using the routing protocol process on the slave control board to recover.
[0016] 4) Sending proxy protocol keepalive messages
[0017] When the routing protocol process restarts, the service board or the control board sends keepalive messages on behalf of the routing protocol process, thereby ensuring that neighboring devices do not experience session timeouts due to failure to receive keepalive messages.
[0018] Summary of the Invention
[0019] Embodiments of the present application provide a routing protocol process processing method, apparatus, device, and storage medium.
[0020] In a first aspect, an embodiment of the present application provides a method for processing a routing protocol process, applied to a network device, the method comprising:
[0021] Establishing a first inter-process session between a main control board protocol process of the network device and a backup protocol session process of the network device;
[0022] When a target protocol session is established between the main control board protocol process and a neighboring device, first session information of the target protocol session is transmitted to the backup protocol session process through the first inter-process session;
[0023] establishing, through the backup protocol session process, a first internal session corresponding to the target protocol session according to the first session information, wherein the first internal session is configured to be in an unresponsive state; and
[0024] When the main control board protocol process is interrupted, the first internal session is configured to be in a response-enabled state through the backup protocol session process, so that the backup protocol session process takes over the target protocol session through the first internal session.
[0025] In one embodiment, the transmitting the first session information of the target protocol session to the backup protocol session process through the first inter-process session includes:
[0026] passing the identification information of the target protocol session to the backup protocol session process through the first inter-process session; and
[0027] The first session information of the target protocol session is transferred to the backup protocol session process according to the identification information through the first inter-process session.
[0028] In one embodiment, the method further includes:
[0029] When the protocol stack of the network device contains received data from the neighboring device, determining whether a complete protocol message exists in the received data;
[0030] If a complete protocol message exists in the received data, reading the complete protocol message from the protocol stack for protocol processing; and
[0031] If the complete protocol message does not exist in the received data, wait until the protocol message in the received data is complete, and then read the complete protocol message from the protocol stack to perform protocol processing.
[0032] In one embodiment, the transmitting the identification information of the target protocol session to the backup protocol session process through the first inter-process session includes:
[0033] Passing the first identifier of the target protocol session to a protocol stack through the main control board protocol process;
[0034] Allocating a second identifier for the backup protocol session process according to the first identifier by the protocol stack, and associating the second identifier with the target protocol session; and
[0035] The second identifier is transmitted to the backup protocol session process through the protocol stack.
[0036] In one embodiment, before transmitting the first session information of the target protocol session to the backup protocol session process according to the identification information through the first inter-process session, the method further includes:
[0037] Setting the target protocol session to an unresponsive state in the protocol stack through the backup protocol session process;
[0038] querying the protocol stack, through the backup protocol session process, for the first identifier associated with the same session as the second identifier; and
[0039] The backup protocol session process stores the association relationship between the first identifier and the second identifier.
[0040] In one embodiment, the transferring, through the first inter-process session, the first session information of the target protocol session to the backup protocol session method according to the identification information includes:
[0041] The first identifier is transmitted to the backup protocol session process through the main control board protocol process, wherein the first identifier is carried in the first session information of the target protocol session.
[0042] In one embodiment, establishing, by the backup protocol session process, a first internal session corresponding to the target protocol session according to the first session information includes:
[0043] parsing the first identifier carried in the first session information through the backup protocol session process, and determining the second identifier associated with the first identifier based on the first identifier; and
[0044] The first internal session corresponding to the target protocol session is established according to the first session information, and the first internal session is associated with the second identifier.
[0045] In one embodiment, when the main control board protocol process is interrupted, setting the first internal session to an enabled response state by the backup protocol session process to take over the target protocol session includes:
[0046] When the main control board protocol process is interrupted, the protocol stack notifies the backup protocol session process that the first inter-process session is disconnected;
[0047] The backup protocol session process deletes the stored association between the first identifier and the second identifier;
[0048] The backup protocol session process sets the first internal session to the enabled response state in the protocol stack according to the second identifier; and
[0049] The keep-alive processing of the target protocol session is started through the backup protocol session process.
[0050] In one embodiment, determining whether a complete protocol message exists in the received data includes:
[0051] Determining whether the message length of the received data is greater than or equal to the target protocol message header length; and
[0052] If the message length of the received data is greater than or equal to the target protocol message header length, the determining whether there is a complete protocol message in the received data further includes:
[0053] Pre-reading first data of the header length from the protocol stack;
[0054] Parsing the first data to obtain the target protocol message header;
[0055] Determining the complete length of the target protocol message according to the target protocol message header;
[0056] Determining whether the message length of the received data is greater than or equal to the complete length; and
[0057] If the message length of the received data is greater than or equal to the complete length, it is determined that a complete protocol message exists in the received data.
[0058] If the message length of the received data is less than the complete length, it is determined that no complete protocol message exists in the received data.
[0059] In one embodiment, the determining whether the message length of the received data is greater than or equal to the complete length, and the determining whether a complete protocol message exists in the received data, further include:
[0060] If the message length of the received data is less than the target protocol message header length, it is determined that no complete protocol message exists in the received data.
[0061] In one embodiment, if the message length of the received data is greater than or equal to the target protocol message header length, determining whether a complete protocol message exists in the received data further includes:
[0062] If the message length of the received data is greater than or equal to the target protocol message header length, and the message length of the received data is less than the complete length, it is determined that no complete protocol message exists in the received data.
[0063] In one embodiment, after setting the first internal session to an enabled response state through the backup protocol session process to take over the target protocol session, reading the complete protocol message from the protocol stack for protocol processing includes:
[0064] If the complete protocol message is a routing message, the complete protocol message is added to a shared queue of routing-related protocol messages to be processed through the backup protocol session process.
[0065] In one embodiment, the method further includes:
[0066] When the network device sends a target message to the neighbor device, if the target message is not completely sent, the unsent data in the target message is added to a shared queue of messages to be sent, and retry sending of the unsent data is started.
[0067] In one embodiment, the method further includes:
[0068] After the main control board protocol process is restarted, the second session information of the target protocol session maintained by the backup protocol session process is transmitted to the main control board protocol process;
[0069] Establishing, by the main control board protocol process, a second internal session corresponding to the target protocol session according to the second session information, wherein the second internal session is configured to be in an unresponsive state;
[0070] Sending a takeover request for the target protocol session to the backup protocol session process through the main control board protocol process;
[0071] Setting the first internal session to an unresponsive state through the backup protocol session process;
[0072] Responding to the takeover request through the backup protocol session process; and
[0073] The second internal session is set to an enable response state through the main control board protocol process, so that the main control board protocol process takes over the target protocol session through the second internal session.
[0074] In one embodiment, the method further includes:
[0075] Notifying the slave control board protocol process of the network device through the master control board protocol process that the target protocol session is backed up, and the slave control board protocol process backs up the information of the target protocol session and / or the routing information of the target protocol session; and
[0076] When the master control board protocol process is restarted due to an interruption, the routing information of the target protocol session is synchronized to the master control board protocol process through the slave control board protocol process.
[0077] In a second aspect, an embodiment of the present application provides a routing protocol process processing device, wherein the device is applied to a network device, and the device includes:
[0078] A first establishing module, configured to establish a first inter-process session between the main control board protocol process and the backup protocol session process;
[0079] a transfer module, configured to transfer the first session information of the target protocol session to the backup protocol session process through the first inter-process session when a target protocol session is established between the main control board protocol process and a neighboring device;
[0080] a second establishing module, configured to establish, through the backup protocol session process, a first internal session corresponding to the target protocol session according to the first session information, wherein the first internal session is configured to be in an unresponsive state; and
[0081] The takeover module is used to set the first internal session to an enabled response state through the backup protocol session process when the main control board protocol process is interrupted, so that the backup protocol session process takes over the target protocol session through the first internal session.
[0082] In a third aspect, an embodiment of the present application provides an electronic device, including:
[0083] at least one processor; and
[0084] a memory communicatively coupled to the at least one processor;
[0085] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the electronic device to execute the method described in any one of the above aspects.
[0086] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when a processor executes the computer-executable instructions, the method described in any one of the above aspects is implemented.
[0087] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the method described in any one of the above aspects is implemented.
[0088] The routing protocol process processing method, apparatus, device and storage medium provided in the embodiments of the present application are provided by pre-
[0089] Establish a first inter-process session between the main control board protocol process of the network device and the backup protocol session process of the network device; when a target protocol session is established between the main control board protocol process and a neighboring device, pass the first session information of the target protocol session to the backup protocol session process through the first inter-process session; establish a first internal session corresponding to the target protocol session according to the first session information through the backup protocol session process, and the first internal session is configured to be in an unresponsive state; and when the main control board protocol process is interrupted, configure the first internal session to be in an enabled response state through the backup protocol session process, so that the backup protocol session process takes over the target protocol session through the first internal session. In this way, there is no need to perform a full protocol process backup, which reduces memory consumption and improves the security and reliability of the protocol process interruption and restart process. BRIEF DESCRIPTION OF THE DRAWINGS
[0090] The accompanying drawings are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are some embodiments of the present invention, and it is clear that those skilled in the art can derive other drawings based on these drawings without inventive effort.
[0091] FIG1 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
[0092] FIG2 is a schematic diagram of a network topology structure of a routing protocol process processing solution provided in an embodiment of the present application.
[0093] FIG3 is a schematic diagram of a scenario architecture of a routing protocol process processing system provided in an embodiment of the present application.
[0094] FIG4 is a schematic diagram of a scenario architecture of a routing protocol process processing system provided in an embodiment of the present application.
[0095] FIG5 is a flow chart of a method for processing a routing protocol process provided in an embodiment of the present application.
[0096] FIG6 is a schematic diagram of signaling interaction of a routing protocol process processing method provided in an embodiment of the present application.
[0097] FIG7 is a schematic diagram of a process flow for processing a protocol message received by a main control board protocol process according to an embodiment of the present application.
[0098] FIG8 is a schematic diagram of a BGP protocol message header provided in an embodiment of the present application.
[0099] FIG9 is a flow chart of a mechanism for sending protocol messages provided in an embodiment of the present application.
[0100] FIG10 is a schematic diagram of a specific flow of a backup protocol session process taking over a target protocol session 2 provided by an embodiment of the present application.
[0101] FIG11 is a schematic diagram of a flow chart of a backup protocol session process receiving a protocol message according to an embodiment of the present application.
[0102] FIG12 is a schematic diagram of a new protocol process startup flow of a main control board provided in an embodiment of the present application.
[0103] FIG13 is a schematic structural diagram of a network device without a slave control board provided in an embodiment of the present application.
[0104] FIG14 is a schematic structural diagram of a routing protocol process processing device provided in an embodiment of the present application.
[0105] FIG15 is a schematic structural diagram of a cloud device provided in an embodiment of the present application.
[0106] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0107] Exemplary embodiments are described in detail herein, with examples illustrated in the accompanying drawings. When the following description refers to the drawings, identical numerals in different drawings represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with this application.
[0108] The term "and / or" in this article is used to describe the association relationship of associated objects, specifically indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0109] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0110] In order to clearly describe the technical solutions of the embodiments of the present application, the following definitions are given first:
[0111] GR: Graceful Restart, graceful restart at the routing protocol level.
[0112] NSR: Non-Stop Routing.
[0113] TCP: Transmission Control Protocol.
[0114] ACK: Acknowledge, confirm the message.
[0115] Socket: socket.
[0116] BGP: Border Gateway Protocol.
[0117] IP: Internet Protocol, refers to the Internet interconnection protocol.
[0118] AS: Autonomous System, refers to a group of networks that use a unified internal routing protocol.
[0119] OSPF: Open Shortest Path First, OSPF routing protocol is a link-state routing protocol used in Internet Protocol networks.
[0120] IS-IS, Intermediate system to intermediate system, intermediate system to intermediate system.
[0121] In data communication networks, Layer 3 packets are forwarded through routing. The Layer 3 routing information used to guide data packet forwarding comes mainly from the following sources:
[0122] 1. The network segment routing of the configured interface.
[0123] 2. Through manually configured static routing.
[0124] 3. Routes dynamically learned through routing protocols.
[0125] Most of the routes are learned dynamically by routing protocols. When the routing protocol software on the network device fails and the routing protocol process is restarted, the routing protocol session will be interrupted, resulting in interruption of Layer 3 routing and affecting the forwarding of user data packets.
[0126] There are currently several solutions to this problem:
[0127] 1) Graceful Restart (GR) at the routing protocol level
[0128] When a routing protocol process restarts, the routing protocol session is interrupted, but neighboring devices still maintain routing information. After the process restarts, the protocol neighbor session is reestablished, and the neighboring devices assist the restarting device in restoring routing information until it is consistent with the pre-restart information.
[0129] Disadvantages: This solution requires the restarting device to interact with neighboring devices according to the protocol standard to ensure complete recovery. However, in practice, compatibility issues often arise due to different vendors' understanding of the standard, resulting in incomplete or impossible recovery. Furthermore, because the restarting device requires neighboring devices to assist in recovery, this solution cannot support simultaneous failures of multiple devices.
[0130] 2) Full protocol process backup
[0131] Protection is achieved through a complete hot backup of the routing protocol process. The backup routing protocol process has the same information as the original routing protocol process. When the original routing protocol process is restarted, the backup routing protocol is upgraded to the main routing protocol process to interact with external devices.
[0132] Disadvantage: Since the protocol process is fully backed up, the routing information that occupies the most memory will also exist twice in the system, resulting in doubling the protocol's routing memory usage. In the case of the same routing volume, its memory cost is doubled.
[0133] In addition: Since the protocol process is a complete backup, the backup protocol process has most of the same logic as the main protocol process. The same software failure may occur in both processes, and it is more likely that both processes will be restarted at the same time.
[0134] 3) Trigger the master-slave control board to switch to NSR protection
[0135] For devices with master-slave control boards and non-stop routing (NSR) protection, when a routing protocol process on the master control board restarts, it directly triggers the master-slave control board to switch, thereby using the routing protocol process on the slave control board to recover.
[0136] Disadvantages: First, this technical solution requires the presence of both a master and slave control board. Second, similar to full protocol process backup, since the slave-to-master protocol process is also fully backed up, the slave control board's protocol process shares much of the same logic with the master control board's protocol process. The same software failure could potentially occur in both processes, leading to a high probability of simultaneous restarts.
[0137] 4) Sending proxy protocol keepalive messages
[0138] When the routing protocol process restarts, the service board or the control board sends keepalive messages on behalf of the routing protocol process, thereby ensuring that neighboring devices do not experience session timeouts due to failure to receive keepalive messages.
[0139] Disadvantages: This only ensures that neighboring devices will not experience neighbor interruptions. However, because the proxy itself does not handle the protocol state machine, it cannot respond when a session is interrupted. The proxy does not receive and process packets sent by neighbors. Therefore, for TCP-based routing protocol processes, the lack of a TCP ACK sequence number (the proxy does not receive and read packets) may cause a TCP timeout, leading to a routing protocol session interruption.
[0140] Therefore, how to ensure that the protocol neighbor session is not interrupted when the protocol process is restarted and improve the reliability of the routing protocol has become a technical problem that needs to be solved urgently.
[0141] In order to solve the above problems, an embodiment of the present application provides a routing protocol process processing solution, which pre-establishes a first inter-process session between the main control board protocol process and the backup protocol session process. When the network device establishes a target protocol session with the neighboring device, the first session information of the target protocol session is backed up to the backup protocol session process, that is, a first internal session corresponding to the target protocol session is established in the backup protocol session process, and the first internal session is kept in an unresponsive state during the normal operation of the main control board protocol process. When the main control board protocol process is interrupted, the backup protocol session process takes over the target protocol session by configuring the first internal session to an enabled response state, so that the backup protocol session process can send and receive protocol messages and perform periodic keep-alive operations for the target protocol session. In this way, there is no need to perform a full protocol process backup, which reduces memory consumption and improves the security and reliability of the protocol process interruption and restart process.
[0142] As shown in FIG1 , this embodiment provides an electronic device 1, comprising: at least one processor 11 and a memory 12. FIG2 takes one processor as an example. The processor 11 and the memory 12 are connected via a bus 10. The memory 12 stores instructions that can be executed by the processor 11. The instructions are executed by the processor 11 so that the electronic device 1 can execute all or part of the process of the method in the following embodiment, so as to realize that when the main control board protocol process where the target protocol session is located is interrupted and restarted, the backup protocol session process takes over the target protocol session, thereby reducing memory consumption and improving the security and reliability of the session during the restart of the protocol process.
[0143] In one embodiment, the electronic device 1 may be a network device such as a switch, a router, or a gateway, or may be a mobile phone, a tablet computer, a laptop computer, a desktop computer, or a large computing system composed of multiple computers.
[0144] Figure 2 is a schematic diagram of a network topology structure of a routing protocol process processing solution provided by an embodiment of the present application in actual application. As shown in Figure 2, the structure includes: network device R1 and network device R2, wherein:
[0145] In an actual communication network, R1 and R2 can establish a protocol neighbor relationship, such as a BGP neighbor relationship, and can establish a protocol session and exchange session information. Assume that R1's address is 1.1.1.1 and its AS number is 100. R2's address is 2.2.2.2 and its AS number is 100.
[0146] The following describes the implementation scheme of this patent using the R1 device
[0147] The network device R1 and the network device R2 can both be implemented by the electronic device 1 .
[0148] The routing protocol process processing solution of the embodiment of the present application can be deployed on network device R1, can also be deployed on network device R2, or can be deployed partially on network device R1 and partially on network device R2. In actual scenarios, the choice can be based on actual needs and this embodiment does not limit it.
[0149] When the routing protocol process processing solution is fully or partially deployed on the network device R1, a calling interface may be opened to the network device R2 to provide algorithm support for the network device R2.
[0150] The method provided in the embodiment of the present application can be implemented by executing corresponding software codes by the electronic device 1 and by interacting with the server for data.
[0151] The protocol process processing method of the embodiment of the present application can be applied to any field that requires protocol session process processing.
[0152] As shown in Figure 3, a schematic diagram of a routing protocol process processing system scenario architecture provided in an embodiment of the present application is applied to the network device R1 and / or network device R2 shown in Figure 2. The network device includes a main control board protocol process, a backup protocol session process and a protocol stack.
[0153] Among them, the main control board protocol process is used to establish a target protocol session with the neighboring device, and establish an inter-process session with the backup protocol session process through the protocol stack, so that the backup protocol session process can back up the target protocol session through the inter-process session, so that when the main control board protocol process where the target protocol session is located is interrupted and restarted, the backup protocol session process can take over the target protocol session, thereby reducing memory consumption and improving the security and reliability of the session during the restart of the protocol process.
[0154] As shown in Figure 4, a schematic diagram of a routing protocol process processing system scenario architecture provided in an embodiment of the present application is provided. Taking a network device with master-slave control board switching NSR protection as an example, the network device may also include: a slave control board, in which a slave control board protocol process is configured, which is used to perform a complete backup of the master control board protocol process, so as to trigger the master-slave control board switching NSR protection when the master control board protocol process where the target protocol session is located is interrupted and restarted.
[0155] The following detailed description of some embodiments of the present application is provided in conjunction with the accompanying drawings. The following embodiments and features thereof may be combined with one another unless they conflict with each other. Furthermore, the sequence of steps in the following method embodiments is provided for illustrative purposes only and is not intended to be a strict limitation.
[0156] Please refer to Figure 5, which shows a routing protocol process processing method according to an embodiment of the present application. This method can be executed by the electronic device 1 shown in Figure 1 and can be applied to the protocol process processing application scenarios shown in Figures 2 to 4. This method enables the backup protocol session process to take over the target protocol session when the main control board protocol process where the target protocol session is located is interrupted and restarted, thereby reducing memory consumption and improving the security and reliability of the session during the protocol process restart. In this embodiment, taking network device R1 as the execution end as an example, the method includes the following steps:
[0157] Step 501: Establish a first inter-process session between the main control board protocol process and the backup protocol session process.
[0158] In this step, the first inter-process session can be a Socket session. The main control board protocol process can establish an inter-process Socket session 1 (i.e., the first inter-process session) with the backup protocol session process through the protocol stack. Socket session 1 can be established in advance before the target protocol session is established to facilitate timely backup of the target protocol session.
[0159] Step 502: When a target protocol session is established between the main control board protocol process and the neighboring device, first session information of the target protocol session is transferred to the backup protocol session process through the first inter-process session.
[0160] In this step, the master control board protocol process successfully establishes the target protocol session and notifies the backup protocol session process of the first session information and the corresponding socket information. Assume that the target protocol session is the protocol session between network device R1 and neighboring device R2, and assume that the target protocol session is a BGP session. When BGP session 2 is established between the master control board protocol process of network device R1 and neighboring device R2, the first session information of session 2 is transmitted to the backup protocol session process via the socket session 1 pre-established in step 501.
[0161] In one embodiment, step 502 may specifically include: transmitting identification information of the target protocol session to the backup protocol session process through the first inter-process session. Transmitting first session information of the target protocol session to the backup protocol session process through the first inter-process session according to the identification information.
[0162] In this embodiment, when the first session information of the target protocol session 2 is passed to the backup protocol session, the target protocol session 2 can be marked with identification information. The identification information of the target protocol session 2 is first passed to the backup protocol session process, and then the first session information is passed to the backup protocol session process using the identification information as a mark, thereby ensuring the security and reliability of the first session information transmission process.
[0163] In one embodiment, in step 502, transmitting the identification information of the target protocol session to the backup protocol session process through the first inter-process session includes transmitting the first identification of the target protocol session to the protocol stack through the main control board protocol process. The protocol stack assigns a second identification to the backup protocol session process based on the first identification, and associates the second identification with the target protocol session.
[0164] In this embodiment, the session identification information can be represented by a socket descriptor. The socket descriptor is a pointer to an internal data structure that points to a descriptor table entry. In this embodiment, socket descriptor N represents the Nth socket descriptor, not the actual socket descriptor value, where N is a positive integer. Assuming that the first identifier is represented by socket descriptor 1 and the second identifier is represented by socket descriptor 2, the main control board protocol process passes the socket session descriptor 1 of the target protocol session 2 to the backup protocol session process through the socket session 1 between the first processes. During this process, when the protocol stack receives the socket descriptor 1 and passes it to the backup protocol session process, the backup protocol session process allocates socket descriptor 2 for this socket and associates socket descriptor 2 with the socket corresponding to socket descriptor 1. That is, the socket descriptor 1 of the main control board protocol process and the socket descriptor 2 of the backup protocol session process are actually associated with the socket of the target protocol session 2. The protocol stack then passes the socket session descriptor 2 to the backup protocol session process.
[0165] In one embodiment, in step 502, before transmitting the first session information of the target protocol session to the backup protocol session process based on the identification information through the first inter-process session, the process further includes: setting the session associated with the second identifier to an unresponsive state in the protocol stack through the backup protocol session process. The backup protocol session process queries the protocol stack for the first identifier associated with the same session as the second identifier. The backup protocol session process stores the association between the first identifier and the second identifier.
[0166] In this embodiment, the unresponsive state of a session may mean that the Socket of this session needs to be prohibited from responding to the corresponding process for readable data. Specifically, when the backup protocol session process receives the Socket session descriptor 2 of the target protocol session 2, it can set the protocol stack to prohibit the Socket from responding to the backup protocol session process for readable data. That is, when the Socket receives data, it does not need to send a notification to the backup protocol session process to prevent the backup protocol session process from reading the data. The backup protocol session process queries the protocol stack for the Socket descriptor of other processes in the same Socket session associated with Socket descriptor 2, namely, Socket descriptor 1. The backup protocol session process then stores the association between the Socket descriptor 1 of other processes and the local Socket descriptor 2.
[0167] In one embodiment, in step 502, the first session information of the target protocol session is passed to the backup protocol session process according to the identification information through the first inter-process session, including: carrying the first identifier in the first session information of the target protocol session through the main control board protocol process and passing it to the backup protocol session process.
[0168] In this embodiment, the master control board protocol process notifies the backup protocol session process of the first session information of the target protocol session 2 through the first inter-process Socket session 1. The first session information is identified by the master control board protocol process's Socket descriptor 1. This ensures that the first session information is accurately delivered to the backup protocol session process.
[0169] Step 503: A first internal session corresponding to the target protocol session is established according to the first session information through the backup protocol session process, and the first internal session is configured to be in an unresponsive state.
[0170] In this step, the backup protocol session process establishes a first internal session corresponding to the target protocol session 2 based on the first session information, thereby backing up the session information and socket of the target protocol session 2. The routing information of the target protocol session 2 includes various routing table information, which will occupy a large amount of memory resources. Here, the backup protocol session process does not back up the routing information of the target protocol session 2, which can greatly save memory resources while ensuring that the session is not interrupted. The first internal session is configured to be unresponsive, that is, when the socket of the target protocol session 2 receives data, it does not need to send a notification to the backup protocol session process, thereby preventing the backup protocol session process from reading the data.
[0171] In one embodiment, step 503 may specifically include: parsing the first identifier carried in the first session information through the backup protocol session process, searching for the second identifier locally associated with the first identifier, establishing a first internal session corresponding to the target protocol session based on the first session information through the backup protocol session process, and associating the first internal session with the second identifier.
[0172] In this embodiment, the backup protocol session process receives the first session information of the target protocol session 2 and searches for the associated local socket descriptor 2 based on the first identifier socket descriptor 1 carried in the first session information. The backup protocol session process creates a first internal session based on the first session information and associates the first internal session with the local socket descriptor 2.
[0173] In one embodiment, the network device R1 further includes a slave control board protocol process. The method further includes: notifying the slave control board protocol process via the master control board protocol process to back up the target protocol session, and the slave control board protocol process backing up information of the target protocol session.
[0174] In this embodiment, if network device R1 has a non-stop routing function, that is, a slave control board protocol process as shown in FIG4 , the master control board protocol process can notify the slave control board protocol process to back up the information of the target protocol session 2. The specific steps can be implemented according to the relevant procedures of the routing protocol NSR (Non-Stop Routing).
[0175] Step 504: When the main control board protocol process is interrupted, the backup protocol session process is used to set the first internal session to an enabled response state, so that the backup protocol session process takes over the target protocol session through the first internal session.
[0176] In this step, when the main control board protocol process is interrupted, in order to ensure the normal sending and receiving of messages in the target protocol session 2, the backup protocol session process takes over the target protocol session 2. Specifically, the backup protocol session process sets the first internal session to an enabled response state, that is, sets the first internal session to enable read data response, so that the backup protocol session process takes over the target protocol session through the first internal session.
[0177] In one embodiment, step 504 may specifically include: when the main control board protocol process is interrupted, the protocol stack notifies the backup protocol session process that the first inter-process session is disconnected. The backup protocol session process deletes the locally stored association. The backup protocol session process sets the first internal session to an enabled response state in the protocol stack based on the second identifier. The backup protocol session process initiates keepalive processing for the target protocol session.
[0178] In this embodiment, the first internal session is a backup of the session information and Socket of the target protocol session 2 by the backup protocol session process. When the main control board protocol process is interrupted, the protocol stack notifies the backup protocol session process that the inter-process Socket session 1 is disconnected. The backup protocol session process deletes the association between the previously stored local protocol session Socket descriptor 2 and the Socket descriptor 1 of the main control board protocol process. The backup protocol session process then performs the following processing on the synchronized first internal session: first, it sets the Socket descriptor 2 corresponding to the first internal session to the protocol stack to enable the read data response. Then, the keep-alive message periodic sending timer of the first internal session is started. The keep-alive timeout timer of the first internal session can also be started. Finally, the backup protocol session process takes over the keep-alive message periodic sending processing and keep-alive message timeout detection processing of the target protocol session 2.
[0179] The above-mentioned routing protocol process processing method pre-establishes a first inter-process session between the main control board protocol process and the backup protocol session process. When the network device establishes a target protocol session with the neighboring device, the first session information of the target protocol session is backed up to the backup protocol session process, that is, a first internal session corresponding to the target protocol session is established in the backup protocol session process, and the first internal session is kept in an unresponsive state during the normal operation of the main control board protocol process. When the main control board protocol process is interrupted, the first internal session is configured to be in an enabled response state, and the backup protocol session process takes over the target protocol session, so that the backup protocol session process can send and receive protocol messages of the target protocol session and perform periodic keep-alive operations. In this way, there is no need to perform a full protocol process backup, which reduces memory consumption and improves the security and reliability of the protocol process interruption and restart process.
[0180] Please refer to Figure 6, which is a signaling interaction diagram of a routing protocol process processing method according to an embodiment of the present application. This method can be executed by the electronic device 1 shown in Figure 1 and can be applied to the protocol process processing application scenarios shown in Figures 2 to 4. This method enables the backup protocol session process to take over the target protocol session when the main control board protocol process where the target protocol session is located is interrupted and restarted, thereby reducing memory consumption and improving the security and reliability of the session during the protocol process restart. This embodiment uses the network device R1 with a master-slave control board as the execution end and takes the protocol session establishment process under normal circumstances as an example. The method includes the following steps:
[0181] 1) The main control board protocol process establishes an inter-process Socket session 1 with the backup protocol session process through the protocol stack.
[0182] 2) The backup protocol session process establishes an inter-process Socket session 1 with the main control board protocol process through the protocol stack.
[0183] 3) The main control board protocol process establishes protocol session 2 with the neighboring device.
[0184] 4) The main control board protocol process passes the Socket session descriptor 1 of the protocol session 2 to the backup protocol session process through the inter-process Socket session 1.
[0185] 5) When the protocol stack receives the Socket session descriptor 1 and passes it to the backup protocol session process, the backup protocol session process allocates Socket descriptor 2 for this Socket and associates Socket descriptor 2 with the Socket corresponding to Socket descriptor 1. That is, Socket descriptor 1 of the main control board protocol process and Socket descriptor 2 of the backup protocol session process are actually associated with the Socket of protocol session 2.
[0186] 6) The protocol stack passes Socket descriptor 2 to the backup protocol session process.
[0187] 7) The backup protocol session process receives the Socket descriptor 2 of this protocol session and sets the protocol stack to prohibit the Socket from responding to data readability from this process (that is, when data is received, there is no need to send a notification to the process to allow it to read the data).
[0188] 8) The backup protocol session process queries the protocol stack for the socket descriptor of the other process of the same socket session associated with socket descriptor 2, that is, socket descriptor 1.
[0189] 9) The backup protocol session process stores the association between the Socket descriptor 1 of the other process and the local Socket descriptor 2.
[0190] 10) The main control board protocol process notifies the backup protocol session process of the session information of the protocol session 2 through the inter-process Socket session 1. The session information is identified by the Socket descriptor 1 of the main control board protocol process.
[0191] 11) The backup protocol session process receives the session information of the protocol session 2, and searches for the associated local Socket descriptor 2 according to the identifier Socket descriptor 1 carried in the session information.
[0192] 12) The backup protocol session process creates an internal session (ie, a first internal session) according to the session information and associates it with the local Socket descriptor 2.
[0193] 13) The master control board protocol process notifies the slave control board protocol process of session information backup. When the master control board protocol process learns protocol messages (including routing-related messages) and stores routing information, it synchronizes the protocol messages to the slave control board protocol process in real time, and the slave control board protocol process stores the routing information.
[0194] For example, in Figure 2, target protocol session 2 is a BGP session. A BGP neighbor relationship is established between network devices R1 and R2, where R1's address is 1.1.1.1 and R2's address is 2.2.2.2. The following describes the normal BGP session establishment and process, using network device R1 as the execution agent:
[0195] 1) The BGP process on the main control board establishes an inter-process socket session 1 with the backup protocol session process through the protocol stack.
[0196] 2) The main control board BGP process establishes a BGP session with neighbor device R2, where the local IP address is 1.1.1.1, the local AS number is 100, and the neighbor IP address is 2.2.2.2, and the neighbor AS number is 100. The socket descriptor corresponding to this BGP session on the main control board BGP process is 100.
[0197] 3) The BGP process of the main control board passes the Socket descriptor 100 of the BGP session to the backup protocol session process through the inter-process Socket session 1.
[0198] 4) When the protocol stack receives the Socket descriptor 100 and passes it to the backup protocol session process, the backup protocol session process allocates a Socket descriptor 200 for the Socket and associates the Socket descriptor 200 with the Socket corresponding to the Socket descriptor 100.
[0199] 5) The protocol stack passes the Socket descriptor 200 to the backup protocol session process.
[0200] 6) The backup protocol session process receives the Socket descriptor 200 of this BGP session and sets the protocol stack to prohibit the Socket from responding to this process so that data can be read.
[0201] 7) The backup protocol session process queries the protocol stack for the socket descriptors 100 of other processes in the same socket session to which the socket descriptor 200 is associated.
[0202] 8) The backup protocol session process stores the association relationship between the Socket descriptor 100 of other processes and the local Socket descriptor 200.
[0203] 9) The master control board BGP process notifies the backup protocol session process of BGP session information via inter-process socket session 1. This session information is identified by the master control board protocol process's socket descriptor 100. This session information may include the BGP session's local IP address, local AS number, neighbor IP address, neighbor AS number, and other information.
[0204] 10) The backup protocol session process receives the session information of the BGP session and searches for the associated local socket descriptor 200 according to the identification socket descriptor 100 carried in the BGP session information.
[0205] 11) The backup protocol session process creates an internal BGP session based on the BGP session information and associates it with the local socket descriptor 200.
[0206] 12) The master control board BGP process notifies the slave control board BGP process of the BGP session information.
[0207] In one embodiment, when the relevant protocol is processing a received protocol message, it generally reads as much data as the protocol stack has. Even if the message data cannot form a complete protocol message, the data will first be read from the protocol stack and then placed in the message cache inside the process to wait for the message to be complete before processing. In order to ensure that the received data is not lost when the subsequent backup protocol session process takes over, the method may also include: when there is received data from a neighboring device in the protocol stack, determining whether there is a complete protocol message in the received data. If there is a complete protocol message in the received data, the complete protocol message is read from the protocol stack for protocol processing. If there is no complete protocol message in the received data, the complete protocol message is read from the protocol stack after the protocol message in the received data is complete and then protocol processing is performed.
[0208] In this embodiment, to ensure that received data is not lost when the backup protocol session process takes over, a method is provided to pre-read the protocol message header, parse the protocol message header, and then pre-read the complete protocol message based on the protocol message header for processing. Reading and processing are performed only when the protocol stack has a complete received protocol message. This ensures that when the backup protocol session process takes over after the main control board protocol process is restarted, received data will not be lost.
[0209] In one embodiment, determining whether a complete protocol message exists in the received data includes: determining whether the message length of the received data is greater than or equal to the target protocol message header length. If the message length of the received data is greater than or equal to the target protocol message header length, pre-reading first data of the header length from the protocol stack. Parsing the first data to obtain the target protocol message header. Determining the complete length of the target protocol message based on the target protocol message header. Determining whether the message length of the received data is greater than or equal to the complete length. If the message length of the received data is greater than or equal to the complete length, determining that a complete protocol message exists in the received data. If the message length of the received data is less than the target protocol message header length, or the message length of the received data is greater than or equal to the target protocol message header length, and the message length of the received data is less than the complete length, determining that a complete protocol message does not exist in the received data.
[0210] In this embodiment, the protocol message header may be pre-read, the protocol message header may be parsed, and then the complete protocol message may be pre-read based on the protocol message header for processing.
[0211] As shown in FIG7 , which is a flowchart of the master control board protocol process receiving protocol messages according to an embodiment of the present application, the network device R1 with a master-slave control board is used as the execution end. Taking the master control board protocol process receiving protocol messages under normal circumstances as an example, the process may include the following steps:
[0212] 1. The protocol stack notifies the main control board that there is readable data in the socket descriptor 1 of the protocol session 2. The readable data here refers to the data received by the network device R1 through the target protocol session 2.
[0213] 2. If the opt module determines that the length of the readable data in the protocol stack is greater than or equal to the target protocol header length, the main control board protocol process pre-reads the first data of the target protocol header length from the protocol stack. Pre-reading means that although the data is read, the read message data is still in the protocol stack. Otherwise, the process exits and waits for the data message to be complete.
[0214] 3. Parse the target protocol message header based on the pre-read first data.
[0215] 4. Based on the parsed target protocol message header, if the opt module determines that the readable data message length in the protocol stack is greater than or equal to the complete protocol message length specified in the target protocol message header (i.e., the complete length of the target protocol message), the main control board protocol process pre-reads the complete protocol message length from the protocol stack based on the complete message length specified in the protocol message header. Otherwise, the process exits and waits for the data message to be completed.
[0216] 5. The main control board protocol process performs protocol processing based on the pre-read complete protocol message.
[0217] 6. The protocol process of the master control board synchronizes the pre-read complete protocol message to the protocol process of the slave control board.
[0218] 7. The control board protocol process performs protocol processing on the synchronized complete protocol message.
[0219] 8. The slave control board protocol process responds to the master control board protocol process that the protocol message has been processed.
[0220] 9. The main control board protocol process actually reads the data of the complete protocol message from the protocol stack.
[0221] For example, network device R1 receives a BGP update message from neighbor device R2. Assume that neighbor device R2 sends a BGP update message (routing-related message) to network device R1, and the length of the BGP update message is assumed to be 200 bytes. Figure 8 shows a schematic diagram of the BGP protocol message header, which includes:
[0222] Marker: Checks whether the synchronization information of the BGP peer is complete. If this verification is not used, all bits are 1.
[0223] Length: The total length of the BGP message, including the message header, in bytes.
[0224] Type: BGP message type.
[0225] The BGP message header can be 19 bytes. Assuming that network device R1 has a master-slave control board, the specific processing flow for network device R1 to receive a BGP update message from neighbor device R2 can be as follows:
[0226] 1. The protocol stack notifies the main control board that readable data exists in BGP session socket descriptor 100.
[0227] 2. If the readable data message length (200 bytes) in the protocol stack is greater than the 19-byte BGP message header, the BGP process on the main control board pre-reads 19 bytes of data from the protocol stack.
[0228] 3. Parse the BGP message header based on the pre-read 19 bytes of data.
[0229] 4. Based on the parsed BGP message header, the complete length of the BGP message is 200 bytes. The readable data message length of 200 bytes in the protocol stack is equal to the expected complete length of the BGP message, 200 bytes. The backup protocol session process protocol stack pre-reads the byte data (since the previous 19 bytes were not actually read, this pre-reading still starts from the beginning).
[0230] 5. The BGP process on the main control board performs protocol processing based on the pre-read BGP message.
[0231] 6. The master control board BGP process synchronizes the pre-read BGP message to the slave control board BGP process.
[0232] 7. The control board BGP process performs protocol processing on the synchronized BGP messages.
[0233] 8. The BGP process on the slave control board responds to the BGP process on the master control board that the BGP message has been processed.
[0234] 9. The BGP process on the main control board actually reads the 200-byte BGP data from the protocol stack.
[0235] In one embodiment, in order to ensure that when the backup protocol session process takes over when the subsequent main control board protocol process is restarted, no data loss occurs, the method may also include: when the current network device sends a target message to a neighboring device, if the target message is not sent completely, the unsent data in the target message is added to the shared queue of messages to be sent, and retry sending is initiated for the unsent data.
[0236] In this embodiment, the shared queue of messages to be sent can be shared by the main control board protocol process and the backup protocol session process. When sending protocol messages, for incomplete protocol messages, the remaining unsuccessfully sent messages are stored in the shared queue of messages to be sent, so that when the main control board protocol process is restarted later, the sent data will not be lost when the backup protocol session process takes over.
[0237] As shown in FIG9 , a protocol message sending mechanism process provided in an embodiment of the present application includes:
[0238] Step 901: Determine whether there is a message in the shared queue of messages to be sent. If so, jump to step 902. Otherwise, jump to step 908. The shared queue of messages to be sent here stores the complete protocol message information that has not been sent to the protocol stack (that is, there may be only part of the data of the protocol stack). This queue is shared by the main control board protocol process and the backup protocol session process, and each protocol session has a queue. In terms of time, only one process will operate at the same time. When the main control board protocol process is normal, the main control board protocol process will operate this queue. When the main control board protocol process is restarted and recovered, the backup protocol process will take over the session, and at this time, the backup protocol process will operate this queue.
[0239] Step 902: Add the protocol message to be sent to the shared queue of messages to be sent.
[0240] Step 903: Determine whether the shared queue of messages to be sent is empty. If not, jump to step 904. Otherwise, jump to step 911.
[0241] Step 904: Send the protocol message at the head of the queue to the protocol.
[0242] Step 905: Determine whether the protocol message is sent completely, if not, jump to step 906. Otherwise, jump to step 907.
[0243] Step 906: Update the protocol message information cached at the head of the shared queue for messages to be sent, and delete some message data that has been sent. Jump to step 911.
[0244] Step 907: Pop out the protocol message at the head of the shared queue of messages to be sent (ie, the first protocol message data at the head of the queue), and then continue to jump to step 903.
[0245] Step 908: Send the protocol message to the protocol stack.
[0246] Step 909: Determine whether the protocol message is sent completely, if not, jump to step 910. Otherwise, jump to step 911.
[0247] Step 910: Add the incomplete protocol message to the shared queue of messages to be sent. Partial message data that has been sent does not need to be added to the queue. Jump to step 911.
[0248] Step 911: Determine whether the shared queue of messages to be sent is empty. If not, proceed to step 912; otherwise, exit the process.
[0249] Step 912: Start the retry sending timer and perform the retry sending process.
[0250] In one embodiment, assuming that the aforementioned network device R1 is the current network device, and taking R1 sending a BGP update message to R2 as an example, where the BGP update message length is assumed to be 200 bytes, the BGP update message sending process can be as follows:
[0251] 1. Suppose network device R1 determines that there are no messages in the shared queue for outgoing BGP sessions. The BGP process on the main control board sends the protocol message directly to the protocol stack. Assume that the current BGP session contains a large number of TCP retransmitted messages in the protocol stack, so only 100 bytes are successfully sent to the protocol stack.
[0252] 2. Since the 200-byte BGP message has not been sent completely, the remaining 100-byte BGP message that has not been sent is added to the shared queue of messages to be sent.
[0253] 3. Start the retry sending timer and perform the retry sending process.
[0254] In one embodiment, when the main control board protocol process is interrupted and restarted, the specific process of the backup protocol session process taking over the target protocol session 2 in step 504 can be as shown in FIG10 , including:
[0255] 1. The protocol stack notifies the backup protocol session process that the inter-process socket session 1 is disconnected.
[0256] 2. The backup protocol session process deletes the previously stored association between the local protocol session Socket descriptor 2 and the main control board protocol process Socket descriptor 1.
[0257] 3. The backup protocol session process performs the following processing on the synchronized protocol session: first, it sets the Socket descriptor 2 corresponding to the protocol session to the protocol stack to enable the read data response.
[0258] 4. Start the keep-alive message period sending timer of the protocol session.
[0259] 5. Start the keep-alive timeout timer for the protocol session.
[0260] Through steps 4 and 5 shown in FIG10 , the backup protocol session process takes over the periodic sending of keep-alive messages and the timeout detection of keep-alive messages of the protocol session.
[0261] Taking the target protocol session 2 as a BGP session as an example, assuming that the aforementioned network device R1 is the current network device, and taking the BGP process of the main control board restarted and the backup protocol session process taking over the BGP session as an example, the takeover process can be as follows:
[0262] 1. The protocol stack notifies the backup protocol session process that Socket session 1 with the BGP process on the active control board is disconnected.
[0263] 2. The backup protocol session process deletes the association between the previously stored local Socket descriptor 200 of the BGP session and the Socket descriptor 100 of the main control board protocol process.
[0264] 3. The backup protocol session process sets the socket descriptor corresponding to the BGP session to 200 in the protocol stack to enable the response data to be readable.
[0265] 4. The backup protocol session process starts the keepalive message sending period timer of the BGP session.
[0266] 5. The backup protocol session process starts the keepalive timeout timer of the BGP session.
[0267] In one embodiment, after step 504, that is, after the backup protocol session process takes over the target protocol session, the complete protocol message is read from the protocol stack for protocol processing, which may specifically include: if the complete protocol message is a routing message, the complete protocol message is added to the shared queue of routing-related protocol messages to be processed through the backup protocol session process.
[0268] In this embodiment, the backup protocol session process will not back up the routing information of the target protocol session when it takes over, and therefore will not process routing messages. In order to avoid the loss of routing information, a shared queue of protocol messages related to routing to be processed can be configured. After the main control board protocol process is interrupted and before it is restarted and restored, the backup protocol session process will add the routing messages to the shared queue of protocol messages related to routing to be processed, so that after the main control board protocol process is restarted, the routing information can be obtained from the shared queue of protocol messages related to routing to be processed for processing, thereby ensuring the information integrity of the target protocol session.
[0269] FIG11 is a flow chart showing a backup protocol session process receiving a protocol message according to an embodiment of the present application. After the backup protocol session process takes over the target protocol session, the protocol message receiving process may specifically include:
[0270] 1. The protocol stack notifies the backup protocol session process that readable data exists in Socket descriptor 2 of target protocol session 2.
[0271] 2. If the opt module determines that the length of the readable data packet in the protocol stack is greater than or equal to the protocol packet header, the backup protocol session process pre-reads data of the protocol packet header length from the protocol stack. Otherwise, it exits the process and waits for the data packet to be complete.
[0272] 3. Parse the protocol message header based on the pre-read data.
[0273] 4. Based on the parsed protocol message header, if the opt module determines that the length of the readable data message in the protocol stack is greater than or equal to the complete protocol message length specified in the protocol message header, the backup protocol session process pre-reads the complete protocol message length from the protocol stack based on the complete message length specified in the protocol message header. Otherwise, the process exits and waits for the data message to be completed.
[0274] 5. If the protocol message read is a routing message, it is added to the shared queue for routing-related protocol messages to be processed. Because the backup protocol session process only handles protocol session state machine-related processing and does not include routing-related processing, routing-related messages must be cached and processed by the new protocol process after the main control board restarts.
[0275] 6. Otherwise, the backup protocol session process processes the protocol message.
[0276] 7. The backup protocol session process actually reads the protocol message data from the protocol stack.
[0277] Taking target protocol session 2 as a BGP session as an example, assuming that the aforementioned network device R1 is the current network device, after the backup protocol session process takes over the BGP session, when device R2 sends a BGP update message (route-related message) to device R1, the BGP update message length is assumed to be 200 bytes. The backup protocol session process may specifically receive the BGP update message from R2, including:
[0278] 1. The protocol stack notifies the backup protocol session process that there is readable data in the BGP session socket descriptor 200.
[0279] 2. The length of the readable data message in the protocol stack (200 bytes) is greater than the length of the BGP message header (19 bytes). The backup BGP session process pre-reads 19 bytes of data from the protocol stack.
[0280] 3. Parse the BGP message header based on the pre-read 19 bytes of data.
[0281] 4. Based on the parsed BGP message header, the complete length of the BGP message is 200 bytes. The readable data message length of 200 bytes in the protocol stack is equal to the expected complete length of the BGP message, 200 bytes. The backup protocol session process protocol stack pre-reads the byte data (since the previous 19 bytes were not actually read, this pre-reading still starts from the beginning).
[0282] 5. According to the BGP message header, it is known that this protocol message is a BGP update message, which is a routing-related message. The message is added to the shared queue of routing-related protocol messages to be processed.
[0283] 6. The backup protocol session process actually reads the 200-byte BGP message data from the protocol stack.
[0284] In one embodiment, after step 504, the process may further include: a process of restarting the main control board protocol process, which may specifically include: after the main control board protocol process is restarted, passing the second session information of the target protocol session maintained by the backup protocol session process to the main control board protocol process. The main control board protocol process establishes a second internal session corresponding to the target protocol session according to the second session information, and the second internal session is configured to be in an unresponsive state. The main control board protocol process sends a takeover request for the target protocol session to the backup protocol session process. The backup protocol session process sets the first internal session to an unresponsive state. The backup protocol session process responds to the takeover request. The main control board protocol process sets the second internal session to an enabled response state, so that the main control board protocol process takes over the target protocol session through the second internal session.
[0285] In this embodiment, after the master control board protocol process restarts, it requests the backup protocol session process to restore session information. The backup protocol session process synchronizes the session and socket information with the master control board protocol process. The master control board protocol process creates the corresponding session and associates the socket with it, then requests the backup protocol session process to take over the session. The backup protocol session process no longer handles session message sending and receiving, or keepalive operations, and sends a takeover request response to the master control board protocol process, allowing the newly restarted master control board protocol process to take over session message sending and receiving, and keepalive operations.
[0286] In one embodiment, for a network device including a slave control board protocol process, if the slave control board protocol process backs up information about a target protocol session and routing information from the target protocol session, when the master control board protocol process is interrupted and restarted, the routing information of the target protocol session can be synchronized with the master control board protocol process via the slave control board protocol process.
[0287] In one embodiment, when the main control board protocol process is restarted:
[0288] 1. The backup protocol session process senses the restart of the main control board protocol process through the interaction channel with the main control board protocol process.
[0289] 2. The backup protocol session process takes over the sending, receiving and keep-alive operations of the session messages.
[0290] 3. The backup protocol session process periodically sends keep-alive messages.
[0291] 4. The backup protocol session process receives and processes the messages sent by the neighboring device. If they are routing-related messages, they are cached in the shared routing message cache. If they are keepalive messages, the keepalive timer is reset.
[0292] In one embodiment, the backup protocol session process may periodically receive and process messages sent by neighboring devices, such as the time at which keep-alive messages are sent.
[0293] 6. When the main control board protocol process restarts, it requests the backup protocol session process to restore the session information. The backup protocol session process synchronizes the session and socket information to the main control board protocol process.
[0294] 7. The main control board protocol process creates the corresponding session and associates the socket, and requests the backup protocol session process to take over the session.
[0295] 8. The backup protocol session process no longer handles the sending and receiving of session messages and the keep-alive operation processing, and sends a request to take over the response to the main control board protocol process.
[0296] 9. The main control board protocol process takes over the sending, receiving and keep-alive operations of session messages.
[0297] 10. The master control board protocol process requests the slave control board protocol process to synchronize the original routing information.
[0298] 11. The slave control board protocol process synchronizes routing-related information to the master control board protocol process, and the master control board protocol process restores the original routing information storage.
[0299] 12. During this period, the main control board protocol process periodically sends keepalive messages to neighboring devices, receives and processes messages sent by neighboring devices, and caches routing-related messages in the shared routing message cache (routes have not yet been restored, so routing-related messages can be cached first). If it is a keepalive message, the keepalive timer is reset.
[0300] In one embodiment, the main control board protocol process may periodically receive and process messages sent by neighboring devices during this period, such as the keep-alive message sending time.
[0301] 14. After the slave control board protocol process completes synchronizing routing information to the master control board protocol process, the master control board protocol process processes the cached shared routing message cache and resumes normal interaction with neighboring devices.
[0302] FIG12 is a schematic diagram of a process flow for starting a new protocol process on a master control board according to an embodiment of the present invention. When the new protocol process on the master control board is restarted, the backup protocol session process will take over the protocol session processing. The specific process can be as follows:
[0303] 1. After the main control board protocol process is started, an inter-process Socket session 3 (second inter-process session) will be established between the protocol stack and the backup protocol session process.
[0304] 2. The protocol stack establishes an inter-process socket session 3 between the main control board protocol process and the backup protocol session process.
[0305] 3. The backup protocol session process performs the following processing on the first internal session: passing the Socket descriptor 2 of the target protocol session 2 to the main control board protocol process through the protocol stack.
[0306] 4. The protocol stack allocates Socket descriptor 3 for the new protocol process of the main control board and associates Socket descriptor 3 with the Socket of Socket description 2.
[0307] 5. The protocol stack passes the socket descriptor 3 of the target protocol session 2 to the main control board protocol process.
[0308] 6. The main control board protocol process sets Socket descriptor 3 to the protocol stack to prohibit triggering a read data response to this process. Since the target protocol session 2 is still taken over by the backup protocol session process, the main control board protocol process needs to set this.
[0309] 7. The main control board protocol process queries the protocol stack for the socket descriptor 2 of other processes that are associated with the same socket as the socket descriptor 3.
[0310] 8. The main control board protocol process stores the association between local Socket descriptor 3 and Socket descriptor 2.
[0311] 9. After passing Socket descriptor 2 of target protocol session 2, the backup protocol session process continues to notify the main control board protocol process of the session information of target protocol session 2, which is identified as Socket descriptor 2.
[0312] 10. The main control board protocol process receives the session information of the target protocol session 2 and searches for the associated local socket descriptor 3 based on its identification socket descriptor 2.
[0313] 11. The main control board protocol process creates an internal protocol session, that is, creates a second internal session, based on the session information of the notified protocol session 2, and associates the second internal session with the local socket descriptor 3.
[0314] 12. When the target protocol session 2 and the session Socket descriptor of the main control board protocol process have been restored, the main control board protocol process requests the backup protocol session process to take over the protocol session 2, which is identified by the backup protocol process's Socket descriptor 2.
[0315] 13. The backup protocol session process searches for the corresponding protocol session based on Socket descriptor 2.
[0316] 14. The backup protocol session process sets Socket descriptor 2 to the protocol stack to prohibit triggering a read data response to this process.
[0317] 15. The backup protocol session process closes the protocol session 2 related timers (such as the keep-alive message sending timer and the timeout timer), reads and writes message data processing, and performs state machine processing.
[0318] 16. The backup protocol session process queries the protocol stack for Socket descriptor 3 of other processes that are associated with the same Socket as Socket descriptor 2.
[0319] 17. The backup protocol session process stores the association between the local Socket descriptor 2 and the Socket descriptors 3 of other processes associated with the same Socket.
[0320] 18. The backup protocol process responds to the main control board protocol process that the protocol process can receive protocol session 2 management.
[0321] 19. The main control board protocol process sets the socket descriptor 3 corresponding to the session to the protocol stack to enable the response data to be readable.
[0322] 20. Main control board protocol process starts the keep-alive message period sending timer of the protocol session
[0323] 21. The main control board protocol process starts the keep-alive timeout timer of the protocol session.
[0324] 22. The master control board protocol process requests the slave control board protocol process to synchronize the original routing information from the protocol session
[0325] 23. The slave control board protocol process synchronizes routing information from the protocol session to the master control board protocol process.
[0326] 24. The main control board protocol process stores the synchronized routes.
[0327] 25. After the slave control board protocol process completes synchronizing the routes from the protocol session, it notifies the master control board protocol process that the routes of the protocol session have been notified.
[0328] 26. If the opt module determines that there are messages in the shared queue of routing-related protocol messages to be processed, it processes the protocol messages in the queue.
[0329] For example, if target protocol session 2 is a BGP session, and network device R1 is the current network device, when the new BGP protocol process on the master control board restarts, the master control board BGP protocol process will take over BGP session processing from the backup protocol session process. The specific process is as follows:
[0330] 1. After the BGP process of the main control board is started, an inter-process Socket session will be established between the protocol stack and the backup protocol session process.
[0331] 2. The backup protocol session process transmits the socket descriptor 200 of the protocol BGP session to the BGP process of the main control board through the protocol stack.
[0332] 3. The protocol stack allocates socket descriptor 300 to the BGP process of the main control board and associates it with the socket of socket description 200.
[0333] 4. The protocol stack passes the BGP session socket descriptor 300 to the BGP process of the main control board.
[0334] 5. The BGP process on the main control board sets Socket descriptor 300 to the protocol stack to prohibit readable response data to this process.
[0335] 6. The BGP process on the main control board queries the protocol stack for the socket descriptor 200 of the same socket associated with the socket descriptor 300.
[0336] 7. Store the association relationship between the local Socket descriptor 300 and the Socket descriptors 200 of other processes.
[0337] 8. The backup protocol session process continues to notify the BGP session information of the BGP session to the main control board BGP process, which is identified by Socket descriptor 200.
[0338] 9. The BGP process of the main control board receives the notification BGP session information and searches for the associated local socket descriptor 300 according to its identification socket descriptor 200.
[0339] 10. The main control board BGP process creates a BGP session based on the notified BGP session information and associates it with the local socket descriptor 300.
[0340] 11. The BGP process of the main control board requests the backup protocol session process to take over the BGP session, which is identified by the socket descriptor 200 of the backup protocol session process.
[0341] 12. The backup protocol session process searches for the corresponding BGP session based on Socket descriptor 200.
[0342] 13. The backup protocol session process sets the socket descriptor 200 to the protocol stack to prohibit the response data from being readable to this process.
[0343] 14. The backup protocol session process turns off BGP session-related timers (such as keep-alive message sending timer and timeout timer), reads and writes message data processing, and performs state machine processing.
[0344] 15. The backup protocol session process queries the protocol stack for the socket descriptor 300 of the BGP process associated with the same socket as the socket descriptor 200.
[0345] 16. The backup protocol session process stores the association relationship between the local Socket descriptor 200 and the Socket descriptor 300 associated with the same Socket.
[0346] 17. The backup protocol session process responds to the main control board BGP process that the BGP process can receive BGP session management.
[0347] 18. The BGP process on the main control board sets the socket descriptor 300 corresponding to the session to the protocol stack, enabling the response data to be readable.
[0348] 19. The main control board BGP process starts the BGP session keepalive message period sending timer
[0349] 20. The BGP process on the main control board starts the keepalive timeout timer for the BGP session.
[0350] 21. The master control board BGP process requests the slave control board BGP process to synchronize BGP routing information from the BGP session
[0351] 22. Synchronize routing information from the BGP session from the control board BGP process to the main control board BGP process.
[0352] 23. The main control board BGP process stores the synchronized routes.
[0353] 24. After the slave control board protocol process completes synchronizing the routes from the BGP session, it notifies the master control board BGP process that the routes for the BGP session have been announced.
[0354] 25. If there are messages in the shared queue for routing-related protocol messages to be processed, the BGP process on the main control board continues to process the protocol messages in the queue.
[0355] In an optional embodiment, for network devices that do not have a slave control board, the original routing information can also be restored through other means, such as storage and recovery through a local database, or the routing protocol itself supports requesting neighboring devices to retransmit routing, then the routing protocol's retransmission routing function mechanism can be used.
[0356] As shown in Figure 13, which is a schematic diagram of the structure of a network device without a slave control board, the master control board of the network device may include: a master control board protocol process, a backup protocol session process, and a database of routing-related protocol data. For protocols with less routing data (e.g., OSPF and IS-IS protocols), the routing-related protocol data can be directly stored in a database. The database can be shared, and when the master control board protocol process is restarted and restored, its routing information can be restored from the shared database. In this way, it is not necessary for the network device to have master and slave control boards, thereby expanding the scope of application of the technical solution of the present application.
[0357] The routing protocol process processing method of the embodiment of the present application backs up the target protocol session and Socket to the backup protocol session process. When the protocol process where the target protocol session is located is restarted, the backup protocol session process takes over the protocol message sending, receiving and periodic keep-alive operation processing of the target protocol session. Then, the restarted protocol process restores the session information and Socket through the backup protocol session process, and takes over the protocol message sending, receiving and periodic keep-alive operation processing of the session again. Then, the routing information is restored, and normal protocol interaction is resumed after the restoration is complete. In this way, it is ensured that when the protocol process is restarted, the protocol neighbor session will not be interrupted, and the service routing and message forwarding will not be interrupted, thereby improving the reliability of the routing protocol.
[0358] In order to ensure that the received data is not lost when the subsequent backup protocol session process takes over, the embodiment of the present application provides pre-reading of the protocol message header, parsing of the protocol message header, and then pre-reading of the complete protocol message for processing based on the protocol message header.
[0359] In order to ensure that when the backup protocol session process takes over when the main control board protocol process is restarted later, no data loss will occur, an embodiment of the present application provides a mechanism for sending protocol messages. For protocol messages that are not sent completely, the remaining messages that have not been sent successfully are stored in a shared queue of messages to be sent.
[0360] Moreover, the technical solution of the embodiment of the present application does not require other devices to collaborate in recovery, so there is no problem of interactive compatibility between different manufacturers, thereby improving the scope of application.
[0361] For details of each step of the above method, please refer to the relevant description of the above embodiments, which will not be repeated here.
[0362] Please refer to Figure 14, which is a routing protocol process processing device 1400 according to an embodiment of the present application. The device can be applied to the electronic device 1 shown in Figure 1. It can also be applied to the application scenarios of protocol process processing of the network devices shown in Figures 2 to 4, so that when the main control board protocol process where the target protocol session is located is interrupted and restarted, the target protocol session is taken over by the backup protocol session process, thereby reducing memory consumption and improving the security and reliability of the session during the protocol process restart. The device includes: a first establishment module 1401, a transfer module 1402, a second establishment module 1403 and a takeover module 1404. The functional principles of each module are as follows:
[0363] The first establishing module 1401 is configured to establish a first inter-process session between the main control board protocol process and the backup protocol session process.
[0364] The transfer module 1402 is configured to transfer first session information of the target protocol session to the backup protocol session process through the first inter-process session when a target protocol session is established between the main control board protocol process and the neighboring device.
[0365] The second establishing module 1403 is configured to establish a first internal session corresponding to the target protocol session according to the first session information through the backup protocol session process, where the first internal session is configured to be in an unresponsive state.
[0366] The takeover module 1404 is configured to set the first internal session to an enabled response state through the backup protocol session process when the main control board protocol process is interrupted, so that the backup protocol session process takes over the target protocol session through the first internal session.
[0367] In one embodiment, the transfer module 1402 is configured to transfer identification information of the target protocol session to the backup protocol session process via the first inter-process session, and to transfer first session information of the target protocol session to the backup protocol session process based on the identification information via the first inter-process session.
[0368] In one embodiment, the transfer module 1402 is configured to transfer the first identifier of the target protocol session to the protocol stack via the main control board protocol process. The protocol stack assigns a second identifier to the backup protocol session process based on the first identifier, associates the second identifier with the target protocol session, and transfers the second identifier to the backup protocol session process via the protocol stack.
[0369] In one embodiment, the transfer module 1402 is further configured to, before transferring the first session information of the target protocol session to the backup protocol session process based on the identification information through the first inter-process session, set the session associated with the second identifier to an unresponsive state in the protocol stack via the backup protocol session process. The backup protocol session process queries the protocol stack for the first identifier associated with the same session as the second identifier. The backup protocol session process stores the association between the first identifier and the second identifier.
[0370] In one embodiment, the transfer module 1402 is further configured to carry the first identifier in the first session information of the target protocol session through the main control board protocol process and transfer the information to the backup protocol session process.
[0371] In one embodiment, first establishing module 1401 is configured to parse a first identifier carried in first session information through a backup protocol session process and search for a second identifier locally associated with the first identifier. The backup protocol session process establishes a first internal session corresponding to the target protocol session based on the first session information and associates the first internal session with the second identifier.
[0372] In one embodiment, takeover module 1404 is configured to, when the main control board protocol process is interrupted, notify the backup protocol session process of the disconnection of the first inter-process session. The backup protocol session process deletes the locally stored association. The backup protocol session process sets the first internal session to an enabled response state in the protocol stack based on the second identifier. The backup protocol session process initiates keepalive processing for the target protocol session.
[0373] In one embodiment, the system further includes: a determination module configured to, when the protocol stack contains received data from a neighboring device, determine whether the received data contains a complete protocol message; a processing module configured to, if the received data contains a complete protocol message, read the complete protocol message from the protocol stack for protocol processing; and, if the received data contains no complete protocol message, wait until the protocol message in the received data is complete, and then read the complete protocol message from the protocol stack for protocol processing.
[0374] In one embodiment, the judgment module is used to judge whether the message length of the received data is greater than or equal to the target protocol message header length. If the message length of the received data is greater than or equal to the target protocol message header length, pre-read the first data of the header length from the protocol stack. Parse the first data to obtain the target protocol message header. According to the target protocol message header, determine the complete length of the target protocol message. Judge whether the message length of the received data is greater than or equal to the complete length. If the message length of the received data is greater than or equal to the complete length, determine that a complete protocol message exists in the received data. If the message length of the received data is less than the target protocol message header length, or the message length of the received data is greater than or equal to the target protocol message header length, and the message length of the received data is less than the complete length, determine that a complete protocol message does not exist in the received data.
[0375] In one embodiment, the processing module is further used to set the first internal session to an enabled response state through the backup protocol session process to take over the target protocol session. If the complete protocol message is a routing message, the complete protocol message is added to the shared queue of routing-related protocol messages to be processed through the backup protocol session process.
[0376] In one embodiment, it also includes: a sending module, which is used to add the unsent data in the target message to the shared queue of messages to be sent when the current network device sends the target message to the neighboring device, if the target message is not sent completely, and start retrying to send the unsent data.
[0377] In one embodiment, it also includes: a recovery module, which is used to pass the second session information of the target protocol session maintained by the backup protocol session process to the main control board protocol process after the main control board protocol process is restarted. The main control board protocol process establishes a second internal session corresponding to the target protocol session according to the second session information, and the second internal session is configured to be in an unresponsive state. The main control board protocol process sends a takeover request for the target protocol session to the backup protocol session process. The backup protocol session process sets the first internal session to an unresponsive state. The backup protocol session process responds to the takeover request. The main control board protocol process sets the second internal session to an enabled response state, so that the main control board protocol process takes over the target protocol session through the second internal session.
[0378] In one embodiment, the network device further includes a slave control board protocol process. The apparatus further includes a notification module configured to notify the slave control board protocol process, via the master control board protocol process, that a target protocol session is backed up, whereby the slave control board protocol process backs up information about the target protocol session and / or routing information for the target protocol session. A synchronization module configured to synchronize the routing information of the target protocol session with the master control board protocol process via the slave control board protocol process when the master control board protocol process is interrupted and restarted.
[0379] For a detailed description of the routing protocol process processing device 1400, please refer to the description of the relevant method steps in the above embodiment. The implementation principle and technical effects are similar and will not be repeated here in this embodiment.
[0380] Figure 15 is a schematic diagram of the structure of a cloud device 150 provided in an exemplary embodiment of the present application. This cloud device 150 can be used to execute the method provided in any of the above embodiments. As shown in Figure 15 , this cloud device 150 may include: a memory 1504 and at least one processor 1505 , with Figure 15 using one processor as an example.
[0381] The memory 1504 is used to store computer programs and can be configured to store various other data to support operations on the cloud device 150. The memory 1504 can be an object storage service (OSS).
[0382] Memory 1504 can be implemented by any type of volatile or non-volatile memory device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0383] The processor 1505 is coupled to the memory 1504 and is used to execute the computer program in the memory 1504 to implement the solution provided by any of the above method embodiments. The specific functions and technical effects that can be achieved are not repeated here.
[0384] 15 , the cloud device also includes other components such as a firewall 1501, a load balancer 1502, a communication component 1506, and a power supply component 1503. FIG15 only schematically illustrates some components, which does not mean that the cloud device only includes the components shown in FIG15 .
[0385] In one embodiment, the communication component 1506 in FIG. 15 is configured to facilitate wired or wireless communication between the device where the communication component 1506 is located and other devices. The device where the communication component 1506 is located can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, LTE (Long Term Evolution, Long Term Evolution, referred to as LTE), 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component 1506 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1506 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0386] In one embodiment, the power supply assembly 1503 of FIG15 provides power to various components of the device in which the power supply assembly 1503 is located. The power supply assembly 1503 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply assembly is located.
[0387] An embodiment of the present application further provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the method of any of the aforementioned embodiments is implemented.
[0388] An embodiment of the present application also provides a computer program product, including a computer program, which implements the method of any of the aforementioned embodiments when executed by a processor.
[0389] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of modules is merely a logical function division. Other division methods can be used during implementation, such as combining or integrating multiple modules into another system, or ignoring or not implementing certain features.
[0390] The above-mentioned integrated module implemented in the form of a software functional module can be stored in a computer-readable storage medium. The above-mentioned software functional module is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.
[0391] It should be understood that the above-mentioned processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or the processor can be any conventional processor, etc. The steps of the method disclosed in the application can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor. The memory may include high-speed RAM (Random Access Memory) memory, and may also include non-volatile storage NVM (Nonvolatile memory, NVM for short), such as at least one disk storage, and can also be a USB flash drive, a mobile hard disk, a read-only memory, a disk or an optical disk, etc.
[0392] The storage medium may be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random-access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium may be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0393] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic device or a main control device.
[0394] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0395] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0396] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods of each embodiment of the present application.
[0397] In the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of user data and other information involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0398] The above are only preferred embodiments of the present application and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for processing a routing protocol process, wherein: Applied to a network device, the method comprises: Establishing a first inter-process session between a main control board protocol process of the network device and a backup protocol session process of the network device; When a target protocol session is established between the main control board protocol process and a neighbor device, first session information of the target protocol session is transmitted to the backup protocol session process through the first inter-process session; Establishing, through the backup protocol session process, a first internal session corresponding to the target protocol session according to the first session information, wherein the first internal session is configured to be in an unresponsive state; and When the main control board protocol process is interrupted, the first internal session is configured to be in an enabled response state through the backup protocol session process, so that the backup protocol session process takes over the target protocol session through the first internal session.
2. The method according to claim 1, wherein: The step of transmitting the first session information of the target protocol session to the backup protocol session process through the first inter-process session includes: passing the identification information of the target protocol session to the backup protocol session process through the first inter-process session; and The first session information of the target protocol session is transferred to the backup protocol session process according to the identification information through the first inter-process session.
3. The method according to claim 1, wherein: The method further comprises: When there is received data from the neighboring device in the protocol stack of the network device, determining whether there is a complete protocol message in the received data; If a complete protocol message exists in the received data, reading the complete protocol message from the protocol stack for protocol processing; and If the complete protocol message does not exist in the received data, wait until the protocol message in the received data is complete, and then read the complete protocol message from the protocol stack to perform protocol processing.
4. The method according to claim 2, wherein: The step of transmitting the identification information of the target protocol session to the backup protocol session process through the first inter-process session includes: Passing the first identifier of the target protocol session to a protocol stack through the main control board protocol process; Allocating a second identifier for the backup protocol session process according to the first identifier by the protocol stack, and associating the second identifier with the target protocol session; and The second identifier is transmitted to the backup protocol session process through the protocol stack.
5. The method according to claim 4, wherein: Before transmitting the first session information of the target protocol session to the backup protocol session process according to the identification information through the first inter-process session, the method further includes: Setting the target protocol session to an unresponsive state in the protocol stack through the backup protocol session process; querying the protocol stack through the backup protocol session process for the first identifier associated with the same session as the second identifier; and The backup protocol session process stores the association relationship between the first identifier and the second identifier.
6. The method according to claim 4, wherein: The method of passing the first session information of the target protocol session to the backup protocol session method according to the identification information through the first inter-process session includes: The first identifier is transmitted to the backup protocol session process through the main control board protocol process, wherein the first identifier is carried in the first session information of the target protocol session.
7. The method according to claim 6, wherein: The step of establishing a first internal session corresponding to the target protocol session according to the first session information through the backup protocol session process includes: parsing the first identifier carried in the first session information through the backup protocol session process, and determining the second identifier associated with the first identifier based on the first identifier; and The first internal session corresponding to the target protocol session is established according to the first session information, and the first internal session is associated with the second identifier.
8. The method according to claim 5, wherein: When the main control board protocol process is interrupted, setting the first internal session to an enabled response state through the backup protocol session process to take over the target protocol session includes: When the main control board protocol process is interrupted, the protocol stack notifies the backup protocol session process that the first inter-process session is disconnected; The backup protocol session process deletes the stored association relationship between the first identifier and the second identifier; The backup protocol session process sets the first internal session to the enabled response state in the protocol stack according to the second identifier; and The keep-alive processing of the target protocol session is started through the backup protocol session process.
9. The method according to claim 3, wherein: The determining whether there is a complete protocol message in the received data includes: Determining whether the message length of the received data is greater than or equal to the message header length of the target protocol; and If the message length of the received data is greater than or equal to the target protocol message header length, the determining whether there is a complete protocol message in the received data further includes: Pre-reading first data of the header length from the protocol stack; Parsing the first data to obtain the target protocol message header; Determining the complete length of the target protocol message according to the target protocol message header; Determining whether the message length of the received data is greater than or equal to the complete length; and If the message length of the received data is greater than or equal to the complete length, it is determined that a complete protocol message exists in the received data. If the message length of the received data is less than the complete length, it is determined that no complete protocol message exists in the received data.
10. The method according to claim 9, wherein: The determining whether the message length of the received data is greater than or equal to the complete length, and the determining whether there is a complete protocol message in the received data, further includes: If the message length of the received data is less than the target protocol message header length, it is determined that no complete protocol message exists in the received data.
11. The method according to claim 9 or 10, wherein: If the message length of the received data is greater than or equal to the target protocol message header length, the determining whether there is a complete protocol message in the received data further includes: If the message length of the received data is greater than or equal to the target protocol message header length, and the message length of the received data is less than the complete length, it is determined that no complete protocol message exists in the received data.
12. The method according to claim 3, wherein: After setting the first internal session to an enabled response state through the backup protocol session process to take over the target protocol session, reading a complete protocol message from the protocol stack for protocol processing includes: If the complete protocol message is a routing message, the complete protocol message is added to a shared queue of routing-related protocol messages to be processed through the backup protocol session process.
13. The method according to any one of claims 1 to 12, wherein: The method further comprises: When the network device sends a target message to the neighbor device, if the target message is not completely sent, the unsent data in the target message is added to a shared queue of messages to be sent, and a retry is started for the unsent data.
14. The method according to any one of claims 1 to 13, wherein: The method further comprises: After the main control board protocol process is restarted, the second session information of the target protocol session maintained by the backup protocol session process is transmitted to the main control board protocol process; Establishing, by the main control board protocol process, a second internal session corresponding to the target protocol session according to the second session information, wherein the second internal session is configured to be in an unresponsive state; Sending a takeover request for the target protocol session to the backup protocol session process through the main control board protocol process; Setting the first internal session to an unresponsive state through the backup protocol session process; Responding to the takeover request through the backup protocol session process; and The second internal session is set to an enable response state through the main control board protocol process, so that the main control board protocol process takes over the target protocol session through the second internal session.
15. The method according to any one of claims 1 to 14, wherein: The method further comprises: The master control board protocol process notifies the slave control board protocol process of the network device to back up the target protocol session, and the slave control board protocol process backs up the information of the target protocol session and / or the routing information of the target protocol session. backup; and When the master control board protocol process is restarted due to an interruption, the routing information of the target protocol session is synchronized to the master control board protocol process through the slave control board protocol process.
16. A routing protocol process processing device, wherein: Applied to network equipment, the device comprises: A first establishing module, used for establishing a first inter-process session between the main control board protocol process and the backup protocol session process; A transfer module, used for transferring the first session information of the target protocol session to the backup protocol session process through the first inter-process session when the target protocol session is established between the main control board protocol process and the neighboring device; A second establishing module, configured to establish a first internal session corresponding to the target protocol session according to the first session information through the backup protocol session process, wherein the first internal session is configured to be in an unresponsive state; and The takeover module is used to set the first internal session to an enabled response state through the backup protocol session process when the main control board protocol process is interrupted, so that the backup protocol session process takes over the target protocol session through the first internal session.
17. An electronic device comprising: at least one processor; as well as a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the electronic device to execute the method described in any one of claims 1-15.
18. A computer-readable storage medium, wherein: The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the method according to any one of claims 1 to 15 is implemented.
Citation Information
Patent Citations
Routing uninterrupted method and main control board
CN109951388A
Forwarding detection of an aggregated interface
CN110535760A
Method and system for realizing protocol NSR by single CPU
CN113114641A
Method and apparatus for enabling non stop routing (NSR) in a packet network
WO2017175033A1