Forwarding rule unloading method based on DPU, network card device, computer storage medium and computer program product
By obtaining and generating forwarding rules in the network card device, monitoring and sending them to the DPU for processing, the problem of low forwarding processing efficiency of the operating system kernel is solved, and the forwarding processing efficiency and system performance of the DPU are improved.
Patent Information
- Application Number
- CN202410660003.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-09-10
AI Technical Summary
The software-configured operating system kernel is less efficient when performing data packet forwarding processing, resulting in inefficient data packet forwarding processing. It is hoped that the forwarding processing rules of the operating system kernel can be offloaded to the DPU of the network card device to improve efficiency.
By obtaining the rule format of the forwarding rule, including the matching field and action field, the initial matching rule is generated based on the session configuration information, and the operating system kernel's processing action type of the data packet is monitored to find and generate the matching rules and action rules of the data packet. , which is sent to the DPU for processing.
The forwarding processing efficiency of the DPU is improved, allowing it to reliably process subsequent data packets and improving the data packet forwarding performance of the overall system.
Smart Images

Figure CN118626163A
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a DPU-based forwarding rule unloading method, a network card device, a computer storage medium, and a computer program product. Background Art
[0002] With the rapid development of cloud network technology, network card devices are installed in the gateway server of the cloud service system, which can send and receive data packets, and the operating system kernel of the gateway server can perform processing such as forwarding and access control on data packets. In the new network equipment, DPU (Data Processing Unit) improves the overall performance of the system while reducing data processing delays. Therefore, DPU has gradually become the hardware computing power of network devices installed on hosts in cloud computing environments.
[0003] Therefore, the operating system kernel as a software configuration has low efficiency in executing data packet forwarding processing. It is expected to offload the forwarding rules of the operating system kernel's forwarding processing to the DPU of the network card device, so as to improve the efficiency of the forwarding processing with the help of the DPU. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a DPU-based forwarding rule unloading method, a network card device, a computer storage medium and a computer program product to solve the above problems.
[0005] According to a first aspect of an embodiment of the present invention, a DPU-based forwarding rule unloading method is provided, which is applied to a network card device configured with a DPU, the network card device is mounted on a gateway server, and the operating system kernel of the gateway server is used to process data packets, the method comprising: obtaining a rule format of a forwarding rule, the rule format comprising a matching field domain and an action field domain; writing at least part of session configuration information into the matching field domain to generate an initial matching rule; monitoring the processing action type of the data packet by the operating system kernel; based on the monitoring result of the processing action type, searching for relevant data of the data packet in the initial matching rule to generate matching rules and action rules of the data packet; and sending the matching rules and action rules of the data packet as forwarding rules to the DPU, so that the DPU processes subsequent data packets based on the forwarding rules.
[0006] In another implementation of the present invention, an initial matching rule is generated based on writing at least part of the session configuration information into the matching field domain, including: writing the port identifier and port address of the network card port into the port attribute field in the matching field domain; writing the node address of the neighboring node learned by the network card port into the node attribute field in the matching field domain; writing the processing action type of the operating system kernel on the data packet into the action field domain; and generating the initial matching rule based on the write information of the matching field domain and the write information of the action field domain.
[0007] In another implementation of the present invention, based on the monitoring result of the processing action type, relevant data of the data packet is searched in the initial matching rule to generate a matching rule for the data packet, including: writing the initial matching rule to a first database; based on the monitoring result of the processing action type, searching in the first database; and generating a matching rule for the data packet based on the data related to the processing action type found in the query.
[0008] In another implementation of the present invention, the method also includes: deleting the port configuration of the network card port according to the port configuration change instruction of the gateway program, wherein the port configuration includes a port identifier and a port address; in response to the deletion of the port configuration, deleting the data related to the port configuration of the data packet from the first database, and deleting the data related to the port configuration in the forwarding rules of the DPU.
[0009] In another implementation of the present invention, querying in the first database according to the monitoring result of the processing action type includes: writing the monitoring result of the processing action type to the second database; in response to the writing operation of the monitoring result in the second database, querying in the first database to obtain the matching rule of the data packet.
[0010] In another implementation of the present invention, according to the monitoring result of the processing action type, the relevant data of the data packet is searched in the initial matching rule, and the matching rule and action rule of the data packet are generated, including: when the monitoring result of the processing action type indicates that the data packet does not comply with the preset passing rule and is discarded, the initial matching rule is searched to see whether there is a port configuration related to the data packet, the port configuration including a port identifier and a port address; if yes, the port configuration and the sending and receiving addresses of the data packet are used to determine the matching rule of the data packet, and the action parameters of the discard action are determined as the action rule of the data packet.
[0011] In another implementation of the present invention, according to the monitoring result of the processing action type, the relevant data of the data packet is searched in the initial matching rule, and the matching rule and action rule of the data packet are generated, including: when the monitoring result of the processing action type indicates that the data packet meets the preset pass rule, according to the port configuration related to the forwarding action of the data packet, the forwarding path parameters of the data packet are generated as the matching rule of the data packet, and the forwarding action parameters of the data packet are generated as the action rule of the data packet.
[0012] In another implementation of the present invention, monitoring the processing action type of the operating system kernel on the data packet includes: monitoring the function of each processing action type of the operating system kernel by inserting a stub to the function of the processing action type, the processing action type including at least one of a discard action, a allow action, and a forwarding action; and determining the monitoring result of the processing action type according to the return result of the function.
[0013] In another implementation of the present invention, obtaining the rule format of the forwarding rule includes: reading and parsing a predefined declaration configuration file to obtain the rule format of the forwarding rule, wherein the rule format includes a matching field domain and an action field domain.
[0014] According to a third aspect of an embodiment of the present invention, there is provided a network card device, which is configured with a DPU. The network card device is mounted on a gateway server, and the operating system kernel of the gateway server is used to process data packets. The network card device comprises: an acquisition module, which acquires a rule format of a forwarding rule, wherein the rule format comprises a matching field domain and an action field domain; a first generation module, which generates an initial matching rule based on at least part of the session configuration information written into the matching field domain; a monitoring module, which monitors the processing action type of the data packet by the operating system kernel; a second generation module, which searches for relevant data of the data packet in the initial matching rule according to the monitoring result of the processing action type, and generates matching rules and action rules for the data packet; and a sending module, which sends the matching rules and action rules of the data packet as forwarding rules to the DPU, so that the DPU processes subsequent data packets based on the forwarding rules.
[0015] According to a third aspect of an embodiment of the present invention, a network card device is provided, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method described in the first aspect.
[0016] According to a fourth aspect of an embodiment of the present invention, there is provided a computer storage medium on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect is implemented.
[0017] According to a fifth aspect of an embodiment of the present invention, there is provided a computer program product, comprising computer instructions, which, when executed by a processor, implement the method as described in the first aspect.
[0018] In the scheme of the embodiment of the present invention, an initial matching rule is generated based on writing at least part of the session configuration information into the matching field domain, so that the configuration information required for the matching rule can be efficiently obtained. In addition, based on the monitoring result of the processing action type, the relevant data of the data packet is searched in the initial matching rule, and the matching rule and action rule of the data packet are generated. The matching rule and action rule related to the processing action type can be obtained from the initial matching rule in a targeted manner, and then the matching rule and action rule of the data packet are sent to the DPU as forwarding rules, so that the DPU can reliably process subsequent data packets, while improving the forwarding processing efficiency of the DPU. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0020] Figure 1 A schematic block diagram of a gateway server equipped with a network card device.
[0021] Figure 2 The present invention is a flowchart of the steps of a DPU-based forwarding rule unloading method according to some embodiments of the present invention.
[0022] Figure 3 To show Figure 2 A schematic block diagram of an uninstallation process of an embodiment.
[0023] Figure 4 It is a schematic block diagram of the uninstallation process of some other embodiments of the present invention.
[0024] Figure 5 It is a schematic block diagram of the uninstallation process of some other embodiments of the present invention.
[0025] Figure 6 The present invention is a schematic block diagram of a network card device according to another embodiment of the present invention.
[0026] Figure 7Schematic diagram of the structure of network card devices according to other embodiments of the present invention. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in the field based on the embodiments in the embodiments of the present invention should fall within the scope of protection of the embodiments of the present invention.
[0028] The specific implementation of the embodiment of the present invention is further described below in conjunction with the accompanying drawings of the embodiment of the present invention.
[0029] Figure 1 FIG. 1 is a schematic block diagram of a gateway server equipped with a network card device. Figure 1 It is a schematic structural diagram of a gateway server equipped with a network card device, and a server operating system such as Linux is installed in the gateway server. The network card device can process the reception and transmission of data packets, and the operating system kernel of the gateway server can perform processing such as forwarding and access control such as ACL on the data packets. The network card device may include an unloading module (configured with a config program, an event program, and an offload program such as described below), which is a functional module of an offload pipeline to realize hardware acceleration, and can send at least part of the processing rules of the operating system kernel for data packets to the DPU, so that the DPU processes subsequent data packets based on the sent processing rules.
[0030] Further. Figure 2 It is shown that the DPU-based forwarding rule unloading method according to some embodiments of the present invention is applied to a network card device configured with a DPU, the network card device is mounted on a gateway server, and the operating system kernel of the gateway server is used to process data packets. The DPU-based forwarding rule unloading method includes:
[0031] S210: Obtain a rule format of a forwarding rule, where the rule format includes a match field domain and an action field domain.
[0032] S220: Generate an initial matching rule based on writing at least part of the session configuration information into the matching field domain.
[0033] S230: Monitor the processing action type of the operating system kernel on the data packet.
[0034] S240: According to the monitoring result of the processing action type, relevant data of the data packet is searched in the initial matching rule, and the matching rule and action rule of the data packet are generated.
[0035] S250: Send the matching rule and action rule of the data packet as the forwarding rule to the DPU, so that the DPU processes subsequent data packets based on the forwarding rule.
[0036] In the scheme of the embodiment of the present invention, an initial matching rule is generated based on writing at least part of the session configuration information into the matching field domain, so that the configuration information required for the matching rule can be efficiently obtained. In addition, based on the monitoring result of the processing action type, the relevant data of the data packet is searched in the initial matching rule, and the matching rule and action rule of the data packet are generated. The matching rule and action rule related to the processing action type can be obtained from the initial matching rule in a targeted manner, and then the matching rule and action rule of the data packet are sent to the DPU as forwarding rules, so that the DPU can reliably process subsequent data packets, while improving the forwarding processing efficiency of the DPU.
[0037] In some examples, the rule format of the DPU's forwarding rules can be predefined so that forwarding rules that conform to the rule format can be efficiently generated and sent to the DPU. For example, a pattern file can be used to define the match (match field domain) and action (action field domain) of the DPU's unloading rules. The match field domain represents the various match fields supported by the DPU's forwarding rules, and the action field domain represents the various action fields supported by the DPU's forwarding rules. The pattern file is an example of a declaration configuration file. Without loss of generality, the predefined declaration configuration file can be read and parsed to obtain the rule format of the forwarding rules.
[0038] Specifically, Figure 3 As shown, the initial matching rules can be written into the first database (database-1) through the config program, and the monitoring results of the processing action type can be written into the second database (database-2) through the event program. In other words, the matching field domain specifies the content that the config program can write into the first database, and the action field domain specifies the content of the processing action type that the event program can process and write into the second database. Then, the forwarding rules sent to the DPU are generated by the unloading (DPU-offload) program based on the information written in the first and second databases.
[0039] It should be understood that before the config program writes the initial configuration rules into the first database, the config program can generate an example of the initial matching rules based on writing at least part of the session configuration information into the matching field domain. Specifically, the config program can write the port identifier and port address of the network card port into the port attribute field in the matching field domain, write the node address of the neighboring node learned by the network card port into the node attribute field in the matching field domain, and write the type of processing action of the operating system kernel on the data packet into the action field domain.
[0040] More specifically, the config program can execute the port configuration, routing configuration, firewall configuration, and external node configuration learned by the kernel neighbor of the network card device, and write the above configurations into the matching field domain. Figure 4 As shown, in process 1, the config program can obtain the port configuration (e.g., port identifier and port MAC address, etc.) and routing configuration of the network card device from applications such as gateway programs. The config program can also obtain the node configuration (e.g., node MAC address) of the external node (e.g., the external host of the network card device) corresponding to each port from the operating system kernel (e.g., through ARP (Address Resolution Protocol) communication, etc.). For example, the config program determines the IP address of the external node to be learned, and broadcasts the ARP request containing the above IP address to all hosts in the subnet through the requesting host. Then, after receiving the ARP request, the target host checks whether the IP address in the request is its own IP address. If the IP address of the target host matches the IP address in the request, it sends an ARP response containing its own MAC address to the requesting host. Then, after receiving the response information, the config program associates the obtained MAC address with the corresponding external node to establish a mapping relationship of the node configuration.
[0041] In addition, the config program can also obtain firewall configurations such as ACL (Access Control List) from applications such as gateway programs. Further, the config program generates an initial matching rule based on the written information of the matching field domain and the written information of the action field domain. It should be understood that when an application such as a gateway program changes the configuration of the network or the configuration of an external node, the config program writes the changed configuration into the first database.
[0042] Without loss of generality, as an example of generating a matching rule for a data packet by searching for relevant data of the data packet in the initial matching rule, the config program may write the initial matching rule to the first database, query the first database based on the monitoring result of the processing action type, and then generate a matching rule for the data packet based on the queried data related to the data packet and the processing action type.
[0043] In other examples, such as Figure 3 As shown, the event program can monitor the processing action type of the data packet and write the monitoring result into the second database. Specifically, after the data packet of the session passes through the kernel protocol stack of the operating system, the event program generates an event and related information of the processing action of the data packet as the monitoring result, and writes the monitoring result into the second database.
[0044] More specifically, if Figure 4 As shown, in process 2, the data packet performs CT detection in the CT (connection track) module, and the CT detection result is notified to the event program through the communication between the operating system kernel and the user component (for example, the netlink mechanism), and then the event program writes the session information and CT detection conditions (for example, <data packet five-tuple, ct_state=new>) of the data packet after CT detection into the second database.
[0045] Then, the event program inserts the functions of each processing action type of the operating system kernel for subsequent data packets, monitors the functions of the processing action type, and writes the monitoring results to the second database. The processing action type includes at least one of a discard action, a pass action, and a forwarding action, such as Figure 4 As shown in process 3 and process 4 in . For example, a key-value pair-based instrumentation is performed through a hash table, with a five-tuple of data packet sessions as a key input, a processing action type as a value output, and written to a second database. For example, for firewall security processing, <data packet five-tuple> is used as a key. If the data packet has not passed through the instrumented inspection function, no value is returned or NULL is returned. If the data packet passes through the instrumented function, a processing action type indicating a discard action or a allowed action is returned. For another example, for forwarding processing, <data packet five-tuple> is used as a key. If the data packet passes through the instrumented forwarding function, a processing action type indicating a forwarding configuration is returned as a value.
[0046] More specifically, taking the Linux kernel as an example, the "dev_hard_start_xmit" function is used to send data packets to the network card's transmit queue and then to the network. The "dev_hard_start_xmit" function is usually called by the network driver's transmit path to pass the data packet to the network card for transmission. The "dev_hard_start_xmit" function can perform network protocol processing such as encapsulating data packets and setting the destination MAC address.
[0047] It should be understood that the stub can be inserted in the "dev_hard_start_xmit" function. For example, ftrace can be enabled by mounting the debug file system / sys / kernel / debug and opening the tracing_on file. Then, the tracing code is inserted in the dev_hard_start_xmit function.
[0048] Without loss of generality, as an example of querying the first database based on the monitoring results of the processing action type, the event program can write the monitoring results of the processing action type to the second database, and then, in response to the write operation of the monitoring results in the second database, query the first database to obtain the matching rules of the data packet.
[0049] Specifically, Figure 3 As shown, the offload program can access the first database and the second database, thereby obtaining the information written in the first database and the second database. When the monitoring result of the processing action type of the data packet is written into the second database, the offload program searches for relevant data in the first database according to the monitoring result, and generates the matching rule and action rule of the data packet as the forwarding rule, such as Figure 4 The offload program then sends the forwarding rules to the DPU, as shown in process 5. Figure 4 This is shown in process 5.
[0050] As an example of searching for relevant data of a data packet in the initial matching rule to generate the matching rule and action rule of the data packet, when the monitoring result of the processing action type indicates that the data packet does not meet the preset passing rule and is discarded, the offload program can search in the initial matching rule whether there is a port configuration related to the data packet. If so, the port configuration and the sending and receiving addresses of the data packet are used to determine the matching rule of the data packet, and the action parameters of the discard action are determined as the action rule of the data packet. For example, when the monitoring result of the processing action type indicates that the data packet does not meet the preset passing rule and is discarded, the offload program obtains the MAC address (including the source MAC address and the destination MAC address) and the five-tuple of the data packet based on the monitoring result of the data packet, and combines the port configuration of the received data packet, the MAC address of the data packet and the five-tuple to obtain the matching rule of the data packet. Accordingly, the discard action parameters of the monitoring result are used as the action rule of the data packet.
[0051] Alternatively, if the action of the operating system kernel on the data packet is a forwarding action, the parameters of the forwarding action are output. As an example of searching for relevant data of the data packet in the initial matching rule to generate the matching rule and action rule of the data packet, when the monitoring result of the processing action type indicates that the data packet meets the preset passing rule, the offload program can generate the forwarding path parameters of the data packet as the matching rule of the data packet according to the port configuration related to the forwarding action of the data packet, and generate the forwarding action parameters of the data packet as the action rule of the data packet. For example, when the monitoring result of the processing action type indicates that the data packet meets the preset passing rule, the offload program obtains the MAC address of the sending port and the MAC address of the node adjacent to the sending port from the second database according to the monitoring result. Then, the source MAC address of the protocol header of the data packet is replaced with the MAC address of the sending port, and the destination MAC address of the protocol header of the data packet is replaced with the MAC address of the neighboring node (optionally or further, the node identifier of the neighboring node (e.g., dport) is used as the forwarding action rule of the data packet (e.g., action = [smac_new, dmac_new, dport]), and at the same time, the identifier (e.g., sport) and MAC address of the receiving port of the data packet (e.g., source MAC address smac, destination MAC address dmac) and the five-tuple (e.g., tuple) of the data packet are used as the matching rule of the data packet (e.g., match = [sport, smac, dmac, tuple]).
[0052] Furthermore, if Figure 5As shown, in process 11, the config program can obtain the port configuration change instruction of the gateway program, and the offload program can delete the port configuration of the network card port according to the port configuration change instruction, wherein the port configuration includes the port identifier and the port address. For example, the deletion command can be<op:del,field:port,val:p2> .
[0053] Further, in process 12, in response to the deletion of the port configuration, data related to the data packet and the port configuration is deleted from the first database, and in process 13, data related to the port configuration in the forwarding rule of the DPU is deleted.
[0054] Furthermore, in process 14, the config program may notify the event program of the deletion result, so that in process 15, event deletes the five-tuple related to the updated port configuration in the stub function.
[0055] Figure 6 The present invention is a schematic block diagram of a network card device according to another embodiment of the present invention. Figure 6 The network card device is configured with a DPU, the network card device is mounted on a gateway server, the operating system kernel of the gateway server is used to process data packets, and the network card device includes:
[0056] An acquisition module 610 acquires a rule format of a forwarding rule, wherein the rule format includes a match field domain and an action field domain;
[0057] A first generating module 620 generates an initial matching rule according to at least part of the session configuration information written into the matching field domain;
[0058] A monitoring module 630 monitors the type of processing action of the operating system kernel on the data packet;
[0059] A second generating module 640 searches for relevant data of the data packet in the initial matching rule according to the monitoring result of the processing action type, and generates a matching rule and an action rule for the data packet;
[0060] The sending module 650 sends the matching rule and the action rule of the data packet to the DPU as a forwarding rule, so that the DPU processes subsequent data packets based on the forwarding rule.
[0061] In the scheme of the embodiment of the present invention, an initial matching rule is generated based on writing at least part of the session configuration information into the matching field domain, so that the configuration information required for the matching rule can be efficiently obtained. In addition, based on the monitoring result of the processing action type, the relevant data of the data packet is searched in the initial matching rule, and the matching rule and action rule of the data packet are generated. The matching rule and action rule related to the processing action type can be obtained from the initial matching rule in a targeted manner, and then the matching rule and action rule of the data packet are sent to the DPU as forwarding rules, so that the DPU can reliably process subsequent data packets, while improving the forwarding processing efficiency of the DPU.
[0062] In some other embodiments, the first generation module is specifically used to: write the port identifier and port address of the network card port into the port attribute field in the matching field domain; write the node address of the neighboring node learned by the network card port into the node attribute field in the matching field domain; write the processing action type of the operating system kernel on the data packet into the action field domain; and generate the initial matching rule based on the write information of the matching field domain and the write information of the action field domain.
[0063] In some other embodiments, the second generation module is specifically used to: write the initial matching rule into the first database; query the first database according to the monitoring result of the processing action type; generate the matching rule of the data packet based on the data related to the processing action type found by querying the data packet.
[0064] In other embodiments, the first generation module is also used to: delete the port configuration of the network card port according to the port configuration change instruction of the gateway program, wherein the port configuration includes a port identifier and a port address; in response to the deletion of the port configuration, delete the data related to the port configuration of the data packet from the first database, and delete the data related to the port configuration in the forwarding rules of the DPU.
[0065] In other embodiments, the second generation module is specifically used to: write the monitoring result of the processing action type into the second database; in response to the writing operation of the monitoring result in the second database, query in the first database to obtain the matching rule of the data packet.
[0066] In other embodiments, the second generation module is specifically used for: when the monitoring result of the processing action type indicates that the data packet does not comply with the preset passing rule and is discarded, searching in the initial matching rule whether there is a port configuration related to the data packet, the port configuration including a port identifier and a port address; if yes, determining the matching rule of the data packet by using the port configuration and the sending and receiving addresses of the data packet, and determining the action parameters of the discarding action as the action rule of the data packet.
[0067] In other embodiments, the second generation module is specifically used to: when the monitoring result of the processing action type indicates that the data packet meets the preset pass rule, generate the forwarding path parameters of the data packet as the matching rule of the data packet according to the port configuration related to the forwarding action of the data packet, and generate the forwarding action parameters of the data packet as the action rule of the data packet.
[0068] In other embodiments, the monitoring module is specifically used to: monitor the functions of each processing action type of the operating system kernel by inserting the functions of the processing action type, wherein the processing action type includes at least one of a discard action, a allow action, and a forwarding action; and determine the monitoring result of the processing action type according to the return result of the function.
[0069] In some other embodiments, the acquisition module is specifically used to: read and parse a predefined declaration configuration file to obtain a rule format of a forwarding rule, wherein the rule format includes a matching field domain and an action field domain.
[0070] The specific implementation of each module in the device can refer to the corresponding description of the corresponding steps in the above method embodiment, and has corresponding beneficial effects, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described device and module can refer to the corresponding process description in the above method embodiment, which will not be repeated here.
[0071] Reference Figure 7 , shows a schematic diagram of the structure of a network card device according to another embodiment of the present invention. The specific embodiment of the present invention does not limit the specific implementation of the network card device.
[0072] like Figure 7 As shown, the network card device may be a network card device, which may include: a processor (processor) 702 for executing a program 710, a communication interface (Communications Interface) 704, a memory (memory) 706, and a communication bus 708.
[0073] The processor, the communication interface, and the memory communicate with each other via a communication bus.
[0074] Communication interface, used to communicate with other electronic devices or servers.
[0075] The processor is used to execute the program, and specifically can execute the relevant steps in the above method embodiment.
[0076] Specifically, the program may include program codes including computer operation instructions.
[0077] The processor may be a CPU, or an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0078] The memory is used to store programs. The memory may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.
[0079] The program may include multiple computer instructions. Specifically, the program may enable the processor to execute operations corresponding to the DPU-based forwarding rule unloading method described in any of the aforementioned method embodiments through multiple computer instructions.
[0080] The specific implementation of each step in the program can refer to the corresponding description of the corresponding steps, modules or units in the above method embodiments, and has corresponding beneficial effects, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described device, equipment or module can refer to the corresponding process description in the above method embodiments, which will not be repeated here.
[0081] The embodiment of the present invention further provides a computer storage medium on which a computer program is stored, and when the program is executed by a processor, the method described in any of the above-mentioned multiple method embodiments is implemented. The computer storage medium includes, but is not limited to: a compact disc read-only memory (CD-ROM), a random access memory (RAM), a floppy disk, a hard disk or a magneto-optical disk, etc.
[0082] An embodiment of the present invention further provides a computer program product, including computer instructions, which instruct a computing device to execute operations corresponding to the DPU-based forwarding rule unloading method in the above-mentioned multiple method embodiments.
[0083] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present invention can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present invention.
[0084] The above-mentioned method according to the embodiment of the present invention can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD-ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as a computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor or programmable or dedicated hardware (such as an application-specific integrated circuit (ASIC) or a field programmable gate array (FPGA)). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., a random access memory (RAM), a read-only memory (ROM), a flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the method shown here, the execution of the code converts the general-purpose computer into a dedicated computer for executing the method shown here.
[0085] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present invention.
[0086] The above implementation methods are only used to illustrate the embodiments of the present invention, and are not limitations of the embodiments of the present invention. Ordinary technicians in the relevant technical field may make various changes and modifications without departing from the spirit and scope of the embodiments of the present invention. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present invention. The patent protection scope of the embodiments of the present invention should be defined by the claims.
Claims
1. A forwarding rule unloading method based on DPU, applied to a network card device configured with DPU, the network card device is mounted on a gateway server, the operating system kernel of the gateway server is used to process data packets, the method include: Obtain a rule format of a forwarding rule, wherein the rule format includes a match field domain and an action field domain; Generating an initial matching rule according to writing at least part of the session configuration information into the matching field domain; Monitoring the type of processing action of the operating system kernel on the data packet; According to the monitoring result of the processing action type, searching the relevant data of the data packet in the initial matching rule to generate the matching rule and action rule of the data packet; The matching rule and the action rule of the data packet are sent to the DPU as forwarding rules, so that the DPU processes subsequent data packets based on the forwarding rules.
2. The method according to claim 1, in, Generating an initial matching rule according to writing at least part of the session configuration information into the matching field domain includes: Writing the port identifier and the port address of the network card port into the port attribute field in the matching field domain; Writing the node address of the neighboring node learned by the network card port into the node attribute field in the matching field domain; Writing the type of processing action of the operating system kernel on the data packet into the action field; The initial matching rule is generated according to the written information of the matching field domain and the written information of the action field domain.
3. The method according to claim 1, in, According to the monitoring result of the processing action type, searching the initial matching rule for the data packet for relevant data, and generating the matching rule for the data packet, including: Writing the initial matching rule into the first database; querying the first database according to the monitoring result of the processing action type; According to the queried data related to the data packet and the processing action type, a matching rule for the data packet is generated.
4. The method according to claim 3, in, The method further comprises: Deleting the port configuration of the network card port according to the port configuration change instruction of the gateway program, wherein the port configuration includes a port identifier and a port address; In response to the deletion of the port configuration, data related to the port configuration of the data packet is deleted from the first database, and data related to the port configuration in the forwarding rule of the DPU is deleted.
5. The method according to claim 3, in, According to the monitoring result of the processing action type, querying in the first database includes: Writing the monitoring result of the processing action type into the second database; In response to the writing operation of the monitoring result in the second database, a query is performed in the first database to obtain a matching rule for the data packet.
6. The method according to claim 1, in, According to the monitoring result of the processing action type, searching the relevant data of the data packet in the initial matching rule, generating the matching rule and action rule of the data packet, including: When the monitoring result of the processing action type indicates that the data packet does not meet the preset passing rule and is discarded, searching in the initial matching rule whether there is a port configuration related to the data packet, the port configuration including a port identifier and a port address; If yes, the port configuration and the receiving and sending addresses of the data packet are used to determine the matching rule of the data packet, and the action parameter of the discard action is determined as the action rule of the data packet.
7. The method according to claim 1, in, According to the monitoring result of the processing action type, searching the relevant data of the data packet in the initial matching rule, generating the matching rule and action rule of the data packet, including: When the monitoring result of the processing action type indicates that the data packet meets the preset passing rule, the forwarding path parameters of the data packet are generated as the matching rules of the data packet according to the port configuration related to the forwarding action of the data packet, and the forwarding action parameters of the data packet are generated as the action rules of the data packet.
8. The method according to claim 7, in, Generating a forwarding path parameter of the data packet as a matching rule of the data packet according to a port configuration related to the forwarding action of the data packet, including: The source MAC address of the protocol header of the data packet is replaced with the MAC address of the sending port of the data packet, and the destination MAC address of the protocol header of the data packet is replaced with the MAC address of the neighboring node as the forwarding action rule of the data packet.
9. The method according to claim 1, in, Monitoring the processing action type of the operating system kernel on the data packet includes: By inserting a function of each processing action type of the operating system kernel, monitoring the function of the processing action type, the processing action type includes at least one of a discard action, a pass action, and a forwarding action; The monitoring result of the processing action type is determined according to the return result of the function.
10. A network card device, configured with a DPU, the network card device is mounted on a gateway server, the operating system kernel of the gateway server is used to process data packets, the network card device include: An acquisition module is used to acquire a rule format of a forwarding rule, wherein the rule format includes a match field domain and an action field domain; A first generating module, generating an initial matching rule according to at least part of the session configuration information written into the matching field domain; A monitoring module, monitoring the type of processing action of the operating system kernel on the data packet; A second generating module, according to the monitoring result of the processing action type, searches for relevant data of the data packet in the initial matching rule, and generates a matching rule and an action rule for the data packet; The sending module sends the matching rule and the action rule of the data packet to the DPU as the forwarding rule, so that the DPU processes the subsequent data packets based on the forwarding rule.
11. A network card device, include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the method according to any one of claims 1-9.
12. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
13. A computer program product, comprising computer instructions, which implement the method according to any one of claims 1 to 9 when executed by a processor.
