Method and device for realizing virtual router by utilizing openvswitch in Openstack

By building a router bridge in Openstack and issuing an openflow flow table, the problem of excessive resource usage and insufficient performance of virtual routers in Openstack is solved, and high-performance east-west routing and north-south network address conversion is achieved.

CN118890313APending Publication Date: 2024-11-01BEIJING CHANGYANG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411014831.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2024-11-01

AI Technical Summary

Technical Problem

In Openstack, when the existing technology uses network namespace to implement a virtual router, it leads to excessive host resource usage and limited bandwidth performance, which cannot effectively meet the needs of high-performance networks.

Method used

By building a router bridge in the host and connecting it to the main switch bridge through the patch port, sending an openflow flow table to the router bridge, using the priority of the flow table entry to match and process data packets from high to low, to achieve East-west routing and north-south network address conversion.

Benefits of technology

This method greatly reduces the resource consumption of the host, avoids bandwidth performance limitations, significantly improves network performance, and can achieve performance comparable to the bandwidth of the physical network card.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118890313A_ABST
    Figure CN118890313A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a device for realizing a virtual router by utilizing openvswitch in an Openstack, and belongs to the field of cloud computing and virtual networks. The method comprises the following steps: constructing a router network bridge in a host machine, wherein the router network bridge is connected with a main switching bridge in the host machine through a patch port; an openflow flow table is issued to the network bridge of the router; the openflow table comprises a plurality of flow table items, and the flow table items comprise feature fields used for matching and corresponding processing means; and receiving a data packet by using a patch port of a router network bridge, performing feature field matching on the data packet by using a flow table entry in the openflow flow table, and processing the data packet by using a processing means in a matched target flow table entry so as to realize east-west routing and south-north network address translation. According to the invention, consumption of host machine resources can be reduced and network performance can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cloud computing and virtual network, and in particular to a method and device for realizing a virtual router by using openvswitch in Openstack. Background Art

[0002] In the related art, the method for implementing virtual routers in Openstack is to use the networknamespace of Linux. This method generates a namespace for each router, and each namespace is a complete network protocol stack. For Openstack, using namespaces is overkill and will occupy a large number of host resources when there are a large number of routers. In addition, the namespace has bandwidth performance limitations, and the network performance is poor.

[0003] Therefore, there is an urgent need to provide a new method for implementing a virtual router to reduce the resource consumption of the host machine while improving network performance. Summary of the invention

[0004] The present invention provides a method and device for implementing a virtual router using openvswitch in Openstack. The technical solution is as follows:

[0005] On the one hand, a method for implementing a virtual router using openvswitch in Openstack is provided, the method comprising:

[0006] A router bridge is constructed in the host machine, wherein the router bridge is connected to the main switching bridge in the host machine through a patch port;

[0007] Sending an openflow flow table to the router bridge; the openflow flow table includes multiple flow table items, and the flow table items include feature fields for matching and corresponding processing means;

[0008] The data packet is received by the patch port of the router bridge, the characteristic fields of the data packet are matched in descending order according to the priorities of the flow items in the openflow flow table, and the data packet is processed by the processing means in the matched target flow item to realize east-west routing and north-south network address translation.

[0009] On the other hand, a device for implementing a virtual router using openvswitch in Openstack is provided, the device comprising:

[0010] A construction unit, used for constructing a router bridge in the host machine, wherein the router bridge is connected to a main switching bridge in the host machine through a patch port;

[0011] A storage unit, used to send an openflow flow table to the router bridge; the openflow flow table includes multiple flow table items, and the flow table items include feature fields for matching and corresponding processing means;

[0012] The routing implementation unit is used to receive data packets using the patch port of the router bridge, match the characteristic fields of the data packets according to the priority order of the flow table items in the openflow flow table from high to low, and process the data packets using the processing means in the matched target flow table items to realize east-west routing and north-south network address translation.

[0013] On the other hand, a computer device is provided, comprising a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to implement the steps of the above-mentioned method of implementing a virtual router using openvswitch in Openstack.

[0014] On the other hand, a computer-readable storage medium is provided, wherein a computer program is stored in the storage medium, and when the computer program is executed by a processor, the steps of the method for implementing a virtual router using openvswitch in Openstack are implemented.

[0015] The technical solution provided by the present invention can at least bring the following beneficial effects:

[0016] By building a router bridge in the host machine, and connecting the router bridge to the main switching bridge existing in the host machine through the patch port, the router bridge is used as a virtual router, and the openflow flow table is sent to the router bridge. The patch port of the router bridge receives the data packet, and the openflow flow table is used to match the characteristic field of the data packet, and the data packet is processed by the processing means in the matched target flow table item, so that the router bridge can realize the east-west routing and north-south network address translation functions through the flow table. In this solution, it only needs the virtual router to realize the east-west routing and north-south network address translation functions required in Openstack. Compared with the network namespace method, it can greatly reduce the consumption of host resources, and this method is not limited by bandwidth performance, which can greatly improve network performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 A flowchart of a method for implementing a virtual router using openvswitch in Openstack is provided in one embodiment of the present invention;

[0019] Figure 2 It is a schematic diagram of the structural relationship between a router bridge and other bridges in a host machine provided by an embodiment of the present invention;

[0020] Figure 3 A device structure diagram of implementing a virtual router using openvswitch in Openstack provided by an embodiment of the present invention;

[0021] Figure 4 It is a hardware architecture diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0023] Please refer to Figure 1 , an embodiment of the present invention provides a method for implementing a virtual router using openvswitch in Openstack, the method comprising:

[0024] Step 100, constructing a router bridge in the host machine, wherein the router bridge is connected to the main switching bridge in the host machine through a patch port;

[0025] Step 102, sending an openflow flow table to the router bridge; the openflow flow table includes multiple flow table items, and the flow table items include feature fields for matching and corresponding processing means;

[0026] Step 104, using the patch port of the router bridge to receive the data packet, matching the characteristic fields of the data packet according to the priority of the flow table items in the openflow flow table from high to low, and processing the data packet using the processing means in the matched target flow table item to achieve east-west routing and north-south network address translation.

[0027] In the embodiment of the present invention, a router bridge is constructed in the host machine, and the router bridge is connected to the main switching bridge existing in the host machine through a patch port, and the router bridge is used as a virtual router. By sending an openflow flow table to the router bridge, the patch port of the router bridge receives a data packet, and the openflow flow table is used to match the characteristic field of the data packet, and the data packet is processed by the processing means in the matched target flow table item, so that the router bridge can realize the east-west routing and north-south network address translation functions through the flow table. In this solution, it is only necessary for the virtual router to realize the east-west routing and north-south network address translation functions required in Openstack. Compared with the network namespace method, it can greatly reduce the consumption of host machine resources, and this method is not limited by bandwidth performance, which can greatly improve network performance.

[0028] Described below Figure 1 How the various steps are performed.

[0029] First, step 100 "building a router bridge in the host machine, the router bridge being connected to the main switching bridge in the host machine through a patch port" and step 102 "issuing an openflow flow table to the router bridge; the openflow flow table includes multiple flow table items, and the flow table items include feature fields for matching and corresponding processing means" are explained at the same time.

[0030] Please refer to Figure 2 , which is a schematic diagram of the structural relationship between the router bridge and other bridges in the host. In the host itself, there are the main switching bridge br-int, the external bridge br-ex and the tunnel bridge br-tun. The virtual machine VM is mounted on the main switching bridge, and the constructed router bridge br-router is connected to the main switching bridge through the patch port. Among them, the qr port (qr-port) type on the main switching bridge is changed from the internal type to the patch type, and the qr port is connected to the intp port (intp-port) of the router bridge. The qg port (qg-port) type on the main switching bridge is changed from the internal type to the patch type, and the qg port is connected to the ex port (ex-port) of the router bridge.

[0031] In the embodiment of the present invention, the virtual machines in the host machine can realize layer 2 and layer 3 communication through the constructed router bridge. There are multiple intp ports in the router bridge, and there are multiple qr ports corresponding to the multiple intp ports in the main switching bridge. The intp ports are connected with the corresponding qr ports to form intp-qr port pairs, and the multiple intp-qr port pairs correspond to the multiple network segments of the virtual machines in the host machine. The router bridge is a virtual router in Openstack, and each intp-qr port pair can be characterized as a gateway of the virtual router.

[0032] Since only a virtual router is needed in Openstack to implement the network address translation (NAT) function of east-west routing and north-south floating IP, and the network namespace method is a complete network protocol stack, which is overkill and occupies a large number of host machine resources, therefore, in the embodiment of the present invention, the openflow flow table is sent to the router bridge to implement the network address translation (NAT) function of the three-layer routing and floating IP by using the openflow flow table method. Specifically, the openflow flow table includes multiple flow table items, and the flow table items include feature fields for matching and corresponding processing means.

[0033] Since the virtual router in Openstack needs to implement east-west routing and north-south network address translation functions, which involves data packet processing in a variety of different situations, using an openflow flow table in the specific implementation will cause the structure of the flow table content to be chaotic, which is not conducive to the arrangement of the flow table. In one embodiment of the present invention, the openflow flow table may include the following six flow tables: input matching table (table 0 input_table), next hop processing table (table 1-next_hop_table), intranet output table (table 2-output_table), MAC address learning table (table 3-mac_learning_table), extranet output table (table 4-ext_output_table) and address conversion output table (table 5-snat_output_table); in each openflow flow table, at least one flow table item is included, and each flow table item includes a feature field for matching and a corresponding processing means. In addition, the flow table entry also includes a corresponding priority. When the openflow flow table is used to match the characteristic fields in the flow table entry, the flow table entries are matched in descending order of priority until the data packet is matched to the target flow table entry with the same characteristic field.

[0034] Different openflow flow tables are used to implement different routing functions, including:

[0035] The input matching table is an openflow flow table that is first matched by the data packets entering the router bridge. The content of the input matching table can be the following example content:

[0036] table0

[0037] table=0,priority=100,ip,m_dst=192.168.2.024actions=resubmit(,1)

[0038] table=0,priority=50,arp,arp_tpa=192.168 2.2actions=resubmit(,1)

[0039] table=0,priority=100,ip,my dst=172.31.2.11actions=resubmit(,1)

[0040] table=0,priority=50,arp,arp_tpa=172.31.2.11actions=resubmit(,1)

[0041] table=0,priority=50,ip,mw_dsl=172,31.2,212

[0042] actions=load:0x4->NXM_NX_REG3,load:0xac1f02d4>NXM_NX_REG4[],learn(table=4,priority=100,cookie 0x5c84f9c2400c3a5d,eth_type=0x800,NXM_OF_IPDST[]=NXM_OF_IP_SRC[],NXM_OF_IP_SRC[]=NXM_NX_REG4[],load:0xa c1f02d4->NXM_OF_IP_SRC[]:load:NXM_OF_ETH_SRC[]-NXM_OF_ETH_DST[],load:Oxa163695683->NXM_OF_ETH_SRC[],output:NX M_NX_REG3[]),mod_nw_dst:192.168.2.162,resubmit(,1)

[0043] table=0,priority=50,arp,app tpa=172.31.2.212actlons=resubmit(,1)

[0044] table=0,priority=30,ip,m_src=192.168.2.162,actions=mod_nw_src:172.31.2.212,dec_ttl,resubmit(,4)

[0045] table 0,priorty,25,ip actions dec_tstl,resubmit(,4)

[0046] After the input matching table (Table 0) successfully matches the characteristic fields of the input data packet, it can be submitted to the next hop processing table (Table 1) as needed, or submitted to the external network output table (Table 4), or the data packet can be directly processed.

[0047] The next hop processing table is an openflow flow table used to match the data packets sent from the input matching table. The content of the next hop processing table can be as follows: table 1:

[0048] table=1,priority=300,arp,in_port="intpf4b7a3r9-e',arp_tpa=192.168,2.2,arp_op=1actions=move:NXM_OF_ETH_SRC[]-

[0049] >NXM_OF_ETH_DST[],mod_dl_src:1a:16:3e:31:11:42,load:0x2-

[0050] >NXM_OF_ARP_OP[],move:NXM_NX_ARP_SHA[]-

[0051] >NXM_NX_ARP_THA[],move:NXM_OF_ARP_SPA[]-

[0052] >NXM_OF_ARP_TPA[],load:0xc0a80202-

[0053] >NXM_OF_ARP_SPA[].load:0xfa163e3f1142-

[0054] >NXM_NX_ARP_SHA[],resubmit(,2),resubmit(,3)

[0055] table=1, priority=200, ip, mw_dst=192.168.2.162, actions=mod_dl_src:fa:16:3e:3f:11:42, mod_dl_dst:fa:16:3e:95:e8:f3,dec_ttl,resu bmit(,2)

[0056] After the next hop processing table (Table 1) successfully matches the characteristic fields of the submitted data packet, it can be processed and submitted to the intranet output table (Table 2) and / or the MAC address learning table (Table 3) as needed.

[0057] The intranet output table is used to output submitted data packets to the intranet. The contents of the intranet output table can be as follows:

[0058] table2:

[0059] table=2,priority=150,icmp,dl_src=fa:16:3e:3f:11:42,nw_src=192.168.2.2actions=IN_PORTtable=2,priority=100,ip,dl_dst=fa:16:3e:95:e8:f3 actions=output:'intpf4b7a3f9-e"table=2.prority=50,arp actions=IN PORT

[0060] table=2,priority=1,actions=NORMAL

[0061] The MAC address learning table is used to realize automatic learning and storage of MAC addresses in the first ... The content of the MAC address learning table can be the following example content:

[0062] table3:

[0063] table=3,priority=150,arp,arp_op=2actions=load:0xfa16366d9b06-

[0064] >NXM_NX_ARP_SHA[],mod_dl_src:fa:16:30:6d:9b:06,mod_dl_dst:ff:ff:ff:ff:ff:ff,load.0xac11020b-

[0065] >NXM_OF_ARP_SPA[],load.0xac1f02fe->NXM_OF_ARP_TPA[],load:0->NX M_NX_ARP_THA[].load:0x1-

[0066] >NXM_OF_ARP_OP[],load:0->NXM_OF_IN_PORT[],output:'ex-6253375f-8c"table=3,priority=1actions=drop

[0067] The external network output table is used to output the submitted data packets to the external network. The content of the external network output table can be as follows:

[0068] table4:

[0069] table=4,priority=100,ip,dl_dst=fa:16:30:3611:42,nw_src=192.168,2.0 / 24actions=resubmit(,5)

[0070] table=4,priority=100,arp,arp_tpa=172.31.2.254,actions=load:0xta163e6d9b06->NXM_NX_ARP_SHA[],output:"ex-6253375f-8c"

[0071] table=4,priority=100,arp,arp_tpa=10.192.5.192,actions=load:0xfa163e6d9606->NXM_NX_ARP_SHA[],output:"ex-6253375f-8c"

[0072] table=4,priority=99,ip

[0073] actions=load:0x4372c713d2->NXM_OF_ETH_DST[],load;0xa163B6d9b08->NXM_OF_ETH_SRC[],output:"ex-6253375f-8c"

[0074] table=4,n_packets=599,n_bytes=40902, priority=25actlons=drop

[0075] The address translation output table is used to implement the translation of network addresses. The content of the address translation output table can be as follows:

[0076] table5:

[0077] table=5,priority=100,dl_dst=fa:16:3e:3f:11:42,actions=mod_dl_src:fa:16:3e:3f:11:42,mod_dl_dst:fa:16:3e:b7:28:79,IN_PORT

[0078] The above flow table contents are only exemplary contents, and other contents may be included according to actual conditions. The functions implemented by each flow table are described in detail in step 104.

[0079] Then, for step 104, the patch port of the router bridge is used to receive the data packet, the characteristic fields of the data packet are matched in descending order of the priority of the flow table items in the openflow flow table, and the data packet is processed using the processing means in the matched target flow table item to realize east-west routing and north-south network address translation.

[0080] In the embodiment of the present invention, in the Openstack, the router bridge can implement the routing function in the following business scenarios:

[0081] 1. Can provide IP response and ARP response of the intranet virtual machine to the intranet gateway

[0082] In this business scenario, the data packet is an IP data packet or an ARP data packet for the intranet virtual machine to access the intranet gateway; then, this step 104 may include:

[0083] When the input matching table is used to determine that the data packet is an IP data packet, the IP data packet is sent to the next hop processing table, and the source IP address and source MAC address of the IP data packet are used as the destination IP address and destination MAC address of the IP response packet by using the next hop processing table, and the IP address and MAC address of the visited intranet gateway are used as the source IP address and source MAC address of the IP response packet, and the IP response packet is sent to the intranet output table, and the intranet output table is used to return the IP response packet to the intranet virtual machine that initiated the access, so as to realize the IP response of the intranet gateway to the intranet virtual machine;

[0084] When the input matching table is used to determine that the data packet is an ARP data packet, and the destination IP address of the ARP data packet is the IP address of the intranet gateway, the ARP data packet is sent to the next hop processing table, and the ARP data packet is matched using the next hop processing table. When the entry of the ARP data packet is matched to the intp port corresponding to the intranet gateway, the source IP address and source MAC address of the ARP data packet are used as the destination IP address and destination MAC address of the ARP response packet, the IP address and MAC address of the visited intranet gateway are used as the source IP address and source MAC address of the ARP response packet, the ARP flag is modified to the reply packet flag, and the ARP response packet is sent to the intranet output table. The intranet output table is used to return the ARP response packet to the intranet virtual machine that initiated the access, thereby realizing the ARP response of the intranet gateway to the intranet virtual machine.

[0085] After receiving the IP data packet or ARP data packet from the intranet virtual machine accessing the intranet gateway, the intranet gateway can use the input matching table → next hop processing table → intranet output table to implement the IP response and ARP response of the intranet gateway to the intranet virtual machine.

[0086] Furthermore, when the data packet is an ARP data packet of the intranet virtual machine accessing the intranet gateway, and it is determined that the intranet virtual machine that initiated the ARP data packet is bound to a floating IP address, then while the intranet gateway is implementing the ARP response to the intranet virtual machine, the virtual router also needs to make an ARP request to the floating IP gateway;

[0087] Among them, the virtual router makes an ARP request to the floating IP gateway, specifically including: copying a copy of the ARP response packet to the MAC address learning table, after matching the ARP response packet in the MAC address learning table, using the MAC address of the ex port corresponding to the external network as the source MAC address of the first ARP request packet, using the broadcast MAC address as the destination MAC address of the first ARP request packet, using the source IP address of the ARP response packet as the source IP address of the first ARP request packet, using the IP address of the floating IP gateway as the destination IP address of the first ARP request packet, modifying the ARP flag bit to the request packet flag, and sending the first ARP request packet from the ex port, thereby realizing the virtual router's ARP request to the floating IP gateway.

[0088] Furthermore, after making an ARP request to the floating IP gateway, the floating IP gateway will make an ARP response to the first ARP request packet, and the virtual router receives and uses the input matching table to determine that the data packet is an ARP data packet entering from the ex port, and determines that the ARP data packet is an ARP response made by the floating IP gateway to the first ARP request packet, and then generates a first learning flow table and a second learning flow table in the external network output table;

[0089] The first learning flow table is used to match the second ARP request packet sent by the virtual machine bound to the floating IP address to the floating IP gateway, fill the floating IP address bound to the virtual machine into the source IP address of the second ARP request packet, and send the second ARP request packet from the ex port to complete the ARP request of the virtual machine bound to the floating IP address to the floating IP gateway;

[0090] The second learning flow table is used to match the target IP data packet sent by the virtual machine bound to the floating IP address to the public network, fill the MAC address of the floating IP gateway into the destination MAC address of the target IP data packet, and send the target IP data packet from the ex port, so as to realize that the next hop of the IP data packet of all virtual machines bound to the floating IP leaving the public network is pointed to the floating IP gateway.

[0091] 2. East-west three-layer routing can be realized

[0092] In this business scenario, the data packet is a communication between virtual machines across network segments; then, this step 104 may include:

[0093] The input matching table is used to match the destination network segment of the data packet, and the data packet is submitted to the next hop processing table, the next hop processing table is used to match the flow table entry whose destination address is the IP address of the destination virtual machine, and the processing means in the flow table entry is used to modify the source MAC address of the data packet to the MAC address of the intranet gateway of the network segment where the destination virtual machine is located, the destination MAC address of the data packet is modified to the MAC address of the destination virtual machine, and the modified data packet is submitted to the intranet output table, the intranet output table is used to match the flow table entry whose destination address is the IP address of the destination virtual machine, and the processing means in the flow table entry is used to output the data packet from the intp port of the intranet gateway corresponding to the destination network segment.

[0094] 3. Provide dnat function for southbound floating IP

[0095] In this business scenario, the data packet is a data packet for accessing an intranet virtual machine from a public network via a floating IP address; then, step 104 may include:

[0096] The input matching table is used to match the flow table entry whose destination IP address is the floating IP address in the data packet, the ex port ID is stored in the first register, the floating IP address is stored in the second register, the destination IP address of the data packet is modified to the IP address of the accessed destination virtual machine in the intranet, and the modified data packet is submitted to the next hop processing table, and a third learning flow table is generated in the external network output table at the same time, the next hop processing table is used to match the flow table entry whose destination address is the IP address of the destination virtual machine, and the processing means in the flow table entry is used to modify the source MAC address of the data packet to the MAC address of the intranet gateway of the network segment where the destination virtual machine is located, the destination MAC address of the data packet is modified to the MAC address of the destination virtual machine, and the modified data packet is submitted to the intranet output table, the intranet output table is used to match the flow table entry whose destination address is the IP address of the destination virtual machine, and the processing means in the flow table entry is used to output the data packet from the intp port of the intranet gateway corresponding to the destination network segment; the intp port is the patch port for the router bridge to communicate with the intranet.

[0097] Among them, the third learning flow table is used to match the reverse message sent by the intranet virtual machine to the public network. When the destination IP address is matched to be the public network IP address and the source IP address is the floating IP address bound to the intranet virtual machine, the data packet is determined to be a reverse message sent by the intranet virtual machine to the public network, and the source MAC address of the reverse message is modified to the MAC address of the intranet virtual machine, and the modified reverse message is sent to the ex port; the third learning flow table is set with an aging time (for example, 30s). If the third learning flow table is not hit within the aging time, it is automatically cleared.

[0098] 4. Provide SNAT function for northbound floating IP

[0099] In this business scenario, the data packet is a data packet for an intranet virtual machine to access a public network through a floating IP; then, this step 104 may include:

[0100] The input matching table is used to determine that the source IP address of the data packet is the intranet IP address of the virtual machine, and the priority of the matched target flow table entry is lower than the priority of the flow table entry corresponding to the intranet communication, then the data packet is determined to be a data packet for communication between the virtual machine and the public network, and the source IP address of the data packet is modified to the floating IP address bound to the intranet virtual machine, and the modified data packet is submitted to the external network output table, and the external network output table is used to send the data packet to the public network through the ex port.

[0101] When the data packet is sent to the public network through the ex port using the external network output table, the second learning flow table and the third learning flow table in the external network output table are used to realize the exit from the public network.

[0102] 5. Provide access to centralized routers

[0103] In this business scenario, when the intranet virtual machine accesses the public network, if the intranet virtual machine is not bound to a floating IP address, it needs to access the public network through a centralized router. Then, this step 104 may include:

[0104] When the input matching table is used to match the IP data packet, if the flow table entry with the lowest priority is matched, the IP data packet is determined to be a data packet sent to the centralized router. When the destination MAC address is matched by the external network output table and is the MAC address of the intranet gateway where the intranet virtual machine is located, the IP data packet is sent to the address translation output table. The address translation output table is used to modify the destination MAC address to the MAC address of the intranet gateway of the centralized router, and the source MAC address is modified to the MAC address of the intranet gateway where the intranet virtual machine is located, and sent out through the corresponding intp port, thereby sending the IP data packet to the centralized router.

[0105] In the embodiment of the present invention, the virtual router can be implemented in Openstack by using the openflow flow table method, which can greatly reduce the consumption of host resources compared with the method of using the network namespace; in addition, this method is not limited by bandwidth performance, which greatly improves network performance, and can reach the rated bandwidth of the physical network card at most when combined with dpdk. Finally, in terms of maintenance, the virtual router can be configured directly on the server without entering the separate network stack of the network namespace.

[0106] Please refer to Figure 3 The embodiment of the present invention provides a device for implementing a virtual router using openvswitch in Openstack, the device comprising:

[0107] A construction unit 300 is used to construct a router bridge in the host machine, wherein the router bridge is connected to a main switching bridge in the host machine through a patch port;

[0108] The storage unit 302 is used to send an openflow flow table to the router bridge; the openflow flow table includes multiple flow table items, and the flow table items include feature fields for matching and corresponding processing means;

[0109] The routing implementation unit 304 is used to receive data packets using the patch port of the router bridge, match the characteristic fields of the data packets in the order of the priorities of the flow table items in the openflow flow table from high to low, and process the data packets using the processing means in the matched target flow table items to achieve east-west routing and north-south network address translation.

[0110] In one embodiment of the present invention, the openflow flow table includes the following six flow tables: input matching table, next hop processing table, intranet output table, MAC address learning table, extranet output table and address conversion output table; wherein,

[0111] The input matching table is the openflow flow table that is first matched against the data packets entering the router bridge.

[0112] In one embodiment of the present invention, the data packet is an IP data packet or an ARP data packet used by the intranet virtual machine to access the intranet gateway;

[0113] The routing implementation unit is specifically used for:

[0114] When the input matching table is used to determine that the data packet is an IP data packet, the IP data packet is sent to the next hop processing table, and the source IP address and source MAC address of the IP data packet are used as the destination IP address and destination MAC address of the IP response packet by using the next hop processing table, and the IP address and MAC address of the visited intranet gateway are used as the source IP address and source MAC address of the IP response packet, and the IP response packet is sent to the intranet output table, and the intranet output table is used to return the IP response packet to the intranet virtual machine that initiated the access, so as to realize the IP response of the intranet gateway to the intranet virtual machine;

[0115] When the input matching table is used to determine that the data packet is an ARP data packet, and the destination IP address of the ARP data packet is the IP address of the intranet gateway, the ARP data packet is sent to the next hop processing table, and the ARP data packet is matched using the next hop processing table. When the entry of the ARP data packet is matched to the intp port corresponding to the intranet gateway, the source IP address and source MAC address of the ARP data packet are used as the destination IP address and destination MAC address of the ARP response packet, the IP address and MAC address of the visited intranet gateway are used as the source IP address and source MAC address of the ARP response packet, the ARP flag is modified to the reply packet flag, and the ARP response packet is sent to the intranet output table. The intranet output table is used to return the ARP response packet to the intranet virtual machine that initiated the access, thereby realizing the ARP response of the intranet gateway to the intranet virtual machine.

[0116] In one embodiment of the present invention, the routing implementation unit is further configured to make an ARP request to the floating IP gateway while making an ARP response to the intranet virtual machine if it is determined that the intranet virtual machine that initiates the ARP data packet is bound to a floating IP address;

[0117] Among them, the ARP request to the floating IP gateway includes: copying a copy of the ARP response packet to the MAC address learning table, and after matching the ARP response packet in the MAC address learning table, using the MAC address of the ex port corresponding to the external network as the source MAC address of the first ARP request packet, using the broadcast MAC address as the destination MAC address of the first ARP request packet, using the source IP address of the ARP response packet as the source IP address of the first ARP request packet, using the IP address of the floating IP gateway as the destination IP address of the first ARP request packet, modifying the ARP flag bit to a request packet flag, and sending the first ARP request packet from the ex port, thereby realizing the virtual router's ARP request to the floating IP gateway.

[0118] In one embodiment of the present invention, after making an ARP request to the floating IP gateway, the floating IP gateway will make an ARP response to the first ARP request packet, and the routing implementation unit is further used to receive and use the input matching table to determine that the data packet is an ARP data packet entering from the ex port, and determine that the ARP data packet is an ARP response made by the floating IP gateway to the first ARP request packet, and then generate a first learning flow table and a second learning flow table in the external network output table;

[0119] The first learning flow table is used to match the second ARP request packet sent by the virtual machine bound to the floating IP address to the floating IP gateway, fill the floating IP address bound to the virtual machine into the source IP address of the second ARP request packet, and send the second ARP request packet from the ex port to complete the ARP request of the virtual machine bound to the floating IP address to the floating IP gateway;

[0120] The second learning flow table is used to match the target IP data packet sent by the virtual machine bound to the floating IP address to the public network, fill the MAC address of the floating IP gateway into the destination MAC address of the target IP data packet, and send the target IP data packet from the ex port, so as to realize that the next hop of the IP data packet of all virtual machines bound to the floating IP leaving the public network is pointed to the floating IP gateway.

[0121] In one embodiment of the present invention, the data packet is a communication between virtual machines across network segments;

[0122] The routing implementation unit is specifically used for: using the input matching table to match the destination network segment of the data packet, and submitting the data packet to the next hop processing table, using the next hop processing table to match the flow table item whose destination address is the IP address of the destination virtual machine, and using the processing means in the flow table item to modify the source MAC address of the data packet to the MAC address of the intranet gateway of the network segment where the destination virtual machine is located, modifying the destination MAC address of the data packet to the MAC address of the destination virtual machine, and submitting the modified data packet to the intranet output table, using the intranet output table to match the flow table item whose destination address is the IP address of the destination virtual machine, and using the processing means in the flow table item to output the data packet from the intp port of the intranet gateway corresponding to the destination network segment; the intp port is the patch port for the router bridge to communicate with the intranet.

[0123] In one embodiment of the present invention, the data packet is a data packet of a public network accessing an intranet virtual machine through a floating IP; the routing implementation unit is specifically used for:

[0124] Utilize the input matching table to match the flow table entry whose destination IP address is the floating IP address in the data packet, store the ex port ID in the first register, store the floating IP address in the second register, modify the destination IP address of the data packet to the IP address of the visited destination virtual machine in the intranet, and submit the modified data packet to the next hop processing table, and generate a third learning flow table in the external network output table at the same time; utilize the next hop processing table to match the flow table entry whose destination address is the IP address of the destination virtual machine, and utilize the processing means in the flow table entry to modify the source MAC address of the data packet to the MAC address of the intranet gateway of the network segment where the destination virtual machine is located, modify the destination MAC address of the data packet to the MAC address of the destination virtual machine, and submit the modified data packet to the intranet output table, utilize the intranet output table to match the flow table entry whose destination address is the IP address of the destination virtual machine, and utilize the processing means in the flow table entry to output the data packet from the intp port of the intranet gateway corresponding to the destination network segment; the intp port is the patch port for the router bridge to communicate with the intranet;

[0125] The third learning flow table is used to match the reverse message sent by the intranet virtual machine to the public network. When the destination IP address is matched to be the public network IP address and the source IP address is the floating IP address bound to the intranet virtual machine, the data packet is determined to be a reverse message sent by the intranet virtual machine to the public network, and the source MAC address of the reverse message is modified to be the MAC address of the intranet virtual machine, and the modified reverse message is sent to the ex port; the third learning flow table is set with an aging time, and if the third learning flow table is not hit within the aging time, it is automatically cleared;

[0126] or,

[0127] The data packet is a data packet of an intranet virtual machine accessing the public network through a floating IP; the routing implementation unit is specifically used to: use the input matching table to determine that the source IP address of the data packet is the intranet IP address of the virtual machine, and the priority of the matched target flow table item is lower than the priority of the flow table item corresponding to the intranet communication, then determine that the data packet is a data packet for communication between the virtual machine and the public network, then modify the source IP address of the data packet to the floating IP address bound to the intranet virtual machine, and submit the modified data packet to the external network output table, and use the external network output table to send the data packet to the public network through the ex port.

[0128] In one embodiment of the present invention, the routing implementation unit is also used to use the input matching table to match the IP data packet. If the flow table entry with the lowest priority is matched, the IP data packet is determined to be a data packet sent to the centralized router. When the destination MAC address is matched using the external network output table and is the MAC address of the intranet gateway where the intranet virtual machine is located, the IP data packet is sent to the address conversion output table, and the address conversion output table is used to modify the destination MAC address to the MAC address of the intranet gateway of the centralized router, and the source MAC address is modified to the MAC address of the intranet gateway where the intranet virtual machine is located, and sent through the corresponding intp port, thereby sending the IP data packet to the centralized router.

[0129] It should be noted that the device for implementing a virtual router using openvswitch in Openstack provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device for implementing a virtual router using openvswitch in Openstack provided in the above embodiment and the method embodiment for implementing a virtual router using openvswitch in Openstack belong to the same concept. The specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0130] The embodiment of the present application also provides a computer device, please refer to Figure 4 The computer device includes a processor and a memory, wherein at least one instruction, at least one program, a code set or an instruction set is stored in the memory, and the at least one instruction, at least one program, a code set or an instruction set is loaded and executed by the processor to implement the method for implementing a virtual router using openvswitch in Openstack provided by the above-mentioned method embodiments.

[0131] An embodiment of the present application also provides a computer-readable storage medium, on which is stored at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the method of implementing a virtual router using openvswitch in Openstack provided by the above-mentioned method embodiments.

[0132] An embodiment of the present application also provides a computer program product, which includes a computer program. A processor of a computer device reads the computer program from a computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the method of implementing a virtual router using openvswitch in Openstack as described in any of the above embodiments.

[0133] For the convenience of description, the above system or device is described by dividing it into various modules or units according to its functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0134] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.

[0135] Finally, it should be noted that, in this article, relational terms such as first, second, third and fourth are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0136] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for implementing a virtual router using openvswitch in Openstack, characterized in that: The method comprises: A router bridge is constructed in the host machine, wherein the router bridge is connected to the main switching bridge in the host machine through a patch port; Sending an openflow flow table to the router bridge; the openflow flow table includes multiple flow table items, and the flow table items include feature fields for matching and corresponding processing means; The data packet is received by the patch port of the router bridge, the characteristic fields of the data packet are matched in descending order according to the priorities of the flow items in the openflow flow table, and the data packet is processed by the processing means in the matched target flow item to realize east-west routing and north-south network address translation.

2. The method according to claim 1, characterized in that The openflow flow table includes the following six flow tables: input matching table, next hop processing table, intranet output table, MAC address learning table, extranet output table and address conversion output table; wherein, The input matching table is the openflow flow table that is first matched against the data packets entering the router bridge.

3. The method according to claim 2, characterized in that The data packet is an IP data packet or an ARP data packet used by the intranet virtual machine to access the intranet gateway; The matching of the characteristic fields of the data packet by using the flow table entry in the openflow flow table, and processing the data packet by using the processing means in the matched target flow table entry, includes: When the input matching table is used to determine that the data packet is an IP data packet, the IP data packet is sent to the next hop processing table, and the source IP address and source MAC address of the IP data packet are used as the destination IP address and destination MAC address of the IP response packet by using the next hop processing table, and the IP address and MAC address of the visited intranet gateway are used as the source IP address and source MAC address of the IP response packet, and the IP response packet is sent to the intranet output table, and the intranet output table is used to return the IP response packet to the intranet virtual machine that initiated the access, so as to realize the IP response of the intranet gateway to the intranet virtual machine; When the input matching table is used to determine that the data packet is an ARP data packet, and the destination IP address of the ARP data packet is the IP address of the intranet gateway, the ARP data packet is sent to the next hop processing table, and the ARP data packet is matched using the next hop processing table. When the entry of the ARP data packet is matched to the intp port corresponding to the intranet gateway, the source IP address and source MAC address of the ARP data packet are used as the destination IP address and destination MAC address of the ARP response packet, the IP address and MAC address of the visited intranet gateway are used as the source IP address and source MAC address of the ARP response packet, the ARP flag is modified to the reply packet flag, and the ARP response packet is sent to the intranet output table. The intranet output table is used to return the ARP response packet to the intranet virtual machine that initiated the access, thereby realizing the ARP response of the intranet gateway to the intranet virtual machine.

4. The method according to claim 3, characterized in that Also includes: If it is determined that the intranet virtual machine that initiated the ARP packet is bound to a floating IP address, an ARP request is made to the floating IP gateway while an ARP response is made to the intranet virtual machine. The ARP request to the floating IP gateway includes: copying a copy of the ARP response packet to the MAC address learning table, and after matching the ARP response packet in the MAC address learning table, using the MAC address of the ex port corresponding to the external network as the source MAC address of the first ARP request packet, using the broadcast MAC address as the destination MAC address of the first ARP request packet, using the source IP address of the ARP response packet as the source IP address of the first ARP request packet, using the IP address of the floating IP gateway as the destination IP address of the first ARP request packet, modifying the ARP flag bit to a request packet flag, and sending the first ARP request packet from the ex port, thereby realizing the ARP request of the virtual router to the floating IP gateway.

5. The method according to claim 4, characterized in that After making an ARP request to the floating IP gateway, the floating IP gateway will make an ARP response to the first ARP request packet. The virtual router receives and uses the input matching table to determine that the data packet is an ARP data packet entering from the ex port, and determines that the ARP data packet is an ARP response made by the floating IP gateway to the first ARP request packet. Then, the first learning flow table and the second learning flow table are generated in the external network output table. The first learning flow table is used to match the second ARP request packet sent by the virtual machine bound to the floating IP address to the floating IP gateway, fill the floating IP address bound to the virtual machine into the source IP address of the second ARP request packet, and send the second ARP request packet from the ex port to complete the ARP request of the virtual machine bound to the floating IP address to the floating IP gateway; The second learning flow table is used to match the target IP data packet sent by the virtual machine bound to the floating IP address to the public network, fill the MAC address of the floating IP gateway into the destination MAC address of the target IP data packet, and send the target IP data packet from the ex port, so as to realize that the next hop of the IP data packet of all virtual machines bound to the floating IP leaving the public network is pointed to the floating IP gateway.

6. The method according to claim 2, characterized in that The data packet is the communication between virtual machines across network segments; The matching of the characteristic fields of the data packet by using the flow table entry in the openflow flow table, and processing the data packet by using the processing means in the matched target flow table entry, includes: The input matching table is used to match the destination network segment of the data packet, and the data packet is submitted to the next hop processing table, the next hop processing table is used to match the flow table item whose destination address is the IP address of the destination virtual machine, and the processing means in the flow table item is used to modify the source MAC address of the data packet to the MAC address of the intranet gateway of the network segment where the destination virtual machine is located, the destination MAC address of the data packet is modified to the MAC address of the destination virtual machine, and the modified data packet is submitted to the intranet output table, the intranet output table is used to match the flow table item whose destination address is the IP address of the destination virtual machine, and the processing means in the flow table item is used to output the data packet from the intp port of the intranet gateway corresponding to the destination network segment; the intp port is the patch port for the router bridge to communicate with the intranet.

7. The method according to claim 2, characterized in that The data packet is a data packet for accessing an intranet virtual machine from a public network through a floating IP; matching the characteristic fields of the data packet using the flow table entry in the openflow flow table, and processing the data packet using the processing means in the matched target flow table entry, including: Utilize the input matching table to match the flow table entry whose destination IP address is the floating IP address in the data packet, store the ex port ID in the first register, store the floating IP address in the second register, modify the destination IP address of the data packet to the IP address of the visited destination virtual machine in the intranet, and submit the modified data packet to the next hop processing table, and generate a third learning flow table in the external network output table at the same time; utilize the next hop processing table to match the flow table entry whose destination address is the IP address of the destination virtual machine, and utilize the processing means in the flow table entry to modify the source MAC address of the data packet to the MAC address of the intranet gateway of the network segment where the destination virtual machine is located, modify the destination MAC address of the data packet to the MAC address of the destination virtual machine, and submit the modified data packet to the intranet output table, utilize the intranet output table to match the flow table entry whose destination address is the IP address of the destination virtual machine, and utilize the processing means in the flow table entry to output the data packet from the intp port of the intranet gateway corresponding to the destination network segment; the intp port is the patch port for the router bridge to communicate with the intranet; The third learning flow table is used to match the reverse message sent by the intranet virtual machine to the public network. When the destination IP address is matched to be the public network IP address and the source IP address is the floating IP address bound to the intranet virtual machine, the data packet is determined to be a reverse message sent by the intranet virtual machine to the public network, and the source MAC address of the reverse message is modified to be the MAC address of the intranet virtual machine, and the modified reverse message is sent to the ex port; the third learning flow table is set with an aging time, and if the third learning flow table is not hit within the aging time, it is automatically cleared; or, The data packet is a data packet of an intranet virtual machine accessing a public network through a floating IP; matching the characteristic fields of the data packet using the flow table entry in the openflow flow table, and processing the data packet using the processing means in the matched target flow table entry, including: The input matching table is used to determine that the source IP address of the data packet is the intranet IP address of the virtual machine, and the priority of the matched target flow table entry is lower than the priority of the flow table entry corresponding to the intranet communication, then the data packet is determined to be a data packet for communication between the virtual machine and the public network, and the source IP address of the data packet is modified to the floating IP address bound to the intranet virtual machine, and the modified data packet is submitted to the external network output table, and the data packet is sent to the public network through the ex port using the external network output table; or, The matching of the characteristic fields of the data packet by using the flow table entry in the openflow flow table, and processing the data packet by using the processing means in the matched target flow table entry, includes: When the input matching table is used to match the IP data packet, if the flow table entry with the lowest priority is matched, the IP data packet is determined to be a data packet sent to the centralized router. When the destination MAC address is matched by the external network output table and is the MAC address of the intranet gateway where the intranet virtual machine is located, the IP data packet is sent to the address translation output table. The address translation output table is used to modify the destination MAC address to the MAC address of the intranet gateway of the centralized router, and the source MAC address is modified to the MAC address of the intranet gateway where the intranet virtual machine is located, and sent out through the corresponding intp port, thereby sending the IP data packet to the centralized router.

8. A device for implementing a virtual router using openvswitch in Openstack, characterized in that: The device comprises: A construction unit, used for constructing a router bridge in the host machine, wherein the router bridge is connected to a main switching bridge in the host machine through a patch port; A storage unit, used to send an openflow flow table to the router bridge; the openflow flow table includes multiple flow table items, and the flow table items include feature fields for matching and corresponding processing means; The routing implementation unit is used to receive data packets using the patch port of the router bridge, match the characteristic fields of the data packets according to the priority order of the flow table items in the openflow flow table from high to low, and process the data packets using the processing means in the matched target flow table items to realize east-west routing and north-south network address translation.

9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to implement the steps of any one of the methods described in claims 1-7.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 7 are implemented.