CN117527687A - Message forwarding method and device, electronic equipment and storage medium - Google Patents

Message forwarding method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117527687A
CN117527687A CN202311428333.XA CN202311428333A CN117527687A CN 117527687 A CN117527687 A CN 117527687A CN 202311428333 A CN202311428333 A CN 202311428333A CN 117527687 A CN117527687 A CN 117527687A
Authority
CN
China
Prior art keywords
message
sent
network card
flow table
modified
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311428333.XA
Other languages
Chinese (zh)
Inventor
郑立来
蒋宸
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sangfor Technologies Co Ltd
Original Assignee
Sangfor Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sangfor Technologies Co Ltd filed Critical Sangfor Technologies Co Ltd
Priority to CN202311428333.XA priority Critical patent/CN117527687A/en
Publication of CN117527687A publication Critical patent/CN117527687A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/30Routing of multiclass traffic
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/24Traffic characterised by specific attributes, e.g. priority or QoS
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/70Admission control; Resource allocation
    • H04L47/80Actions related to the user profile or the type of traffic
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/565Conversion or adaptation of application format or content
    • H04L67/5651Reducing the amount or size of exchanged application data

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the application provides a message forwarding method, a message forwarding device, electronic equipment and a storage medium. The message forwarding method comprises the following steps: acquiring a message to be sent; if the hardware flow table matched with the message to be sent is determined to exist, modifying the message to be sent based on the hardware flow table to obtain a modified message to be sent; if the modified message to be sent belongs to the cross-card flow, the modified message to be sent is sent to the message forwarding module, so that the message forwarding module sends the modified message to be sent to the second network card according to a preset outlet interface, and the preset outlet interface is an interface of the second network card. After the modified message to be sent belongs to the cross-card flow, the message forwarding module sends the modified message to be sent to the preset interface, so that the message forwarding module is prevented from carrying out excessive processing on the modified message, the problem of excessive CPU consumption during software processing is solved, and the resource utilization rate is improved.

Description

Message forwarding method and device, electronic equipment and storage medium
Technical Field
The application belongs to the technical field of computers, and particularly relates to a message forwarding method, a message forwarding device, electronic equipment and a readable storage medium.
Background
In the related technology, when forwarding traffic, the traffic is generally processed completely by software, after receiving a message, the software queries the traffic by a software flow table, then performs software express processing, and then sends the processed message to a corresponding output interface. However, the software processing results in longer message forwarding time and larger consumption of CPU resources.
Disclosure of Invention
In view of the above problems, the present application proposes a method, an apparatus, an electronic device, and a storage medium for forwarding a message, so as to improve the above problems.
In a first aspect, an embodiment of the present application provides a method for forwarding a message, which is applied to a first network card, where the method includes: acquiring a message to be sent; if the hardware flow table matched with the message to be sent is determined to exist, modifying the message to be sent based on the hardware flow table to obtain a modified message to be sent, wherein the hardware flow table is stored in a hardware chip of the first network card; if the modified message to be sent belongs to the cross-card flow, the modified message to be sent is sent to a message forwarding module, so that the message forwarding module sends the modified message to be sent to a second network card according to a preset interface, wherein the message forwarding module is a software module outside the first network card and the second network card, and the preset interface is an interface of the second network card.
Further, if it is determined that there is a hardware flow table matching the message to be sent, modifying the message to be sent based on the hardware flow table to obtain a modified message to be sent, including: if the message information of the message to be sent is determined to be matched with the first matching rule in the hardware flow table, determining that a hardware flow table matched with the message to be sent exists; and modifying the message information of the message to be sent according to a second matching rule in the hardware flow table to obtain the modified message to be sent, wherein the first matching rule is a rule for determining that the message to be sent is matched with the hardware flow table, and the second matching rule is a rule for modifying the message to be sent by the first network card.
Further, the method further comprises: and if the modified message to be sent does not belong to the cross-card flow, sending the modified message to be sent to a preset output interface of the first network card.
Further, the method further comprises: if it is determined that the hardware flow table matched with the message to be sent does not exist, the message to be sent is sent to a message forwarding module, so that the message forwarding module modifies the message information corresponding to the message to be sent according to configuration information corresponding to network equipment under the condition that the message information to be sent does not meet a preset condition, the modified message to be sent is obtained, and the modified message to be sent is sent to the second network card according to the preset interface, wherein the network equipment is equipment comprising the first network card and the second network card. By the method, after the fact that the hardware flow table matched with the message to be sent does not exist is determined, the first network card cannot modify the message to be sent, the message to be sent is sent to the message forwarding module, and the message forwarding module modifies the message to be sent, so that the modified message to be sent can be successfully sent to the second network card.
Further, the method further comprises: if the hardware flow table matched with the message to be sent does not exist, the message to be sent is sent to a message forwarding module, so that the message forwarding module sends the message to be sent to a target network card corresponding to a preset outlet interface according to the preset outlet interface under the condition that the message information to be sent meets the preset condition.
In a second aspect, an embodiment of the present application provides a method for forwarding a message, which is applied to a message forwarding module, where the method includes: receiving a modified message to be sent, which is sent by a first network card, wherein the modified message to be sent is obtained by modifying the message to be sent by the first network card based on a hardware flow table matched with the message to be sent; and if the modified message to be sent has the cross-card mark, sending the modified message to be sent to the second network card through a preset interface.
Further, the method further comprises: receiving a message to be transmitted, wherein the message to be transmitted is transmitted after the first network card determines that a hardware flow table matched with the message to be transmitted does not exist; if the message to be sent meets the preset condition, performing data operation on the message to be sent to obtain the operated message to be sent; if no message forwarding mark exists in the operated message to be sent, the operated message to be sent is issued to the first network card, so that the first network card updates an original hardware flow table based on the operated message to be sent to obtain a hardware flow table, wherein the message forwarding mark represents a mark which is set after forwarding the message in the message flow to which the message to be sent belongs; and sending the message to be sent after the operation to a target network card corresponding to the preset interface through the preset interface. By the method, the first network card determines the hardware flow table according to the received message to be sent after the operation, and if the first network card receives the message to be sent again, the first network card can modify the received message to be sent according to the determined hardware flow table, so that the message forwarding module can accurately send the modified message to be sent to the target network card.
Further, if it is determined that the message to be sent meets the preset condition, performing data operation on the message to be sent to obtain an operated message to be sent, including: if the fact that the cross-card mark does not exist in the message to be sent and a software flow table matched with the message to be sent does not exist, determining that the message to be sent meets a preset condition; carrying out slow path processing on the message to be sent, wherein the slow path processing is to create an original software flow table based on the message information, and determine a preset interface corresponding to the message to be sent, and the software flow table is stored in a memory of the message forwarding module; and performing fast path processing on the message to be sent after the slow path processing to obtain the message to be sent after the operation, wherein the fast path processing is to modify the message to be sent after the slow path processing according to configuration information corresponding to network equipment, and update the original software flow table based on the modified message to be sent after the slow path processing to obtain the software flow table. By the method, the software flow table is determined according to the modified message to be sent, so that when the message to be sent is processed later, the software flow table matched with the message to be sent exists, and after the software flow table matched with the message to be sent is determined, the message to be sent can be directly subjected to fast path processing, so that the forwarding speed of the message to be sent is increased.
Further, if it is determined that the message forwarding flag does not exist in the operated message to be sent, the operated message to be sent is issued to the first network card, so that the first network card updates an original hardware flow table based on the operated message to be sent, to obtain a hardware flow table, including: if the fact that the message forwarding mark does not exist in the message to be sent after the operation is determined, extracting a first matching rule and a second matching rule which are included in a software flow table, wherein the software flow table is located in the message to be sent after the operation, and the first matching rule and the second matching rule are determined based on the data operation; and issuing the extracted first matching rule and the second matching rule to the first network card so that the first network card updates the original hardware flow table based on the first matching rule and the second matching rule to obtain the hardware flow table.
In a third aspect, an embodiment of the present application provides a packet forwarding device, running on a first network card, where the device includes: the device comprises a message to be sent acquisition unit, a message to be sent modification unit and a message to be sent sending unit. The message to be sent obtaining unit is used for obtaining the message to be sent; the message to be sent modifying unit is used for modifying the message to be sent based on the hardware flow table if the hardware flow table matched with the message to be sent exists, so as to obtain a modified message to be sent, wherein the hardware flow table is stored in a hardware chip of the first network card; and the message to be sent sending unit is used for sending the modified message to be sent to the message forwarding module if the modified message to be sent belongs to the cross-card flow, so that the message forwarding module sends the modified message to be sent to the second network card according to a preset outlet interface, wherein the message forwarding module is a software module outside the first network card and the second network card, and the preset outlet interface is an interface of the second network card.
In a fourth aspect, an embodiment of the present application provides a packet forwarding device, running in a packet forwarding module, where the device includes: and the message receiving unit to be transmitted and the message forwarding unit to be transmitted. The device comprises a message to be transmitted receiving unit, a first network card and a second network card, wherein the message to be transmitted receiving unit is used for receiving a modified message to be transmitted, and the modified message to be transmitted is obtained by modifying the message to be transmitted by the first network card based on a hardware flow table matched with the message to be transmitted; and the message to be transmitted forwarding unit is used for transmitting the modified message to be transmitted to the second network card through a preset interface if the modified message to be transmitted is determined to have the cross-card mark.
In a fifth aspect, embodiments of the present application provide an electronic device comprising one or more processors and a memory; one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to perform the methods described above.
In a sixth aspect, embodiments of the present application provide a computer readable storage medium having program code stored therein, wherein the above-described method is performed when the program code is run.
The embodiment of the application provides a message forwarding method, a message forwarding device, electronic equipment and a storage medium. Firstly, modifying an acquired message to be sent, judging whether the modified message to be sent belongs to the cross-card flow, if so, sending the modified message to be sent to a message forwarding module, and sending the received modified message to be sent to a second network card by the message forwarding module according to a preset interface. By the method, after the modified message to be sent belongs to the cross-card flow, the message forwarding module sends the modified message to be sent to the preset interface, so that the message forwarding module is prevented from carrying out excessive processing on the modified message, the problem of excessive CPU consumption during software processing is solved, and the resource utilization rate is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 shows a flowchart of a message forwarding method according to an embodiment of the present application;
fig. 2 shows an application scenario diagram of a message forwarding method according to an embodiment of the present application;
fig. 3 shows an application scenario diagram of a message forwarding method according to an embodiment of the present application;
fig. 4 is a flowchart of a message forwarding method according to another embodiment of the present application;
fig. 5 shows a flowchart of a message forwarding method according to still another embodiment of the present application;
fig. 6 is a flowchart of a message forwarding method according to another embodiment of the present application;
fig. 7 is a flowchart of a message forwarding method according to another embodiment of the present application;
fig. 8 is a flowchart of a message forwarding method according to still another embodiment of the present application;
fig. 9 is a flowchart of a message forwarding method according to still another embodiment of the present application;
fig. 10 is a flowchart illustrating a method for forwarding a message according to still another embodiment of the present application;
FIG. 11 is a flowchart illustrating a method for forwarding a message according to still another embodiment of the present application;
fig. 12 is a block diagram of a packet forwarding device according to still another embodiment of the present application;
Fig. 13 is a block diagram of a packet forwarding device according to still another embodiment of the present application;
fig. 14 shows a block diagram of an electronic device for executing the message forwarding method of the embodiment of the present application in real time;
fig. 15 shows a storage unit for storing or carrying program codes for implementing the message forwarding method according to an embodiment of the present application in real time.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that embodiments of the present application described herein may be implemented in other sequences than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or server that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
When forwarding a received message through a network card, the network card generally sends the message to a software end, and the software end is responsible for sending the message sent by the network card to an output interface.
The inventor finds out in the research of the related message forwarding method, and generally, the related message forwarding method queries an outgoing interface through a software flow table after the software receives the message, then performs software express processing, and then sends the message to the corresponding outgoing interface. However, the message forwarding time is long and the CPU resource consumption is large due to the software processing.
Therefore, the inventor proposes a message forwarding method, a message forwarding device, an electronic device and a storage medium in the embodiments of the present application. Firstly, obtaining a message to be sent, if a hardware flow table matched with the message to be sent is determined to exist, modifying the message to be sent based on the hardware flow table to obtain a modified message to be sent, wherein the hardware flow table is stored in a hardware chip of the first network card, and if the modified message to be sent is determined to belong to a cross-card flow, the modified message to be sent is sent to a message forwarding module, so that the message forwarding module sends the modified message to be sent to a second network card according to a preset output interface, wherein the message forwarding module is a software module outside the first network card and the second network card, and the preset output interface is an interface of the second network card. By the method, after the modified message to be sent belongs to the cross-card flow, the message forwarding module sends the modified message to be sent to the preset interface, so that the message forwarding module is prevented from carrying out excessive processing on the modified message, the problem of excessive CPU consumption during software processing is solved, and the resource utilization rate is improved.
Embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Referring to fig. 1, an embodiment of the present application provides a method for forwarding a message, which is applied to a first network card, and the method includes:
step S110: and obtaining the message to be sent.
In the embodiment of the application, two interfaces, namely a first interface and a second interface, exist in the first network card, and when the electronic equipment sends a message to be sent to the first network card, the input interface in the first network card receives the message to be sent by the electronic equipment. The first network card is used for representing a network card for receiving a message to be transmitted, which is sent by the electronic equipment, wherein the message to be transmitted is used for representing a message needing to be forwarded by the first network card, and the message to be transmitted can comprise at least one message sequence which comprises at least one message; the input interface is used for representing an interface for receiving a message sent by the electronic device in the first network card.
As one way, after the electronic device establishes communication connection with the network card, the electronic device may transmit a message to the network card, and the network card may receive the message transmitted by the electronic device. The electronic device may be a computer, a smart phone, or a tablet computer, which is not particularly limited herein.
As one way, the electronic device may establish a communication connection with the first network card by using a network cable. The message sending interface in the electronic equipment is connected with the input interface in the first network card through a network cable, so that the electronic equipment can send the message to be sent to the message sending interface, and the message sending interface transmits the received message to be sent to the input interface in the first network card through the network cable, so that the first network card receives the message to be sent by the electronic equipment through the input interface.
As one way, the electronic device may establish a wireless communication connection with the first network card, where the wireless communication connection may include a bluetooth connection, a WIFI connection, and so on, and is not specifically limited herein. After the electronic equipment and the first network card are in wireless communication connection, the first network card can acquire a message to be transmitted, which is transmitted by the electronic equipment in a wireless way.
Step S120: and if the hardware flow table matched with the message to be sent exists, modifying the message to be sent based on the hardware flow table to obtain a modified message to be sent, wherein the hardware flow table is stored in a hardware chip of the first network card.
In this embodiment of the present application, the hardware flow table is session control information in the network card, where the session control information in the network card includes message matching information that matches a message to be sent and message modification action information that modifies the message to be sent. After the first network card receives the message to be sent, inquiring the stored hardware flow table in the memory in the hardware chip of the first network card, and judging whether the inquired hardware flow table has the hardware flow table matched with the message to be sent. After the fact that the hardware flow table matched with the message to be sent exists in the memory of the first network card is inquired, the message information to be sent is modified according to the hardware flow table matched with the message to be sent, and therefore the modified message to be sent is obtained. One or more hardware flow tables may be stored in the memory, and if the first network card is just installed, the hardware flow table does not exist in the first network card.
As a way, when the first network card receives the message to be sent for the first time, the hardware flow table matched with the message to be sent does not exist in the hardware chip. When forwarding the first message in the message to be sent, the first network card generates a hardware flow table matched with the message to be sent according to the received rule matched with the message. After the first network card creates a hardware flow table matched with the message to be sent according to the first message in the message to be sent, the subsequent messages of the first message of the message to be sent are matched with the hardware flow table. Each time the first network card creates a hardware flow table, the hardware flow table can be stored in a memory in the hardware chip according to the time of creating the hardware flow table, so as to obtain a hardware flow table queue containing a plurality of hardware flow tables.
When the first network card needs to match the message, the message is matched with a plurality of hardware flow tables in a hardware flow table queue in sequence until the hardware flow table matched with the message is determined or until the hardware flow table queue is queried, if the hardware flow table matched with the message does not exist in the hardware flow table queue, an original hardware flow table is created when the message is forwarded, the created original hardware flow table is inserted into the tail end of the hardware flow table queue, and no information is included in the original hardware flow table. The hardware flow table queue is used for representing a queue recorded with a plurality of hardware flow tables.
Step S130: if the modified message to be sent belongs to the cross-card flow, the modified message to be sent is sent to a message forwarding module, so that the message forwarding module sends the modified message to be sent to a second network card according to a preset interface, wherein the message forwarding module is a software module outside the first network card and the second network card, and the preset interface is an interface of the second network card.
In this embodiment of the present application, the location information of the preset interface of the to-be-sent message is located in a hardware flow table matched with the to-be-sent message, and it may be determined, by using the location information of the preset interface, whether the preset interface corresponding to the to-be-sent message is located in the first network card or the second network card. After the message to be sent is modified, inquiring the position information of the preset interface corresponding to the modified message to be sent in the hardware flow table, so as to determine that the modified message to be sent is sent to the first network card or the second network card, and if the position of the preset interface of the modified message to be sent is determined not to belong to the first network card, determining that the modified message to be sent belongs to the cross-card flow. And after the modified message to be sent belongs to the cross-card flow, the modified message to be sent is sent to the message forwarding module, so that the message forwarding module receives the modified message to be sent and then sends the modified message to be sent to the second network card through the preset interface. The message forwarding module is used for representing software for forwarding the message, the cross-card flow is used for representing that positions of preset interfaces corresponding to a plurality of messages in the flow are network cards corresponding to non-incoming interfaces, and the incoming interfaces are network card interfaces for receiving the messages sent by the electronic equipment. The message forwarding module is a software program for processing and forwarding a message to be sent, and is located in a network device, and the network device further comprises a first network card and a second network card, wherein the network device can be a firewall.
As a way, whether the message to be sent belongs to the cross-card traffic can be determined by determining the tag in the hardware flow table in the first network card. When the input interface corresponding to the message to be sent is a first network card, when the message forwarding module determines a preset output interface corresponding to a first message in the message to be sent and forwards the message according to the preset output interface, interface information corresponding to the preset output interface is sent to the first network card, when the first network card receives the interface information, the position of the preset output interface corresponding to the message is determined to be the first network card or the second network card according to the interface information, a label is created according to the position of the preset output interface, and if the position of the preset output interface of the message is the first network card, a non-cross-card label is created in a hardware flow table corresponding to the message; if the preset interface position of the message is the second network card, creating a cross-card label in a hardware flow table corresponding to the message. When the forwarding of the first message in the flow is completed and the subsequent message of the first message in the message to be sent is forwarded, determining whether the message belongs to the cross-card flow according to whether the label in the corresponding hardware flow table is the cross-card label or the non-cross-card label. The method comprises the steps that a cross-card label is used for representing that the flow corresponding to a message is the cross-card flow, a non-cross-card label is used for representing that the flow corresponding to the message is the non-cross-card flow, and interface information is used for representing information of a position where a preset outgoing connection belongs.
As an alternative, as shown in fig. 2 and 3, the first network card and the second network card are located in the network device. If the first network card and the second network card are both intelligent network cards, the message can be forwarded in two directions, namely the first network card can forward the received message to be sent to the second network card, the second network card can also forward the received message to be sent to the first network card, and the two directions of the message can be simultaneously carried out; if the first network card is an intelligent network card and the second network card is a non-intelligent network card, the message can only be forwarded unidirectionally, namely the first network card can forward the received message to be sent to the second network card, and the second network card cannot forward the received message to be sent to the first network card. The intelligent network card is a flexible programmable network card, and the non-intelligent network card is a non-programmable network card.
The embodiment of the application provides a message forwarding method, which is applied to a first network card, and is used for firstly acquiring a message to be sent, modifying the message to be sent based on a hardware flow table if the hardware flow table matched with the message to be sent exists, obtaining the modified message to be sent, wherein the hardware flow table is stored in a hardware chip of the first network card, and sending the modified message to be sent to a message forwarding module if the modified message to be sent is determined to belong to a cross-card flow, so that the message forwarding module sends the modified message to be sent to a second network card according to a preset output interface, wherein the message forwarding module is a software module outside the first network card and the second network card, and the preset output interface is an interface of the second network card. By the method, after the modified message to be sent belongs to the cross-card flow, the message forwarding module sends the modified message to be sent to the preset interface, so that the message forwarding module is prevented from carrying out excessive processing on the modified message, the problem of excessive CPU consumption during software processing is solved, and the resource utilization rate is improved.
Referring to fig. 4, an embodiment of the present application provides a method for forwarding a message, which is applied to a first network card, and the method includes:
step S210: and obtaining the message to be sent.
Step S210 may be specifically explained with reference to the above embodiments, so that details are not repeated in this embodiment.
Step S220: if the message information of the message to be sent is matched with the first matching rule in the hardware flow table, determining that a hardware flow table matched with the message to be sent exists.
In this embodiment of the present application, a message to be sent includes a header and a data portion, where the header may include a source port, a destination port, a source IP, and a destination IP, and the data portion includes data to be sent. After the message to be sent is obtained, determining message quintuple information corresponding to the message to be sent as message information of the message to be sent, sequentially matching the message quintuple information with first matching rules corresponding to the plurality of hardware flow tables stored in the hardware chip, and if the first matching rules matched with the message quintuple information exist in the first matching rules corresponding to the plurality of hardware flow tables, determining that the hardware flow table corresponding to the first matching rules is the hardware flow table matched with the message to be sent. Wherein, the message quintuple information comprises: the first matching rule is a rule for determining that a message to be sent is matched with a hardware flow table.
As one way, it may be determined from fields included in the hardware flow table whether the hardware flow table matches a message to be sent. For example, the first matching rule of the hardware flow table includes three parts of a base field, a matching field and an action field, and a plurality of fields are included in the base field, the matching field and the action field. And matching the message quintuple information of the message to be sent with a matching field of the first matching rule, and if the field related to the message quintuple information in the matching field is identical to the message quintuple information, determining that the message information of the message to be sent is matched with the first matching rule of the hardware flow table, namely determining that the message to be sent is matched with the hardware flow table. For example, the message quintuple information of the message to be sent is the source IP:1.1.1.1, destination IP:3.3.3.3, source port: 80, destination port: 80, protocol number: 6, preparing a base material; the matching fields in the first matching rule are respectively matching source IP fields: 1.1.1.1, matching destination IP field: 3.3.3.3, match source port field: 80, match destination port field: 80, matching protocol number field: 6, wherein the source IP corresponds to a matching source IP field, the destination IP corresponds to a matching destination IP field, the source port corresponds to a matching source port field, the destination port corresponds to a matching destination port field, and the protocol number corresponds to a matching protocol number field, it is determined that the message quintuple information of the message to be sent is matched with the first matching rule of the hardware flow table, that is, it is determined that the message to be sent is matched with the hardware flow table.
Step S230: and modifying the message information of the message to be sent according to a second matching rule in the hardware flow table to obtain the modified message to be sent, wherein the first matching rule is a rule for determining that the message to be sent is matched with the hardware flow table, and the second matching rule is a rule for modifying the message to be sent by the first network card.
In the embodiment of the application, after the fact that the message to be sent is matched with the first matching rule of the hardware flow table is determined, the message information to be sent is processed according to the second matching rule in the hardware flow table, and therefore the processed message to be sent is obtained. The processing may include modifying a MAC, modifying an IP, adding a VLAN, modifying an out interface, etc., which are not specifically limited herein.
As a way, after the message information is matched according to the matching field included in the first matching rule of the hardware flow table, the message information can be modified according to the action field included in the second matching rule, so as to obtain the modified message to be sent. For example, the action field is modification source MAC 00:00:00:00:00:03, modified destination MAC 00:00:00:00:01:02, the source MAC of the message to be sent is modified to 00:00:00:00:00:03, modifying the destination MAC of the message to be sent to 00:00:00:00:01:02.
Step S240: judging whether the modified message to be sent belongs to the cross-card flow or not, and if so, executing step S250; if not, step S260 is performed.
Step S250: if the modified message to be sent belongs to the cross-card flow, the modified message to be sent is sent to a message forwarding module, so that the message forwarding module sends the modified message to be sent to a second network card according to a preset interface, wherein the message forwarding module is a software module outside the first network card and the second network card, and the preset interface is an interface of the second network card.
In this embodiment of the present application, after modifying a message to be sent according to a hardware flow table, a preset interface corresponding to the message to be sent in the hardware flow table is queried, if it is determined that the preset interface is not an interface located in a first network card, it is determined that the modified message to be sent belongs to a cross-card flow, information of the preset interface corresponding to the queried message to be sent is set in a header of the message to be sent, the modified message to be sent is sent to a message forwarding module outside the first network card and the second network class, and the message forwarding module determines, according to the received information of the preset interface in the header of the modified message to be sent, to forward the modified message to the preset interface in the second network card.
Step S260: and if the modified message to be sent does not belong to the cross-card flow, sending the modified message to be sent to a preset output interface of the first network card.
In this embodiment of the present application, after modifying a message to be sent according to a hardware flow table, a preset interface corresponding to the message to be sent in the hardware flow table is queried, if it is determined that the preset interface is an interface located in a first network card, it is determined that the modified message to be sent does not belong to a cross-card flow, and then the modified message to be sent is directly sent to the preset interface in the first network card through a hardware chip.
For example, as shown in fig. 5, step S210 to step S260 may be performed, after the input interface of the first network card receives the message to be sent, first, query whether the memory of the hardware chip exists in the hardware flow table matched with the received message to be sent, and if not, directly send the message to be sent to the message forwarding module; if the hardware flow table matched with the message to be sent is queried, modifying the message to be sent according to a second matching rule in the queried hardware flow table, judging whether the modified message to be sent belongs to the cross-card flow or not, if not, indicating that the preset interface corresponding to the modified message to be sent is another interface in the first network card, and directly sending the modified message to be sent to the preset interface in the first network card by the hardware chip; if the flow belongs to the cross-card flow, the preset interface corresponding to the modified message to be sent is indicated to be the interface in the second network card, the first network card sends the modified message to be sent to the message forwarding module, and the message forwarding module forwards the received modified message to be sent.
The method for forwarding the message is applied to a first network card, firstly, the message to be sent is obtained, then if the message information of the message to be sent is determined to be matched with a first matching rule in a hardware flow table, the hardware flow table matched with the message to be sent is determined to exist, then the message information of the message to be sent is modified according to a second matching rule in the hardware flow table, the modified message to be sent is obtained, the first matching rule is a rule for determining that the message to be sent is matched with the hardware flow table, the second matching rule is a rule for modifying the message to be sent by the first network card, then whether the modified large message to be sent belongs to a cross-card flow rate is judged, if so, the modified message to be sent is sent to a message forwarding module, the message forwarding module sends the modified message to a second network card according to a preset interface, the message forwarding module is a software module outside the first network card and the second network card, and the preset interface is a second network card interface; if not, the modified message to be sent is sent to a preset output interface of the first network card. By the method, the message to be sent is determined to be matched with the hardware flow table, the preset output interface of the modified message to be sent is determined to be positioned on the second network card according to the fact that the modified message to be sent belongs to the cross-card flow, and the message forwarding module directly sends the modified message to be sent to the preset output interface, so that the problem that CPU (Central processing unit) consumes too much during software processing is solved, and the resource utilization rate is improved.
Referring to fig. 6, an embodiment of the present application provides a method for forwarding a message, which is applied to a first network card, and the method includes:
step S310: and obtaining the message to be sent.
Step S310 may be specifically explained with reference to the above embodiments, so that details are not repeated in this embodiment.
Step S320: judging whether the hardware flow table matched with the message to be sent exists or not, and if the hardware flow table matched with the message to be sent does not exist, executing step S330; if so, step S340 is performed.
Step S330: if it is determined that the hardware flow table matched with the message to be sent does not exist, the message to be sent is sent to a message forwarding module, so that the message forwarding module modifies the message information corresponding to the message to be sent according to configuration information corresponding to network equipment under the condition that the message information to be sent does not meet a preset condition, the modified message to be sent is obtained, and the modified message to be sent is sent to the second network card according to the preset interface, wherein the network equipment is equipment comprising the first network card and the second network card.
In this embodiment of the present application, when the transmission speed of the packet in the packet to be sent is fast, there may be a case where the first packet in the packet to be sent has been forwarded, and the first network card has not created the hardware flow table according to the received first matching rule and second matching rule. Therefore, when the hardware flow table matched with the message to be sent does not exist, the message to be sent is directly sent to the message forwarding module, and the message forwarding module judges that the message to be sent does not meet the preset condition at the moment, so that the message to be sent is modified according to the configuration information corresponding to the network equipment, and the modified message to be sent is obtained. And the modified message to be sent is sent to the second network card through the preset interface.
For example, if the source MAC included in the message to be sent received by the message forwarding module is 00:00:00:00:01:01, destination MAC is 00:00:00:00:01:01, wherein the source MAC is a MAC corresponding to the electronic device connected to the ingress interface, and the destination MAC is a MAC corresponding to the ingress interface in the first network card. After the message forwarding module receives the message to be sent, determining the MAC corresponding to the destination IP according to an ARP (address resolution protocol ) request, where the MAC corresponding to the destination IP is 00:00:00:00:01:02, simultaneously determining the MAC corresponding to the preset output interface, wherein the MAC corresponding to the preset output interface is 00:00:00:00:00:03, modifying the source MAC of the message to be sent to the MAC corresponding to the preset output interface, and modifying the destination MAC corresponding to the message to be sent to the MAC corresponding to the destination IP, i.e. the modified source MAC is 00:00:00:00:00:03, modified destination MAC is 00:00:00:00:01:02.
step S340: and modifying the message information of the message to be sent according to a second matching rule in the hardware flow table to obtain the modified message to be sent, wherein the first matching rule is a rule for determining that the message to be sent is matched with the hardware flow table, and the second matching rule is a rule for modifying the message to be sent by the first network card.
Step S350: judging whether the modified message to be sent belongs to the cross-card flow or not, and if so, executing a step S360; if not, step S370 is performed.
Step S360: if the modified message to be sent belongs to the cross-card flow, the modified message to be sent is sent to a message forwarding module, so that the message forwarding module sends the modified message to be sent to a second network card according to a preset interface, wherein the message forwarding module is a software module outside the first network card and the second network card, and the preset interface is an interface of the second network card.
Step S370: and if the modified message to be sent does not belong to the cross-card flow, sending the modified message to be sent to a preset output interface of the first network card.
The specific explanation of step S340 to step S370 in the above embodiment can be referred to, so that the details are not repeated in this embodiment.
The message forwarding method provided by the embodiment of the application is applied to a first network card, firstly, judging whether a hardware flow table matched with a message to be sent exists after the message to be sent is acquired, if the hardware flow table matched with the message to be sent does not exist, sending the message to be sent to a message forwarding module, modifying message information of the message to be sent by the message forwarding module under the condition that a preset condition is not met, and sending the modified message to be sent to a second network card; if so, modifying the message to be sent according to a second matching rule, judging whether the modified message to be sent belongs to the cross-card flow, if so, sending the modified message to be sent to a message forwarding module, and directly sending the modified message to be sent to a second network card by the message forwarding module according to a preset interface; if not, the modified message to be sent is sent to a preset interface in the first network card. According to the method, after the hardware flow table matched with the message to be sent is determined, the message to be sent is modified according to the hardware flow table, the message to be sent is determined to belong to the cross-card flow, and the modified message to be sent is sent to the second network card through the message forwarding module, so that the problem that CPU consumption is excessive during software processing is solved, and the resource utilization rate is improved.
Referring to fig. 7, an embodiment of the present application provides a method for forwarding a message, which is applied to a first network card, and the method includes:
step S410: and obtaining the message to be sent.
Step S410 may be specifically explained with reference to the above embodiments, so that details are not repeated in this embodiment.
Step S420: if the hardware flow table matched with the message to be sent does not exist, the message to be sent is sent to a message forwarding module, so that the message forwarding module sends the message to be sent to a target network card corresponding to a preset outlet interface according to the preset outlet interface under the condition that the message information to be sent meets the preset condition.
In this embodiment of the present application, the preset condition is that it is determined that a cross-card flag does not exist in a message to be sent, and a software flow table matched with the message to be sent does not exist in a message forwarding module. When the hardware flow table matched with the message to be sent does not exist, the first network card is determined to receive the message to be sent for the first time, and the first network card is not established in the hardware flow table matched with the message to be sent. And after the first network card receives the message to be sent, inquiring whether a hardware flow table matched with the received message to be sent exists in a memory in the hardware chip or not, if so, determining that the hardware flow table matched with the message to be sent is not inquired in the memory, judging that the message to be sent meets the preset condition, after determining a preset output interface corresponding to the message to be sent, sending the message to be sent to a target network card corresponding to the preset output interface according to the preset output interface, and creating an original hardware flow table, wherein the original hardware flow table does not comprise any data. If the preset interface is determined to be positioned in the first network card, the target network card is the first network card; if the preset interface is determined to be positioned in the second network card, the target network card is the second network card.
The message forwarding method is applied to a first network card, and when the fact that a hardware flow table matched with a received message to be sent does not exist is determined, the message to be sent is sent to a message forwarding module, and when the fact that the message to be sent meets preset conditions is determined, the message forwarding module sends the message to be sent to a target network card corresponding to a preset output interface. And under the condition that a hardware flow table matched with the message to be sent does not exist, the message forwarding module determines a preset interface, so that the message to be sent can be successfully sent to the second network card.
Referring to fig. 8, an embodiment of the present application provides a method for forwarding a message, which is applied to a message forwarding module, and the method includes:
step S510: and receiving a modified message to be sent, which is sent by the first network card, wherein the modified message to be sent is obtained by modifying the message to be sent by the first network card based on a hardware flow table matched with the message to be sent.
In this embodiment of the present application, when the first network card modifies a to-be-transmitted packet according to a hardware flow table that matches the to-be-transmitted packet, after obtaining a modified to-be-transmitted packet, the modified to-be-transmitted packet is reported to the packet forwarding module, and the packet forwarding module receives the modified to-be-transmitted packet.
Step S520: and if the modified message to be sent has the cross-card mark, sending the modified message to be sent to the second network card through a preset interface.
In the embodiment of the application, when the first network card determines that the preset interface corresponding to the modified message to be sent is located in the second network card according to the hardware flow table, a cross-card mark is added to the modified message to be sent; if the preset interface corresponding to the modified message to be sent is determined to be positioned on the second network card, a cross-card mark is not added for the modified message to be sent. If the modified message to be sent has the cross-card mark, the preset interface is determined to be positioned in the second network card, so that the modified message to be sent is directly sent to the second network card through the preset interface, the processing time of the message forwarding module to the message is reduced, and the consumption of a CPU is reduced.
The message forwarding method is applied to a message forwarding module, and is used for receiving a modified message to be sent, which is sent by a first network card, wherein the modified message to be sent is obtained by modifying the message to be sent based on a hardware flow table matched with the message to be sent by the first network card, and if the modified message to be sent is determined to have a cross-card mark, the modified message to be sent is sent to a second network card through a preset output interface. According to the method, the message forwarding module directly sends the received modified message to be sent to the second network card according to the preset interface, so that the problem of overlarge CPU consumption during software processing is solved, and the resource utilization rate is improved.
Referring to fig. 9, an embodiment of the present application provides a method for forwarding a message, which is applied to a message forwarding module, and the method includes:
step S610: and receiving a message to be transmitted, wherein the message to be transmitted is transmitted after the first network card determines that a hardware flow table matched with the message to be transmitted does not exist.
In the embodiment of the application, after the first network card determines that the hardware flow table matched with the message to be sent does not exist, the message to be sent is sent to the message forwarding module, so that the message forwarding module receives the message to be sent.
Step S620: and if the message to be sent meets the preset condition, performing data operation on the message to be sent to obtain the operated message to be sent.
Step S630: if it is determined that the message forwarding mark does not exist in the operated message to be sent, the operated message to be sent is issued to the first network card, so that the first network card updates an original hardware flow table based on the operated message to be sent to obtain a hardware flow table, wherein the message forwarding mark represents a mark set after forwarding the message in the message flow to which the message to be sent belongs.
In the embodiment of the application, if the message forwarding module determines that the message forwarding mark does not exist in the message to be forwarded after the operation, it is determined that the message to be sent included in the message to be sent after the operation is the first message in the message flow to which the message to be sent belongs, and the message to be sent after the operation is issued to the first network card. After the first network card receives the operated message to be sent, updating the original hardware flow table according to the operated message to be sent, thereby obtaining the hardware flow table. The original hardware flow table is a flow table which is created for the network card and does not comprise a matching rule.
Step S640: and sending the message to be sent after the operation to a target network card corresponding to the preset interface through the preset interface.
In the embodiment of the application, when data operation is performed, a preset interface corresponding to the message to be sent after the operation can be determined, so that the message forwarding module issues the message to be sent after the operation to a target network card corresponding to the preset interface through the determined preset interface.
The message forwarding method provided by the embodiment of the invention is applied to a message forwarding module, and is used for receiving a message to be sent first, determining that a hardware flow table matched with the message to be sent does not exist for a first network card, sending the message to be sent, if the message to be sent is determined to meet a preset condition, performing data operation on the message to be sent to obtain the message to be sent after operation, if no message forwarding mark exists in the message to be sent after operation, sending the message to be sent after operation to the first network card, so that the first network card updates an original hardware flow table based on the message to be sent after operation to obtain the hardware flow table, wherein the message forwarding mark represents a mark set after forwarding the message in message flow of the message to be sent, then sending the message to be sent after operation to a target corresponding to the preset output interface through the preset output interface, and enabling the forwarding speed of the message to be sent to be accelerated when the subsequent processing is performed through the method.
Referring to fig. 10, an embodiment of the present application provides a method for forwarding a message, which is applied to a message forwarding module, and includes:
step S710: and receiving a message to be transmitted, wherein the message to be transmitted is transmitted after the first network card determines that a hardware flow table matched with the message to be transmitted does not exist.
Step S720: if the fact that the cross-card mark does not exist in the message to be sent and the software flow table matched with the message to be sent does not exist, the fact that the message to be sent meets the preset condition is determined.
In this embodiment of the present application, the software flow table is session control information in the packet forwarding module, where the session control information in the packet forwarding module includes packet matching information that matches a packet to be sent. After receiving the message to be sent, checking whether a message header of the received message to be sent comprises a cross-card mark, if the message header of the message to be sent is determined to not comprise the cross-card mark, checking whether a software flow table matched with the message to be sent exists in a software flow table included in a memory of a message forwarding module, and if the software flow table matched with the message to be sent does not exist in the memory of the message forwarding module at the same time, determining that the message to be sent meets a preset condition.
As a way, each time the message forwarding module creates a software flow table, the created software flow table is sequentially stored into the memory of the message forwarding module according to the creation time, so as to obtain a software flow table queue. When the message forwarding module matches the software flow table of the message to be sent, the message to be sent is matched in sequence according to a plurality of software flow tables in the software flow table queue until the message to be sent is successfully matched or until no matched software flow table exists in the software flow table queue after the inquiry is completed.
Step S730: and carrying out slow path processing on the message to be sent, wherein the slow path processing is to create an original software flow table based on the message information, and determine a preset interface corresponding to the message to be sent, and the software flow table is stored in a memory of the message forwarding module.
In the embodiment of the application, after determining that the received message to be sent meets the preset condition, starting to perform data operation processing on the message to be sent, wherein the data operation includes slow path processing and fast path processing. And firstly, carrying out slow path processing on the received message to be sent to obtain the message to be sent after the slow path processing.
When the slow path processing is carried out on the message to be sent, an original software flow table is firstly established according to the message information corresponding to the message to be sent, and meanwhile, the position of a preset interface corresponding to the message to be sent is determined in a route inquiring mode.
For example, if it is determined that the message quintuple information included in the message information of the message to be sent is the source IP:1.1.1.1, destination IP:3.3.3.3, source port: 80, destination port: 80, protocol number: and 6, creating a field included in a first matching rule in the original software flow table according to the message quintuple information corresponding to the message to be sent, for example, creating a matching source IP field according to a source IP, creating a matching destination IP field according to a destination IP, creating a matching source port field according to a source port, creating a matching destination port field according to a destination port, creating a matching protocol number field according to a protocol number, wherein the matching source IP field is 1.1.1.1, the matching destination IP field is 3.3.3, the matching source port field is 80, the matching destination port field is 80, the matching protocol number field is 6, and taking the matching source IP field, the matching destination IP field, the matching source address field, the matching destination address field and the matching protocol number field which are created according to the message quintuple information as the first matching rule in the original software flow table, and determining that the original software flow table is created.
Step S740: and performing fast path processing on the message to be sent after the slow path processing to obtain the message to be sent after the operation, wherein the fast path processing is to modify the message to be sent after the slow path processing according to configuration information corresponding to network equipment, and update the original software flow table based on the modified message to be sent after the slow path processing to obtain the software flow table.
In this embodiment of the present application, the message to be sent after the slow path processing includes the message to be sent, a software flow table, and related information of a preset interface. After the slow path processing is carried out on the message to be sent, the fast path processing is carried out on the message to be sent after the slow path processing, so that the message to be sent after the operation is obtained.
In the fast path processing of the message to be sent after the slow path processing, configuration information in a message forwarding module is acquired, the message to be sent in the message to be sent after the slow path processing is modified according to the acquired configuration information, the modified message to be sent is obtained, the original software flow table is updated according to the modified message to be sent, and the modified content is added into the original software flow table as a second matching rule, so that the software flow table is obtained.
Step S750: and if the fact that the message forwarding mark does not exist in the message to be sent after the operation is determined, extracting a first matching rule and a second matching rule which are included in a software flow table, wherein the software flow table is located in the message to be sent after the operation, and the first matching rule and the second matching rule are determined based on the data operation.
In this embodiment of the present application, the message to be sent after the operation includes the modified message to be sent, the software flow table, and the related information of the preset interface. After finishing data operation of the message to be sent, checking whether a message forwarding mark exists in a software flow table included in the operated message to be sent. If the message forwarding mark does not exist in the software flow table, the modified message to be sent is determined to be the first message in the message to be sent, namely, the message in the message to be sent does not exist before the modified message to be sent and is forwarded to the second network card. And after determining that the message forwarding mark does not exist, extracting a first matching rule and a second matching rule included in the software flow table.
As a way, if the modified message to be forwarded is the first message of the message to be sent, when forwarding the modified message to be sent, there is no message forwarding flag corresponding to the modified message to be sent in the software flow table matched with the modified message to be sent. And when the message forwarding module forwards the subsequent message of the first message in the message to be sent, the message forwarding mark can be judged to exist in the software flow table, so that the subsequent message can be directly forwarded to the second network card through the preset interface.
Step S760: and issuing the extracted first matching rule and the second matching rule to the first network card so that the first network card updates the original hardware flow table based on the first matching rule and the second matching rule to obtain the hardware flow table.
In the embodiment of the application, the message forwarding module issues the extracted first matching rule and second matching rule to the first network card, and the first network card updates the pre-created original hardware flow table according to the received first matching rule and second matching rule, so as to obtain a hardware flow table, so that the hardware flow table comprises the first matching rule and the second matching rule received by the first network card.
For example, the first matching rule received by the first network card is that the matching source IP field is 1.1.1.1, the matching destination IP field is 3.3.3.3, the matching source port field is 80, the matching destination port field is 80, the matching protocol number field is 6, and the second matching rule is that the modification source MAC 00:00:00:00:00:03, modified destination MAC 00:00:00:00:01: and 02, the first network card transmits the received first matching rule and the second matching rule to the original hardware flow table, so that a hardware flow table is obtained, and the hardware flow table also comprises the first matching rule and the second matching rule received by the first network card.
Step S770: and sending the message to be sent after the operation to a target network card corresponding to the preset interface through the preset interface.
Step S770 may be specifically explained with reference to the above embodiments, and thus will not be described in detail in this embodiment.
For example, as shown in fig. 11, in step S710 to step S770, after the first interface of the first network card receives the message to be sent, it is determined that the hardware flow table matched with the message to be sent does not exist in the hardware chip, and then the message to be sent is sent to the message forwarding module. When the message forwarding module receives a message to be sent by a first network card, judging that a cross-card mark does not exist, and a software flow table matched with the message to be sent does not exist, firstly carrying out slow path processing on the message to be sent, then carrying out fast path processing on the message to be sent after the slow path processing, thus obtaining the message to be sent after operation, determining that a preset output interface is a third interface in a second network card, then determining that the message to be sent after operation does not exist, extracting the first matching rule and the second matching rule included in the message to be sent after operation, sending the extracted first matching rule and second matching rule into the first network card, determining a hardware flow table by the first network card according to the received first matching rule and second matching rule, and finally sending the message to be sent after operation into the second network card according to the preset output interface.
The method for forwarding the message is applied to a message forwarding module, determines that a cross-card mark does not exist in a received message to be sent, meanwhile, does not exist a matched software flow table, carries out slow path processing and fast path processing on the message to be sent, and accordingly obtains the message to be sent after operation, if the fact that the message forwarding mark does not exist in the message to be sent after operation is determined, extracts a first matching rule and a second matching rule in the software flow table included in the message to be sent after operation, and sends the first matching rule and the second matching rule to a first network card, so that the first network card obtains a hardware flow table according to the fact that the first matching rule and the second matching rule are received, meanwhile, the message to be sent after operation is sent to a target network card corresponding to a preset interface by the message forwarding module, and the software flow table and the hardware flow table are determined, and forwarding speed can be accelerated when the message to be sent subsequently is forwarded.
Referring to fig. 12, an embodiment of the present application provides a message forwarding apparatus 800, which operates on a first network card, where the apparatus 800 includes:
the to-be-transmitted message obtaining unit 810 is configured to obtain a to-be-transmitted message.
And the message to be sent modifying unit 820 is configured to modify the message to be sent based on the hardware flow table if it is determined that there is a hardware flow table matched with the message to be sent, so as to obtain a modified message to be sent, where the hardware flow table is stored in a hardware chip of the first network card.
As one way, the message modification unit 820 is further configured to determine that a hardware flow table matching the message to be sent exists if it is determined that the message information of the message to be sent matches the first matching rule in the hardware flow table; and modifying the message information of the message to be sent according to a second matching rule in the hardware flow table to obtain the modified message to be sent, wherein the first matching rule is a rule for determining that the message to be sent is matched with the hardware flow table, and the second matching rule is a rule for modifying the message to be sent by the first network card.
Optionally, the to-be-sent message modifying unit 820 is further configured to send the to-be-sent message to a message forwarding module if it is determined that there is no hardware flow table matched with the to-be-sent message, so that the message forwarding module modifies, according to configuration information corresponding to a network device, message information corresponding to the to-be-sent message to obtain a modified to-be-sent message, and sends, according to the preset interface, the modified to-be-sent message to the second network card, where the network device is a device including the first network card and the second network card.
Optionally, the to-be-sent message modifying unit 820 is further configured to send the to-be-sent message to a message forwarding module if it is determined that the hardware flow table matched with the to-be-sent message does not exist, so that the message forwarding module sends the to-be-sent message to a target network card corresponding to the preset output interface according to the preset output interface when it is determined that the to-be-sent message information meets the preset condition.
And a to-be-sent message sending unit 830, configured to send the modified to-be-sent message to a message forwarding module if it is determined that the modified to-be-sent message belongs to a cross-card flow, so that the message forwarding module sends the modified to-be-sent message to a second network card according to a preset output interface, where the message forwarding module is a software module other than the first network card and the second network card, and the preset output interface is an interface of the second network card.
As a way, the to-be-sent message sending unit 830 is further configured to send the modified to-be-sent message to a preset output interface of the first network card if it is determined that the modified to-be-sent message does not belong to the cross-card traffic.
Referring to fig. 13, an embodiment of the present application provides a packet forwarding device 900, which is operated in a packet forwarding module, where the device 900 includes:
The to-be-transmitted message receiving unit 910 is configured to receive a modified to-be-transmitted message sent by the first network card, where the modified to-be-transmitted message is obtained by modifying the to-be-transmitted message by the first network card based on a hardware flow table matched with the to-be-transmitted message.
As a way, the to-be-sent message receiving unit 910 is further configured to receive a to-be-sent message, where the to-be-sent message is sent after determining, for the first network card, that there is no hardware flow table matching with the to-be-sent message.
And the message to be sent forwarding unit 920 is configured to send the modified message to be sent to the second network card through a preset interface if it is determined that the modified message to be sent has a cross-card tag.
As a way, the to-be-sent message forwarding unit 920 is further configured to perform data operation on the to-be-sent message if it is determined that the to-be-sent message meets a preset condition, so as to obtain an operated to-be-sent message; if no message forwarding mark exists in the operated message to be sent, the operated message to be sent is issued to the first network card, so that the first network card updates an original hardware flow table based on the operated message to be sent to obtain a hardware flow table, wherein the message forwarding mark represents a mark which is set after forwarding the message in the message flow to which the message to be sent belongs; and sending the message to be sent after the operation to a target network card corresponding to the preset interface through the preset interface.
Optionally, the message forwarding unit 920 to be sent is further configured to determine that the message to be sent meets a preset condition if it is determined that the message to be sent does not have a cross-card tag and there is no software flow table matched with the message to be sent; carrying out slow path processing on the message to be sent, wherein the slow path processing is to create an original software flow table based on the message information, and determine a preset interface corresponding to the message to be sent, and the software flow table is stored in a memory of the message forwarding module; and performing fast path processing on the message to be sent after the slow path processing to obtain the message to be sent after the operation, wherein the fast path processing is to modify the message to be sent after the slow path processing according to configuration information corresponding to network equipment, and update the original software flow table based on the modified message to be sent after the slow path processing to obtain the software flow table.
Optionally, the message forwarding unit 920 to be sent is further configured to extract a first matching rule and a second matching rule included in a software flow table if it is determined that the message forwarding flag does not exist in the operated message to be sent, where the software flow table is located in the operated message to be sent, and the first matching rule and the second matching rule are determined based on the data operation; and issuing the extracted first matching rule and the second matching rule to the first network card so that the first network card updates the original hardware flow table based on the first matching rule and the second matching rule to obtain the hardware flow table.
It should be noted that, in the present application, the device embodiment and the foregoing method embodiment correspond to each other, and specific principles in the device embodiment may refer to the content in the foregoing method embodiment, which is not described herein again.
An electronic device provided in the present application will be described with reference to fig. 14.
Referring to fig. 14, based on the above-mentioned data processing method and apparatus, another electronic device 1000 capable of executing the foregoing data processing method is provided in the embodiments of the present application. The electronic device 1000 includes one or more (only one shown) processors 1002, memory 1004, and a network module 1006 coupled to each other. The memory 1004 stores therein a program capable of executing the contents of the foregoing embodiments, and the processor 1002 can execute the program stored in the memory 1004.
Wherein the processor 1002 may include one or more processing cores. The processor 1002 utilizes various interfaces and lines to connect various portions of the overall electronic device 1000, perform various functions of the server 1000, and process data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 1004, and invoking data stored in the memory 1004. Alternatively, the processor 1002 may be implemented in hardware in at least one of Digital signal processing (Digital SignalProcessing, DSP), field-programmable gate array (Field-Programmable Gate Array, FPGA), programmable logic array (Programmable Logic Array, PLA). The processor 1002 may integrate one or a combination of several of a central processing unit (Central Processing Unit, CPU), an image processor (Graphics Processing Unit, GPU), and a modem, etc. The CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for being responsible for rendering and drawing of display content; the modem is used to handle wireless communications. It will be appreciated that the modem may not be integrated into the processor 1002 and may be implemented solely by a single communication chip.
The Memory 1004 may include a random access Memory (Random Access Memory, RAM) or a Read-Only Memory (Read-Only Memory). Memory 1004 may be used to store instructions, programs, code, sets of codes, or instruction sets. The memory 1004 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described below, etc. The storage data area may also store data created by the electronic device 1000 in use (e.g., phonebook, audiovisual data, chat log data), and the like.
The network module 1006 is configured to receive and transmit electromagnetic waves, and implement mutual conversion between the electromagnetic waves and the electrical signals, so as to communicate with a communication network or other devices, such as an audio playback device. The network module 1006 may include various existing circuit elements for performing these functions, such as an antenna, a radio frequency transceiver, a digital signal processor, an encryption/decryption chip, a Subscriber Identity Module (SIM) card, memory, and the like. The network module 1006 may communicate with various networks such as the internet, intranets, wireless networks, or other devices via wireless networks. The wireless network may include a cellular telephone network, a wireless local area network, or a metropolitan area network. For example, the network module 1006 may interact with base stations.
Referring to fig. 15, a block diagram of a computer readable storage medium according to an embodiment of the present application is shown. The computer readable medium 1100 has stored therein program code that can be invoked by a processor to perform the methods described in the method embodiments above.
The computer readable storage medium 1100 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. Optionally, computer readable storage medium 1100 includes non-volatile computer readable medium (non-transitory computer-readable storage medium). The computer readable storage medium 1100 has storage space for program code 1110 that performs any of the method steps described above. The program code can be read from or written to one or more computer program products. Program code 1110 may be compressed, for example, in a suitable form.
The embodiment of the application provides a message forwarding method, a message forwarding device, electronic equipment and a storage medium. The message forwarding method comprises the following steps: acquiring a message to be sent; if the hardware flow table matched with the message to be sent is determined to exist, modifying the message to be sent based on the hardware flow table to obtain a modified message to be sent; if the modified message to be sent belongs to the cross-card flow, the modified message to be sent is sent to the message forwarding module, so that the message forwarding module sends the modified message to be sent to the second network card according to a preset outlet interface, and the preset outlet interface is an interface of the second network card. After the modified message to be sent belongs to the cross-card flow, the message forwarding module sends the modified message to be sent to the preset interface, so that the message forwarding module is prevented from carrying out excessive processing on the modified message, the problem of excessive CPU consumption during software processing is solved, and the resource utilization rate is improved.
The embodiments of the present invention have been described above with reference to the accompanying drawings, but the present invention is not limited to the above-described embodiments, which are merely illustrative and not restrictive, and many forms may be made by those having ordinary skill in the art without departing from the spirit of the present invention and the scope of the claims, which are to be protected by the present invention.

Claims (12)

1. The message forwarding method is characterized by being applied to a first network card, and comprises the following steps:
acquiring a message to be sent;
if the hardware flow table matched with the message to be sent is determined to exist, modifying the message to be sent based on the hardware flow table to obtain a modified message to be sent, wherein the hardware flow table is stored in a hardware chip of the first network card;
if the modified message to be sent belongs to the cross-card flow, the modified message to be sent is sent to a message forwarding module, so that the message forwarding module sends the modified message to be sent to a second network card according to a preset interface, wherein the message forwarding module is a software module outside the first network card and the second network card, and the preset interface is an interface of the second network card.
2. The method of claim 1, wherein if it is determined that there is a hardware flow table matching the to-be-sent message, modifying the to-be-sent message based on the hardware flow table to obtain a modified to-be-sent message, including:
if the message information of the message to be sent is determined to be matched with the first matching rule in the hardware flow table, determining that a hardware flow table matched with the message to be sent exists;
and modifying the message information of the message to be sent according to a second matching rule in the hardware flow table to obtain the modified message to be sent, wherein the first matching rule is a rule for determining that the message to be sent is matched with the hardware flow table, and the second matching rule is a rule for modifying the message to be sent by the first network card.
3. The method according to claim 1, wherein the method further comprises:
and if the modified message to be sent does not belong to the cross-card flow, sending the modified message to be sent to a preset output interface of the first network card.
4. The method according to claim 1, wherein the method further comprises:
if it is determined that the hardware flow table matched with the message to be sent does not exist, the message to be sent is sent to a message forwarding module, so that the message forwarding module modifies the message information corresponding to the message to be sent according to configuration information corresponding to network equipment under the condition that the message information to be sent does not meet a preset condition, the modified message to be sent is obtained, and the modified message to be sent is sent to the second network card according to the preset interface, wherein the network equipment is equipment comprising the first network card and the second network card.
5. The method according to claim 1, wherein the method further comprises:
if the hardware flow table matched with the message to be sent does not exist, the message to be sent is sent to a message forwarding module, so that the message forwarding module sends the message to be sent to a target network card corresponding to a preset outlet interface according to the preset outlet interface under the condition that the message information to be sent meets the preset condition.
6. A message forwarding method, applied to a message forwarding module, the method comprising:
receiving a modified message to be sent, which is sent by a first network card, wherein the modified message to be sent is obtained by modifying the message to be sent by the first network card based on a hardware flow table matched with the message to be sent;
and if the modified message to be sent has the cross-card mark, sending the modified message to be sent to the second network card through a preset interface.
7. The method of claim 6, wherein the method further comprises:
receiving a message to be transmitted, wherein the message to be transmitted is transmitted after the first network card determines that a hardware flow table matched with the message to be transmitted does not exist;
If the message to be sent meets the preset condition, performing data operation on the message to be sent to obtain the operated message to be sent;
if no message forwarding mark exists in the operated message to be sent, the operated message to be sent is issued to the first network card, so that the first network card updates an original hardware flow table based on the operated message to be sent to obtain a hardware flow table, wherein the message forwarding mark represents a mark which is set after forwarding the message in the message flow to which the message to be sent belongs;
and sending the message to be sent after the operation to a target network card corresponding to the preset interface through the preset interface.
8. The method of claim 7, wherein if the message to be sent is determined to meet the preset condition, performing a data operation on the message to be sent to obtain the operated message to be sent, including:
if the fact that the cross-card mark does not exist in the message to be sent and a software flow table matched with the message to be sent does not exist, determining that the message to be sent meets a preset condition;
carrying out slow path processing on the message to be sent, wherein the slow path processing is to create an original software flow table based on the message information, and determine a preset interface corresponding to the message to be sent, and the software flow table is stored in a memory of the message forwarding module;
And performing fast path processing on the message to be sent after the slow path processing to obtain the message to be sent after the operation, wherein the fast path processing is to modify the message to be sent after the slow path processing according to configuration information corresponding to network equipment, and update the original software flow table based on the modified message to be sent after the slow path processing to obtain the software flow table.
9. The method of claim 7, wherein if it is determined that the message forwarding flag does not exist in the operated message to be sent, sending the operated message to be sent to the first network card, so that the first network card updates an original hardware flow table based on the operated message to be sent to obtain the hardware flow table, including:
if the fact that the message forwarding mark does not exist in the message to be sent after the operation is determined, extracting a first matching rule and a second matching rule which are included in a software flow table, wherein the software flow table is located in the message to be sent after the operation, and the first matching rule and the second matching rule are determined based on the data operation;
and issuing the extracted first matching rule and the second matching rule to the first network card so that the first network card updates the original hardware flow table based on the first matching rule and the second matching rule to obtain the hardware flow table.
10. A message forwarding device, operating on a first network card, the device comprising:
the message to be sent obtaining unit is used for obtaining the message to be sent;
the message to be sent modifying unit is used for modifying the message to be sent based on the hardware flow table if the hardware flow table matched with the message to be sent exists, so as to obtain a modified message to be sent, wherein the hardware flow table is stored in a hardware chip of the first network card;
and the message to be sent sending unit is used for sending the modified message to be sent to the message forwarding module if the modified message to be sent belongs to the cross-card flow, so that the message forwarding module sends the modified message to be sent to the second network card according to a preset outlet interface, wherein the message forwarding module is a software module outside the first network card and the second network card, and the preset outlet interface is an interface of the second network card.
11. An electronic device comprising one or more processors and a memory, one or more programs stored in the memory and configured to perform the method of any of claims 1-9 by the one or more processors.
12. A computer readable storage medium, characterized in that the computer readable storage medium stores a program code comprising instructions for performing the method of any of claims 1-9.
CN202311428333.XA 2023-10-27 2023-10-27 Message forwarding method and device, electronic equipment and storage medium Pending CN117527687A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311428333.XA CN117527687A (en) 2023-10-27 2023-10-27 Message forwarding method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311428333.XA CN117527687A (en) 2023-10-27 2023-10-27 Message forwarding method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117527687A true CN117527687A (en) 2024-02-06

Family

ID=89748664

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311428333.XA Pending CN117527687A (en) 2023-10-27 2023-10-27 Message forwarding method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117527687A (en)

Similar Documents

Publication Publication Date Title
CN111193653B (en) Data transmission method, device, equipment and storage medium
CN104967596A (en) Method and apparatus for realizing binding and communication between user terminal and Internet of things device
CN111830844B (en) Intelligent equipment control method and device and intelligent home control panel
CN109714716B (en) Data packet forwarding method and device and mobile terminal
CN104751833A (en) Intelligent music beat interaction equipment
CN115039392A (en) Message processing method, device and system and server
WO2023020253A1 (en) Data acquisition method and apparatus, electronic device, and storage medium
CN114650520A (en) Method and device for realizing wireless network connection based on standard Bluetooth broadcast
CN114285906B (en) Message processing method and device, electronic equipment and storage medium
CN111338710A (en) Application program control method and device, electronic equipment and storage medium
CN108093390A (en) A kind of smart machine of feature based information finds method
CN111813529B (en) Data processing method, device, electronic equipment and storage medium
CN111245702B (en) Data transmission method and device based on 5GS, forwarding equipment and UPF communication equipment
CN110708293B (en) Method and device for distributing multimedia service
CN117527687A (en) Message forwarding method and device, electronic equipment and storage medium
CN112040057B (en) Device control method, device, electronic device, control system and storage medium
WO2017032110A1 (en) Application message processing system and method, and application device
US20220322199A1 (en) Electronic device transmitting and/or receiving packet through network slice and method for operating the same
CN103916837B (en) Data receiving-transmitting method and intelligent terminal
WO2022262445A1 (en) Method and apparatus for acquiring positioning information, electronic device, and storage medium
CN109766347B (en) Data updating method, device, system, computer equipment and storage medium
CN114024898B (en) Message transmission method, device, equipment and storage medium
WO2018059509A1 (en) Channel searching method and system for television terminal
CN114584615A (en) Cloud service collaborative interaction method, device and equipment
CN113596827A (en) Key generation method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination