WO2018121373A1 - 基于操作系统内核网桥的数据转发方法和装置 - Google Patents

基于操作系统内核网桥的数据转发方法和装置 Download PDF

Info

Publication number
WO2018121373A1
WO2018121373A1 PCT/CN2017/117415 CN2017117415W WO2018121373A1 WO 2018121373 A1 WO2018121373 A1 WO 2018121373A1 CN 2017117415 W CN2017117415 W CN 2017117415W WO 2018121373 A1 WO2018121373 A1 WO 2018121373A1
Authority
WO
WIPO (PCT)
Prior art keywords
data packet
network card
address
port
forwarding
Prior art date
Application number
PCT/CN2017/117415
Other languages
English (en)
French (fr)
Inventor
韩健
Original Assignee
腾讯科技(深圳)有限公司
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 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2018121373A1 publication Critical patent/WO2018121373A1/zh
Priority to US16/351,322 priority Critical patent/US11201760B2/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4535Network directories; Name-to-address mapping using an address exchange platform which sets up a session between two nodes, e.g. rendezvous servers, session initiation protocols [SIP] registrars or H.323 gatekeepers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/46Interconnection of networks
    • H04L12/4604LAN interconnection over a backbone network, e.g. Internet, Frame Relay
    • H04L12/462LAN interconnection over a bridge based backbone
    • H04L12/4625Single bridge functionality, e.g. connection of two networks over a single bridge
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/46Interconnection of networks
    • H04L12/4604LAN interconnection over a backbone network, e.g. Internet, Frame Relay
    • H04L12/462LAN interconnection over a bridge based backbone
    • 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
    • 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/742Route cache; Operation thereof
    • 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
    • H04L49/00Packet switching elements
    • H04L49/30Peripheral units, e.g. input or output ports
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/58Caching of addresses or names

Definitions

  • the present application relates to the field of computer technologies, and in particular, to a data forwarding method and apparatus based on an operating system kernel bridge.
  • a bridge is a Layer 2 network device used to connect different network segments. It has several ports, and several hosts connected to these ports can communicate with each other through packet forwarding of the bridge. The bridge forwards or discards the received message. It only requires one switch chip and does not require a processor.
  • the machine running the Linux kernel itself has a processor that can be bridged through a virtual bridge device.
  • the process of forwarding data by the Linux kernel bridge is: the processor extracts the network data packet from the network card cache of the network card 1 through the network card driver of the network card 1, and then the processor transmits the network data packet through the network card driver of the network card 1
  • the Linux kernel bridge subsystem queries the address forwarding table to determine the outgoing port of the network data packet, and sends the network data packet from the outgoing port through the network card driver of the network card 2 corresponding to the outgoing port.
  • the embodiment of the present application provides a data forwarding method and device based on an operating system kernel bridge, which can improve data forwarding performance of an operating system kernel bridge.
  • the embodiment of the present application provides a data forwarding method based on an operating system kernel bridge, including:
  • the processor of the data forwarding device executes the network card driver corresponding to the first port to read the data to be forwarded from the network card cache corresponding to the first port.
  • a packet wherein the network card cache stores address forwarding information obtained from an operating system kernel bridge;
  • the processor performs a network card driver corresponding to the first port to search for address forwarding information corresponding to the data packet in the cached address forwarding information;
  • the processor Transmitting the data packet to the target network card driver, the processor executing the target network card driver to forward the data packet through the second port.
  • the embodiment of the present application further provides a data forwarding device, including:
  • processor a memory coupled to the processor, a first port, and a second port; the memory having machine readable instruction units executable by the processor; the machine readable instruction unit comprising:
  • a reading unit configured to: when the first port of the data forwarding device receives the data packet to be forwarded, read the data packet to be forwarded from the network card cache corresponding to the first port, where the network card cache stores Address forwarding information obtained by the operating system kernel bridge;
  • a searching unit configured to search, in the cached address forwarding information, address forwarding information corresponding to the data packet;
  • a determining unit configured to determine, according to the found address forwarding information, a target network card driver for forwarding the data packet when the address forwarding information corresponding to the data packet is found;
  • a sending unit configured to send the data packet to the target network card driver to forward the data packet through the second port.
  • the embodiment of the present application further provides a non-transitory computer readable storage medium storing machine readable instructions, the machine readable instructions being executable by a processor to perform the following operations:
  • the processor of the data forwarding device executes the network card driver corresponding to the first port to read the data to be forwarded from the network card cache corresponding to the first port.
  • a packet wherein the network card cache stores address forwarding information obtained from an operating system kernel bridge;
  • the processor performs a network card driver corresponding to the first port to search for address forwarding information corresponding to the data packet in the cached address forwarding information;
  • the processor Transmitting the data packet to the target network card driver, the processor executing the target network card driver to forward the data packet through the second port.
  • FIG. 1 is a schematic diagram of a scenario of a data forwarding system according to an embodiment of the present application
  • 1b is a flowchart of a data forwarding method based on an operating system kernel bridge provided by an embodiment of the present application
  • FIG. 2a is a schematic structural diagram of a Linux bridge system provided by an embodiment of the present application.
  • 2b is another flowchart of a data forwarding method based on an operating system kernel bridge provided by an embodiment of the present application
  • FIG. 3 is a schematic structural diagram of a data forwarding device based on an operating system kernel bridge according to an embodiment of the present application
  • FIG. 3b is another schematic structural diagram of a data forwarding device based on an operating system kernel bridge provided by an embodiment of the present application.
  • FIG. 3c is still another schematic structural diagram of a data forwarding device based on an operating system kernel bridge provided by an embodiment of the present application.
  • FIG. 4 is another schematic structural diagram of a data forwarding device based on an operating system kernel bridge provided by an embodiment of the present application.
  • the embodiment of the present application provides a data forwarding method and apparatus based on an operating system kernel bridge.
  • the embodiment of the present application provides a data forwarding system including: an operating system kernel bridge-based data forwarding device provided by any embodiment of the present application.
  • the data forwarding device can be integrated in a server, for example, integrated into a server of a Linux operating system.
  • the data forwarding system includes a server 101, a server 102, and a terminal 103.
  • the server 101 is integrated with an operating system kernel bridge-based data forwarding device 1011 provided by any embodiment of the present application.
  • the server 101 and the server 102 are connected by a network 104, and the server 101 and the terminal 103 are connected by a link 105.
  • the data forwarding device 1011 in the server 101 is configured to execute the first network card driver corresponding to the first port to read the to-be-forwarded from the corresponding network card cache.
  • a data packet wherein the network card cache stores address forwarding information obtained from an operating system kernel bridge. Then, in the cached address forwarding information, the address forwarding information corresponding to the data packet is searched. When the address forwarding information corresponding to the data packet is found, the second port for forwarding the data packet is determined according to the found address forwarding information.
  • the data forwarding device 1011 determines a second network card driver corresponding to the second port, and sends the data packet to the second network card driver, where the second network card driver sends the data packet to the server 102 through the second port or Terminal 103.
  • the server 101 is further configured to convert the signal sent by the server 103 or the terminal 103 into network data through a network card, and store the data in the corresponding network card cache.
  • the data packet to be forwarded is read from the NIC cache, and then the address forwarding information corresponding to the data packet is searched in the cached address forwarding information.
  • the found address forwarding information determines a target network card driver for forwarding the data packet, and directly sends the data packet to the target network card driver, so that the target network card driver forwards the data packet.
  • the solution can send the data packet directly to the target network card driver, and forward the data packet through the target network card driver, without first sending the data packet to the operating system kernel bridge system, and then forwarding by the operating system kernel bridge system. Processing to send data out; therefore, the scheme can improve the data forwarding speed of the operating system kernel bridge, thereby improving the data forwarding performance of the operating system kernel bridge.
  • the data forwarding device may be specifically integrated into a server.
  • the server may be a Linux server.
  • a data forwarding method based on an operating system kernel bridge comprising: a first network card driver reads a data packet to be forwarded from a cache of the first network card, and then searches for an address corresponding to the data packet in the cached address forwarding information. Forwarding information, when the address forwarding information corresponding to the data packet is found, determining an outgoing port of the data packet according to the found address forwarding information, and sending the data packet to a second network card driver corresponding to the outgoing port, that is, the target The NIC driver so that the target NIC driver forwards the packet out through the egress port.
  • the flowchart of the data forwarding method based on the operating system kernel bridge may be specifically implemented by the data forwarding device shown in FIG. 1a, and includes the following operations:
  • the processor of the data forwarding device executes the network card driver corresponding to the first port to read the to-be-forwarded packet from the network card cache corresponding to the first port.
  • the data packet wherein the network card cache stores address forwarding information obtained from an operating system kernel bridge.
  • the network card cache is used to store network data packets forwarded by the network card, and each network card may correspond to one network card cache.
  • the network card may be a physical network card or a virtual network card.
  • the operating system may be a Linux system or another operating system.
  • the method before step S101, further includes: copying address forwarding information of the operating system kernel bridge, and buffering the copied address forwarding information. This facilitates the determination of the address forwarding information of the data packet before the data packet enters the operating system kernel bridge when the subsequent data packet is forwarded.
  • the operating system kernel bridge when the address forwarding information of the operating system kernel bridge changes, the operating system kernel bridge sends the updated address forwarding information to the network card cache.
  • the processor performs a network card driver corresponding to the first port, so as to search for address forwarding information corresponding to the data packet in the cached address forwarding information.
  • the address forwarding (fdb) information is information for forwarding or transmitting data packets, and its main function is for a network device such as a server to forward data packets at the data link layer, and is used to determine which port the data packet is sent to.
  • the address forwarding information mainly includes a correspondence (ie, a mapping relationship) between a MAC (Media Access Control) address and a forwarding port.
  • the address forwarding information may include an address forwarding table, for example, may include a MAC (Media Access Control) address forwarding table; the MAC address may also be referred to as a physical address, a hardware address, or the like.
  • an address forwarding table for example, may include a MAC (Media Access Control) address forwarding table; the MAC address may also be referred to as a physical address, a hardware address, or the like.
  • MAC Media Access Control
  • the address forwarding table includes a mapping relationship between the forwarding address and the forwarding port (port). Specifically, the address forwarding table includes a plurality of address forwarding entries, where the forwarding entry includes the forwarding address and forwarding. Correspondence (map relationship) between ports.
  • the MAC address forwarding table includes a plurality of MAC address forwarding entries, and each entry includes a correspondence between a MAC address and a forwarding port.
  • the address forwarding table can be a Layer 2 forwarding table.
  • the step of: searching for the address forwarding information corresponding to the data packet in the cached address forwarding information may include:
  • the address forwarding entry corresponding to the destination address is searched in the cached address forwarding table according to the destination address.
  • the address forwarding entry corresponding to the destination address may include a correspondence between the destination address and the forwarding port.
  • the destination MAC address corresponding to the data packet can be obtained, and then the address forwarding entry corresponding to the destination MAC address is searched in the MAC address forwarding table according to the destination MAC address, and the address forwarding entry corresponding to the destination MAC address includes the destination. Correspondence between the MAC address and the forwarding port.
  • the step "determine the target network card driver for forwarding the data packet according to the found address forwarding information" including:
  • the NIC driver associated with the forwarding port is determined to be the target NIC driver for forwarding the packet.
  • the address forwarding table includes a plurality of address forwarding entries, and each address forwarding entry includes a correspondence between the forwarding address and the forwarding port;
  • the information includes an address forwarding entry corresponding to the destination address, where the destination address is the destination address of the data packet, that is, the address forwarding entry corresponding to the destination address includes a mapping relationship between the destination address and the forwarding port.
  • the step of searching for the corresponding forwarding port according to the found address forwarding information may include: searching for the corresponding forwarding port according to the found address forwarding entry.
  • the cached address forwarding information includes the MAC address forwarding table
  • the destination MAC address corresponding to the data packet may be obtained, and then the MAC address forwarding table corresponding to the destination MAC address is searched in the MAC address forwarding table according to the destination MAC address. item. After the MAC address forwarding entry corresponding to the destination MAC address is found, the corresponding forwarding port may be searched based on the MAC address forwarding entry.
  • the network card driver associated with the forwarding port may be determined based on the set of port-driven mapping relationships; that is, the step of “using the network card driver associated with the forwarding port as the target network card driver for forwarding the data packet” may include:
  • the port driving mapping set includes a mapping relationship (corresponding relationship) between the forwarding port and the network card driver;
  • the network card driver associated with the forwarding port is used as a target network card driver for forwarding the data packet.
  • the NIC driver is a device driver, which is a device driver. It is a special program that can make the computer central processor-CPU control and use the device, which is equivalent to the hardware interface. The operating system controls the operation of the hardware device through this interface.
  • S104 Send the data packet to the target network card driver, and the processor executes the target network card driver to forward the data packet through the forwarding port.
  • the step of “sending the data packet to the target network card driver corresponding to the destination port” may include:
  • the data packet is sent to the target network card driver through a communication channel with the target network card driver.
  • the method of the embodiment may send the data packet to the kernel bridge system, so that the kernel bridge system sends the data packet.
  • the data packet may be sent to a kernel bridge system (such as the Linux kernel bridge subsystem), and the kernel bridge system starts the learning mode, and according to the learning result, The data packet is sent to the corresponding network card driver so that the network card driver sends the data packet out.
  • a kernel bridge system such as the Linux kernel bridge subsystem
  • the embodiment of the present application reads the data packet to be forwarded from the network card cache, and then searches for the address forwarding information corresponding to the data packet in the cached address forwarding information, and finds the address forwarding corresponding to the data packet.
  • the target network card driver for forwarding the data packet is determined according to the found address forwarding information, and the data packet is directly sent to the target network card driver, so that the target network card driver forwards the data packet.
  • the solution can send the data packet directly to the target network card driver, and forward the data packet through the target network card driver, without first sending the data packet to the operating system kernel bridge system, and then forwarding processing by the subsystem to data Send out; therefore, the scheme can improve the data forwarding speed of the operating system kernel bridge, thereby improving the data forwarding performance of the operating system kernel bridge and saving device resources.
  • a server (referred to as a Linux server) whose operating system is Linux integrated with the data forwarding device will be described as an example.
  • the Linux server may include a Linux bridge system, which may include a processor 210, a memory 220, and network cards 230-1 through 230-n.
  • the memory 220 includes a Linux kernel bridge (the Linux kernel bridge) subsystem 221 and network card drivers 220-1 to 220-n of the network cards 230-1 to 230-n.
  • n is a natural number.
  • kernel bridge As shown in FIG. 2b, a data forwarding method based on an operating system kernel bridge (kernel bridge), the specific process is as follows:
  • S201 The Linux server copies the address forwarding information of the Linux kernel bridge subsystem, and caches the copied address forwarding information.
  • the address forwarding information may include a MAC address forwarding table, where the MAC address forwarding table includes a plurality of MAC address entries, where the entry includes a mapping relationship between the MAC address and the forwarding port.
  • the network card driver 1 can copy the address forwarding information of the Linux kernel bridge subsystem, and cache the copied address forwarding information.
  • the network card 1 receives an electrical signal, converts the electrical signal into network data, and stores the network data in a corresponding network card cache.
  • the network card 1 receives an electrical signal through the network, and then converts the electrical signal into corresponding data to obtain a network data packet.
  • the network card driver 1 reads the network data packet to be forwarded from the network card cache.
  • the network card driver 1 searches for the address forwarding information corresponding to the network data packet from the cached address forwarding information.
  • a function can be inserted in the network card driver 1 for performing steps S204-S208.
  • the network card driver 1 obtains the destination MAC address corresponding to the network data packet, and then searches for the MAC address entry corresponding to the destination MAC address in the cached MAC address forwarding table according to the destination MAC address.
  • step S205 The network card driver 1 determines whether the address forwarding information corresponding to the network data packet is found. If yes, step S206 is performed, and if no, step S210 is performed.
  • nfp_process (uint32_t if_index, struct sk_buff*skb) is used to find the address forwarding information corresponding to the network packet from the address forwarding information, and if it is found, it returns 0, and if it is not found, it returns -1.
  • the network card driver 1 searches for a corresponding forwarding port according to the found address forwarding information.
  • the NIC driver 1 When the NIC driver 1 finds the MAC address entry corresponding to the destination MAC address, it can search for the corresponding forwarding port based on the MAC address entry.
  • nfp_process() is executed, and if nfp_process() returns 0, the fdb information corresponding to the network packet is found.
  • dev_queue_xmit() can be called to forward the packet (steps S206-S208), and tun_netif_rx_ni(skb) is no longer executed, ie the packet is no longer passed to the Linux kernel bridge subsystem.
  • the network card driver 1 determines that the target network card driver associated with the forwarding port is the network card driver 2.
  • the network card driver 1 establishes a communication channel with the network card driver 2, and transmits the network data packet to the network card driver 2 through the communication.
  • the network card driver 2 puts the network data packet into a corresponding network card cache, and the network card 2 converts the network data packet in the network card buffer into an electrical signal for forwarding.
  • the network card driver 1 sends the network data packet to the Linux kernel bridge subsystem.
  • nfp_process() For example, in NIC driver 1, in tun_get_user(), after generating the packet sk_buff, execute nfp_process(). If nfp_process() returns -1, continue to execute tun_netif_rx_ni(skb) to pass the packet to linux kernel bridge. Subsystem.
  • the S211 and the Linux kernel bridge subsystem enable the learning mode, and send network data packets to the corresponding network card driver 3 according to the learning result.
  • the network card driver 3 puts the network data packet into the corresponding network card cache, and the network card 3 converts the network data packet in the network card buffer into an electrical signal for forwarding.
  • the network card driver 1 can execute nfp_process() after generating the data packet sk_buff in tun_get_user(). If nfp_process() returns 0, the fdb information corresponding to the network data packet is found, and dev_queue_xmit() is called. The data packet is forwarded out. At this time, tun_netif_rx_ni(skb) is no longer executed, that is, the data packet is no longer transmitted to the Linux kernel bridge subsystem; if nfp_process() returns -1, the tun_netif_rx_ni(skb) is executed, and the data packet is transmitted. Give the Linux kernel bridge subsystem.
  • the specific code is as follows:
  • the embodiment of the present application can read the data packet to be forwarded from the network card cache, and then search for the address forwarding information corresponding to the data packet in the cached address forwarding information, and find the address forwarding corresponding to the data packet.
  • the information determining the target network card driver for sending the data packet according to the found address forwarding information, and directly forwarding the data packet to the target network card driver, so as to forward the data packet through the target network card driver; when the data packet is not found
  • the data packet is sent to the kernel bridge system to send the data packet through the kernel bridge system.
  • the solution can send a part of the data packet directly to the target network card driver, and forward the data packet through the target network card driver, without first sending the data packet to the Linux kernel bridge subsystem, and then forwarding the data to the data processing by the subsystem. Send out; therefore, the scheme can improve the data forwarding speed of the Linux kernel bridge, thereby improving the data forwarding performance of the Linux kernel bridge and saving the resources of the server.
  • the embodiment of the present application further provides a data forwarding device based on an operating system kernel bridge.
  • the data forwarding device includes: a reading unit 301, a searching unit 302, and a determining unit. 303 and sending unit 304, wherein:
  • the reading unit 301 is configured to: when the first port of the data forwarding device receives the data packet to be forwarded, read the data packet to be forwarded from the network card cache corresponding to the first port, where the network card cache The address forwarding information obtained from the operating system kernel bridge is saved.
  • the network card cache is used to store network data converted by the network card, and each network card can correspond to one network card cache.
  • the operating system may be a Linux system or another operating system.
  • the searching unit 302 is configured to search, in the cached address forwarding information, address forwarding information corresponding to the data packet.
  • the address forwarding (fdb) information is information for forwarding or sending data packets, and its main function is for a network device, such as a server, to forward data packets at the data link layer, and is used to determine which port the data packet is sent to.
  • the address forwarding information mainly includes a correspondence (ie, a mapping relationship) between a MAC (Media Access Control) address and a forwarding port.
  • the searching unit 302 may specifically include:
  • An address obtaining subunit 3021 configured to acquire a destination address corresponding to the data packet
  • the locating unit 3022 is configured to search for the address forwarding information corresponding to the destination address in the cached address forwarding table according to the destination address.
  • the address obtaining sub-unit 3021 may be configured to obtain a destination MAC address corresponding to the data packet, and the searching sub-unit 3022 is configured to search, in the MAC address forwarding table, the address forwarding table corresponding to the destination MAC address according to the destination MAC address. item.
  • the determining unit 303 is configured to determine, according to the found address forwarding information, a target network card driver for forwarding the data packet when the address forwarding information corresponding to the data packet is found.
  • the determining unit 303 may include:
  • the port lookup subunit 3031 is configured to search for a corresponding forwarding port according to the found address forwarding information.
  • the driver determining subunit 3032 is configured to determine a network card driver associated with the forwarding port as a target network card driver for transmitting the data packet.
  • the port lookup subunit 3031 is configured to search for a corresponding forwarding port according to the found MAC address entry.
  • the driver determining subunit 3032 is configured to determine, according to the forwarding port and the port driving mapping set, a network card driver associated with the forwarding port, where the port driving mapping set includes a mapping relationship (corresponding relationship) between the forwarding port and the network card driver. .
  • the NIC driver is a device driver, which is a device driver. It is a special program that can make the computer central processor-CPU control and use the device, which is equivalent to the hardware interface. The operating system controls the operation of the hardware device through this interface.
  • the sending unit 304 is configured to send the data packet to the target network card driver, so that the target network card driver forwards the data packet through the second port.
  • the sending unit 304 may specifically include:
  • a channel establishing subunit 3041 configured to establish a communication channel with the target network card driver
  • the sending subunit 3042 is configured to forward the data packet to the target network card driver through the communication channel.
  • the data forwarding device may further include: a cache unit 305; the cache unit is configured to:
  • the copied address forwarding information is cached.
  • the foregoing units may be implemented as a separate entity, or may be implemented in any combination, and may be implemented as the same or a plurality of entities.
  • the foregoing method embodiments and details are not described herein.
  • the data forwarding device based on the operating system kernel bridge may be integrated into a network device such as a server, and the server may be a Linux server or the like. In practical applications, the data forwarding device can be integrated in the network card driver.
  • FIG. 4 is another schematic structural diagram of a data forwarding device based on an operating system kernel bridge provided by an embodiment of the present application.
  • the data forwarding device includes: a processor 410, a memory 420 connected to the processor 410, a first port 430, and a second port 440; the memory 420 stores therein the processing A machine readable instruction unit executed by the processor 410; the machine readable instruction unit comprising:
  • the reading unit 421 is configured to: when the first port 430 of the data forwarding device receives the data packet, read the data packet to be forwarded from the network card cache corresponding to the first port 430, where the network card cache stores the slave Address forwarding information obtained by the operating system kernel bridge;
  • the searching unit 422 is configured to search, in the cached address forwarding information, address forwarding information corresponding to the data packet.
  • the determining unit 423 is configured to: when the address forwarding information corresponding to the data packet is found, determine, according to the found address forwarding information, a target network card driver used to forward the data packet;
  • the sending unit 424 is configured to send the data packet to the target network card driver to forward the data packet through the second port 440.
  • the specific functions and implementation manners of the foregoing reading unit 421, the searching unit 422, the determining unit 423, and the sending unit 424 are the same as those of the foregoing units 301 to 304, and details are not described herein again.
  • the data forwarding device of the embodiment of the present application reads the data packet to be forwarded from the network card cache by the reading unit 301, and then the search unit 302 searches the cached address forwarding information for the address forwarding information corresponding to the data packet.
  • the determining unit 303 determines the target network card driver for transmitting the data packet according to the found address forwarding information, and the sending unit 304 directly forwards the data to the target network card driver. Packet so that the target NIC driver forwards the packet out.
  • the solution can send the data packet directly to the target network card driver, and forward the data packet through the target network card driver, without first sending the data packet to the operating system kernel bridge system, and then forwarding processing by the subsystem to data Send out; therefore, the scheme can improve the data forwarding speed of the operating system kernel bridge, thereby improving the data forwarding performance of the operating system kernel bridge and saving device resources.
  • the program may be stored in a computer readable storage medium, and the storage medium may include: Read Only Memory (ROM), Random Access Memory (RAM), disk or optical disk.
  • ROM Read Only Memory
  • RAM Random Access Memory

Landscapes

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

Abstract

本申请实施例公开了一种基于操作系统内核网桥的数据转发方法和装置;本申请实施例采用从网卡缓存中读取待转发的数据包,然后,在缓存的地址转发信息中查找该数据包对应的地址转发信息,当查找到该数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发该数据包的目标网卡驱动,直接向该目标网卡驱动发送该数据包,以便该目标网卡驱动将该数据包转发出去。

Description

基于操作系统内核网桥的数据转发方法和装置
本申请要求于2016年12月26日提交中国专利局、申请号为201611218589.8,发明名称为“一种基于操作系统内核网桥的数据发送方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,具体涉及一种基于操作系统内核网桥的数据转发方法和装置。
发明背景
网桥(bridge)是一种二层网络设备,用来连接不同网段。它具有若干个端口,与这些端口连接的若干主机可以通过网桥的报文转发而互相通信。网桥对于接收到的报文,要么转发、要么丢弃。它只需要一个交换芯片即可,不需要处理器。而运行着Linux内核的机器本身具有处理器,它可以通过一个虚拟的网桥设备来实现桥接功能。
Linux kernel bridge(内核网桥)转发数据的过程为:处理器通过网卡1的网卡驱动从网卡1的网卡缓存中提取网络数据包,然后,处理器通过网卡1的网卡驱动将该网络数据包传输至Linux kernel bridge子系统,Linux kernel bridge子系统查询地址转发表,确定网络数据包的出端口,通过该出端口对应的网卡2的网卡驱动将该网络数据包由该出端口发送出去。
发明内容
本申请实施例提供一种基于操作系统内核网桥的数据转发方法和装 置,可以提高操作系统内核网桥的数据转发性能。
本申请实施例提供一种基于操作系统内核网桥的数据转发方法,包括:
当数据转发装置的第一端口接收到待转发的数据包时,数据转发装置的处理器执行该第一端口对应的网卡驱动,以从该第一端口对应的网卡缓存中读取待转发的数据包,其中所述网卡缓存中保存有从操作系统内核网桥获取的地址转发信息;
所述处理器执行所述第一端口对应的网卡驱动,以在所述缓存的地址转发信息中查找所述数据包对应的地址转发信息;
当查找到所述数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发所述数据包的目标网卡驱动;
将所述数据包发送到所述目标网卡驱动,所述处理器执行所述目标网卡驱动,以将所述数据包通过第二端口转发出去。
相应的,本申请实施例还提供一种数据转发装置,包括:
处理器,与所述处理器相连接的存储器,第一端口,以及第二端口;所述存储器中存储有可由所述处理器执行的机器可读指令单元;所述机器可读指令单元包括:
读取单元,用于当数据转发装置的第一端口接收到待转发的数据包时,从该第一端口对应的网卡缓存中读取待转发的数据包,其中所述网卡缓存中保存有从操作系统内核网桥获取的地址转发信息;
查找单元,用于在缓存的地址转发信息中查找所述数据包对应的地址转发信息;
确定单元,用于当查找到所述数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发所述数据包的目标网卡驱动;
发送单元,用于将所述数据包发送到所述目标网卡驱动,以将所述 数据包通过所述第二端口转发出去。
本申请实施例还提供了一种非易失性计算机可读存储介质,所述存储介质中存储有机器可读指令,所述机器可读指令可以由处理器执行以完成以下操作:
当数据转发装置的第一端口接收到待转发的数据包时,数据转发装置的处理器执行该第一端口对应的网卡驱动,以从该第一端口对应的网卡缓存中读取待转发的数据包,其中所述网卡缓存中保存有从操作系统内核网桥获取的地址转发信息;
所述处理器执行所述第一端口对应的网卡驱动,以在所述缓存的地址转发信息中查找所述数据包对应的地址转发信息;
当查找到所述数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发所述数据包的目标网卡驱动;
将所述数据包发送到所述目标网卡驱动,所述处理器执行所述目标网卡驱动,以将所述数据包通过第二端口转发出去。
附图简要说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1a是本申请实施例提供的数据转发系统的场景示意图;
图1b是本申请实施例提供的基于操作系统内核网桥的数据转发方法的流程图;
图2a是本申请实施例提供的Linux bridge(网桥)系统的结构示意图;
图2b是本申请实施例提供的基于操作系统内核网桥的数据转发方法的另一流程图;
图3a是本申请实施例提供的基于操作系统内核网桥的数据转发装置的结构示意图;
图3b是本申请实施例提供的基于操作系统内核网桥的数据转发装置的另一结构示意图;
图3c是本申请实施例提供的基于操作系统内核网桥的数据转发装置的又一结构示意图。
图4是本申请实施例提供的基于操作系统内核网桥的数据转发装置的另一结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请实施例提供一种基于操作系统内核网桥的数据转发方法和装置。
本申请实施例提供了一种数据转发系统包括:本申请任一实施例提供的基于操作系统内核网桥的数据转发装置。该数据转发装置可以集成在服务器中,比如,集成在Linux操作系统的服务器中。
如图1a所示,该数据转发系统包括服务器101、服务器102以及终端103,其中,服务器101集成有本申请任一实施例提供的基于操作系统内核网桥的数据转发装置1011。该服务器101与服务器102之间通过 网络104连接,服务器101与终端103之间通过链路105连接。
在服务器101从第一端口接收到待转发的数据包时,服务器101中的数据转发装置1011用于,执行与该第一端口对应的第一网卡驱动从对应的网卡缓存中读取待转发的数据包,其中所述网卡缓存中保存有从操作系统内核网桥获取的地址转发信息。然后,在缓存的地址转发信息中查找该数据包对应的地址转发信息,当查找到该数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发该数据包的第二端口,数据转发装置1011确定该第二端口对应的第二网卡驱动,将所述数据包发送到第二网卡驱动,所述第二网卡驱动将该数据包通过所述第二端口发送给服务器102或者终端103。
此外,服务器101还用于通过网卡将服务器103或者终端103发送的信号转换成网络数据,并存放在相应的网卡缓存中。
本申请实施例采用从网卡缓存中读取待转发的数据包,然后,在缓存的地址转发信息中查找该数据包对应的地址转发信息,当查找到该数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发该数据包的目标网卡驱动,直接向该目标网卡驱动发送该数据包,以便该目标网卡驱动将该数据包转发出去。该方案可以将数据包直接发送给目标网卡驱动,并通过目标网卡驱动将数据包转发出去,无需再先将数据包发送至操作系统内核网桥系统,然后由该操作系统内核网桥系统进行转发处理以将数据发送出去;因此,该方案可以提高操作系统内核网桥的数据转发速度,进而提高操作系统内核网桥的数据转发性能。
本申请一些实施例中,将从基于操作系统内核网桥(kernel bridge)的数据转发装置的角度进行描述,该数据转发装置具体可以集成服务器中,比如,该服务器可以为Linux服务器。
一种基于操作系统内核网桥的数据转发方法,包括:第一网卡驱动 从第一网卡的缓存中读取待转发的数据包,然后,在缓存的地址转发信息中查找该数据包对应的地址转发信息,当查找到该数据包对应的地址转发信息时,根据查找到的地址转发信息确定该数据包的出端口,将该数据包发送至与该出端口对应的第二网卡驱动,即目标网卡驱动,以便该目标网卡驱动将该数据包通过出端口转发出去。
如图1b所示,该基于操作系统内核网桥的数据转发方法的流程图具体可以由如图1a所示的数据转发装置执行,包括如下操作:
S101、当数据转发装置的第一端口接收到待转发的数据包时,数据转发装置的处理器执行该第一端口对应的网卡驱动,以从该第一端口对应的网卡缓存中读取待转发的数据包,其中所述网卡缓存中保存有从操作系统内核网桥获取的地址转发信息。
其中,网卡缓存用于存放网卡转发的网络数据包,每个网卡可以对应一个网卡缓存。在本申请一些实施例中,所述网卡可以是物理网卡,也可以是虚拟网卡。
本实施例中操作系统可以Linux系统、或者其他的操作系统。
在一些实施例中,在步骤S101之前,还可以包括:对操作系统内核网桥的地址转发信息进行拷贝,对拷贝的地址转发信息进行缓存。这样便于后续数据包转发时数据包进入操作系统内核网桥之前进行数据包的地址转发信息的确定。在本申请一些实施例中,当操作系统内核网桥的地址转发信息发生变化时,操作系统内核网桥会将更新之后的地址转发信息发送到网卡缓存中。
S102、处理器执行所述第一端口对应的网卡驱动,以在所述缓存的地址转发信息中查找该数据包对应的地址转发信息。
其中,地址转发(fdb)信息为用于转发或者发送数据包的信息,其主要功能是供网络设备如服务器在数据链路层对数据包进行转发,用于 确定数据包发往哪个端口。该地址转发信息主要包括MAC(Media Access Control,媒体访问控制)地址与转发端口之间的对应关系(即映射关系)。
该地址转发信息可以包括地址转发表,比如,可以包括MAC(Media Access Control,媒体访问控制)地址转发表;该MAC地址也可以称为物理地址、硬件地址等等。
其中,地址转发表包含了转发地址与转发端口(port)之间的对应关系(映射关系),具体地,该地址转发表包含若干地址转发表项,该地址转发表项包含了转发地址与转发端口之间的对应关系(映射关系)。
比如,MAC地址转发表包含若干MAC地址转发表项,每个表项包含了MAC地址与转发端口(port)之间的对应关系。该地址转发表可以为一个二层转发表。
当缓存的地址转发信息包括地址转发表时,步骤“在缓存的地址转发信息中查找该数据包对应的地址转发信息”可以包括:
获取该数据包对应的目的地址;
根据该目的地址在缓存的地址转发表中,查找与目的地址对应的地址转发表项。
其中,目的地址对应的地址转发表项可以包含目的地址与转发端口之间的对应关系。
比如,可以获取数据包对应的目的MAC地址,然后,根据该目的MAC地址在MAC地址转发表中,查找与目的MAC地址对应的地址转发表项,该目的MAC地址对应的地址转发表项包含目的MAC地址与转发端口之间的对应关系。
S103、当查找到该数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发该数据包的目标网卡驱动。
步骤“根据查找到的地址转发信息确定用于转发该数据包的目标网卡驱动”,包括:
根据该查找到的地址转发信息查找相应的转发端口;
将与该转发端口关联的网卡驱动,确定为用于转发该数据包的目标网卡驱动。
具体地,当地址转发信息包括地址转发表时,该地址转发表包含若干地址转发表项,每个地址转发表项包含转发地址与转发端口之间的对应关系;此时,查找到的地址转发信息包括目的地址对应的地址转发表项,该目的地址为数据包的目的地址,也即目的地址对应的地址转发表项包含目的地址与转发端口之间的映射关系。
步骤“根据该查找到的地址转发信息查找相应的转发端口”可以包括:根据查找到的地址转发表项查找相应的转发端口。
比如,当缓存的地址转发信息包括MAC地址转发表时,可以获取数据包对应的目的MAC地址,然后,根据该目的MAC地址在该MAC地址转发表中查找与目的MAC地址对应的MAC地址转发表项。在查找到目的MAC地址对应的MAC地址转发表项之后,可以基于该MAC地址转发表项查找相应的转发端口。
本实施例中,可以基于端口驱动映射关系集合来确定转发端口关联的网卡驱动;也即步骤“将与该转发端口关联的网卡驱动,作为用于转发该数据包的目标网卡驱动”可以包括:
根据该转发端口、端口驱动映射集合确定与该转发端口关联的网卡驱动,该端口驱动映射集合包括转发端口与网卡驱动之间的映射关系(对应关系);
将该转发端口关联的网卡驱动,作为用于转发该数据包的目标网卡驱动。
本实施例中,网卡驱动为一种驱动程序(Device Driver)全称为“设备驱动程序”,是一种可以使计算机中央处理器——CPU控制和使用设备的特殊程序,相当于硬件的接口,操作系统通过这个接口,控制硬件设备的工作。
S104、将所述数据包发送到所述目标网卡驱动,处理器执行所述目标网卡驱动,以将该数据包通过所述转发端口转发出去。
具体地,步骤“将所述数据包发送到与所述目的端口对应的目标网卡驱动”可以包括:
通过与所述目标网卡驱动之间的通信通道向该目标网卡驱动发送该数据包。
在一些实施例中,当未查找到该数据包对应的地址转发信息时,本实施例方法可以向内核网桥系统发送该数据包,以便该内核网桥系统将数据包发送出去。
比如,当未查找到目的地址对应的地址转发表项时,可以向内核网桥系统(如Linux kernel bridge子系统)发送该数据包,该内核网桥系统开启学习模式,并根据学习结果将该数据包发送给对应的网卡驱动,以便该网卡驱动将该数据包发送出去。
由上可知,本申请实施例采用从网卡缓存中读取待转发的数据包,然后,在缓存的地址转发信息中查找该数据包对应的地址转发信息,当查找到该数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发该数据包的目标网卡驱动,直接向该目标网卡驱动发送该数据包,以便该目标网卡驱动将该数据包转发出去。该方案可以将数据包直接发送给目标网卡驱动,并通过目标网卡驱动将数据包转发出去,无需再先将数据包发送至操作系统内核网桥系统,然后由该子系统进行转发处理以将数据发送出去;因此,该方案可以提高操作系统内核网桥的 数据转发速度,进而提高操作系统内核网桥的数据转发性能以及节省了设备资源。
根据图1b所示实施例所描述的方法,以下将举例作进一步详细说明。
在本实施例中,将以该数据转发装置具体集成操作系统为Linux的服务器(称为Linux服务器)为例进行说明。
如图2a所示,该Linux服务器可以包括Linux bridge(网桥)系统,该系统可以包括:处理器210、存储器220、网卡230-1至230-n。其中,存储器220中包含Linux kernel bridge(Linux内核网桥)子系统221、网卡230-1至230-n各自的网卡驱动220-1至220-n。n为自然数。
下面基于图2a所示的Linux bridge(网桥)系统来详细介绍本申请的数据转发方法。
如图2b所示,一种基于操作系统内核网桥(kernel bridge)的数据转发方法,具体流程如下:
S201、Linux服务器对Linux kernel bridge子系统的地址转发信息进行拷贝,并缓存拷贝的地址转发信息。
比如,在linux kernel bridge子系统插入一个function,用于拷贝缓存inux kernel bridge子系统的地址转发(fdb)信息。
其中,地址转发信息可以包括MAC地址转发表,该MAC地址转发表包括若干MAC地址表项,该表项包含了MAC地址与转发端口(port)之间的映射关系。
又比如,可以由网卡驱动1对Linux kernel bridge子系统的地址转发信息进行拷贝,并缓存拷贝的地址转发信息。
S202、网卡1接收电信号,并将电信号转换成网络数据,以及将该网络数据存放在相应的网卡缓存中。
比如,网卡1通过网络接收电信号,然后,将电信号转换成相应的 数据,得到网络数据包。
S203、网卡驱动1从网卡缓存中读取待转发的网络数据包。
S204、网卡驱动1从缓存的地址转发信息中查找该网络数据包对应的地址转发信息。
比如,可以在网卡驱动1中插入一个function用于执行步骤S204-S208。
具体地,网卡驱动1获取网络数据包对应的目的MAC地址,然后,根据该目的MAC地址在缓存的MAC地址转发表中查找该目的MAC地址对应的MAC地址表项。
S205、网卡驱动1确定是否查找到该网络数据包对应的地址转发信息,若是,则执行步骤S206,若否,则执行步骤S210。
比如,通过一个函数int nfp_process(uint32_t if_index,struct sk_buff*skb)来从地址转发信息中查找该网络数据包对应的地址转发信息,若查找到,则返回0,若查不到则返回-1。
S206、网卡驱动1根据查找到的地址转发信息查找相应的转发端口。
当网卡驱动1查找到目的MAC地址对应的MAC地址表项时,可以基于该MAC地址表项查找相应的转发端口。
其中,可以调用函数dev_queue_xmit()来执行步骤206-208。
例如,在网卡驱动1中,在tun_get_user()中,生成数据包sk_buff后,执行nfp_process(),若nfp_process()返回0,即查找到网络数据包对应的fdb信息。此时,可以调用dev_queue_xmit()将该数据包转发出去(执行步骤S206-S208),不再执行tun_netif_rx_ni(skb),即不再将数据包传给linux kernel bridge子系统。
S207、网卡驱动1确定该转发端口关联的目标网卡驱动为网卡驱动2。
S208、网卡驱动1与网卡驱动2之间建立通信通道,并通过该通信通过将该网络数据包发送至网卡驱动2。
S209、网卡驱动2将该网络数据包放入到相应的网卡缓存中,网卡2将该网卡缓存中的网络数据包转换成电信号转发出去。
S210、网卡驱动1将该网络数据包发送给Linux kernel bridge子系统。
比如,在网卡驱动1中,在tun_get_user()中,生成数据包sk_buff后,执行nfp_process(),若nfp_process()返回-1,则继续执行tun_netif_rx_ni(skb),以将数据包传给linux kernel bridge子系统。
S211、Linux kernel bridge子系统开启学习模式,并根据学习结果向对应的网卡驱动3发送网络数据包。
S212、网卡驱动3将该网络数据包放入到相应的网卡缓存中,网卡3将该网卡缓存中的网络数据包转换成电信号转发出去。
本实施例中,网卡驱动1可以在tun_get_user()中,生成数据包sk_buff后,执行nfp_process(),若nfp_process()返回0,即查找到网络数据包对应的fdb信息,并调用dev_queue_xmit()将该数据包转发出去,此时不再执行tun_netif_rx_ni(skb),即不再将数据包传给linux kernel bridge子系统;若nfp_process()返回-1,则继续执行tun_netif_rx_ni(skb),将数据包传给linux kernel bridge子系统。具体代码如下:
if(!nfp_process(skb->dev->ifindex,skb)){
tun_netif_rx_ni(skb);
}。
由上可知,本申请实施例可以从网卡缓存中读取待转发的数据包,然后,在缓存的地址转发信息中查找该数据包对应的地址转发信息,当查找到该数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于发送该数据包的目标网卡驱动,直接向该目标网卡驱动转发该数 据包,以便通过目标网卡驱动将该数据包转发出去;当未查找到该数据包对应的地址转发信息时将该数据包发送给内核网桥系统,以便通过内核网桥系统将数据包发送出去。该方案可以将一部分数据包直接发送给目标网卡驱动,并通过目标网卡驱动将数据包转发出去,无需再先将数据包发送至Linux kernel bridge子系统,然后由该子系统进行转发处理以将数据发送出去;因此,该方案可以提高Linux kernel bridge的数据转发速度,进而提高Linux kernel bridge的数据转发性能以及节省了服务器的资源。
为了更好地实施以上方法,本申请实施例还提供一种基于操作系统内核网桥的数据转发装置,如图3a所示,该数据转发装置包括:读取单元301、查找单元302、确定单元303以及发送单元304,其中:
读取单元301,用于当所述数据转发装置的第一端口接收到待转发的数据包时,从与第一端口对应的网卡缓存中读取待转发的数据包,其中所述网卡缓存中保存有从操作系统内核网桥获取的地址转发信息。
其中,网卡缓存用于存放网卡转换的网络数据,每个网卡可以对应一个网卡缓存。
本实施例中操作系统可以Linux系统、或者其他的操作系统。
查找单元302,用于在缓存的地址转发信息中查找该数据包对应的地址转发信息。
其中,地址转发(fdb)信息为用于转发或者发送数据包的信息,其主要功能是供网络设备如服务器在数据链路层对数据包进行转发,用于确定数据包发往哪个端口。该地址转发信息主要包括MAC(Media Access Control,媒体访问控制)地址与转发端口之间的对应关系(即映射关系)。
比如,参考图3b,当该缓存的地址转发信息包括:地址转发表时, 该查找单元302,具体可以包括:
地址获取子单元3021,用于获取该数据包对应的目的地址;
查找子单元3022,用于根据该目的地址在缓存的地址转发表中,查找与目的地址对应的地址转发信息。
比如,地址获取子单元3021,可以用于获取该数据包对应的目的MAC地址;查找子单元3022,用于据该目的MAC地址在MAC地址转发表中,查找与目的MAC地址对应的地址转发表项。
确定单元303,用于当查找到该数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发该数据包的目标网卡驱动。
比如,参考图3c,确定单元303,可以包括:
端口查找子单元3031,用于根据该查找到的地址转发信息查找相应的转发端口;
驱动确定子单元3032,用于将与该转发端口关联的网卡驱动,确定为用于发送该数据包的目标网卡驱动。
例如,端口查找子单元3031,用于根据查找到的MAC地址表项查找相应的转发端口。
又例如,驱动确定子单元3032,用于根据该转发端口、端口驱动映射集合确定与该转发端口关联的网卡驱动,该端口驱动映射集合包括转发端口与网卡驱动之间的映射关系(对应关系)。
本实施例中,网卡驱动为一种驱动程序(Device Driver)全称为“设备驱动程序”,是一种可以使计算机中央处理器——CPU控制和使用设备的特殊程序,相当于硬件的接口,操作系统通过这个接口,控制硬件设备的工作。
发送单元304,用于将该数据包发送到所述目标网卡驱动,以便该目标网卡驱动将该数据包通过第二端口转发出去。
比如,该发送单元304,可以具体包括:
通道建立子单元3041,用于与该目标网卡驱动之间建立通信通道;
发送子单元3042,用于通过该通信通道向该目标网卡驱动转发该数据包。
在一些实施例中,该数据转发装置还可以包括:缓存单元305;该缓存单元用于:
在读取单元301读取数据包之前,对内核网桥系统的地址转发信息进行拷贝;
对拷贝的地址转发信息进行缓存。
具体实施时,以上各个单元可以作为独立的实体来实现,也可以进行任意组合,作为同一或若干个实体来实现,以上各个单元的具体实施可参见前面的方法实施例,在此不再赘述。
该基于操作系统内核网桥的数据转发装置具体可以集成在服务器等网络设备中,该服务器可以为Linux服务器等。实际应用中,该数据转发装置可以集成在网卡驱动中。
图4是本申请实施例提供的基于操作系统内核网桥的数据转发装置的另一结构示意图。如图4所示,该数据转发装置包括:处理器410,与所述处理器410相连接的存储器420,第一端口430,以及第二端口440;所述存储器420中存储有可由所述处理器410执行的机器可读指令单元;所述机器可读指令单元包括:
读取单元421,用于当数据转发装置的第一端口430接收到数据包时,从该第一端口430对应的网卡缓存中读取待转发的数据包,其中所述网卡缓存中保存有从操作系统内核网桥获取的地址转发信息;
查找单元422,用于在缓存的地址转发信息中查找所述数据包对应的地址转发信息;
确定单元423,用于当查找到所述数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发所述数据包的目标网卡驱动;
发送单元424,用于将所述数据包发送到所述目标网卡驱动,以将所述数据包通过所述第二端口440转发出去。
在本申请实施例中,上述读取单元421、查找单元422、确定单元423和发送单元424的具体功能和实现方式与前面所述的单元301至304相同,在此不再赘述。
由上可知,本申请实施例数据转发装置通过读取单元301从网卡缓存中读取待转发的数据包,然后,由查找单元302在缓存的地址转发信息中查找该数据包对应的地址转发信息,当查找到该数据包对应的地址转发信息时,由确定单元303根据查找到的地址转发信息确定用于发送该数据包的目标网卡驱动,由发送单元304直接向该目标网卡驱动转发该数据包,以便该目标网卡驱动将该数据包转发出去。该方案可以将数据包直接发送给目标网卡驱动,并通过目标网卡驱动将数据包转发出去,无需再先将数据包发送至操作系统内核网桥系统,然后由该子系统进行转发处理以将数据发送出去;因此,该方案可以提高操作系统内核网桥的数据转发速度,进而提高操作系统内核网桥的数据转发性能以及节省了设备资源。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:只读存储器(ROM,Read Only Memory)、随机存取记忆体(RAM,Random Access Memory)、磁盘或光盘等。
以上对本申请实施例所提供的一种基于操作系统内核网桥的数据转发方法和装置进行了详细介绍,本文中应用了具体个例对本申请的原理 及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。

Claims (16)

  1. 一种基于操作系统内核网桥的数据转发方法,包括:
    当数据转发装置的第一端口接收到待转发的数据包时,数据转发装置的处理器执行该第一端口对应的网卡驱动,以从该第一端口对应的网卡缓存中读取待转发的数据包,其中所述网卡缓存中保存有从操作系统内核网桥获取的地址转发信息;
    所述处理器执行所述第一端口对应的网卡驱动,以在所述缓存的地址转发信息中查找所述数据包对应的地址转发信息;
    当查找到所述数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发所述数据包的目标网卡驱动;
    将所述数据包发送到所述目标网卡驱动,所述处理器执行所述目标网卡驱动,以将所述数据包通过第二端口转发出去。
  2. 如权利要求1所述的数据转发方法,所述根据查找到的地址转发信息确定用于转发所述数据包的目标网卡驱动,包括:
    根据所述查找到的地址转发信息查找相应的第二端口;
    将与所述第二端口关联的网卡驱动,确定为用于发送所述数据包的目标网卡驱动。
  3. 如权利要求1或2所述的数据转发方法,所述缓存的地址转发信息包括:地址转发表;
    在缓存的地址转发信息中查找所述数据包对应的地址转发信息,包括:
    获取所述数据包对应的目的地址;
    根据所述目的地址在缓存的地址转发表中,查找与目的地址对应的地址转发表项。
  4. 如权利要求1所述的数据转发方法,所述将所述数据包发送到所 述目标网卡驱动,包括:
    通过所述第一端口对应的网卡驱动与所述目标网卡驱动之间的通信通道,将所述数据包发送到所述目标网卡驱动。
  5. 如权利要求1所述的数据转发方法,还包括:
    当未查找到所述数据包对应的地址转发信息时,向所述操作系统内核网桥发送所述数据包,以便所述操作系统内核网桥将数据包发送出去。
  6. 如权利要求1-5任一项所述的数据转发方法,在从网卡缓存中读取数据包之前,还包括:
    对操作系统内核网桥的地址转发信息进行拷贝;
    将拷贝的地址转发信息保存到所述网卡缓存中。
  7. 一种基于操作系统内核网桥的数据转发装置,包括:
    处理器,与所述处理器相连接的存储器,第一端口,以及第二端口;所述存储器中存储有可由所述处理器执行的机器可读指令单元;所述机器可读指令单元包括:
    读取单元,用于当数据转发装置的第一端口接收到待转发的数据包时,从该第一端口对应的网卡缓存中读取待转发的数据包,其中所述网卡缓存中保存有从操作系统内核网桥获取的地址转发信息;
    查找单元,用于在缓存的地址转发信息中查找所述数据包对应的地址转发信息;
    确定单元,用于当查找到所述数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发所述数据包的目标网卡驱动;
    发送单元,用于将所述数据包发送到所述目标网卡驱动,以将所述数据包通过所述第二端口转发出去。
  8. 如权利要求7所述的数据转发装置,所述确定单元,包括:
    端口查找子单元,用于根据所述查找到的地址转发信息查找相应的 第二端口;
    驱动确定子单元,用于将与所述第二端口关联的网卡驱动,作为用于转发所述数据包的目标网卡驱动。
  9. 如权利要求7所述的数据转发装置,所述缓存的地址转发信息包括:地址转发表;
    所述查找单元,具体包括:
    地址获取子单元,用于获取所述数据包对应的目的地址;
    查找子单元,用于根据所述目的地址在缓存的地址转发表中,查找与目的地址对应的地址转发表项。
  10. 如权利要求7所述的数据转发装置,发送单元,进一步用于:通过所述第一端口对应的网卡驱动和所述目标网卡驱动之间的通信通道向所述目标网卡驱动发送所述数据包。
  11. 一种非易失性计算机可读存储介质,所述存储介质中存储有机器可读指令,所述机器可读指令可以由处理器执行以完成以下操作:
    当数据转发装置的第一端口接收到待转发的数据包时,数据转发装置的处理器执行该第一端口对应的网卡驱动,以从该第一端口对应的网卡缓存中读取待转发的数据包,其中所述网卡缓存中进一步保存有从操作系统内核网桥获取的地址转发信息;
    所述处理器执行所述第一端口对应的网卡驱动,以在所述缓存的地址转发信息中查找所述数据包对应的地址转发信息;
    当查找到所述数据包对应的地址转发信息时,根据查找到的地址转发信息确定用于转发所述数据包的目标网卡驱动;
    将所述数据包发送到所述目标网卡驱动,处理器执行所述目标网卡驱动,以将所述数据包转发出去。
  12. 如权利要求11所述的非易失性计算机可读存储介质,所述根据 查找到的地址转发信息确定用于转发所述数据包的目标网卡驱动,包括:
    根据所述查找到的地址转发信息查找相应的第二端口;
    将与所述第二端口关联的网卡驱动,确定为用于发送所述数据包的目标网卡驱动。
  13. 如权利要求11或12所述的非易失性计算机可读存储介质,所述缓存的地址转发信息包括:地址转发表;
    在缓存的地址转发信息中查找所述数据包对应的地址转发信息,包括:
    获取所述数据包对应的目的地址;
    根据所述目的地址在缓存的地址转发表中,查找与目的地址对应的地址转发表项。
  14. 如权利要求11所述的非易失性计算机可读存储介质,所述将所述数据包发送到所述目标网卡驱动,包括:
    通过所述第一端口对应的网卡驱动与所述目标网卡驱动之间的通信通道,将所述数据包发送到所述目标网卡驱动。
  15. 如权利要求11所述的非易失性计算机可读存储介质,还包括:
    当未查找到所述数据包对应的地址转发信息时,向操作系统内核网桥发送所述数据包,以便所述操作系统内核网桥将数据包转发出去。
  16. 如权利要求11-15任一项所述的非易失性计算机可读存储介质,在从网卡缓存中读取数据包之前,还包括:
    对操作系统内核网桥的地址转发信息进行拷贝;
    将拷贝的地址转发信息保存到所述网卡缓存中。
PCT/CN2017/117415 2016-12-26 2017-12-20 基于操作系统内核网桥的数据转发方法和装置 WO2018121373A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US16/351,322 US11201760B2 (en) 2016-12-26 2019-03-12 Data forwarding method and apparatus based on operating system kernel bridge

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201611218589.8 2016-12-26
CN201611218589.8A CN106789756A (zh) 2016-12-26 2016-12-26 一种基于操作系统内核网桥的数据发送方法和装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/351,322 Continuation US11201760B2 (en) 2016-12-26 2019-03-12 Data forwarding method and apparatus based on operating system kernel bridge

Publications (1)

Publication Number Publication Date
WO2018121373A1 true WO2018121373A1 (zh) 2018-07-05

Family

ID=58926741

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/117415 WO2018121373A1 (zh) 2016-12-26 2017-12-20 基于操作系统内核网桥的数据转发方法和装置

Country Status (3)

Country Link
US (1) US11201760B2 (zh)
CN (1) CN106789756A (zh)
WO (1) WO2018121373A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115941531A (zh) * 2022-12-06 2023-04-07 江苏杰瑞信息科技有限公司 基于新增内核驱动模块的网络原始报文提取方法
CN116546557A (zh) * 2023-06-29 2023-08-04 阿里巴巴(中国)有限公司 数据包处理方法、系统、设备和存储介质

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106789756A (zh) 2016-12-26 2017-05-31 腾讯科技(深圳)有限公司 一种基于操作系统内核网桥的数据发送方法和装置
CN112540941B (zh) 2019-09-21 2024-09-20 华为技术有限公司 一种数据转发芯片及服务器
CN116366542B (zh) * 2021-12-27 2024-08-20 成都鼎桥通信技术有限公司 数据传输方法和相关设备
CN114500654B (zh) * 2022-02-23 2024-03-22 石家庄通合电子科技股份有限公司 一种数据转发装置、电源模块及数据转发方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103347014A (zh) * 2013-06-25 2013-10-09 深圳市共进电子股份有限公司 网络快速转发模块及网络快速转发实现方法
WO2015058698A1 (en) * 2013-10-23 2015-04-30 Hangzhou H3C Technologies Co., Ltd. Data forwarding
CN105553889A (zh) * 2015-12-21 2016-05-04 浪潮集团有限公司 一种内核网桥下物理网卡和虚拟网卡快速收发包传递方法
CN106789756A (zh) * 2016-12-26 2017-05-31 腾讯科技(深圳)有限公司 一种基于操作系统内核网桥的数据发送方法和装置

Family Cites Families (38)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5940596A (en) * 1996-03-25 1999-08-17 I-Cube, Inc. Clustered address caching system for a network switch
US6904519B2 (en) * 1998-06-12 2005-06-07 Microsoft Corporation Method and computer program product for offloading processing tasks from software to hardware
DE69934192T2 (de) * 1998-10-27 2007-08-30 Hewlett-Packard Development Co., L.P., Houston Verfahren und Einrichtung zur Netzverbindung mittels Brücken
US20020039365A1 (en) * 1999-03-17 2002-04-04 Broadcom Corporation Pipelined searches with a cache table
JP2001211190A (ja) * 2000-01-25 2001-08-03 Hitachi Ltd 通信管理装置及び通信管理方法
JP2002057682A (ja) * 2000-08-09 2002-02-22 Hitachi Ltd ネットワークインタフェース切替え方法及びネットワークに接続可能なコンピュータ
US7089335B2 (en) * 2000-10-30 2006-08-08 Microsoft Corporation Bridging multiple network segments and exposing the multiple network segments as a single network to a higher level networking software on a bridging computing device
JP2003281109A (ja) * 2002-03-26 2003-10-03 Hitachi Ltd 負荷分散方法
US7269739B2 (en) * 2002-05-30 2007-09-11 International Business Machines Corporation Method and system for allowing for the secure transmission and reception of data in a processing system
US7111303B2 (en) * 2002-07-16 2006-09-19 International Business Machines Corporation Virtual machine operating system LAN
KR20040023843A (ko) * 2002-09-12 2004-03-20 삼성전기주식회사 메모리의 결함 처리 장치 및 그 방법
US7305493B2 (en) * 2002-11-27 2007-12-04 Intel Corporation Embedded transport acceleration architecture
KR100612315B1 (ko) * 2003-02-20 2006-08-16 삼성전자주식회사 핑퐁 방지 기능이 구비된 분산형 라우터 및 그를 이용한핑퐁 방지 방법
TWI243555B (en) * 2003-07-09 2005-11-11 Hon Hai Prec Ind Co Ltd Apparatus and method of firewall
EP1503286B1 (en) * 2003-07-30 2014-09-03 Jaluna SA Multiple operating system networking
JP4365672B2 (ja) * 2003-12-04 2009-11-18 株式会社日立製作所 パケット通信ノード装置
JP2006060579A (ja) * 2004-08-20 2006-03-02 Fujitsu Ltd アプリケーション特性に応じて複数の経路を同時に利用する通信装置
US7688825B2 (en) * 2005-04-12 2010-03-30 Fujitsu Limited Filtering frames at an input port of a switch
TW200826571A (en) * 2006-12-08 2008-06-16 Univ Nat Chiao Tung Identification and management system and method applicable to a point-to-point gateway
US8312541B2 (en) * 2007-07-17 2012-11-13 Cisco Technology, Inc. Detecting neighbor discovery denial of service attacks against a router
CN101582880B (zh) * 2008-05-14 2012-06-06 北京启明星辰信息技术股份有限公司 一种基于被审计对象的报文过滤方法及系统
TWI393390B (zh) * 2009-01-20 2013-04-11 Ralink Technology Corp 封包傳送方法與裝置
US9111325B2 (en) * 2009-12-31 2015-08-18 Nvidia Corporation Shared buffer techniques for heterogeneous hybrid graphics
US20160154673A1 (en) * 2014-07-23 2016-06-02 Sitting Man, Llc Methods, systems, and computer program products for providing a minimally complete operating environment
US8478997B2 (en) * 2010-09-10 2013-07-02 Raytheon Company Multi-level security software architecture
US8468225B2 (en) * 2010-12-16 2013-06-18 Samsung Electronics Co., Ltd. Roaming TCP connections between changing physical networks
CN102694727A (zh) * 2012-05-21 2012-09-26 太仓市同维电子有限公司 实现网络数据包转发加速的方法及装置
CN103404084B (zh) * 2012-11-21 2017-11-17 华为技术有限公司 Mac地址强制转发装置及方法
US9218356B2 (en) * 2013-01-31 2015-12-22 Cumulus Networks, Inc. Systems and methods for accelerating networking functionality
US9092336B2 (en) * 2013-03-15 2015-07-28 Intelligent Intellectual Property Holdings 2 Llc Write admittance policy for a memory cache
US8954631B2 (en) * 2013-04-08 2015-02-10 International Business Machines Corporation Continuously transferring data using a USB mass storage device
US9385773B2 (en) * 2013-06-14 2016-07-05 Broadcom Corporation Traffic tunnel for end to end low latency
CN103812751A (zh) * 2014-02-28 2014-05-21 成都卫士通信息产业股份有限公司 一种基于ndis的ssl vpn终端数据交互方法
US10129148B2 (en) * 2014-08-18 2018-11-13 Red Hat Israel, Ltd. Table-based load balancing for bonded network interfaces
WO2016088371A1 (ja) * 2014-12-05 2016-06-09 日本電気株式会社 管理ノード、端末、通信システム、通信方法、および、プログラム記録媒体
CN104883302B (zh) * 2015-03-18 2018-11-09 华为技术有限公司 一种数据包转发的方法、装置及系统
WO2017004746A1 (zh) * 2015-07-03 2017-01-12 华为技术有限公司 一种网络的配置方法、网络系统和设备
US9923818B2 (en) * 2015-09-14 2018-03-20 Citrix Systems, Inc. Systems and methods of achieving equal distribution of packets in a multicore system which acts as a tunnel end point

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103347014A (zh) * 2013-06-25 2013-10-09 深圳市共进电子股份有限公司 网络快速转发模块及网络快速转发实现方法
WO2015058698A1 (en) * 2013-10-23 2015-04-30 Hangzhou H3C Technologies Co., Ltd. Data forwarding
CN105553889A (zh) * 2015-12-21 2016-05-04 浪潮集团有限公司 一种内核网桥下物理网卡和虚拟网卡快速收发包传递方法
CN106789756A (zh) * 2016-12-26 2017-05-31 腾讯科技(深圳)有限公司 一种基于操作系统内核网桥的数据发送方法和装置

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115941531A (zh) * 2022-12-06 2023-04-07 江苏杰瑞信息科技有限公司 基于新增内核驱动模块的网络原始报文提取方法
CN116546557A (zh) * 2023-06-29 2023-08-04 阿里巴巴(中国)有限公司 数据包处理方法、系统、设备和存储介质
CN116546557B (zh) * 2023-06-29 2023-11-17 阿里巴巴(中国)有限公司 数据包处理方法、系统、设备和存储介质

Also Published As

Publication number Publication date
US20190207783A1 (en) 2019-07-04
CN106789756A (zh) 2017-05-31
US11201760B2 (en) 2021-12-14

Similar Documents

Publication Publication Date Title
WO2018121373A1 (zh) 基于操作系统内核网桥的数据转发方法和装置
US10033637B2 (en) Method and apparatus for switching data between virtual machines, and communications system
US8886827B2 (en) Flow cache mechanism for performing packet flow lookups in a network device
US10644991B2 (en) Cluster communictaion
US8005968B2 (en) Single-interface dynamic MTU control
CN107800625B (zh) 一种报文转发方法及装置
US9979643B2 (en) Communication apparatus, communication method, and computer-readable recording medium
WO2017185878A1 (zh) 报文转发
WO2014079005A1 (zh) Mac地址强制转发装置及方法
US7856024B1 (en) Method and apparatus for integrating routing and bridging functions
WO2017186159A1 (zh) 报文传输
JP2016509822A (ja) イーサネットパケットの転送
JP2019523608A (ja) パケット監視
WO2019033891A1 (zh) 一种基于rdma的网络流量确定方法及装置
US10536368B2 (en) Network-aware routing in information centric networking
US10554548B2 (en) Partially deferred packet access
EP3531636B1 (en) Detecting stale memory addresses for a network device flow cache
CN108111422B (zh) 一种基于dpdk的数据高速多路转发方法及装置
US20170012874A1 (en) Software router and methods for looking up routing table and for updating routing entry of the software router
CN113965521A (zh) 数据包的传输方法、服务器及存储介质
CN109413118B (zh) 一种实现会话同步的方法、装置及存储介质、程序产品
KR101530013B1 (ko) 효율적인 네트워크 주소 변환 및 애플리케이션 레벨 게이트웨이 프로세싱을 위한 장치 및 방법들
US20180367452A1 (en) Information centric networking over multi-access network interfaces
JP6470640B2 (ja) 通信装置及びその制御方法、コンピュータプログラム
CN111800340A (zh) 数据包转发方法和装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17888583

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17888583

Country of ref document: EP

Kind code of ref document: A1