Virtual local area network equipment registration method and device, computer equipment and storage medium
By sending test messages during the registration process of virtual LAN equipment and judging their identification consistency, the problems of normal use of virtual LAN equipment and resource release are solved, and the normal use of equipment and timely release of resources are achieved.
Patent Information
- Application Number
- CN202510120678.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2045-01-24
AI Technical Summary
The prior art cannot determine whether the virtual LAN device can be used normally, and cannot timely release the resources occupied by the virtual LAN device that cannot be used normally, resulting in unusable equipment in the kernel, increasing the debugging cost.
During the virtual LAN device registration process, a test message containing the device identification is generated and sent to the target device, and it is determined whether the identification in the intermediate message is consistent with the device identification. If inconsistent, release resources occupied by virtual LAN devices to avoid unusable devices left in the kernel.
Ensure that the registered virtual LAN equipment can be used normally in the future, and timely release the resources occupied by the equipment that cannot be used normally, solving the problems of equipment usability and resource release and reducing debugging costs.
Smart Images

Figure CN119945835A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a virtual local area network device registration method, device, computer device and storage medium. Background Art
[0002] The current VLAN (Virtual Local Area Network) device registration method can only ensure that the Linux kernel applies for the memory and other resources required by the virtual local area network device and registers it as a network device. However, after the virtual local area network device is successfully registered, it cannot guarantee that the virtual local area network device can be used normally in the future. The virtual local area network device may have errors when sending data packets through the physical transmission port. Because it is uncertain whether the registered virtual local area network device can be used normally, additional debugging costs will be added in the subsequent testing and debugging of the virtual local area network device.
[0003] In addition, if the registered virtual LAN device cannot be used, an unusable virtual LAN device will exist in the Linux kernel, and the resources occupied by the virtual LAN device cannot be released in time, and the virtual LAN device may cause errors in the Linux kernel.
[0004] Therefore, the related art has the problem that it is not possible to determine whether the virtual LAN device can be used normally, and it is not possible to release the resources occupied by the virtual LAN device that cannot be used normally in a timely manner. Summary of the invention
[0005] In view of this, the present invention provides a virtual LAN device registration method, apparatus, computer equipment and storage medium to solve the problem of not being able to determine whether the virtual LAN device can be used normally and not being able to release the resources occupied by the virtual LAN device that cannot be used normally in time.
[0006] In a first aspect, the present invention provides a method for registering a virtual local area network device, the method comprising:
[0007] Registering an initial virtual local area network device and determining a device identifier of the initial virtual local area network device;
[0008] Generate a test message containing a device identifier;
[0009] Sending a test message to a target device so that the target device determines whether the identifier contained in the intermediate message is consistent with the device identifier, wherein the intermediate message is the test message received by the target device;
[0010] When the target device does not receive the test message, or the identifier contained in the intermediate message is inconsistent with the device identifier, releasing the resources occupied by the initial virtual local area network device;
[0011] When the identifier included in the intermediate message is consistent with the device identifier, the initial virtual local area network device is set as the target virtual local area network device.
[0012] The virtual LAN device registration method provided in this embodiment adds a test of whether the initial virtual LAN device can normally send and receive data messages. Write a device tag in the test message, send the test message to the target device, and use the target device to determine whether the identifier in the received test message is consistent with the device identifier. Only when the two are consistent, it is determined that the virtual LAN device is successfully registered. Otherwise, the memory and other resources applied for by the virtual LAN device will be released, and no unusable virtual LAN device will be left in the kernel. Ensure that the registered virtual LAN device can be used normally later, and release the resources occupied by the virtual LAN device that cannot be used normally in time. Solve the problem that it is not possible to determine whether the virtual LAN device can be used normally, and it is not possible to release the resources occupied by the virtual LAN device that cannot be used normally in time.
[0013] In a second aspect, the present invention provides a virtual local area network device registration device, the device comprising:
[0014] A registration module, used to register an initial virtual local area network device and determine a device identifier of the initial virtual local area network device;
[0015] A generating module, used for generating a test message including a device identification;
[0016] A sending module, used for sending a test message to a target device, so that the target device determines whether the identifier included in the intermediate message is consistent with the device identifier, wherein the intermediate message is a test message received by the target device;
[0017] A release module, used to release the resources occupied by the initial virtual local area network device when the target device does not receive the test message or the identifier contained in the intermediate message is inconsistent with the device identifier;
[0018] The setting module is used to set the initial virtual local area network device as the target virtual local area network device when the identifier included in the intermediate message is consistent with the device identifier.
[0019] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the virtual local area network device registration method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0020] In a fourth aspect, the present invention provides a computer non-volatile readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the virtual local area network device registration method of the first aspect or any corresponding embodiment thereof.
[0021] In a fifth aspect, the present invention provides a computer program product, including computer instructions, and the computer instructions are used to enable a computer to execute the virtual local area network device registration method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions 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.
[0023] Figure 1 is a flow chart of a method for registering a virtual local area network device according to an embodiment of the present invention;
[0024] Figure 2 is a schematic diagram of a data frame according to an embodiment of the present invention;
[0025] Figure 3 is a flow chart of another virtual local area network device registration method according to an embodiment of the present invention;
[0026] Figure 4 is a structural block diagram of a virtual local area network device registration apparatus according to an embodiment of the present invention;
[0027] Figure 5 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution 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, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0029] The development of Local Area Network (LAN) is the basis for the emergence of VLAN. Network devices such as hubs, bridges, and switches connect all nodes in the same network segment to form a LAN, which is usually a separate broadcast domain. Network nodes in the same LAN can communicate directly. A virtual LAN is a group of logical devices and users. These devices and users are not restricted by physical network segments. They can be organized according to functions, departments, and applications, and the communication between them is just like being in the same network segment. In the Linux kernel, a virtual LAN is a special network device. Before using the virtual LAN function, you need to create a virtual LAN device through the ioctl (Input / Output Control) interface before operating.
[0030] The current virtual LAN usage process is to first register the virtual LAN device, then activate the interface corresponding to the virtual LAN device, and then send data packets through the host device of the virtual LAN device when waiting for use. Among them, the process of registering the virtual LAN device is simply to apply for some data structures. As long as the corresponding resources and memory are applied for in the kernel, a signal of successful registration of the virtual LAN device will be returned after registration as a network device; only when the registration as a network device fails, the memory and other resources applied for the virtual LAN device will be released. At present, it can only be guaranteed that the Linux kernel applies for the memory and other resources required by the virtual LAN device and registers it as a network device. Even if the virtual LAN device is successfully registered, it cannot be guaranteed that the virtual LAN device can be truly used in the future. Errors may occur when the virtual LAN device sends data packets through the physical transmission port.
[0031] The current virtual LAN device registration method has some problems: although it can create the data structure required by the virtual LAN device, it is impossible to determine whether the registered virtual LAN device has been successfully integrated into the entire network transmission system, and it cannot guarantee that data packets containing virtual LAN tags can be sent through the physical transmission port. There is a situation where the virtual LAN device is successfully registered but the VLAN function cannot be used normally, which will increase additional debugging costs in the subsequent testing and debugging process. The current virtual LAN device registration method will not detect errors in the physical transmission port. After the virtual LAN device is successfully registered as a network device, but the physical transmission port does not provide correct support, the memory and other resources occupied by the virtual LAN device cannot be released in time, and there is an unusable virtual LAN device in the kernel.
[0032] Based on the above content, an embodiment of the present invention provides a method for registering a virtual LAN device. In the registration process of the virtual LAN device, a test is added to determine whether the physical transmission port can normally send and receive virtual LAN data packets. Only when the virtual LAN device is successfully registered as a network device and the physical transmission port can normally send and receive data packets, a signal indicating that the virtual LAN device has been successfully registered will be returned. After the virtual LAN device is successfully registered as a network device, if the sending and receiving test of the physical transmission port fails, the memory and other resources applied for by the virtual LAN device will be released, and no unusable virtual LAN device will be left in the kernel. In addition, the test can test whether the current physical transmission port can normally send and receive data packets in an offline state, and delete the data of the test process after the test is completed. After the test is completed, it will not affect the subsequent normal use of the network device. This ensures that the registered virtual LAN device can be used normally in the future, and timely releases the resources occupied by the virtual LAN device that cannot be used normally.
[0033] According to an embodiment of the present invention, a virtual local area network device registration embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer device with data processing capabilities, such as a computer, a server, etc., and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0034] In this embodiment, a virtual local area network device registration method is provided. Figure 1 is a flow chart of a method for registering a virtual local area network device according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0035] Step S101, registering an initial virtual local area network device and determining a device identifier of the initial virtual local area network device.
[0036] Specifically, registering a new virtual LAN device as an initial virtual LAN device, the registration process may include: using the vconfig add command to register a new virtual LAN device, calling the vlan_ioctl_handler function in the Linux kernel, vconfig add is a command for adding a virtual LAN sub-interface in the Linux system, the vlan_ioctl_handler function is a processor for processing the input and output control interface calls of virtual LAN related operations, responsible for parsing the input and output control commands from the user space, and performing corresponding operations according to these commands. The function calls the virtual LAN registration device (register_vlan_device) to register a new virtual LAN device. First, apply for the memory resources of the virtual LAN device, configure the various attributes of the virtual LAN device in the network device structure, and bind the virtual LAN device to the real network device, that is, the host device of the virtual LAN device.
[0037] Determine the device identification of the initial virtual local area network device, such as a virtual local area network ID (Identity document), and write the device identification into the real network device bound to the initial virtual local area network device.
[0038] Step S102: Generate a test message including a device identification.
[0039] Specifically, when sending a test message through a network device under the Linux kernel, the vlan_dev_hard_start_xmit function of the network device will be called. This function passes the test message to the network device registered in the kernel through vlan_netdev_ops. vlan_netdev_ops is a structure instance. This structure contains pointers to various network device operation functions, such as sending data packets, opening or closing devices, etc. The vlan_dev_hard_start_xmit function is mainly used to transmit network data messages to the hardware of the network device so that these messages can be transmitted through the network. The specific implementation process is: use the device identifier as a virtual LAN tag (VLAN tag) and add a virtual LAN tag to the test message. Configure the physical transmission port of the data message under the virtual LAN; put the data message into the network device queue and send it out through the physical transmission port.
[0040] Step S103: Send the test message to the target device, so that the target device determines whether the identifier included in the intermediate message is consistent with the device identifier, wherein the intermediate message is the test message received by the target device.
[0041] Specifically, the target device is, for example, a host device of the initial virtual LAN device or other network device containing the device identification of the initial virtual LAN device, and the device identification of the initial virtual LAN device is recorded in the host device.
[0042] When sending a test message, the address of the target device is set as the target address for sending. After the target device receives the test message, the test message received by the target device is used as an intermediate message. The identifier contained in the intermediate message is extracted from the intermediate message and compared with the device identifier of the initial virtual local area network device stored therein.
[0043] Step S104: when the target device does not receive the test message, or the identifier included in the intermediate message is inconsistent with the device identifier, the resources occupied by the initial virtual local area network device are released.
[0044] Specifically, if the test message is not transmitted successfully within the specified time, the unregister function of the network device in the kernel is called to release the resources and memory applied for by the initial virtual LAN device, and delete the device identifier in the real network device bound to the initial virtual LAN device. The unregister function is used to deregister or remove a certain resource or device from the system.
[0045] Step S105: When the identifier included in the intermediate message is consistent with the device identifier, the initial virtual local area network device is set as the target virtual local area network device.
[0046] Specifically, if the test message is successfully sent within the specified time and the device identification is matched successfully, the identification contained in the intermediate message is consistent with the device identification, indicating that the virtual LAN device is registered successfully, and a signal of successful registration of the virtual LAN device is returned, and the initial virtual LAN device is set as the target virtual LAN device.
[0047] It should be noted that this technical solution can be used to add virtual LAN devices in different protocols. It only needs to modify the corresponding detection process to test whether the physical transmission port can normally send and receive test messages of multiple protocols. In addition, when creating other devices, you can add test functions for the basic functions of the device to ensure that the added device can complete basic use.
[0048] The virtual LAN device registration method provided in this embodiment adds a test of whether the initial virtual LAN device can normally send and receive data messages. Write a device tag in the test message, send the test message to the target device, and use the target device to determine whether the identifier in the received test message is consistent with the device identifier. Only when the two are consistent, it is determined that the virtual LAN device is successfully registered. Otherwise, the memory and other resources applied for by the virtual LAN device will be released, and no unusable virtual LAN device will be left in the kernel. Ensure that the registered virtual LAN device can be used normally later, and release the resources occupied by the virtual LAN device that cannot be used normally in time. Solve the problem that it is not possible to determine whether the virtual LAN device can be used normally, and it is not possible to release the resources occupied by the virtual LAN device that cannot be used normally in time.
[0049] In some optional implementations, sending the test message to the target device includes:
[0050] Determine the host device to which the initial virtual LAN device is bound;
[0051] Setting the address of the host device to a target address, wherein the target device includes the host device;
[0052] The physical transmission port is determined by using a preset message sending function, and the test message is put into a network device queue, wherein the physical transmission port is used to send the test message in the network device queue to a target address.
[0053] Specifically, the real physical device bound to the initial virtual LAN device, ie, the host device, is determined. The target device includes the host device, that is, the target device may be the host device of the initial virtual LAN device, or other network devices containing the device identifier of the initial virtual LAN device.
[0054] The preset message sending function is for example: the dev_direct_xmit function in the kernel. The dev_direct_xmit function is used to directly send the message to the specified network device queue. This function usually directly submits the message to the underlying hardware for transmission without complex scheduling and queuing. Call the preset message sending function to send the configured test message. The destination address of the test message is the real network device bound to the virtual LAN device to be registered, that is, the address of the host device is set as the target address. It can be understood that the host device sends the test message to itself.
[0055] The physical transmission port is determined by using a preset message sending function, and the test message is put into a network device queue, and the test message in the network device queue is sent to a target address through the physical transmission port.
[0056] In this embodiment, a test message is placed into a network device queue using a preset message sending function, and the test message is sent to a target device through a physical transmission port. The target device determines whether the identifier contained in the intermediate message is consistent with the device identifier, and then determines whether the initial virtual LAN device is available, thereby avoiding the situation where the initial virtual LAN device that has been registered as a network device cannot be used but the occupied memory and other resources cannot be released in time.
[0057] In some optional implementations, after sending the test message to the target device, the method further includes:
[0058] Monitor the sending process of the test message by the physical transmission port within a preset time, and determine whether the target device receives the test message within the preset time;
[0059] If the target device does not receive the test message within a preset time, generate a first signal, wherein the first signal is used to indicate that the target device has not received the test message;
[0060] When the target device receives the test message within a preset time, the identifier contained in the intermediate message is compared with the device identifier, and a second signal or a third signal is generated based on the comparison result, wherein the second signal is used to characterize that the identifier contained in the intermediate message is inconsistent with the device identifier, and the third signal is used to characterize that the identifier contained in the intermediate message is consistent with the device identifier.
[0061] Specifically, in the improved virtual LAN device registration method, it is judged whether the physical transmission port has successfully sent the virtual LAN test data message. After the virtual LAN test data message is configured, the physical transmission port is used to directly transmit the test message, and the transmission process is monitored within a specified time. The preset time is, for example, 5 minutes, 10 minutes or other time that meets actual needs. The physical transmission port is monitored within the preset time to send the test message, and it is judged whether the target device receives the test message within the preset time.
[0062] If the test message is not sent to the target device within the preset time, it means that the initial virtual LAN device is unavailable, and a first signal is generated, for example, a signal indicating that the registration of the virtual LAN device has failed.
[0063] If the test message is successfully sent to the target device within the preset time, the identifier contained in the intermediate message is compared with the device identifier. If the identifier contained in the intermediate message is inconsistent with the device identifier, it means that the initial virtual LAN device is unavailable, and a second signal is generated, for example: a signal that the virtual LAN device registration failed. If the identifier contained in the intermediate message is consistent with the device identifier, a third signal is generated, for example: a signal that the virtual LAN device registration is successful.
[0064] If the first signal or the second signal is generated, the unregister function of the network device in the kernel is called to release the resources and memory applied for the virtual LAN device, and delete the device identifier of the real network device. The kernel's dev_remove_pack interface is called to delete the message type (text_pack_type) related to the virtual LAN test message in the protocol stack. The dev_remove_pack interface is used to remove text_pack_type from the packet processing linked list of the network protocol.
[0065] In this embodiment, the target device determines whether the identifier contained in the intermediate message is consistent with the device identifier, and then determines whether the initial virtual LAN device is available, and generates a second signal or a third signal to avoid the situation where the initial virtual LAN device that has been registered as a network device cannot be used but the occupied memory and other resources cannot be released in time.
[0066] In some optional implementations, comparing the identifier included in the intermediate message with the device identifier includes:
[0067] Using the host device to determine the message type corresponding to the intermediate message, and determining the message processing function according to the message type;
[0068] Extracting an identifier contained in the intermediate message from the intermediate message according to the message processing function;
[0069] Obtain the device ID from the host device and compare the ID contained in the intermediate message with the device ID.
[0070] Specifically, after completing the memory resource application for the initial virtual LAN device, the initial virtual LAN device structure attribute configuration, and the real network device binding process with the initial virtual LAN device, you first need to configure the message type related to the test message and define the message processing function (test_func) in the message type.
[0071] For example, the intermediate message is the sk_buff (socket buffer) data received by the target device. sk_buff is a key data structure in the Linux kernel for managing and controlling network data packets. The identifier contained in the intermediate message is extracted from the intermediate message according to the message processing function. The device identifier is obtained from the host device, and the identifier contained in the intermediate message is compared with the device identifier to determine whether the identifier in the received test message is consistent with the device identifier added when the message is sent.
[0072] In some optional implementations, registering an initial virtual local area network device includes:
[0073] Create an initial network device based on a preset structure and allocate corresponding storage space for the initial network device;
[0074] Determine an initialization function corresponding to the initial network device, and use the initialization function to determine the device type of the initial network device;
[0075] Determine the operation logic of the initial network equipment;
[0076] Determine the device identification of the initial network device and the bound host device, record the device identification to the host device, and record the device identification and information of the host device to the storage space;
[0077] The initial network device is registered into the kernel's network device list, and the initial virtual LAN device is obtained according to the initial network device, storage space, device type and operation logic.
[0078] Specifically, in the Linux kernel, a virtual LAN device is a special network device. Before using the virtual LAN device function, it is necessary to create the virtual LAN device through ioctl and then operate it. Create a virtual LAN device through ioctl operation.
[0079] First, apply for a new network device structure as the preset structure. Create the initial network device based on the preset structure, and allocate a private space of type vlan_dev_priv as storage space for the initial network device. Specify the initialization function of the initial network device, for example: virtual LAN setting function. vlan_dev_priv is a private data structure used in the Linux kernel to manage virtual network devices, which contains various status and configuration information related to virtual network devices.
[0080] Use the initialization function to determine the device type of the initial network device. For example, the initialization function sets the function flag of the initial network device to a certain value. In this way, the device type is determined and how the virtual local area network corresponding to the initial network device works based on the port is defined. Determine the operation logic of the initial network device. For example, setting the initial network device includes some operation functions. Through these operation functions, the operation logic of various operations of the initial network device is realized, such as turning on and off the device, sending data packets, etc.
[0081] Determine the device identification of the initial network device and the bound host device, modify the storage space of the initial network device, record the host device information and device identification of the initial network device in the storage space, and modify the virtual local area network information in the host device accordingly, and record the device identification in the host device.
[0082] Register the initial network device into the network device list in the kernel, and get the initial virtual LAN device based on the initial network device, storage space, device type, and operation logic. At this time, for the upper layer protocol stack, the initial virtual LAN device is an actual device with equal status to all other devices. It can be configured with command line tools or added to a bridge.
[0083] In addition, to successfully use the virtual LAN function in the Linux kernel, in addition to registering the virtual LAN device, EMAC (Ethernet Media Access Controller) is also required to support the virtual LAN function. EMAC needs to edit the data message and correctly add the device identifier at the corresponding position of the Ethernet frame according to the information in the private space of the virtual LAN device. The correctness of adding the virtual LAN device and EMAC is a necessary condition for the normal use of the virtual LAN function.
[0084] In some optional implementations, releasing resources occupied by the initial virtual local area network device includes:
[0085] Use the resource release function in the kernel to remove the initial network device from the network device list;
[0086] Release the resources corresponding to the preset structure, device type, operation logic, and device identification, and release the storage space;
[0087] Unbind the initial virtual LAN device and the host device, and call the kernel's preset interface to delete the message type corresponding to the test message in the protocol stack.
[0088] Specifically, the resource release function is, for example, the unregister function of the network device in the kernel. If the test message is not transmitted successfully within the specified time, or the identifier contained in the intermediate message is inconsistent with the device identifier, it is determined that the initial virtual LAN device registration has failed, then the resource release function in the kernel is called to release the resources and memory requested by the virtual LAN device, and delete the device identifier of the real network device, and call the kernel's dev_remove_pack interface to delete the VLAN test data message type in the protocol stack. Specifically, it includes: removing the initial network device from the network device list; releasing the resources corresponding to the preset structure, device type, operating logic, and device identifier, and releasing storage space; unbinding the initial virtual LAN device and the host device, and calling the kernel's preset interface to delete the message type corresponding to the test message in the protocol stack.
[0089] In this implementation, after determining that the initial virtual LAN device is unavailable, the resources occupied by it are released in time, and no unusable virtual LAN device is left in the kernel.
[0090] In some optional implementations, generating a test message including a device identifier includes:
[0091] Get the structure corresponding to the test message;
[0092] Obtaining a device identifier from a storage space of an initial virtual local area network device;
[0093] Generate tag information of the initial virtual local area network device according to the device identifier;
[0094] Add the marking information to the preset position of the structure and generate a test message.
[0095] Specifically, a test message structure is generated, for example, the sk_buff structure, which is the basic unit of data packet management in the Linux kernel. The structure defines the marked data frame, such as Figure 2 As shown, an untagged frame is a common data frame without a virtual LAN tag, and a tagged frame is a data frame with a virtual LAN tag sent by a virtual LAN device. Compared with an untagged data frame, a tagged data frame adds a virtual LAN tag between the source media access control address and the type, and records the device identification in the virtual LAN tag. Both tagged data frames and untagged data frames include: a destination media access control address, a source media access control address, a type, a data payload, and a frame check code (FCS).
[0096] The device identification is obtained from the storage space of the initial virtual local area network device. According to the device identification, the tag information of the initial virtual local area network device is generated, for example, the device identification is used as the tag information.
[0097] The preset position is, for example, a virtual local area network tag in a marked data frame. The tag information is added to the preset position of the structure to generate a test message, for example, adding a virtual local area network tag to the sk_buff structure, that is, adding the device identifier of the virtual local area network device being registered to the corresponding position of the test message.
[0098] In addition, when sending messages through network devices under the kernel, the device's vlan_dev_hard_start_xmit function is usually called. This function is registered or specified during the device initialization phase. The ndo_start_xmit function is passed to the registered network device in the kernel through vlan_netdev_ops. The specific implementation process is: first add a virtual LAN tag to the data message; configure the physical transmission port of the data message under the virtual LAN; put the data message into the network device queue and send it out through the physical transmission port.
[0099] In this embodiment, the tag information of the initial virtual local area network device is generated according to the device identification, and the tag information is added to the preset position of the structure to generate a test message. The device identification of the initial virtual local area network device is added to the test message, so that the subsequent target device can judge whether the identification in the received test message is consistent with the test identification, and determine whether the function of the initial virtual local area network device is normal.
[0100] In some optional implementations, after the virtual LAN device is successfully registered, the virtual LAN device may be actively revoked or deleted, and the specific process may include steps A1 to A3.
[0101] Step A1: The access switch receives a offline notification sent by the virtual server.
[0102] In step A2, the access switch cancels the virtual LAN attribute of the virtual LAN device of the network side interface of the access switch according to the offline notification.
[0103] Step A3: The access switch sends a GVRP Leave Control Packet (GVRPLeave message) to the aggregation switch through the network side interface.
[0104] Specifically, the access switch cancels the virtual LAN attributes of the network side interface of the access switch according to the offline notification, including: the access switch cancels the virtual LAN attributes that are identical to the virtual LAN attributes of the virtual server in the user side interface that receives the offline notification; traverses all user side interfaces of the access switch to determine whether there is a user side interface that activates the virtual LAN attributes of the virtual server; if no user side interface activates the virtual LAN attributes of the virtual server, canceling the virtual LAN attributes that are identical to the virtual LAN attributes of the virtual server in the network side interface of the access switch.
[0105] In this embodiment, by defining the interface type of the access switch, after receiving the offline notification of the virtual server, the diffusion behavior of the protocol message and the revocation behavior of the virtual LAN attributes are controlled according to the interface type of the access switch, thereby reducing maintenance costs and saving network and server resources.
[0106] In some optional implementations, another virtual local area network device registration method is provided, which can solve the same technical problems as steps S101 to S105, such as Figure 3 As shown, the method includes:
[0107] Check the real network device; apply for virtual LAN device memory resources; connect the virtual LAN device to the real network; configure virtual LAN device properties; register the virtual LAN device with the network device; join the virtual LAN device to the virtual LAN group; create a test message type; create a test message processing function; create a virtual LAN test data message; send a virtual LAN test data message; determine whether the received virtual LAN identifier is consistent with the new device virtual LAN identifier; if not, delete the new virtual LAN device in the network device and release the virtual LAN device memory resources; if consistent, delete the test message type; virtual LAN device registration is complete.
[0108] In this embodiment, the existing virtual LAN device registration method is improved. After the virtual LAN device is registered, the physical transmission port is tested for sending and receiving virtual LAN test data packets, which ensures that once the virtual LAN device registration is completed, the virtual LAN device is available. This avoids the situation that the virtual LAN device can be successfully registered but cannot be used normally to send and receive virtual LAN data packets in the existing virtual LAN device registration method, and reduces the debugging cost of the virtual LAN function. After using the improved virtual LAN device registration method, the virtual LAN device can be successfully registered only after ensuring that the physical transmission port can smoothly send and receive virtual LAN packets.
[0109] In this embodiment, a virtual local area network device registration device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0110] This embodiment provides a virtual local area network device registration device, such as Figure 4 As shown, including:
[0111] The registration module 401 is used to register the initial virtual local area network device and determine the device identification of the initial virtual local area network device;
[0112] A generating module 402, used to generate a test message including a device identification;
[0113] The sending module 403 is used to send the test message to the target device so that the target device determines whether the identifier included in the intermediate message is consistent with the device identifier, wherein the intermediate message is the test message received by the target device;
[0114] A release module 404, used to release the resources occupied by the initial virtual local area network device when the target device does not receive the test message or the identifier included in the intermediate message is inconsistent with the device identifier;
[0115] The setting module 405 is used to set the initial virtual local area network device as the target virtual local area network device when the identifier included in the intermediate message is consistent with the device identifier.
[0116] In some optional implementations, the sending module 403 includes:
[0117] A first determining unit, used to determine a host device to which an initial virtual local area network device is bound;
[0118] A setting unit, configured to set an address of a host device as a target address, wherein the target device includes the host device;
[0119] The second determining unit is used to determine the physical transmission port by using a preset message sending function, and put the test message into the network device queue, wherein the physical transmission port is used to send the test message in the network device queue to a target address.
[0120] In some optional embodiments, the device further comprises:
[0121] A judgment module, used to monitor the sending process of the test message by the physical transmission port within a preset time, and judge whether the target device receives the test message within the preset time;
[0122] A first signal generating module, configured to generate a first signal when the target device does not receive the test message within a preset time, wherein the first signal is used to indicate that the target device does not receive the test message;
[0123] The second signal generating module is used to compare the identifier contained in the intermediate message with the device identifier when the target device receives the test message within a preset time, and generate a second signal or a third signal according to the comparison result, wherein the second signal is used to indicate that the identifier contained in the intermediate message is inconsistent with the device identifier, and the third signal is used to indicate that the identifier contained in the intermediate message is consistent with the device identifier.
[0124] In some optional implementations, the second signal generating module includes:
[0125] A third determining unit, configured to determine a message type corresponding to the intermediate message by using the host device, and determine a message processing function according to the message type;
[0126] An extraction unit, used for extracting the identifier contained in the intermediate message from the intermediate message according to the message processing function;
[0127] The comparison unit is used to obtain the device identification from the host device and compare the identification included in the intermediate message with the device identification.
[0128] In some optional implementations, the registration module 401 includes:
[0129] A creation unit, used to create an initial network device based on a preset structure and allocate corresponding storage space to the initial network device;
[0130] A fourth determining unit, configured to determine an initialization function corresponding to the initial network device, and determine a device type of the initial network device using the initialization function;
[0131] A fifth determining unit, configured to determine an operation logic of an initial network device;
[0132] A sixth determining unit, configured to determine a device identification of the initial network device and a bound host device, record the device identification in the host device, and record information of the device identification and the host device in a storage space;
[0133] The registration unit is used to register the initial network device into the network device linked list of the kernel, and obtain the initial virtual local area network device according to the initial network device, storage space, device type and operation logic.
[0134] In some optional implementations, the release module 404 includes:
[0135] A first release unit, used to remove the initial network device from the network device linked list by using a resource release function in the kernel;
[0136] A second releasing unit is used to release resources corresponding to the preset structure, device type, operation logic, and device identification, and release storage space;
[0137] The third releasing unit is used to unbind the initial virtual local area network device and the host device, and call the preset interface of the kernel to delete the message type corresponding to the test message in the protocol stack.
[0138] In some optional implementations, the generating module 402 includes:
[0139] A first acquisition unit, used to acquire a structure corresponding to a test message;
[0140] A second acquisition unit is used to acquire a device identifier from a storage space of an initial virtual local area network device;
[0141] A first generating unit, used for generating tag information of an initial virtual local area network device according to a device identifier;
[0142] The second generating unit is used to add the marking information to a preset position of the structure to generate a test message.
[0143] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0144] The virtual LAN device registration device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0145] The embodiment of the present invention also provides a computer device having the above Figure 4 The virtual LAN device registration apparatus is shown.
[0146] See also Figure 5 , Figure 5 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 5 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.
[0147] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include an integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0148] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0149] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0150] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0151] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0152] The embodiment of the present invention also provides a computer non-volatile readable storage medium. The above method according to the embodiment of the present invention can be implemented in hardware, firmware, or implemented as a computer code that can be recorded in a storage medium, or downloaded through a network and originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method shown in the above embodiment is implemented.
[0153] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable non-volatile storage medium or communication medium accessible to the computer.
[0154] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined in this application.
Claims
1. A method for registering a virtual local area network device, characterized in that: The method comprises: Registering an initial virtual local area network device and determining a device identifier of the initial virtual local area network device; generating a test message including the device identification; Sending the test message to a target device, so that the target device determines whether the identifier included in the intermediate message is consistent with the device identifier, wherein the intermediate message is the test message received by the target device; When the target device does not receive the test message, or the identifier included in the intermediate message is inconsistent with the device identifier, releasing the resources occupied by the initial virtual local area network device; When the identifier included in the intermediate message is consistent with the device identifier, the initial virtual local area network device is set as the target virtual local area network device.
2. The method according to claim 1, characterized in that The sending of the test message to the target device includes: Determine the host device to which the initial virtual local area network device is bound; Setting the address of the host device as a target address, wherein the target device includes the host device; A physical transmission port is determined using a preset message sending function, and the test message is placed in a network device queue, wherein the physical transmission port is used to send the test message in the network device queue to the target address.
3. The method according to claim 2, characterized in that After sending the test message to the target device, the method further includes: Monitoring the sending process of the test message by the physical transmission port within a preset time, and determining whether the target device receives the test message within the preset time; If the target device does not receive the test message within the preset time, generate a first signal, wherein the first signal is used to indicate that the target device does not receive the test message; When the target device receives the test message within the preset time, the identifier contained in the intermediate message is compared with the device identifier, and a second signal or a third signal is generated according to the comparison result, wherein the second signal is used to characterize that the identifier contained in the intermediate message is inconsistent with the device identifier, and the third signal is used to characterize that the identifier contained in the intermediate message is consistent with the device identifier.
4. The method according to claim 3, characterized in that The comparing the identifier included in the intermediate message with the device identifier includes: Determining, by using the host device, a message type corresponding to the intermediate message, and determining a message processing function according to the message type; Extracting the identifier contained in the intermediate message from the intermediate message according to the message processing function; The device identification is obtained from the host device, and the identification included in the intermediate message is compared with the device identification.
5. The method according to claim 1, characterized in that The registering of the initial virtual local area network device comprises: Creating an initial network device based on a preset structure, and allocating corresponding storage space to the initial network device; Determine an initialization function corresponding to the initial network device, and determine a device type of the initial network device using the initialization function; Determining the operation logic of the initial network device; Determine the device identification of the initial network device and the bound host device, record the device identification in the host device, and record the device identification and information of the host device in the storage space; The initial network device is registered into the network device linked list of the kernel, and the initial virtual local area network device is obtained according to the initial network device, the storage space, the device type and the operation logic.
6. The method according to claim 5, characterized in that The releasing of resources occupied by the initial virtual local area network device comprises: Using a resource release function in the kernel, the initial network device is removed from the network device linked list; Release the preset structure, the device type, the operation logic, and the resources corresponding to the device identifier, and release the storage space; The initial virtual local area network device and the host device are unbound, and a preset interface of the kernel is called to delete the message type corresponding to the test message in the protocol stack.
7. The method according to claim 5, characterized in that The generating of the test message including the device identification comprises: Obtain the structure corresponding to the test message; Acquire the device identifier from the storage space of the initial virtual local area network device; Generating tag information of the initial virtual local area network device according to the device identification; The marking information is added to a preset position of the structure to generate the test message.
8. A virtual local area network device registration device, characterized in that: The device comprises: A registration module, used to register an initial virtual local area network device and determine a device identifier of the initial virtual local area network device; A generating module, used for generating a test message including the device identification; A sending module, used for sending the test message to a target device, so that the target device determines whether the identifier included in the intermediate message is consistent with the device identifier, wherein the intermediate message is the test message received by the target device; A release module, used for releasing the resources occupied by the initial virtual local area network device when the target device does not receive the test message or the identifier included in the intermediate message is inconsistent with the device identifier; A setting module is used to set the initial virtual local area network device as a target virtual local area network device when the identifier included in the intermediate message is consistent with the device identifier.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the virtual local area network device registration method according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the virtual local area network device registration method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Equipment testing method based on virtual module, storage medium and electronic device
CN116647488A
Network testing method, computer equipment, network equipment and readable storage medium
CN116886584A
Function test method and device of virtual power plant, computer equipment, readable storage medium and program product
CN119226153A
Locating virtual machine(s) within virtual networks
US20160352579A1