Method for realizing UDP port proxy of dual-mode base station based on eBPF

By using eBPF technology in the base station, loading it into the data link layer of the TCP/IP protocol stack, the base station UDP port proxy is implemented, solving the problems of poor message processing performance and poor kernel module adaptation in the existing technology, and improving processing speed and compatibility.

CN119520641APending Publication Date: 2025-02-25深圳市佳贤通信科技股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411466756.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

When implementing the base station UDP port proxy, the use of the Netfilter subsystem leads to poor packet processing performance and poor kernel module adaptation, which can easily cause kernel crashes.

Method used

The eBPF-based method is adopted to load the eBPF program into the data link layer of the TCP/IP protocol stack through TC commands, realizing the UDP port proxy function, avoiding the use of RCU locks and the dependence of the kernel module.

Benefits of technology

It improves the forwarding rate of packet processing, reduces the risk of kernel crashes, and achieves compatibility for running on different kernel versions through the CO-RE function of eBPF.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119520641A_ABST
    Figure CN119520641A_ABST
Patent Text Reader

Abstract

The invention discloses a method for realizing dual-mode base station UDP (User Datagram Protocol) port proxy based on an eBPF (evolved Broadband Power Function), which comprises the following steps that: an eBPF program is loaded to a data link layer of a TCP / IP (Transmission Control Protocol / Internet Protocol) protocol stack by a TC (Train Control) command, the eBPF program is used for proxy of a 2152 port of a 4G UDP by a 2153 port, and the eBPF program is called when messages received by a network card pass through the data link layer; and the eBPF program is loaded to a 4G post-transmission network port eth1. According to the method, the UDP port of the 5G process or the 4G process is agented through the eBPF technology, and whether the 5G process or the 4G process is agented can be configured through the configuration file. And a kernel module is not used, so that the risk of service interruption caused by kernel crash is avoided, and compared with the prior art, the forwarding rate of message processing is greatly improved. In addition, the eBPF program has the advantage that multiple positions can be operated at one time of compiling, the compiled eBPF program can be operated in multiple kernel mode versions, and the time cost of a module adaptive operation system is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of communication technology and is a method for implementing a dual-mode base station UDP port proxy based on eBPF, particularly involving a base station backhaul port using a kernel-mode TCP / IP protocol stack and the base station simultaneously enabling a 4G protocol stack and a 5G protocol stack. Background Art

[0002] When creating a socket, the backhaul application of the 4G protocol stack does not bind to UDP port 2152 (the port used by GTPU), but binds to a UDP proxy port. When creating a socket, the backhaul application of the 5G protocol stack still binds to UDP port 2152 (the port used by GTPU). The main function of UDP port proxy technology is to convert the destination UDP port in the transport layer header of the GTPU message sent to the 4G protocol stack into a UDP proxy port, where the UDP port conversion condition is that the tunnel ID of the GTPU header in the message needs to be within the tunnel ID range of the 4G protocol stack.

[0003] To implement this UDP port conversion function, you can use the netfilter subsystem in the Linux system. The netfilter subsystem has 5 Hook points, namely: NF_INET_PRE_ROUTING, NF_INET_LOCAL_IN, NF_INET_FORWARD, NF_INET_OUTPUT, NF_INET_POST_ROUTING. The positions of these 5 Hooks in the network layer are as follows: Figure 1 As shown:

[0004] For GTPU messages in the receiving direction, they will only pass through two hook points: NF_INET_PRE_ROUTING and NF_INET_LOCAL_IN. NF_INET_PRE_ROUTING is the hook point before the network layer searches for the route after the message passes the network layer header check. This is also the first hook point for the message to enter the network layer. This hook point is mainly used for DNAT function processing. NF_INET_LOCAL_IN is the hook point before the message is handed over to the transport layer for processing after checking the local route. The transport layer header of the message can be modified at this hook point. To implement this function, you must create a KO module according to the framework of creating kernel modules in the Linux operating system. The following functions need to be implemented in this kernel module:

[0005] 1. Create a hook function at the NF_INET_LOCAL_IN Hook point;

[0006] 2. Parse the UDP header in the hook function to determine whether the destination port is 2152 (the port used by GTPU);

[0007] 3. If the UDP destination port is 2152, parse the first 8 bytes of the application layer and obtain the GTPU tunnel ID from the 4th, 5th, 6th and 7th bytes;

[0008] 4. Determine whether the GTPU tunnel ID is within the range of the 4G protocol stack. If it is the 4G tunnel ID, modify the destination port in the UDP header to the UDP proxy port and pass it to the UDP layer. In the transport layer, find the socket created by the 4G protocol stack according to the four-tuple, insert the message into the receiving list of this socket, and finally notify the 4G protocol stack to receive this message.

[0009] 5. If the GTPU tunnel ID is not within the range of the 4G protocol stack, no modification is made to the message header in this hook function, and it is directly handed over to the UDP layer. Finally, the message is received by the 5G protocol stack. Summary of the invention

[0010] In view of the technical problems raised by the background technology, the present invention proposes a method for realizing a dual-mode base station UDP port proxy based on eBPF, aiming to solve the problem that the Netfilter subsystem of the network layer has 5 Hook points, and the processing function of each Hook point is nf_hook(), and the RCU lock is used in this function implementation.

[0011] Each GTPU message passes through two Hook points at the network layer through the Netfilter subsystem: NF_INET_PRE_ROUTING and NF_INET_LOCAL_IN. The processing functions of the two hook points use RCU locks to implement mutual exclusion operations on resources with the other three hook points, which greatly reduces the message processing speed.

[0012] Therefore, using the Netfilter subsystem to implement the UDP port proxy function has the following disadvantages:

[0013] 1. When the RCU lock is used, a GTPU message hits two filter points, resulting in poor message processing performance;

[0014] 2. The kernel module needs to be implemented. The kernel module is not compatible with multiple versions of Linux. It cannot be developed and run in multiple versions at one time. It must be adapted to each Linux release version.

[0015] 3. If the kernel module is not well adapted, it may easily cause kernel crash.

[0016] In the first aspect, the present application provides a method for implementing a dual-mode base station UDP port proxy based on eBPF, comprising loading an eBPF program into the data link layer of a TCP / IP protocol stack using a TC command, wherein the eBPF program is used to proxy port 2152 of 4G UDP with port 2153, and the eBPF program is called when all messages received by the network card pass through the data link layer; the eBPF program is loaded onto the 4G backhaul network port eth1.

[0017] Furthermore, the instructions for TC to load the eBPF program are as follows:

[0018] tc filter add dev eth1 ingress bpf da obj ingress.ebpf sec tc_ingress

[0019] Among them: ingress.ebpf is the name of the eBPF program file loaded into the data link layer; tc_ingress is the code segment entry name of the eBPF program. A hook function will be implemented in this code segment to parse and process 4G packets.

[0020] Furthermore, the message received by the network card will be processed by the hook function defined in the code segment tc_ingress. The implementation steps of the hook function are as follows:

[0021] 1) Parse the link layer header to obtain whether the protocol number is 8021Q or 8021AD. If so, parse the VLAN header and obtain the lower network layer protocol number. Otherwise, parse the network layer protocol number directly from the link layer header.

[0022] 2) If the network layer protocol number is 0x800 or 0x86DD, if it is 0x800, it means that this message is an IPv4 network layer message. The pointer is offset to the starting address of the network layer header, and the transport layer protocol number is parsed from the IPv4 network layer to determine whether it is UDP; if it is 0x86DD, it means that this message is an IPv6 network layer message. The pointer is offset to the starting address of the network layer header, and the transport layer protocol number is parsed from the IPv6 network layer to determine whether it is UDP;

[0023] 3) When the protocol number of the transport layer parsed from the network layer header is the UDP protocol number, the pointer is offset to the starting address of the transport layer header;

[0024] 4) Parse the transport layer header to determine whether the destination port is 2152. If so, offset the pointer to the starting address of the GTPU header; and parse the TEID value of the GTPU header;

[0025] 5) Determine whether the TEID value falls within the 4G protocol stack range to determine whether the message is a 4G protocol stack;

[0026] 6) If the message is of 4G protocol stack, change the destination port in the UDP header to the proxy port 2153, and recalculate the checksum field in the UDP header.

[0027] In a second aspect, the present application provides a computer program product for implementing the method described in the first aspect, comprising a storage medium and computer-readable instructions stored on the medium, wherein the instructions are configured to implement the method described in the first aspect when executed by a processor.

[0028] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0029] When processing messages, RCU locks are no longer needed to protect shared resources. There is no need to use new kernel modules to avoid the risk of service interruption caused by kernel crashes.

[0030] In addition, when the eBPF program is loaded into the kernel, it will be verified by the eBPF virtual machine to ensure the security of the execution instructions to avoid causing disasters to the Linux kernel.

[0031] eBPF's CO-RE (compile once, run everywhere) feature allows running the same eBPF program on different kernel versions without recompiling, thereby reducing the workload of adapting to different kernel versions.

[0032] Putting aside the use of kernel modules, the risk of business interruption caused by kernel crash is avoided, and the forwarding rate of message processing is greatly improved. In addition, eBPF programs have the advantage of being compiled once and run in multiple places: the compiled eBPF program can run in multiple kernel versions, greatly reducing the time cost of module adaptation to the operating system. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0034] Figure 1 It is a position relationship diagram of Hook in the network layer provided by the background technology of this application;

[0035] Figure 2 This is a framework diagram of the TC command loading eBPF program provided in an embodiment of the present application. DETAILED DESCRIPTION

[0036] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0037] Example 1

[0038] When the 5G protocol stack and the 4G protocol stack share the same backhaul and core network, in order to enable the operating system to run the 5G process and the 4G process to receive the downlink GTPU messages from the core network, the eBPF technology is used to use port 2153 as a proxy for the 4G UDP port 2152. Of course, the proxy port can be flexibly selected according to the usage of the operating system UDP port.

[0039] This embodiment uses the TC command to load the eBPF program into the data link layer of the TCP / IP protocol stack. Each message received by the network card will call the eBPF program for processing when it passes through the data link layer. Figure 2 As shown:

[0040] Change the port in the configuration file of the 4G protocol stack to the proxy port 2153. When the protocol stack is started, it starts to listen to the messages of this port.

[0041] Use the TC command to load the eBPF program to the 4G backhaul network port eth1. The TC command to load the eBPF program is as follows:

[0042] tc filter add dev eth1 ingress bpf da obj ingress.ebpf sec tc_ingress

[0043] Among them: ingress.ebpf is the name of the eBPF program file loaded into the data link layer; tc_ingress is the code segment entry name of the eBPF program. A hook function will be implemented in this code segment to parse and process 4G packets.

[0044] After running this command, the eBPF program ingress.ebpf is loaded into the data link layer. At this time, the message received from the network card eth1 will be processed by the hook function defined in the code segment tc_ingress. This hook function mainly implements the following functions:

[0045] 1) Parse the link layer header to obtain whether the protocol number is 8021Q or 8021AD. If so, parse the VLAN header and obtain the lower network layer protocol number. Otherwise, parse the network layer protocol number directly from the link layer header.

[0046] 2) If the network layer protocol number is 0x800 or 0x86DD, if it is 0x800, it means that this message is an IPv4 network layer message. The pointer is offset to the starting address of the network layer header, and the transport layer protocol number is parsed from the IPv4 network layer to determine whether it is UDP; if it is 0x86DD, it means that this message is an IPv6 network layer message. The pointer is offset to the starting address of the network layer header, and the transport layer protocol number is parsed from the IPv6 network layer to determine whether it is UDP;

[0047] 3) When the protocol number of the transport layer parsed from the network layer header is the UDP protocol number, the pointer is offset to the starting address of the transport layer header;

[0048] 4) Parse the transport layer header to determine whether the destination port is 2152. If so, offset the pointer to the starting address of the GTPU header; and parse the TEID value of the GTPU header;

[0049] 5) Determine whether the TEID value falls within the 4G protocol stack range to determine whether the message is a 4G protocol stack;

[0050] 6) If the message is of 4G protocol stack, change the destination port in the UDP header to the proxy port 2153, and recalculate the checksum field in the UDP header.

[0051] Specifically, when the base station 4G / 5G protocol stack sends and receives GTPU messages from the backhaul network port and the core network,

[0052] The number of cells supported by the 5G base station protocol stack has been increased from 4 cells to 8 cells. At the same time, to ensure the stability and quality of the 4G signal, each base station still needs to deploy the 4G protocol stack. Such a technical configuration puts forward more stringent requirements on the transmission rate of the backhaul network port. Whether in 5G multi-cell or 4G multi-cell, the uplink and downlink transmission rates must meet the air interface speed limit standard to ensure the efficiency and stability of the communication network.

[0053] eBPF: Extended Berkeley Packet Filter

[0054] Those of ordinary skill in the art will appreciate that the units and algorithm 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 this application.

[0055] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for implementing a dual-mode base station UDP port proxy based on eBPF, characterized in that: It includes loading the eBPF program into the data link layer of the TCP / IP protocol stack with the TC command, wherein the eBPF program is used to proxy the 4G UDP port 2152 with port 2153, and the eBPF program is called when all the messages received by the network card pass through the data link layer; the eBPF program is loaded onto the 4G backhaul network port eth1.

2. According to a method for implementing a dual-mode base station UDP port proxy based on eBPF according to claim 1, it is characterized in that: The instructions for TC command to load the eBPF program are as follows: tc filter add dev eth1 ingress bpf da obj ingress.ebpf sec tc_ingress In which, ingress.ebpf is the name of the eBPF program file loaded into the data link layer; tc_ingress is the code segment entry name of the eBPF program. A hook function will be implemented in this code segment to parse and process 4G packets.

3. According to a method for implementing a dual-mode base station UDP port proxy based on eBPF according to claim 1, it is characterized in that: The message received by the network card will be processed by the hook function defined in the code segment tc_ingress. The implementation steps of the hook function are as follows: 1) Parse the link layer header to obtain whether the protocol number is 8021Q or 8021AD. If so, parse the VLAN header and obtain the lower network layer protocol number. Otherwise, parse the network layer protocol number directly from the link layer header. 2) If the network layer protocol number is 0x800 or 0x86DD, if it is 0x800, it means that this message is an IPv4 network layer message. The pointer is offset to the starting address of the network layer header, and the transport layer protocol number is parsed from the IPv4 network layer to determine whether it is UDP; if it is 0x86DD, it means that this message is an IPv6 network layer message. The pointer is offset to the starting address of the network layer header, and the transport layer protocol number is parsed from the IPv6 network layer to determine whether it is UDP; 3) When the protocol number of the transport layer parsed from the network layer header is the UDP protocol number, the pointer is offset to the starting address of the transport layer header; 4) Parse the transport layer header to determine whether the destination port is 2152. If so, shift the pointer to the starting address of the GTPU header; And parse the TEID value of the GTPU header; 5) Determine whether the TEID value falls within the 4G protocol stack range to determine whether the message is a 4G protocol stack; 6) If the message is of 4G protocol stack, change the destination port in the UDP header to the proxy port 2153, and recalculate the checksum field in the UDP header.

4. A computer program product for implementing the method of claim 1, characterized in that: The method comprises a storage medium and computer-readable instructions stored on the medium, wherein the instructions are configured to implement the method according to any one of claims 1 to 3 when executed by a processor.