Disclosure of Invention
In view of this, embodiments of the present application provide a method and an apparatus for creating a Virtual router interface, a storage medium, and a device, where a tenant network interface and a gateway interface are created through a Virtual Function (VF) in a network card of a physical network based on Single Root I/O Virtualization (SR-IOV), so that the tenant network interface and the gateway interface are both SR-IOV type interfaces, and thus, in a packet forwarding process, a Virtual network card device is not used as an east-west traffic forwarding interface and a south-north traffic forwarding interface, but a physical network card device is directly used as an east-west traffic forwarding interface and a south-north traffic forwarding interface, so that a packet forwarding path can be shortened, and L3 network forwarding performance can be improved.
The embodiment of the application mainly provides the following technical scheme:
in a first aspect, an embodiment of the present application provides a method for creating a virtual router interface, where the method includes: when a tenant network is added to a virtual router, a three-layer proxy L3agent selects an unused first Virtual Function (VF) from a plurality of Virtual Functions (VFs) virtualized by a network card of a physical network corresponding to the tenant network to establish a tenant network interface for the virtual router; setting a network attribute of the first VF based on a network attribute of the tenant network; when a gateway is set for a virtual router, an L3agent selects an unused second VF from a plurality of VFs virtualized by a network card of a physical network corresponding to the gateway network to establish a gateway interface for the virtual router; setting the network attributes of the second VF based on the network attributes of the gateway network.
In a second aspect, an embodiment of the present application provides an apparatus for creating a virtual router interface, where the apparatus includes: the first interface creating unit is used for selecting an unused first Virtual Function (VF) from a plurality of Virtual Functions (VFs) virtualized by a network card of a physical network corresponding to a tenant network by a three-layer proxy L3agent to create a tenant network interface for the virtual router when the tenant network is added to the virtual router; a first setting unit, configured to set a network attribute of the first VF based on a network attribute of the tenant network; the second interface creating unit is used for selecting an unused second VF from the VFs virtualized by the network card of the physical network corresponding to the gateway network from the L3agent when the gateway is set for the virtual router to create a gateway interface for the virtual router; and the second setting unit is used for setting the network attribute of the second VF based on the network attribute of the gateway network.
In a third aspect, an embodiment of the present application provides a computer-readable storage medium, where the storage medium includes a stored program, where the program, when running, controls a computer device in which the storage medium is located to perform the above-mentioned steps of the method for creating a virtual router interface.
In a fourth aspect, an embodiment of the present application provides a computer device, where the computer device includes: at least one processor; and at least one memory, bus connected with the processor; the processor and the memory complete mutual communication through the bus; the processor is configured to call program instructions in the memory to perform the steps of the above-described method of creating a virtual router interface.
First, when a tenant network is added to a virtual router, a third-layer proxy L3agent selects an unused first Virtual Function (VF) from a plurality of virtual VFs virtualized by a network card of a physical network corresponding to the tenant network to create a tenant network interface for the virtual router, and sets a network attribute of the first VF based on a network attribute of the tenant network; then, when a gateway is set for the virtual router, the L3agent selects an unused second VF from the VFs virtualized by the network card of the physical network corresponding to the gateway network to create a gateway interface for the virtual router, and sets the network attribute of the second VF based on the network attribute of the gateway network. Therefore, the created virtual router interface is realized, namely, the tenant network interface and the gateway interface are both SR-IOV type interfaces, and the virtual router can support the SR-IOV technology, so that in the message forwarding process, the virtual network card equipment is not used as an east-west flow forwarding interface and a south-north flow forwarding interface, but the physical network card equipment is directly used as the east-west flow forwarding interface and the south-north flow forwarding interface, so that the L3 network forwarding performance of the virtual router is accelerated to reach the network forwarding performance equivalent to that of a physical machine, the message forwarding path can be shortened, and the L3 network forwarding performance is improved.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the application. Other advantages of the application may be realized and attained by the instrumentalities and combinations particularly pointed out in the specification, claims, and drawings.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
The embodiment of the application provides a method for creating a virtual router interface. Be applied to Openstack cloud platform, Openstack cloud platform includes: neutron component, network card of physical network.
Wherein, Neutron subassembly includes: computing node, network node, control node, wherein, computing node includes: virtual machine, the network node includes: virtual router, L3 agent.
Here, the network card of the physical network is a network card supporting the SR-IOV function. The network card of the Physical network includes one or more PFs (Physical Functions), wherein each PF virtualizes one or more VFs.
Fig. 1 is a schematic flowchart of a method for creating a virtual router interface in this embodiment, and referring to fig. 1, the method for creating a virtual router interface may include:
s101: when a tenant network is added to a virtual router, an L3agent selects an unused first Virtual Function (VF) from a plurality of Virtual Functions (VFs) virtualized by a network card of a physical network corresponding to the tenant network to establish a tenant network interface for the virtual router;
in practical application, in order to enable the virtual router to support the SR-IOV technology, the VF needs to be added to the virtual router, and then, when a tenant network is added to the virtual router, the L3agent may select an unused first VF from the VFs virtualized by the network card of the physical network corresponding to the tenant network to create a tenant network interface for the virtual router, so that the created tenant network interface is an SR-IOV type interface.
In another embodiment of the present application, the S101 may include: when a tenant network is added to the virtual router, the L3agent obtains a field for indicating the type of the virtual network card bound by the tenant network interface; the L3agent determines whether a field for indicating the virtual network card type bound by the tenant network interface is a field for representing a single-root input/output virtualization (SR-IOV) type; if so, the L3agent selects an unused first Virtual Function (VF) from a plurality of Virtual Functions (VFs) virtualized by a network card of a physical network corresponding to the tenant network to establish a tenant network interface for the virtual router.
In practical application, a field for indicating the virtual network card type bound by the tenant network interface may be a vnic _ type field, where the vnic _ type field may support two types of fields, namely normal and direct, and if the direct field is introduced when the tenant network is added, it indicates that the virtual network card type bound by the tenant network interface is a field for representing an SR-IOV type.
As an example, after creating the virtual router, the tenant network may be added to the virtual router through an interface operation or through a command line or directly calling a neurtron API interface. In order to make the tenant network interface SR-IOV type, when adding the tenant network to the virtual router, the neurtron process in the Neutron component can pass the vnic _ type field to the L3agent through the neuron _ server process deployed in the control node. Next, the L3-agent triggers the router _ interface _ add module, and then the router _ interface _ add module can determine whether the vnic _ type field is a direct field, and if so, obtains the network card of the physical network of the tenant network pair, and selects an unused first VF to create a router interface, i.e., a tenant network interface.
S102: setting the network attribute of the first VF based on the network attribute of the tenant network;
specifically, after the tenant network interface is created according to the first VF, in order to enable the tenant network interface to normally receive and send the packet, the first VF needs to set a corresponding network attribute according to the network attribute of the tenant network.
Here, the network attribute may refer to a network type and a network ID.
In a specific implementation process, if the Network type of the tenant Network is a Virtual Local Area Network (VLAN), the step S102 may include: the VLAN attribute of the first VF is set to the VLAN attribute of the tenant network.
Specifically, the network type of the first VF may be set to the VLAN type and the network ID of the first VF may be set to the VLAN ID of the tenant network.
S103: when a gateway is set for a virtual router, the L3agent selects an unused second VF from the VFs virtualized by the network card of the physical network corresponding to the gateway network to establish a gateway interface for the virtual router;
in practical application, in order to enable the virtual router to support the SR-IOV technology, the VF needs to be added to the virtual router, and in order that the virtual machine can be connected to the gateway network and further connected to an external network, when the virtual router sets the gateway, the L3agent can select an unused second VF from the VFs virtualized by the network card of the physical network corresponding to the gateway network to create a gateway interface for the virtual router, so that the created gateway interface is an SR-IOV type interface.
In another embodiment of the present application, the S103 may include: when a gateway is set for a virtual router, the L3agent obtains a field for indicating the type of a virtual network card bound by a gateway interface; the L3agent determines whether a field for indicating the type of the virtual network card bound by the gateway interface is a field for representing the SR-IOV type; if so, the L3agent selects an unused second VF from the VFs virtualized by the network card of the physical network corresponding to the gateway network to create a gateway interface for the virtual router.
In practical application, a field for indicating the type of the virtual network card bound by the gateway network interface may be a vnic _ type field, where the vnic _ type field may support two types of fields, namely normal and direct, and if the direct field is introduced when the gateway is set, a field for indicating that the type of the virtual network card bound by the gateway interface is a type for representing an SR-IOV is introduced.
As an example, after the virtual router is created, the gateway can be set up for the virtual router through interface operation, or through a command line or directly calling a neurtron API interface. In order to extend the gateway interface to be SR-IOV type, when setting the gateway for the virtual router, the Neutron component may transfer the vnic _ type field to the L3agent through the neuron _ server deployed in the control node. Next, the L3-agent triggers the router-update module, and the router-update module may determine whether the vnic _ type field is a direct field, and if so, obtain a network card of the physical network of the gateway network pair, and select an unused second VF to create a router interface, i.e., a gateway interface.
S104: the network attributes of the second VF are set based on the network attributes of the gateway network.
Specifically, after the gateway interface is created according to the second VF, in order to enable the gateway interface to normally receive and send the packet, the second VF needs to set a corresponding network attribute according to the network attribute of the gateway network.
In a specific implementation process, if the network type of the gateway network is a VLAN, the step S104 may include: the VLAN attribute of the second VF is set to the VLAN attribute of the gateway network.
Specifically, the network type of the second VF may be set to the VLAN type and the network ID of the second VF may be set to the VLAN ID of the gateway network.
At this point, the process of creating a virtual router interface based on SR-IOV is completed.
As can be seen from the above, in the method for creating a virtual router interface provided in the embodiment of the present application, first, when a tenant network is added to a virtual router, a third-layer proxy L3agent selects an unused first VF from a plurality of virtual functions VFs virtualized by a network card of a physical network corresponding to the tenant network to create the tenant network interface for the virtual router, and sets a network attribute of the first VF based on a network attribute of the tenant network; then, when a gateway is set for the virtual router, the L3agent selects an unused second VF from the VFs virtualized by the network card of the physical network corresponding to the gateway network to create a gateway interface for the virtual router, and sets the network attribute of the second VF based on the network attribute of the gateway network. Therefore, the created virtual router interface is realized, namely, the tenant network interface and the gateway interface are both SR-IOV type interfaces, the virtual router can support SR-IOV technology, the virtual router can be directly connected with the physical network card, and the L3 network forwarding performance of the virtual router can be accelerated to reach the network forwarding performance equivalent to that of a physical machine, so that when the tenant network interface and the gateway interface are used for forwarding messages, the message forwarding path can be shortened, and the L3 network forwarding performance can be improved.
Based on the same inventive concept, as an implementation of the method, the embodiment of the present application provides a device for creating a virtual router interface. Fig. 2 is a schematic structural diagram of an apparatus for creating a virtual router interface in an embodiment of the present application, and referring to fig. 2, the apparatus 20 for creating a virtual router interface may include: a first interface creating unit 201, configured to select, when a tenant network is added to a virtual router, an unused first VF from multiple virtual functions VF virtualized by a network card of a physical network corresponding to the tenant network by a three-layer proxy L3agent to create a tenant network interface for the virtual router; a first setting unit 202, configured to set a network attribute of the first VF based on a network attribute of the tenant network; a second interface creating unit 203, configured to select, when a gateway is set for the virtual router, an unused second VF from the multiple VFs virtualized by the network card of the physical network corresponding to the gateway network by the L3agent, to create a gateway interface for the virtual router; a second setting unit 204, configured to set a network attribute of the second VF based on the network attribute of the gateway network.
In the embodiment of the application, the first interface creating unit is configured to, when a tenant network is added to the virtual router, obtain, by the L3agent, a field for indicating a virtual network card type to which a tenant network interface is bound; the L3agent determines whether a field for indicating the virtual network card type bound by the tenant network interface is a field for representing a single-root input/output virtualization (SR-IOV) type; if so, the L3agent selects an unused first Virtual Function (VF) from a plurality of Virtual Functions (VFs) virtualized by a network card of a physical network corresponding to the tenant network to establish a tenant network interface for the virtual router.
In the embodiment of the present application, the second interface creating unit is configured to, when a gateway is set for a virtual router, obtain, by an L3agent, a field for indicating a type of a virtual network card bound to an interface of the gateway; the L3agent determines whether a field for indicating the type of the virtual network card bound by the gateway interface is a field for representing the SR-IOV type; if yes, the L3agent selects an unused second VF from the VFs virtualized by the network card of the physical network corresponding to the gateway network to establish a gateway interface for the virtual router
In this embodiment of the application, the first setting unit is configured to set the VLAN attribute of the first VF to the VLAN attribute of the tenant network if the network type of the tenant network is a VLAN.
In this embodiment of the present application, the first setting unit is configured to set the VLAN attribute of the second VF to the VLAN attribute of the gateway network if the network type of the gateway network is a virtual local area network VLAN.
Based on the same inventive concept, the embodiment of the application provides computer equipment. Fig. 3 is a schematic structural diagram of a computer device in an embodiment of the present application, and referring to fig. 3, the computer device 30 includes: at least one processor 31; and at least one memory 32, a bus 33, connected to the processor 31; the processor 31 and the memory 32 complete communication with each other through the bus 33; the processor 31 is configured to call program instructions in the memory 32 to perform the steps of the method of creating a virtual router interface in one or more of the embodiments described above.
Accordingly, based on the same inventive concept, embodiments of the present application further provide a processor, where the processor is configured to execute a program, where the program executes the steps of the method for creating a virtual router interface in one or more embodiments described above.
The Processor may be implemented by a Central Processing Unit (CPU), a microprocessor Unit (MPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), or the like. The Memory may include volatile Memory in a computer readable medium, Random Access Memory (RAM), and/or nonvolatile Memory such as Read Only Memory (ROM) or Flash Memory (Flash RAM), and the Memory includes at least one Memory chip.
It should be noted that, in the embodiment of the present application, if the method for creating a virtual router interface in one or more embodiments described above is implemented in the form of a software functional module, and is sold or used as a stand-alone product, it may also be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially implemented or portions thereof that contribute to the prior art may be embodied in the form of a software product stored in a storage medium, and including several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the methods of the embodiments of the present application.
Accordingly, based on the same inventive concept, an embodiment of the present application further provides a computer-readable storage medium, where the computer-readable storage medium includes a stored program, and when the program runs, the computer device in which the storage medium is controlled to execute the steps of the method for creating a virtual router interface in one or more embodiments described above.
Here, it should be noted that: the above description of the apparatus, computer device or computer-readable storage medium embodiments is similar to the description of the method embodiments above, with similar beneficial effects as the method embodiments. For technical details not disclosed in the embodiments of the apparatus, the computer device or the computer-readable storage medium of the present application, reference is made to the description of the embodiments of the method of the present application for understanding.
The present application describes embodiments, but the description is illustrative rather than limiting and it will be apparent to those of ordinary skill in the art that many more embodiments and implementations are possible within the scope of the embodiments described herein. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are possible. Any feature or element of any embodiment may be used in combination with or instead of any other feature or element in any other embodiment, unless expressly limited otherwise.
The present application includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The embodiments, features and elements disclosed in this application may also be combined with any conventional features or elements to form a unique inventive concept as defined by the claims. Any feature or element of any embodiment may also be combined with features or elements from other inventive aspects to form yet another unique inventive aspect, as defined by the claims. Thus, it should be understood that any of the features shown and/or discussed in this application may be implemented alone or in any suitable combination. Accordingly, the embodiments are not limited except as by the appended claims and their equivalents. Furthermore, various modifications and changes may be made within the scope of the appended claims.
Further, in describing representative embodiments, the specification may have presented the method and/or process as a particular sequence of steps. However, to the extent that the method or process does not rely on the particular order of steps set forth herein, the method or process should not be limited to the particular sequence of steps described. Other orders of steps are possible as will be understood by those of ordinary skill in the art. Therefore, the particular order of the steps set forth in the specification should not be construed as limitations on the claims. Further, the claims directed to the method and/or process should not be limited to the performance of their steps in the order written, and one skilled in the art can readily appreciate that the sequences may be varied and still remain within the spirit and scope of the embodiments of the present application.
It will be understood by those of ordinary skill in the art that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed by several physical components in cooperation. Some or all of the components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as is well known to those of ordinary skill in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, Digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by a computer. In addition, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as known to those skilled in the art.