A method and apparatus for maintaining packet marking integrity for a virtual network
By centrally performing NAT operations within the host network namespace and utilizing VRF + Conntrack Zone technology, the problem of packet tag loss in virtual networks is solved, packet tag integrity is maintained, and the continuity and reliability of virtual network policies are guaranteed.
Patent Information
- Application Number
- CN202611189410.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-06
- Publication Date
- 2026-11-24
AI Technical Summary
In a virtual private cloud network, when a packet crosses a network namespace, the Linux kernel will forcibly clear skb->mark, causing the packet mark to be lost, which affects the continuity and reliability of the virtual network policy.
The VRF + Conntrack Zone combination technology is used to logically isolate the network namespace and to centralize NAT operations in the host network namespace. The veth pair is used to introduce traffic into the host network stack to ensure that packet markings remain consistent before and after NAT.
Under the premise of multi-tenant isolation, it ensures the integrity of packet labeling, guarantees the continuity and reliability of virtual network policies, realizes context synchronization between OVS and Netfilter, and supports fine-grained operation such as accurate billing and QoS.
Smart Images

Figure CN123164089A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer network communication technology, and specifically to a method and apparatus for maintaining message tag integrity for virtual networks. Background Technology
[0002] Currently, in modern cloud computing and SDN (Software-Defined Networking) architectures, the Linux kernel's packet tagging field (skb->mark) plays a crucial role as a "control plane metadata carrier." It is widely used for: 1. Business Orchestration: Identifies tenant ID and business flow ID, used for service chain routing.
[0003] 2. QoS Policy: Carries priority tags to guide the underlying traffic shaping and scheduling.
[0004] 3. Policy-based routing (PBR): Determines the next hop for a packet.
[0005] 4. State association: Passing processing context between OVS (Open vSwitch) and Netfilter.
[0006] However, there is a core contradiction in the existing VPC (Virtual Private Cloud) network implementation: in order to isolate the VPC, the existing technology must use an independent Network Namespace, but packet transmission across Namespaces will cause skb->mark to be forcibly cleared by the kernel.
[0007] Therefore, to address the above issues and meet practical needs, a message marking integrity preservation technology for virtual networks is proposed. Summary of the Invention
[0008] In view of the deficiencies in the existing technology, the purpose of this application is to provide a method and apparatus for maintaining the integrity of packet markings in virtual networks. This method and apparatus can ensure that the service markings of packets remain consistent before and after NAT processing, while ensuring multi-tenant isolation, so as to guarantee the continuity and reliability of virtual network policies.
[0009] To achieve the above objectives, the technical solution adopted in this application is as follows: In a first aspect, this application provides a method for maintaining message marking integrity in a virtual network, the method comprising the following steps: Move all VPC NAT operations out of their respective network namespaces and centrally configure and execute them in the host machine's network namespace; The VRF + Conntrack Zone combination technology is used to logically isolate the namespaces of each network.
[0010] Based on the above technical solution, a combination of VRF + Conntrack Zone technology is used to logically isolate the namespaces of each network, including the following steps: VRF technology is used to isolate routes in each of the network namespaces.
[0011] Based on the above technical solution, a combination of VRF + Conntrack Zone technology is used to logically isolate the namespaces of each network, including the following steps: The Conntrack Zone technology is used to isolate the state of each network namespace.
[0012] Based on the above technical solution, the adoption of VRF + Conntrack Zone combined technology to logically isolate the network namespaces includes the following steps: Interface matching + SKB Mark matching are performed on each of the network namespaces to achieve rule isolation for each of the network namespaces.
[0013] Based on the above technical solution, the method further includes the following steps: The VPC traffic is diverted from the OVS bridge to the host network stack using a veth pair.
[0014] Secondly, this application provides a message marking integrity maintenance device for virtual networks, the device comprising: The network namespace configuration module is used to move all VPC NAT operations out of their respective network namespaces and centrally configure them to be executed in the host machine's network namespace. The network namespace isolation module is used to logically isolate each network namespace using a combination of VRF and Conntrack Zone technologies.
[0015] Based on the above technical solution, the network namespace isolation module is also used to perform route isolation for each of the network namespaces using VRF technology.
[0016] Based on the above technical solution, the network namespace isolation module is also used to perform state isolation of each network namespace using ConntrackZone technology.
[0017] Based on the above technical solution, the network namespace isolation module is also used to perform interface matching + SKB Mark matching on each network namespace to achieve rule isolation of each network namespace.
[0018] Based on the above technical solution, the network namespace configuration module is also used to use veth pairs to direct the traffic of each VPC from the OVS bridge to the host network stack.
[0019] Compared with the prior art, the advantages of this application are: This application can ensure that the service label of the message remains consistent before and after NAT processing, while guaranteeing multi-tenant isolation, so as to ensure the continuity and reliability of the virtual network policy. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating the steps of a message marking integrity preservation method for a virtual network according to an embodiment of this application. Figure 2 This is a structural block diagram of a message marking integrity maintenance device for a virtual network according to an embodiment of this application. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0023] The embodiments of this application will be further described in detail below with reference to the accompanying drawings.
[0024] This application provides a method and apparatus for maintaining the integrity of message markings in virtual networks. It can ensure that the service markings of messages remain consistent before and after NAT processing, while ensuring multi-tenant isolation, so as to guarantee the continuity and reliability of virtual network policies.
[0025] To achieve the aforementioned technical effects, the overall concept of this application is as follows: A method for maintaining message tag integrity in a virtual network, the method comprising the following steps: S1. Move all VPC NAT operations out of their respective network namespaces and centrally configure them to be executed in the host machine's network namespace; S2. Employs a combination of VRF and Conntrack Zone technologies to logically isolate the namespaces of each network.
[0026] The embodiments of this application will be further described in detail below with reference to the accompanying drawings.
[0027] Firstly, see [the following] Figure 1 As shown in the figure, this application provides a method for maintaining message marking integrity in a virtual network, the method comprising the following steps: S1. Move all VPC NAT operations out of their respective network namespaces and centrally configure them to be executed in the host machine's network namespace; S2. Employs a combination of VRF and Conntrack Zone technologies to logically isolate the namespaces of each network.
[0028] It should be noted that, in order to achieve NAT isolation between VPCs (to prevent IP conflicts and session interference), existing technologies generally adopt a distributed isolation architecture based on Network Namespaces: 1. Create a separate Network Namespace for each VPC tenant.
[0029] 2. Confine NAT rules, routing tables, and Conntrack tables within their respective namespaces.
[0030] 3. Data flow must switch from the host namespace to the VPC namespace in order to perform NAT.
[0031] Continuity has the following key drawbacks: Flaw 1: Cross-domain zeroing (inherent mechanism). For security reasons, the Linux kernel resets skb->mark to 0 when packets are transmitted between different Network Namespaces.
[0032] Defect 2: NAT Reconstruction Risk. In a distributed namespace environment, the independent execution of the NAT module may involve packet reassembly, increasing the risk of metadata loss.
[0033] The consequences of these defects include: context breakage. When a packet completes NAT and returns to OVS or the host network stack, the original service tag has been lost. OVS cannot identify the original service flow to which the packet belongs, leading to QoS failure, billing errors, or policy matching failure.
[0034] In summary, existing technologies cannot simultaneously ensure multi-tenant isolation and maintain packet label integrity. This application aims to provide a technical method that preserves packet labels (e.g., skb->mark) before and after NAT, and by reconstructing the NAT execution architecture, completely solves the problem of packet labels being cleared across namespaces.
[0035] In this embodiment of the application, it is possible to ensure that the service label of the packet remains consistent before and after NAT processing, while ensuring multi-tenant isolation, so as to guarantee the continuity and reliability of the virtual network policy.
[0036] Furthermore, a combination of VRF and Conntrack Zone technology is used to logically isolate the namespaces of each network, including the following steps: VRF technology is used to isolate routes in each of the network namespaces.
[0037] Furthermore, a combination of VRF and Conntrack Zone technology is used to logically isolate the namespaces of each network, including the following steps: The Conntrack Zone technology is used to isolate the state of each network namespace.
[0038] Furthermore, the use of VRF + Conntrack Zone combined technology to logically isolate each network namespace includes the following steps: Interface matching + SKB Mark matching are performed on each of the network namespaces to achieve rule isolation for each of the network namespaces.
[0039] Furthermore, the method also includes the following steps: The VPC traffic is diverted from the OVS bridge to the host network stack using a veth pair.
[0040] It should be noted that the core technical logic of the technical solution in the embodiments of this application lies in: Step 1 (Resolving missing markers): Change the execution location of NAT. Move all VPC NAT operations out of their respective namespaces and execute them uniformly in the host namespace.
[0041] Principle: The packet flows within the host network stack (even if it passes through VRF) and does not cross the namespace boundary. The kernel will not trigger the mark clearing logic, thus ensuring the absolute preservation of skb->mark.
[0042] Step 2 (Resolving the resulting isolation issues): Since all VPCs share the host network stack, a new isolation mechanism must be introduced. This application's embodiment employs a combination of VRF and Conntrack Zone technologies to achieve logical isolation within a single namespace.
[0043] Furthermore, based on the technical solution of the embodiments of this application, a specific implementation scheme is given: (1) Traffic introduction and tag retention: 1. Use a veth pair to redirect VPC traffic from the OVS bridge to the host network stack. 2. During this process, the kernel skb structure corresponding to the message is not reconstructed, and the skb->mark value remains unchanged.
[0044] (2) Design of multi-dimensional isolation mechanism To simulate a "namespace-like" isolation effect on the host machine, this application embodiment constructs a triple isolation fence:
[0045] 3. Data flow processing closed loop (strategy closed loop stage): The embodiments of this application ensure that traffic can always be correctly identified by the control plane (OVS / host policy) throughout its entire lifecycle after NAT processing.
[0046] Uplink (OVS->NAT->External Network): Packets after SNAT, because they flow continuously within the host kernel, still carry the original mark assigned by OVS. The host-side TC (TrafficControl) or policy routing module can directly use this mark for precise scheduling (such as rate limiting, route selection) and send them out of the network.
[0047] Downlink (External Network -> NAT -> OVS): After the return packet arrives at the host, the kernel automatically performs DNAT to restore the IP address based on CTZone. Subsequently, the packet is accurately routed back to the corresponding OVS interface (veth) according to the VRF routing table. After receiving the packet, OVS can again identify the service affiliation based on the ingress interface or flow table logic, thereby achieving policy closure.
[0048] Furthermore, the core technology of the technical solution in this application embodiment lies in: (1) The NAT operations of multi-tenants are concentrated in the host network namespace to avoid packet mark (skb->mark) clearing caused by packets crossing namespaces.
[0049] (2) Within the host network namespace, use Conntrack Zone technology to logically isolate the connection tracking entries of different tenants.
[0050] (3) Within the host network namespace, use VRF (Virtual Router Forwarding) technology to logically isolate the routing domains of different tenants.
[0051] (4) Furthermore, based on the technical solution of the embodiments of this application, a label-preserving network system can be constructed, including a cooperative OVS forwarding module and a centralized NAT module, as follows: Uplink direction: When performing address translation, the NAT module does not modify the pre-configured packet markers in OVS, so that the host-side policy can continue to recognize the markers; Downlink direction: The NAT module accurately sends return packets back to the specific interface of OVS through VRF routing, enabling OVS to identify the service affiliation based on the interface topology.
[0052] Compared with the prior art, the technical solution of this application has the following significant advantages: 1. Completely resolve the issue of lost markers: It has overcome the persistent technical problem of clearing the mark across namespaces in the Linux kernel, achieving 100% inheritance of business coloring before and after NAT without modifying the kernel source code.
[0053] 2. Consistency between the control plane and the forwarding plane: This ensures high context synchronization between OVS (the policy maker) and Netfilter (the NAT enforcer), enabling fine-grained operations based on flow IDs (such as precise billing and QoS).
[0054] 3. Lightweight architecture and high performance: It eliminates the heavy overhead of creating a namespace for each NAT instance and utilizes the kernel's native lightweight features (VRF / CT Zone) to achieve isolation, resulting in lower resource consumption and better forwarding performance.
[0055] 4. High compatibility: This solution is fully compatible with existing iptables / nftables toolchains and OVS architecture, and is easy to deploy and implement quickly in existing cloud infrastructure.
[0056] Secondly, see Figure 2 As shown, this application provides a packet marking integrity maintenance device for a virtual network, the device comprising: The network namespace configuration module is used to move all VPC NAT operations out of their respective network namespaces and centrally configure them to be executed in the host machine's network namespace. The network namespace isolation module is used to logically isolate each network namespace using a combination of VRF and Conntrack Zone technologies.
[0057] It should be noted that, in order to achieve NAT isolation between VPCs (to prevent IP conflicts and session interference), existing technologies generally adopt a distributed isolation architecture based on Network Namespaces: 1. Create a separate Network Namespace for each VPC tenant.
[0058] 2. Confine NAT rules, routing tables, and Conntrack tables within their respective namespaces.
[0059] 3. Data flow must switch from the host namespace to the VPC namespace in order to perform NAT.
[0060] Continuity has the following key drawbacks: Flaw 1: Cross-domain zeroing (inherent mechanism). For security reasons, the Linux kernel resets skb->mark to 0 when packets are transmitted between different Network Namespaces.
[0061] Defect 2: NAT Reconstruction Risk. In a distributed namespace environment, the independent execution of the NAT module may involve packet reassembly, increasing the risk of metadata loss.
[0062] The consequences of these defects include: context breakage. When a packet completes NAT and returns to OVS or the host network stack, the original service tag has been lost. OVS cannot identify the original service flow to which the packet belongs, leading to QoS failure, billing errors, or policy matching failure.
[0063] In summary, existing technologies cannot simultaneously ensure multi-tenant isolation and maintain packet label integrity. This application aims to provide a technical method that preserves packet labels (e.g., skb->mark) before and after NAT, and by reconstructing the NAT execution architecture, completely solves the problem of packet labels being cleared across namespaces.
[0064] In this embodiment of the application, it is possible to ensure that the service label of the packet remains consistent before and after NAT processing, while ensuring multi-tenant isolation, so as to guarantee the continuity and reliability of the virtual network policy.
[0065] Furthermore, the network namespace isolation module is also used to perform route isolation for each of the network namespaces using VRF technology.
[0066] Furthermore, the network namespace isolation module is also used to perform state isolation for each network namespace using Conntrack Zone technology.
[0067] Furthermore, the network namespace isolation module is also used to perform interface matching + SKB Mark matching on each network namespace to achieve rule-based isolation of each network namespace.
[0068] Furthermore, the network namespace configuration module is also used to use veth pairs to direct the traffic of each VPC from the OVS bridge to the host network stack.
[0069] It should be noted that the core technical logic of the technical solution in the embodiments of this application lies in: Step 1 (Resolving missing markers): Change the execution location of NAT. Move all VPC NAT operations out of their respective namespaces and execute them uniformly in the host namespace.
[0070] Principle: The packet flows within the host network stack (even if it passes through VRF) and does not cross the namespace boundary. The kernel will not trigger the mark clearing logic, thus ensuring the absolute preservation of skb->mark.
[0071] Step 2 (Resolving the resulting isolation issues): Since all VPCs share the host network stack, a new isolation mechanism must be introduced. This application's embodiment employs a combination of VRF and Conntrack Zone technologies to achieve logical isolation within a single namespace.
[0072] Furthermore, based on the technical solution of the embodiments of this application, a specific implementation scheme is given: (1) Traffic introduction and tag retention: 1. Use a veth pair to redirect VPC traffic from the OVS bridge to the host network stack.
[0073] 2. During this process, the kernel skb structure corresponding to the message is not reconstructed, and the skb->mark value remains unchanged.
[0074] (2) Design of multi-dimensional isolation mechanism To simulate a "namespace-like" isolation effect on the host machine, this application embodiment constructs a triple isolation fence:
[0075] 3. Data flow processing closed loop (strategy closed loop stage): The embodiments of this application ensure that traffic can always be correctly identified by the control plane (OVS / host policy) throughout its entire lifecycle after NAT processing.
[0076] Uplink (OVS->NAT->External Network): Packets after SNAT, because they flow continuously within the host kernel, still carry the original mark assigned by OVS. The host-side TC (TrafficControl) or policy routing module can directly use this mark for precise scheduling (such as rate limiting, route selection) and send them out of the network.
[0077] Downlink (External Network -> NAT -> OVS): After the return packet arrives at the host, the kernel automatically performs DNAT to restore the IP address based on CTZone. Subsequently, the packet is accurately routed back to the corresponding OVS interface (veth) according to the VRF routing table. After receiving the packet, OVS can again identify the service affiliation based on the ingress interface or flow table logic, thereby achieving policy closure.
[0078] Furthermore, the core technology of the technical solution in this application embodiment lies in: (1) The NAT operations of multi-tenants are concentrated in the host network namespace to avoid packet mark (skb->mark) clearing caused by packets crossing namespaces.
[0079] (2) Within the host network namespace, use Conntrack Zone technology to logically isolate the connection tracking entries of different tenants.
[0080] (3) Within the host network namespace, use VRF (Virtual Router Forwarding) technology to logically isolate the routing domains of different tenants.
[0081] (4) Furthermore, based on the technical solution of the embodiments of this application, a label-preserving network system can be constructed, including a cooperative OVS forwarding module and a centralized NAT module, as follows: Uplink direction: When performing address translation, the NAT module does not modify the pre-configured packet markers in OVS, so that the host-side policy can continue to recognize the markers; Downlink direction: The NAT module accurately sends return packets back to the specific interface of OVS through VRF routing, enabling OVS to identify the service affiliation based on the interface topology.
[0082] Compared with the prior art, the technical solution of this application has the following significant advantages: 1. Completely resolve the issue of lost markers: It has overcome the persistent technical problem of clearing the mark across namespaces in the Linux kernel, achieving 100% inheritance of business coloring before and after NAT without modifying the kernel source code.
[0083] 2. Consistency between the control plane and the forwarding plane: This ensures high context synchronization between OVS (the policy maker) and Netfilter (the NAT enforcer), enabling fine-grained operations based on flow IDs (such as precise billing and QoS).
[0084] 3. Lightweight architecture and high performance: It eliminates the heavy overhead of creating a namespace for each NAT instance and utilizes the kernel's native lightweight features (VRF / CT Zone) to achieve isolation, resulting in lower resource consumption and better forwarding performance.
[0085] 4. High compatibility: This solution is fully compatible with existing iptables / nftables toolchains and OVS architecture, and is easy to deploy and implement quickly in existing cloud infrastructure.
[0086] In summary, the packet marking integrity preservation device for virtual networks provided in this application embodiment has the same technical principle as the packet marking integrity preservation method for virtual networks provided in the first aspect in terms of technical problems, technical solutions and technical effects, so it will not be described in detail here.
[0087] In the description of this application, it should be noted that the terms "upper," "lower," etc., indicating the orientation or positional relationship are based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the system or component referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application. Unless otherwise expressly specified and limited, the terms "installed," "connected," and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication between two components. For those skilled in the art, the specific meaning of the above terms in this application can be understood according to the specific circumstances.
[0088] It should be noted that in this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0089] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for maintaining message tag integrity in virtual networks, characterized in that, The method includes the following steps: Move all VPC NAT operations out of their respective network namespaces and centrally configure and execute them in the host machine's network namespace; The VRF + Conntrack Zone combination technology is used to logically isolate the namespaces of each network.
2. The message tag integrity preservation method for virtual networks as described in claim 1, characterized in that, The VRF + Conntrack Zone combination technology is used to logically isolate the namespaces of each network, including the following steps: VRF technology is used to isolate routes in each of the network namespaces.
3. The message tag integrity preservation method for virtual networks as described in claim 1, characterized in that, The VRF + Conntrack Zone combination technology is used to logically isolate the namespaces of each network, including the following steps: The Conntrack Zone technology is used to isolate the state of each network namespace.
4. The message tag integrity preservation method for virtual networks as described in claim 1, characterized in that, The method of using VRF + Conntrack Zone combined technology to logically isolate the network namespaces includes the following steps: Interface matching + SKB Mark matching are performed on each of the network namespaces to achieve rule isolation for each of the network namespaces.
5. The message tag integrity preservation method for virtual networks as described in claim 1, characterized in that, The method further includes the following steps: The VPC traffic is diverted from the OVS bridge to the host network stack using a veth pair.
6. A message tag integrity maintenance device for virtual networks, characterized in that, The device includes: The network namespace configuration module is used to move all VPC NAT operations out of their respective network namespaces and centrally configure them to be executed in the host machine's network namespace. The network namespace isolation module is used to logically isolate each network namespace using a combination of VRF and Conntrack Zone technologies.
7. The message tag integrity preservation device for virtual networks as described in claim 6, characterized in that: The network namespace isolation module is also used to perform route isolation for each of the network namespaces using VRF technology.
8. The message tag integrity preservation device for virtual networks as described in claim 6, characterized in that: The network namespace isolation module is also used to perform state isolation for each network namespace using Conntrack Zone technology.
9. The message tag integrity preservation device for virtual networks as described in claim 6, characterized in that: The network namespace isolation module is also used to perform interface matching + SKB Mark matching on each network namespace to achieve rule-based isolation of each network namespace.
10. The message tag integrity preservation device for virtual networks as described in claim 6, characterized in that: The network namespace configuration module is also used to use veth pairs to direct the traffic of each VPC from the OVS bridge to the host network stack.
