A method and device for processing a transceiving packet based on an encrypted card call, a terminal device, and a storage medium

By monitoring packet sending and receiving requests in real time in the embedded network device, creating a kernel thread and processing it in an asynchronous request pool, the encryption card asynchronously processes data packets, solving the problem of soft interrupt infinite loop waiting and improving device performance.

CN122197095APending Publication Date: 2026-06-12CHINA PETROLEUM & CHEMICAL CORP +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA PETROLEUM & CHEMICAL CORP
Filing Date
2024-12-12
Publication Date
2026-06-12

AI Technical Summary

Technical Problem

In embedded network devices, when encrypting and decrypting data packets in a soft interrupt environment, the infinite loop waiting for the calculation results of the hardware peripherals leads to a serious degradation in device performance.

Method used

By monitoring the sending and receiving of packets in real time, a kernel thread is created to put the requests and pending data into an asynchronous request pool. The encryption card is then called in the kernel thread to perform encryption or decryption, and the processing result is returned to complete the request.

Benefits of technology

Without affecting the soft interrupt environment, infinite loop waiting was avoided, the overall performance of the device was improved, asynchronous processing of encryption and decryption was achieved, and the overall performance of the device was enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122197095A_ABST
    Figure CN122197095A_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on encryption card call transceiving packet processing method, device, terminal equipment and storage medium, method includes: real-time monitoring transceiving packet processing flow in transceiving packet processing request;In the case where monitoring transceiving packet processing request, create kernel thread;With transceiving packet processing request and the transceiving packet processing request corresponding to be handled transceiving packet, put into the asynchronous request pool of preset;And wake up kernel thread;According to the transceiving packet processing request, call encryption card in kernel thread, so that encryption card is handled transceiving packet and is encrypted or decrypted processing, obtains the transceiving packet after encryption card processing;The transceiving packet after encryption card processing is returned to transceiving packet processing flow, to make complete transceiving packet processing request.By implementing the present application, avoid because soft interrupt waiting time is too long and consume the efficiency of whole machine, improve the performance of whole machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network security technology, and in particular to a method, apparatus, terminal device, and storage medium for sending and receiving packets based on encrypted card invocation. Background Technology

[0002] In embedded network devices, the process of sending and receiving data packets typically involves complex processing flows. To improve system performance and responsiveness, the Linux kernel employs a software interrupt mechanism to handle the sending (net_tx_action) and receiving (net_rx_action) of network data packets. Because software interrupts are not allowed to sleep or block—and because they are not part of the operating system's scheduling unit, there is no interrupt descriptor to control them—once a software interrupt enters a sleep state, it cannot be woken up.

[0003] In a network packet transmission and reception software interrupt environment, any newly added functions must not block or sleep. This is because the primary purpose of software interrupts is to process tasks quickly and avoid prolonged blocking that could affect other parts of the system. In packet encryption and decryption scenarios, except for internationally accepted algorithms that do not require hardware peripherals, other cryptographic algorithms whose principles are not publicly disclosed require specific hardware peripherals. Therefore, software interrupts must wait for the hardware peripherals' calculation results before continuing their work. Since software interrupts cannot block while waiting, infinite loops are a common method. If the performance of the hardware peripherals is low, the software interrupt waiting time will be too long, severely impacting the overall performance of the device. Summary of the Invention

[0004] This invention provides a method, apparatus, terminal device, and storage medium for packet sending and receiving based on encrypted card calls, which can effectively solve the problem of infinite loop waiting in the existing soft interrupt environment, which seriously affects the performance of the entire device.

[0005] An embodiment of the present invention provides a packet sending and receiving processing method based on encrypted card invocation, comprising:

[0006] Real-time monitoring of packet sending and receiving requests in the packet sending and receiving process;

[0007] A kernel thread is created upon detecting a request to send or receive packets.

[0008] The request to send and receive packets, along with the corresponding packets to be processed, are placed into a pre-defined asynchronous request pool; and the kernel thread is then awakened.

[0009] According to the packet processing request, the encryption card is invoked in the kernel thread so that the encryption card can encrypt or decrypt the packet to be processed, and the processed packet is obtained.

[0010] The encrypted card processes the sent and received packets and returns them to the sent and received packet processing flow to complete the sent and received packet processing request.

[0011] Furthermore, the creation of kernel threads includes:

[0012] Upon detecting a packet sending / receiving processing request, the kernel creation interface of the Linux kernel is invoked according to the packet sending / receiving processing request;

[0013] Kernel threads are created within the Linux kernel space using the kernel creation interface.

[0014] Furthermore, the packet sending and receiving processing requests and the corresponding pending packet sending and receiving requests are placed into a preset asynchronous request pool, including:

[0015] The packet sending and receiving processing request is initialized with context to obtain the initialized packet sending and receiving processing request.

[0016] The preset asynchronous request pool is initialized to obtain the initialized asynchronous request pool;

[0017] Based on the initialized packet sending and receiving processing request, the initialized packet sending and receiving processing request and the corresponding pending packet sending and receiving request are placed into the initialized asynchronous request pool.

[0018] Furthermore, before invoking the encryption card in the kernel thread according to the packet sending and receiving processing request, the process also includes:

[0019] Based on the packet sending and receiving processing request, determine the request time corresponding to the packet sending and receiving processing request;

[0020] In the kernel thread, packets to be sent and received are retrieved from the asynchronous request pool in chronological order of request time.

[0021] Furthermore, it also includes:

[0022] The encryption card processing result is obtained by comparing the packets to be processed with the packets processed by the encryption card.

[0023] The processing result of the encryption card is returned to the encryption card.

[0024] Furthermore, the encryption card is used to encrypt or decrypt the packets to be processed, resulting in packets processed by the encryption card.

[0025] The packets to be sent and received are encrypted or decrypted to obtain the encrypted packets, including:

[0026] Identify the processing type corresponding to the pending sent and received packets based on the pending sent and received packets;

[0027] Determine the processing mode corresponding to the processing type based on the processing type;

[0028] The packets to be processed are processed according to the processing mode to obtain the encrypted packets;

[0029] The processing types include encryption and decryption.

[0030] As an improvement to the above solution, another embodiment of the present invention provides a packet sending and receiving processing device based on an encrypted card call, comprising:

[0031] The real-time monitoring module is used to monitor packet sending and receiving requests in the packet sending and receiving process in real time.

[0032] The kernel thread creation module is used to create kernel threads when a request to send or receive packets is detected.

[0033] Register the asynchronous request module, which is used to put the packet sending and receiving processing requests and the corresponding pending packets into the preset asynchronous request pool; and wake up the kernel thread;

[0034] The encryption card invocation module is used to invoke the encryption card in the kernel thread according to the packet processing request, so that the encryption card can encrypt or decrypt the packet to be processed, and obtain the packet processed by the encryption card.

[0035] The packet return module is used to return the processed packets from the encrypted card to the packet processing flow to complete the packet processing request.

[0036] Furthermore, it also includes:

[0037] The scheduling module is used to determine the request time corresponding to the packet processing request based on the packet processing request; in the kernel thread, the packets to be processed are retrieved from the asynchronous request pool in the order of the request time.

[0038] Another embodiment of the present invention provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a packet sending and receiving processing method based on an encryption card call as described in the above embodiments.

[0039] Another embodiment of the present invention provides a computer-readable storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform a packet sending and receiving processing method based on an encrypted card call as described in the above embodiment.

[0040] By implementing this invention, at least the following beneficial effects are achieved:

[0041] This invention provides a method, apparatus, terminal device, and storage medium for packet sending and receiving processing based on an encryption card. The method can monitor packet sending and receiving requests in the packet sending and receiving process in real time. Upon detecting a packet sending and receiving request, a kernel thread is created. The packet sending and receiving request and its corresponding pending packets are placed in a preset asynchronous request pool. The kernel thread is then awakened. Based on the packet sending and receiving request, the encryption card is invoked in the kernel thread to encrypt or decrypt the pending packets, resulting in processed packets. The processed packets are then returned to the packet sending and receiving process to complete the request. In a soft terminal environment, the packet sending and receiving process generates requests, and the encryption card is invoked through the kernel thread. This ensures that packet sending and receiving processing and interaction with the encryption card occur within the kernel thread. Since the kernel thread is not in the soft interrupt environment of the packet sending and receiving process, it can block and wait instead of looping and waiting for the processed packets from the encryption card peripheral, significantly improving overall system performance. Attached Figure Description

[0042] Figure 1 This is a flowchart illustrating a packet sending and receiving processing method based on an encrypted card call according to an embodiment of the present invention;

[0043] Figure 2 This is a kernel thread flowchart provided in an embodiment of the present invention;

[0044] Figure 3 This is a schematic diagram of the registration algorithm flow provided in an embodiment of the present invention;

[0045] Figure 4 This is a schematic diagram of the initialization process provided in an embodiment of the present invention;

[0046] Figure 5 This is a schematic diagram of a packet sending and receiving processing device based on an encrypted card call according to an embodiment of the present invention. Detailed Implementation

[0047] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0048] See Figure 1 This is a flowchart illustrating a packet sending and receiving processing method based on an encrypted card call according to an embodiment of the present invention, including:

[0049] S1. Real-time monitoring of packet sending and receiving requests in the packet sending and receiving process;

[0050] S2. Upon detecting a request to send or receive packets, a kernel thread is created.

[0051] S3. Place the packet sending and receiving processing requests and the corresponding pending packets into the preset asynchronous request pool; and wake up the kernel thread.

[0052] S4. According to the packet processing request, the encryption card is called in the kernel thread so that the encryption card can encrypt or decrypt the packet to be processed, and the packet processed by the encryption card is obtained.

[0053] S5. Return the encrypted packet processing results to the packet processing flow to complete the packet processing request.

[0054] In a preferred embodiment of the present invention, the packet sending and receiving process requires encryption and decryption. When packet sending and receiving needs to be encrypted or decrypted, a soft interrupt is generated, so it is necessary to monitor the packet sending and receiving processing requests in the packet sending and receiving process in real time. When a packet sending and receiving processing request is detected, a kernel thread is created, which is a kernel thread that performs encryption or decryption operations. Then, the packet sending and receiving processing request and the corresponding pending packet are placed into a preset asynchronous request pool, and the kernel thread is woken up. The kernel thread sequentially hands the pending packet to the encryption card peripheral, that is, according to the packet sending and receiving processing request, the encryption card is called in the kernel thread so that the encryption card can encrypt or decrypt the pending packet, and the encrypted or decrypted data packet is obtained. The encrypted or decrypted data packet is then copied back to the packet sending and receiving process to complete the packet sending and receiving processing request. Because it runs in a kernel thread, it can block and wait instead of looping and waiting for the processing result of the encryption card peripheral. For access to other resources, it can also use mutex locks instead of spinlocks, which will greatly improve the overall performance of the machine.

[0055] Specifically, the creation of kernel threads includes:

[0056] Upon detecting a packet sending / receiving processing request, the kernel creation interface of the Linux kernel is invoked according to the packet sending / receiving processing request;

[0057] Kernel threads are created within the Linux kernel space using the kernel creation interface.

[0058] In a preferred embodiment of the present invention, upon detecting a packet sending / receiving processing request, a kernel creation interface of the Linux kernel, such as the kthread_create interface, is invoked according to the packet sending / receiving processing request. A kernel thread is then created within the Linux kernel space according to the kthread_create interface. The kernel thread can receive information related to the packet sending / receiving processing request, such as encryption methods (e.g., sm1, sm4), data encryption modes (e.g., CBC, ECB), and encryption / decryption methods (e.g., ablkcipher), through the crypto_alg interface.

[0059] In another preferred embodiment of the present invention, taking the sm1 algorithm as an example, the details are as follows:

[0060]

[0061]

[0062] Among them, the `cra_flags` and `cra_type` members must use `CRYPTO_ALG_TYPE_ABLKCIPHER` and `&crypto_ablkcipher_type`; `swxa_cbc_sm1_encrypt` and `swxa_cbc_sm1_decrypt` only handle asynchronous request data (`struct ablkcipher_request*req`), such as... Figure 4 As shown, the asynchronous request data ctx is initialized, the request is placed in the preset asynchronous request pool, and the kernel thread is woken up.

[0063] Preferably, the packet sending and receiving processing requests and the corresponding pending packet sending and receiving requests are placed into a preset asynchronous request pool, including:

[0064] The packet sending and receiving processing request is initialized with context to obtain the initialized packet sending and receiving processing request.

[0065] The preset asynchronous request pool is initialized to obtain the initialized asynchronous request pool;

[0066] Based on the initialized packet sending and receiving processing request, the initialized packet sending and receiving processing request and the corresponding pending packet sending and receiving request are placed into the initialized asynchronous request pool.

[0067] In a preferred embodiment of the present invention, the preset asynchronous request pool can be created by calling the crypto_init_queue interface, i.e. Figure 3The code shows the call to `crypto_init_queue` to initialize the asynchronous request pool (request cache pool). This asynchronous request pool sequentially arranges encrypted or decrypted block data (send and receive data packets) for processing in the asynchronous encryption or decryption process.

[0068] In another preferred embodiment of the present invention, the packet sending and receiving processing request is initialized with context to obtain an initialized packet sending and receiving processing request; then as follows Figure 3 As shown, the initialization of the request cache pool (asynchronous request pool) involves initializing the preset asynchronous request pool to obtain the initialized asynchronous request pool. Finally, based on the initialized packet processing requests, the initialized packet processing requests and the corresponding pending packets are placed into the initialized asynchronous request pool. Figure 4 As shown, after the packet sending and receiving processing request is placed into the request cache pool, that is, after the packet sending and receiving processing request is placed into the initialized asynchronous request pool, the encryption or decryption kernel thread is woken up.

[0069] Specifically, before invoking the encryption card in the kernel thread according to the packet sending and receiving processing request, the process also includes:

[0070] Based on the packet sending and receiving processing request, determine the request time corresponding to the packet sending and receiving processing request;

[0071] In the kernel thread, packets to be sent and received are retrieved from the asynchronous request pool in chronological order of request time.

[0072] In a preferred embodiment of the present invention, the request time corresponding to the packet sending and receiving processing request is first determined according to the packet sending and receiving processing request; in the kernel thread, the packets to be processed are retrieved from the asynchronous request pool in the order of the request time, and then the encryption card is called in the kernel thread according to the packet sending and receiving processing request.

[0073] Indicatively, it also includes:

[0074] The encryption card processing result is obtained by comparing the packets to be processed with the packets processed by the encryption card.

[0075] The processing result of the encryption card is returned to the encryption card.

[0076] In a preferred embodiment of the present invention, the encryption card processing result includes processing success and processing failure. Because after encrypting or decrypting data, a return message needs to be sent to the soft interrupt, the kernel provides an interface for this operation: `sg_copy_from_buffer` copies the data to the soft interrupt. `complete` tells the soft interrupt that encryption and decryption are complete.

[0077] Specifically, the encryption card is used to encrypt or decrypt the packets to be processed, so as to obtain the packets processed by the encryption card.

[0078] The packets to be sent and received are encrypted or decrypted to obtain the encrypted packets, including:

[0079] Identify the processing type corresponding to the pending sent and received packets based on the pending sent and received packets;

[0080] Determine the processing mode corresponding to the processing type based on the processing type;

[0081] The packets to be processed are processed according to the processing mode to obtain the encrypted packets;

[0082] The processing types include encryption and decryption.

[0083] In a preferred embodiment of the present invention, encryption and decryption are indistinguishable in the packet sending and receiving process; that is, if it is plaintext, it is encrypted; if it is ciphertext, it is decrypted. For how to determine whether it is ciphertext or plaintext, please refer to the rfcesp protocol.

[0084] In a preferred embodiment of the present invention, such as Figure 2 As shown, first determine whether a soft interrupt generated an encryption or decryption processing request. Then, retrieve the encryption or decryption asynchronous request block data from the asynchronous request pool. If there is an encryption or decryption processing request, call the encryption card to process the request block data in the kernel thread. sg_copy_from_buffer copies the encrypted or decrypted block data back to the asynchronous request. Call complete to complete the asynchronous request and inform the encryption card of the processing result.

[0085] By implementing this embodiment, packet processing requests in the packet sending and receiving process are monitored in real time. Upon detecting a packet processing request, a kernel thread is created. The packet processing request and its corresponding pending packets are placed in a preset asynchronous request pool. The kernel thread is then awakened. Based on the packet processing request, the encryption card is invoked in the kernel thread to encrypt or decrypt the pending packets, resulting in processed packets. The processed packets are then returned to the packet processing flow to complete the packet processing request. In the soft terminal environment, the packet processing flow generates packet processing requests, and the encryption card is invoked through the kernel thread. This ensures that packet processing and interaction with the encryption card occur within the kernel thread. Since the kernel thread is not in the soft interrupt environment for packet sending and receiving, it can block and wait instead of looping and waiting for the processed packets from the encryption card peripheral, significantly improving the overall performance of the device. Asynchronous processing involves two processes working simultaneously, without requiring one process to complete before the other can begin. In this embodiment, there are two processes: a soft interrupt (the packet sending and receiving process) and an encryption / decryption kernel thread. The soft interrupt adds data blocks to the request pool, and the encryption / decryption kernel thread retrieves data from the pool for encryption. This is asynchronous processing. Because it's asynchronous, the performance of the encryption card doesn't affect the efficiency of normal packet sending and receiving, effectively improving the overall encryption / decryption performance of the machine. Since the entire encryption process doesn't occur within the soft interrupt environment, the limitations of soft interrupts don't need to be considered. The encryption card driver is not restricted by the soft interrupt context and can use all resource access methods, including resource mutexes, wait, and spinlocks, according to its specific needs. It can also be compatible with different encryption card peripherals using the same encryption algorithm, as long as the encryption card driver provides the encryption / decryption interface specified in this embodiment. This embodiment no longer uses the traditional synchronous infinite loop waiting method but instead uses the asynchronous method of the kernel's crypto kernel module to handle the encryption card peripheral's calculation process. This prevents the overall machine efficiency from being consumed by excessively long soft interrupt waiting times, fully leveraging the capabilities of both the machine and the encryption card.

[0086] See Figure 5 This is a schematic diagram of a packet sending and receiving processing device based on an encryption card call according to an embodiment of the present invention, comprising:

[0087] The real-time monitoring module is used to monitor packet sending and receiving requests in the packet sending and receiving process in real time.

[0088] The kernel thread creation module is used to create kernel threads when a request to send or receive packets is detected.

[0089] Register the asynchronous request module, which is used to put the packet sending and receiving processing requests and the corresponding pending packets into the preset asynchronous request pool; and wake up the kernel thread;

[0090] The encryption card invocation module is used to invoke the encryption card in the kernel thread according to the packet processing request, so that the encryption card can encrypt or decrypt the packet to be processed, and obtain the packet processed by the encryption card.

[0091] The packet return module is used to return the processed packets from the encrypted card to the packet processing flow to complete the packet processing request.

[0092] Specifically, it also includes:

[0093] The scheduling module is used to determine the request time corresponding to the packet processing request based on the packet processing request; in the kernel thread, the packets to be processed are retrieved from the asynchronous request pool in the order of the request time.

[0094] Preferably, the creation of a kernel thread includes:

[0095] Upon detecting a packet sending / receiving processing request, the kernel creation interface of the Linux kernel is invoked according to the packet sending / receiving processing request;

[0096] Kernel threads are created within the Linux kernel space using the kernel creation interface.

[0097] Specifically, the packet sending and receiving processing requests and the corresponding pending packets are placed into a preset asynchronous request pool, including:

[0098] The packet sending and receiving processing request is initialized with context to obtain the initialized packet sending and receiving processing request.

[0099] The preset asynchronous request pool is initialized to obtain the initialized asynchronous request pool;

[0100] Based on the initialized packet sending and receiving processing request, the initialized packet sending and receiving processing request and the corresponding pending packet sending and receiving request are placed into the initialized asynchronous request pool.

[0101] Schematic, before invoking the encryption card in the kernel thread according to the packet sending and receiving processing request, the process also includes:

[0102] Based on the packet sending and receiving processing request, determine the request time corresponding to the packet sending and receiving processing request;

[0103] In the kernel thread, packets to be sent and received are retrieved from the asynchronous request pool in chronological order of request time.

[0104] Preferably, it further includes:

[0105] The encryption card processing result is obtained by comparing the packets to be processed with the packets processed by the encryption card.

[0106] The processing result of the encryption card is returned to the encryption card.

[0107] In a preferred embodiment of the present invention, the encryption card is used to encrypt or decrypt the packets to be processed, so as to obtain the packets processed by the encryption card.

[0108] The packets to be sent and received are encrypted or decrypted to obtain the encrypted packets, including:

[0109] Identify the processing type corresponding to the pending sent and received packets based on the pending sent and received packets;

[0110] Determine the processing mode corresponding to the processing type based on the processing type;

[0111] The packets to be processed are processed according to the processing mode to obtain the encrypted packets;

[0112] The processing types include encryption and decryption.

[0113] This invention provides a packet sending and receiving processing device based on an encryption card invocation. The device comprises: a real-time monitoring module that monitors packet sending and receiving requests in real time; a kernel thread creation module that creates a kernel thread upon detecting a packet sending and receiving request; an asynchronous request registration module that places the packet sending and receiving requests and their corresponding pending packets into a preset asynchronous request pool and wakes up the kernel thread; an encryption card invocation module that invokes the encryption card within the kernel thread based on the packet sending and receiving request, enabling the encryption card to encrypt or decrypt the pending packets to obtain the processed packets; and finally, a packet return module that returns the processed packets to the packet sending and receiving process to complete the packet sending and receiving request. In the soft terminal environment, the packet sending and receiving process generates packet sending and receiving requests. The encryption card is called through the kernel thread, so that packet sending and receiving processing and interaction with the encryption card are both in the kernel thread. Since the kernel thread is not in the soft interrupt environment of packet sending and receiving, it can block and wait instead of looping and waiting for the packet sending and receiving of the encryption card peripheral, which greatly improves the overall performance of the machine.

[0114] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.

[0115] Those skilled in the art will understand that, for convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0116] Another embodiment of the present invention provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a packet sending and receiving processing method based on an encrypted card as described in the above embodiments. The terminal device may be a desktop computer, laptop, handheld computer, or cloud server, etc. The terminal device may include, but is not limited to, a processor and a memory.

[0117] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the terminal device, connecting various parts of the terminal device via various interfaces and lines.

[0118] The memory can be used to store the computer program. The processor implements various functions of the terminal device by running or executing the computer program stored in the memory and calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function, etc.; the data storage area may store data created based on the use of the mobile phone, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, RAM, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0119] Another embodiment of the present invention provides a computer-readable storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform a packet sending and receiving processing method based on an encrypted card call as described in the above embodiment.

[0120] The storage medium is a computer-readable storage medium, and the computer program is stored in the computer-readable storage medium. When executed by a processor, the computer program can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.

[0121] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A packet sending and receiving processing method based on encrypted card invocation, characterized in that, include: Real-time monitoring of packet sending and receiving requests in the packet sending and receiving process; A kernel thread is created upon detecting a request to send or receive packets. The request to send and receive packets, along with the corresponding packets to be processed, are placed into a preset asynchronous request pool. And wake up the kernel thread; According to the packet processing request, the encryption card is invoked in the kernel thread so that the encryption card can encrypt or decrypt the packet to be processed, and the processed packet is obtained. The encrypted card processes the sent and received packets and returns them to the sent and received packet processing flow to complete the sent and received packet processing request.

2. The packet sending and receiving processing method based on encrypted card invocation as described in claim 1, characterized in that, The creation of kernel threads includes: Upon detecting a packet sending / receiving processing request, the kernel creation interface of the Linux kernel is invoked according to the packet sending / receiving processing request; Kernel threads are created within the Linux kernel space using the kernel creation interface.

3. The packet sending and receiving processing method based on encrypted card invocation as described in claim 1, characterized in that, The packet sending and receiving processing requests, along with the corresponding pending packets, are placed into a preset asynchronous request pool, including: The packet sending and receiving processing request is initialized with context to obtain the initialized packet sending and receiving processing request. The preset asynchronous request pool is initialized to obtain the initialized asynchronous request pool; Based on the initialized packet sending and receiving processing request, the initialized packet sending and receiving processing request and the corresponding pending packet sending and receiving request are placed into the initialized asynchronous request pool.

4. The packet sending and receiving processing method based on encrypted card invocation as described in claim 1, characterized in that, Before invoking the encryption card in the kernel thread according to the packet sending and receiving processing request, the process also includes: Based on the packet sending and receiving processing request, determine the request time corresponding to the packet sending and receiving processing request; In the kernel thread, packets to be sent and received are retrieved from the asynchronous request pool in chronological order of request time.

5. The packet sending and receiving processing method based on encrypted card invocation as described in claim 1, characterized in that, Also includes: The encryption card processing result is obtained by comparing the packets to be processed with the packets processed by the encryption card. The processing result of the encryption card is returned to the encryption card.

6. The packet sending and receiving processing method based on encrypted card invocation as described in claim 1, characterized in that, The encryption card is used to encrypt or decrypt the packets to be processed, so as to obtain the packets processed by the encryption card. The packets to be sent and received are encrypted or decrypted to obtain the encrypted packets, including: Identify the processing type corresponding to the pending sent and received packets based on the pending sent and received packets; Determine the processing mode corresponding to the processing type based on the processing type; The packets to be processed are processed according to the processing mode to obtain the encrypted packets; The processing types include encryption and decryption.

7. A packet sending and receiving processing device based on encrypted card invocation, characterized in that, include: The real-time monitoring module is used to monitor packet sending and receiving requests in the packet sending and receiving process in real time. The kernel thread creation module is used to create kernel threads when a request to send or receive packets is detected. The asynchronous request module is used to put packet sending and receiving processing requests and the corresponding pending packets into a preset asynchronous request pool. And wake up the kernel thread; The encryption card invocation module is used to invoke the encryption card in the kernel thread according to the packet processing request, so that the encryption card can encrypt or decrypt the packet to be processed, and obtain the packet processed by the encryption card. The packet return module is used to return the processed packets from the encrypted card to the packet processing flow to complete the packet processing request.

8. The packet sending and receiving processing device based on encrypted card access as described in claim 7, characterized in that, Also includes: The scheduling module is used to determine the request time corresponding to the packet processing request based on the packet processing request; in the kernel thread, the packets to be processed are retrieved from the asynchronous request pool in the order of the request time.

9. A terminal device, characterized in that, The device includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement a packet sending and receiving processing method based on an encryption card call as described in any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform a packet sending and receiving processing method based on an encrypted card call as described in any one of claims 1 to 6.