DPDK dynamic network card adding method, storage medium, electronic equipment and program product

By monitoring network card events and using DPDK's hotplug module processing function, dynamically add network cards and binding AF_XDP sockets, the problem of network interruption during dynamic addition of DPDK network card is solved, and efficient packet processing and system stability are achieved.

CN119135534AInactive Publication Date: 2024-12-13BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411165983.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-12-13
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing DPDK network card dynamic addition method will cause the network interruption of the existing DPDK interface during the restart process, affecting network communication.

Method used

By monitoring network card device events, use DPDK's hotplug module to call the add network card event handling function, assign PORT ID, and create and bind AF_XDP sockets for each network card queue to realize dynamic network card addition and avoid restarting the DPDK process.

Benefits of technology

It realizes dynamic addition of network cards without affecting the network communication of existing network cards, significantly reducing packet processing delays, improving parallel processing capabilities, and enhancing system stability and real-time performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119135534A_ABST
    Figure CN119135534A_ABST
Patent Text Reader

Abstract

The invention provides a DPDK dynamic network card adding method, a storage medium, an electronic device and a program product, a dynamically added network card is processed in real time by monitoring a network card adding event sent by a kernel and calling a corresponding network card adding event processing function, in the process of dynamically adding the network card by a DPDK, the whole DPDK process does not need to be restarted, and the dynamic network card adding efficiency is improved. Therefore, the network communication of the existing network card equipment is not influenced. Moreover, the DPDK uses the AFXDP socket, so that the data packet processing delay can be remarkably reduced. The AFXDP is an efficient data packet receiving mechanism, allows an application program to directly access a queue of network hardware and bypasses a kernel protocol stack, so that CPU consumption and delay are reduced. By creating and binding the AFXDP socket for each network card queue, data packet processing with finer granularity can be realized, and the parallel processing capability is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of network communication technology, and in particular to a DPDK dynamic network card adding method, storage medium, electronic device and program product. Background Art

[0002] DPDK (Data Plane Development Kit) is an open source development platform and interface for fast processing of data plane packet forwarding. It implements high-performance packet forwarding capabilities under the x86 processor architecture through multiple technologies such as environment abstraction layer, bypass kernel protocol stack, uninterrupted transmission and reception of messages in polling mode, optimized memory / buffer / queue management, and load balancing based on network card multi-queue and flow identification.

[0003] First, the Environment Abstraction Layer (EAL) provides DPDK applications with a unified, low-latency interface to access underlying hardware resources such as CPU cores, memory, and network interface cards (NICs), thereby bypassing certain limitations of traditional operating system kernels and reducing the overhead of context switching and data copying.

[0004] Secondly, DPDK adopts the strategy of bypassing the kernel protocol stack, that is, processing network packets directly in user mode, avoiding multiple memory copies and CPU interrupts in the traditional network stack, and achieving true zero-copy and efficient packet processing. This design not only reduces latency, but also significantly improves system throughput.

[0005] In terms of message transmission and reception, DPDK introduces the Polling Mode Driver (PMD), which receives and sends data packets through polling rather than interrupts. This method reduces the idle waiting time of the CPU and allows applications to process network events at a higher frequency and lower latency.

[0006] In addition, DPDK further improves the efficiency of packet processing by optimizing memory, buffer, and queue management strategies. It provides efficient data structures such as lock-free ring buffers and memory pools to support fast packet access and reuse, reducing the overhead of memory allocation and release.

[0007] In terms of load balancing, DPDK makes full use of the multi-queue characteristics of modern network cards and combines flow identification technology to achieve intelligent load balancing based on traffic characteristics and application requirements. This helps to disperse processing pressure and improve the overall performance and scalability of the system.

[0008] In high-performance network servers and network function virtualization scenarios, DPDK is usually used to process and forward packets. When the system needs to expand its network functions, such as achieving load balancing and high availability, it may be necessary to add new network cards to increase network capacity and improve forwarding performance. Therefore, we need to support DPDK to dynamically add network cards.

[0009] The current method for dynamically adding network cards is to bind the newly added network card to the DPDK driver, and then restart the DPDK network service or restart the entire DPDK. This method will cause the existing DPDK interfaces to be disconnected during the restart process, affecting network communication. Summary of the invention

[0010] The purpose of the embodiments of the present application is to provide a DPDK dynamic network card adding method, storage medium, electronic device and program product to solve the technical problem that the existing network card dynamic adding method causes the network interruption of the existing DPDK interface during the restart process.

[0011] The embodiment of the present application provides a DPDK dynamic network card adding method, the method comprising:

[0012] Use the network card device event monitoring module to monitor the event of adding a network card;

[0013] Use the hotplug module of DPDK to call the function of adding network card event processing;

[0014] Assign an available PORT ID to the added network card;

[0015] By adding a network card event processing function, the number of network card queues enabled by the added network card is configured, and an AF_XDP socket is created and bound to each network card queue enabled by the network card; and the network card is started, and according to the corresponding relationship between the PORT ID of the newly created network card, the network card queue and the AF_XDP socket, the AF_XDP socket is used to receive and send packets on the corresponding network card queue.

[0016] In the above technical solution, by monitoring the network card addition events sent by the kernel and calling the corresponding network card addition event processing function, the dynamically added network card is processed in real time. In the process of DPDK dynamically adding network cards, there is no need to restart the entire DPDK process, thereby not affecting the network communication of existing network card devices. In addition, DPDK uses AF_XDP sockets to significantly reduce packet processing delays. AF_XDP is an efficient packet reception mechanism that allows applications to directly access the queues of network hardware, bypassing the kernel protocol stack, thereby reducing CPU consumption and latency. By creating and binding AF_XDP sockets for each network card queue, more fine-grained packet processing can be achieved, improving parallel processing capabilities.

[0017] In some optional implementations, before the network card device event monitoring module is used to monitor the event of adding a network card, the method further includes:

[0018] DPDK is initialized and the thread used to create the network card device event monitoring module is started.

[0019] In the above technical solution, starting a dedicated thread to create and manage the network card device event monitoring module can ensure that the module runs independently of the main program, reduce the impact on the performance of the main program, and improve the stability and reliability of the system. In addition, by using a dedicated thread to monitor network card device events, it is possible to respond more quickly to events such as network card addition and removal. This instant response capability is particularly important for network applications that require high real-time performance.

[0020] In some optional implementations, creating a network card device event monitoring module includes:

[0021] Create a udev monitoring socket for monitoring the kernel to send network card device event data;

[0022] Configure the network card device event monitoring module. When the kernel sends the network card device event data to the udev monitoring socket, parse the network card device event data to obtain the event type and device information.

[0023] In some optional implementations, the event type includes a network card adding event and a network card removing event.

[0024] In some optional implementations, the device information includes a network card name.

[0025] In the above technical solution, udev is the device manager of the Linux kernel, which can dynamically update device files according to the status of the hardware devices in the system, including the creation and deletion of device files. The udev library provides an API interface for monitoring network card events, and performs corresponding hot plug-in actions by monitoring uevent sent by the kernel. Through the udev monitoring socket, the system can receive network card device event data sent by the kernel in real time. This mechanism ensures that the system can respond to the addition or removal of network card devices almost immediately, thereby improving the real-time and accuracy of event processing. Parsing the network card device event data can accurately identify the event type (such as adding a network card or removing a network card) and specific device information (such as the network card name), and can subsequently execute corresponding processing logic according to different event types, thereby improving the flexibility and adaptability of the system.

[0026] In some optional implementations, using the hotplug module of DPDK, before calling the add network card event processing function, the following is also included:

[0027] Initialize the hotplug module and start the hotplug processing mechanism to monitor and respond to network card device event data from the kernel;

[0028] Register callback functions corresponding to different event types. The callback functions are used to be called when network card device events of the corresponding event types occur.

[0029] In some optional implementations, the event types include adding a network card event and removing a network card event, the callback function corresponding to the adding a network card event is the adding a network card event processing function, and the callback function corresponding to the removing a network card event is the removing a network card event processing function.

[0030] In the above technical solution, when a new network card device is added to the system, the system can automatically call the add network card event processing function to configure the device. This includes operations such as allocating PORT ID, configuring the number of network card queues, and binding AF_XDP sockets. Similarly, when the network card device is removed, the system can also automatically call the remove network card event processing function to release related resources. By initializing the hotplug module of DPDK and starting its processing mechanism, it brings about the effects of high integration, event-driven, automated processing, improved stability and reliability, support for dynamic network configuration, and optimized resource utilization.

[0031] The embodiment of the present application provides a DPDK-based dynamic network card adding device, including:

[0032] A monitoring component is used to monitor the event of adding a network card by using a network card device event monitoring module;

[0033] The calling component is used to use the hotplug module of DPDK to call the function of adding network card event processing;

[0034] The allocation component is used to allocate available PORT IDs to the added network cards;

[0035] The processing component is used to configure the number of network card queues enabled by the added network card by adding a network card event processing function, create and bind an AF_XDP socket for each network card queue enabled by the network card; and start the network card, and use the AF_XDP socket to receive and send packets on the corresponding network card queue according to the corresponding relationship between the PORT ID of the newly created network card, the network card queue and the AF_XDP socket.

[0036] In some optional embodiments, the method further comprises:

[0037] Configuration components are used for DPDK initialization and start the thread used to create the network card device event monitoring module.

[0038] In some optional implementations, the configuration component is further configured to:

[0039] Create a udev monitoring socket for monitoring the kernel to send network card device event data;

[0040] Configure the network card device event monitoring module. When the kernel sends the network card device event data to the udev monitoring socket, parse the network card device event data to obtain the event type and device information; among which, the event type includes adding a network card event and removing a network card event, and the device information includes the network card name.

[0041] In some optional implementations, the configuration component is further configured to:

[0042] Initialize the hotplug module and start the hotplug processing mechanism to monitor and respond to network card device event data from the kernel;

[0043] Register callback functions corresponding to different event types. The callback functions are used to be called when network card device events of corresponding event types occur. Among them, event types include adding network card events and removing network card events. The callback function corresponding to adding network card events is the adding network card event processing function, and the callback function corresponding to removing network card events is the removing network card event processing function.

[0044] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, any of the above methods is executed.

[0045] An electronic device provided in an embodiment of the present application includes: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the machine-readable instructions are executed by the processor, any of the above methods is performed.

[0046] A computer program product provided in an embodiment of the present application includes a computer program / instruction, which implements the steps of any of the above methods when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0048] Figure 1 A flowchart of the steps of a DPDK dynamic network card adding method provided in an embodiment of the present application;

[0049] Figure 2A functional module diagram of a dynamic network card adding device based on DPDK provided in an embodiment of the present application;

[0050] Figure 3 A possible structural diagram of an electronic device provided for an application embodiment.

[0051] Icons: 1- configuration component, 2- monitoring component, 3- calling component, 4- allocation component, 5- processing component, 61- processor, 62- memory, 63- communication interface, 64- communication bus. DETAILED DESCRIPTION

[0052] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0053] Please refer to Figure 1 , Figure 1 A flowchart of a method for adding a DPDK dynamic network card is provided in an embodiment of the present application, and the method includes:

[0054] Step S1, using the network card device event monitoring module to monitor the event of adding a network card;

[0055] Among them, the network card device event monitoring module can use the API interface provided by the udev library to monitor network card events, and perform corresponding hot plug actions by monitoring the uevent sent by the kernel. Udev is the device manager of the Linux kernel, which can dynamically update device files according to the status of hardware devices in the system, including the creation and deletion of device files.

[0056] Step S2, using the hotplug module of DPDK, calling the function of adding a network card event processing function;

[0057] Step S3, allocating an available PORT ID to the added network card;

[0058] Step S4, by adding a network card event processing function, configuring the number of network card queues enabled by the added network card, creating and binding an AF_XDP socket for each network card queue enabled by the network card; and starting the network card, according to the corresponding relationship between the PORT ID of the newly created network card, the network card queue and the AF_XDP socket, using the AF_XDP socket to receive and send packets on the corresponding network card queue.

[0059] Among them, AF_XDP is a kind of protocol family, which is used to specify the type of socket communication. We use the socket() system call to create an AF_XDP socket (XSK), and then call the bind() system function to bind the previously created AF_XDP socket to the network card. Each XSK has two rings: RX RING and TX RING. The application can receive data packets on the RX RING by calling the recv() function, and can send data packets on the TX RING by calling the send() function. These rings are registered and resized through XDP_RX_RING and XDP_TX_RING of setockopts() respectively. Calling the mmap() function can share the memory of the RX RING and TX RING in the user state and memory state, so that there is no need to copy data packets in the kernel state and user state, which improves performance. The principle of AF_XDP socket is: after the data packet arrives at the XDP network hook point of the network card, the data packet is stored in the RX RING, the application calls the recv() system function to obtain the data packet from the RX RING through the AF_XDP socket; the application calls send() to store the sent data packet in the TX RING through the AF_XDP socket.

[0060] Socket is a basic concept in computer network communication. It is an abstract data structure used to provide a communication interface between network applications. A socket can be regarded as an endpoint for sending and receiving data, so that applications running on different machines can exchange information, thereby realizing network functions.

[0061] In an embodiment of the present application, by monitoring the add network card event sent by the kernel and calling the corresponding add network card event processing function, the dynamically added network card is processed in real time. In the process of DPDK dynamically adding a network card, there is no need to restart the entire DPDK process, thereby not affecting the network communication of the existing network card device. In addition, DPDK can significantly reduce packet processing delays using AF_XDP sockets. AF_XDP is an efficient packet receiving mechanism that allows applications to directly access the queues of network hardware, bypassing the kernel protocol stack, thereby reducing CPU consumption and latency. By creating and binding AF_XDP sockets for each network card queue, more fine-grained packet processing can be achieved, improving parallel processing capabilities.

[0062] In some optional implementations, before the network card device event monitoring module is used to monitor the event of adding a network card, the method further includes:

[0063] DPDK is initialized and the thread used to create the network card device event monitoring module is started.

[0064] In the embodiment of the present application, starting a dedicated thread to create and manage the network card device event monitoring module can ensure that the module runs independently of the main program, reduce the impact on the performance of the main program, and improve the stability and reliability of the system. In addition, by using a dedicated thread to monitor network card device events, it is possible to respond more quickly to events such as adding and removing network cards. This instant response capability is particularly important for network applications that require high real-time performance.

[0065] In some optional implementations, creating a network card device event monitoring module includes:

[0066] Create a udev monitoring socket for monitoring the kernel to send network card device event data;

[0067] Configure the network card device event monitoring module. When the kernel sends the network card device event data to the udev monitoring socket, parse the network card device event data to obtain the event type and device information; among which, the event type includes adding a network card event and removing a network card event, and the device information includes the network card name.

[0068] In the embodiment of the present application, udev is the device manager of the linux kernel, which can dynamically update the device file according to the status of the hardware device in the system, including the creation and deletion of the device file, etc. The udev library provides an API interface for monitoring network card events, and performs corresponding hot plug actions by monitoring the uevent sent by the kernel. Through the udev monitoring socket, the system can receive the network card device event data sent by the kernel in real time. This mechanism ensures that the system can respond to the addition or removal of the network card device almost immediately, thereby improving the real-time and accuracy of event processing. By parsing the network card device event data, the event type (such as adding a network card or removing a network card) and specific device information (such as the name of the network card) can be accurately identified, and the corresponding processing logic can be executed according to different event types in the future, thereby improving the flexibility and adaptability of the system.

[0069] Specifically, DPDK is initialized, a thread is started, and the API interface of the udev library is used to monitor the hot plug events of the network card, including the following steps:

[0070] Step S11, creating a udev monitoring socket, which is completed by calling the udev_monitor_new_from_netlink() function, which creates a monitoring socket that monitors the network card device event data sent by the kernel.

[0071] Step S12, receiving network card device events: when events such as network card hot plugging, network card device status change, etc. occur, the kernel sends network card device event data to the monitoring socket. The network card device event monitoring thread uses the read() function to read the event data from the socket.

[0072] Step S13, parsing network card device events: The received network card device data events need to be parsed to determine the event type and related device information. Event types include network card addition, network card removal, etc.; device information includes network card name, etc. This will be used in subsequent steps.

[0073] In some optional implementations, using the hotplug module of DPDK, before calling the add network card event processing function, the following is also included:

[0074] Initialize the hotplug module and start the hotplug processing mechanism to monitor and respond to the network card device event data from the kernel;

[0075] Register callback functions corresponding to different event types. The callback functions are used to be called when network card device events of corresponding event types occur. Among them, event types include adding network card events and removing network card events. The callback function corresponding to adding network card events is the adding network card event processing function, and the callback function corresponding to removing network card events is the removing network card event processing function.

[0076] In an embodiment of the present application, when a new network card device is added to the system, the system can automatically call the add network card event processing function to configure the device. This includes operations such as allocating PORT ID, configuring the number of network card queues, and binding AF_XDP sockets. Similarly, when the network card device is removed, the system can also automatically call the remove network card event processing function to release related resources. By initializing the hotplug module of DPDK and starting its processing mechanism, it brings about effects such as high integration, event-driven, automated processing, improved stability and reliability, support for dynamic network configuration, and optimized resource utilization.

[0077] Specifically, the hotplug module of DPDK is a network card device event processing framework provided by DPDK. When a network card event occurs, the function module that pays attention to the network card event is notified through this framework. After DPDK initializes the monitoring of network card hot plug events, it registers the network card device hot plug event processing function. The processing function binds the AF_XDP socket to the newly added network card, including the following steps:

[0078] Step S21, first call rte_dev_hotplug_handle_enable() to initialize the network card device event processing framework; then call rte_dev_event_callback_register() to register the network card device hot plug event processing function.

[0079] Step S22, parse the message and process it according to the message type. If the name of the network card is obtained and the network card event is a newly added network card, rte_dev_event_callback_process() will be called to send a network card hot plug event with an event type of RTE_DEV_EVENT_ADD and the name of the network card.

[0080] Step S23, when the rte_dev_event_callback_process() function is called, the registered network card device hot plug event processing function will be called, and the processing function binds the AF_XDP socket to the queue of the newly added network card.

[0081] After the network card device event monitoring module is created and the event processing function is registered, when a newly created network card event occurs, the network card device event processing framework of the hotplug module of DPDK calls the registered device hot plug event processing function, and the processing function initializes the network card queue and starts the network card.

[0082] The implementation steps are as follows:

[0083] Step S31: When DPDK operates the network card, it indirectly operates the network card through the PORT ID number. First, an available PORT ID is allocated to the network card, and the corresponding relationship between the PORT ID and the network card name is recorded.

[0084] Step S32, setting the number of network card queues: the device hot plug event processing function obtains the name of the newly added network card, and then calls setsockopt() to configure the number of queues enabled by the network card. The number of queues that can be enabled for each network card can be configured when DPDK is started.

[0085] S33. Create an AF_XDP socket (XSK) for the network card: Use the socket() system call to create an AF_XDP socket for each queue enabled by the network card.

[0086] S34. Bind the socket to the queue of the network card: Use bind() to bind the socket XSK to the queue of a specific network card, and record the correspondence between the socket XSK, the network card PORT ID, and the network card queue.

[0087] S35. After the above work is completed, DPDK starts the network card and can use the AF_XDP socket to receive and send packets on each queue of the network card to complete the forwarding of network data packets.

[0088] In summary, this embodiment monitors the hot-plugging event of the network card through udev, and calls the relevant event processing function to process the dynamically added network card in real time. And with the help of AF_XDP technology, the packet receiving and sending function on the newly added network card is realized, so that the DPDK dynamically adds the network card without restarting the DPDK process.

[0089] The dynamic network card adding method of this embodiment can be used for the underlying drainage of the security resource pool and the dynamic adding of network cards of the virtualized security network element. Taking the virtualized security network element as an example, the process is as follows:

[0090] When the DPDK process of the virtualized security NE is started, the maximum number of queues enabled by the dynamically added NIC is set as needed.

[0091] When the DPDK process of the virtualized security network element is started, a thread is started to monitor the network card hot plug event.

[0092] When the DPDK process of the virtualized security network element is started, the network card event processing framework is initialized, and then the device hot plug event processing function is registered.

[0093] The DPDK process of the virtualized security network element assigns a PORT ID to the network card.

[0094] The DPDK process of the virtualized security network element initializes the network card queue for the newly added network card, creates an AF_XDP socket for each enabled queue, and records the correspondence between the created AF_XDP socket and the network card queue.

[0095] The DPDK process of the virtualized security network element starts the network card.

[0096] The DPDK process of the virtualized security network element calls the packet receiving and sending interfaces rte_eth_rx_burst() and rte_eth_tx_burst() to send and receive packets. The interface finds the corresponding AF_XDP socket based on the passed parameters PORT ID and queue number, and then receives and sends packets on each queue of the network card to complete the forwarding of network data packets.

[0097] Please refer to Figure 2 , Figure 2 A functional module diagram of a dynamic network card adding device based on DPDK provided in an embodiment of the present application includes a monitoring component 2, an allocation component 4, a calling component 3 and a processing component 5.

[0098] Among them, the monitoring component 2 is used to monitor the event of adding a network card by using the network card device event monitoring module; the calling component 3 is used to call the event processing function of adding a network card by using the hotplug module of DPDK; the allocation component 4 is used to allocate an available PORT ID for the added network card; the processing component 5 is used to configure the number of network card queues enabled by the added network card through the event processing function of adding a network card, and create and bind an AF_XDP socket for each network card queue enabled by the network card; and start the network card, and according to the corresponding relationship between the PORT ID of the newly created network card, the network card queue and the AF_XDP socket, use the AF_XDP socket to receive and send packets on the corresponding network card queue.

[0099] In some optional implementations, it also includes: a configuration component 1 for initializing DPDK and starting a thread for creating a network card device event monitoring module.

[0100] In some optional embodiments, configuration component 1 is also used to: create a udev monitoring socket for listening to the kernel sending network card device event data; configure a network card device event monitoring module, and when the kernel sends the network card device event data to the udev monitoring socket, parse the network card device event data to obtain the event type and device information; wherein the event type includes adding a network card event and removing a network card event, and the device information includes the network card name.

[0101] In some optional embodiments, the configuration component 1 is also used to: initialize the hotplug module, start the hotplug processing mechanism to listen to and respond to network card device event data from the kernel; register callback functions corresponding to different event types, and the callback function is used to be called when a network card device event of the corresponding event type occurs; wherein the event types include adding a network card event and removing a network card event, and the callback function corresponding to the adding a network card event is the adding a network card event processing function, and the callback function corresponding to the removing a network card event is the removing a network card event processing function.

[0102] Figure 3 A possible structure of an electronic device provided by an embodiment of the present application is shown. Figure 3 The electronic device includes: a processor 61, a memory 62 and a communication interface 63. These components are interconnected and communicate with each other through a communication bus 64 and / or other forms of connection mechanisms (not shown).

[0103] The memory 62 includes one or more (only one is shown in the figure), which may be, but not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. The processor 61 and other possible components may access the memory 62, and read and / or write data therein.

[0104] The processor 61 includes one or more (only one is shown in the figure), which can be an integrated circuit chip with signal processing capabilities. The above-mentioned processor 61 can be a general-purpose processor, including a central processing unit (CPU), a micro control unit (MCU), a network processor (NP) or other conventional processors; it can also be a dedicated processor, including a neural network processor (NPU), a graphics processor (GPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. In addition, when there are multiple processors 61, some of them can be general-purpose processors and the other part can be dedicated processors.

[0105] The communication interface 63 includes one or more (only one is shown in the figure), which can be used to communicate directly or indirectly with other devices to exchange data. The communication interface 63 can include an interface for wired and / or wireless communication.

[0106] One or more computer program instructions may be stored in the memory 62 , and the processor 61 may read and execute these computer program instructions to implement the method provided in the embodiment of the present application.

[0107] Understandably, Figure 3 The structure shown is for illustration only. The electronic device may also include Figure 3 More or fewer components as shown, or with Figure 3 Different structures are shown. Figure 3 The components shown in the figure can be implemented by hardware, software or a combination thereof. The electronic device may be a physical device, such as a PC, a laptop, a tablet computer, a mobile phone, a server, an embedded device, etc., or a virtual device, such as a virtual machine, a virtualized container, etc. Moreover, the electronic device is not limited to a single device, but may also be a combination of multiple devices or a cluster consisting of a large number of devices.

[0108] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, any of the above methods is executed.

[0109] A computer program product provided in an embodiment of the present application includes a computer program / instruction, which implements the steps of any of the above methods when executed by a processor.

[0110] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0111] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0112] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0113] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0114] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A DPDK dynamic network card adding method, characterized in that: The method comprises: Use the network card device event monitoring module to monitor the event of adding a network card; Use the hotplug module of DPDK to call the function of adding network card event processing; Assign an available PORT ID to the added network card; By adding a network card event processing function, the number of network card queues enabled by the added network card is configured, and an AF_XDP socket is created and bound to each network card queue enabled by the network card; and the network card is started, and according to the corresponding relationship between the PORT ID of the newly created network card, the network card queue and the AF_XDP socket, the AF_XDP socket is used to receive and send packets on the corresponding network card queue.

2. The method according to claim 1, characterized in that Before the network card device event monitoring module is used to monitor the event of adding a network card, the method further includes: DPDK is initialized and the thread used to create the network card device event monitoring module is started.

3. The method according to claim 2, characterized in that The step of creating a network card device event monitoring module includes: Create a udev monitoring socket for monitoring the kernel to send network card device event data; Configure the network card device event monitoring module. When the kernel sends the network card device event data to the udev monitoring socket, parse the network card device event data to obtain the event type and device information.

4. The method according to claim 3, characterized in that in, The event types include a network card adding event and a network card removing event.

5. The method according to claim 3, characterized in that in, The device information includes the network card name.

6. The method according to claim 1, characterized in that The hotplug module of DPDK is used to call the function of adding a network card event processing function, and further includes: Initialize the hotplug module and start the hotplug processing mechanism to monitor and respond to the network card device event data from the kernel; Register callback functions corresponding to different event types. The callback functions are used to be called when network card device events of the corresponding event types occur.

7. The method according to claim 6, characterized in that in, The event types include an add network card event and a remove network card event. The callback function corresponding to the add network card event is an add network card event processing function, and the callback function corresponding to the remove network card event is a remove network card event processing function.

8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, which, when executed by a processor, executes the method according to any one of claims 1 to 7.

9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the machine-readable instructions are executed by the processor, the method according to any one of claims 1 to 7 is performed.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Traffic processing method and device

    CN114244560A

  • Network card adding method and device, computing equipment and machine readable storage medium

    CN117793034A

  • Local domain name system server optimization method and related device

    WO2024159963A1