# Patent

## Title
Hash-based load balancing for bonded network interfaces

## Abstract

Systems and methods for hash-based load balancing implemented by bonded network interfaces. An example method may comprise: receiving, by a bonded interface of a computer system, a data link layer frame originated by a virtual machine; identifying a network interface controller (NIC) of the bonded interface by calculating a value of a hash function of an identifier of the virtual machine and at least one of: a destination Media Access Control (MAC) address of the data link layer frame or a destination network layer address of a network layer packet comprised by the data link layer frame; and transmitting the data link layer frame via the identified NIC.

## Background
TECHNICAL FIELD
The present disclosure is generally related to link aggregation, and is more specifically related to systems and methods for providing load balancing for bonded interfaces.
BACKGROUND
Link aggregation refers to various methods of combining multiple network connections in order to increase the overall throughput which might not be achieved by a single connection. Network interface controller (NIC) bonding refers to a method of aggregating multiple NICs into a single logical interface.



BRIEF DESCRIPTION OF THE DRAWINGS
The present disclosure is illustrated by way of examples, and not by way of limitation, and may be more fully understood with references to the following detailed description when considered in connection with the figures, in which:
FIG. 1 depicts a high-level component diagram of an example computer system operating in accordance with one or more aspects of the present disclosure;
FIG. 2 schematically illustrates an example networking configuration implemented by a host computer system, in accordance with one or more aspects of the present disclosure;
FIG. 3 schematically illustrates hash-based load balancing implemented by a bonded network interface, in accordance with one or more aspects of the present disclosure;
FIG. 4 depicts a flow diagram of an example method 400 for hash-based load balancing implemented by bonded network interfaces, in accordance with one or more aspects of the present disclosure; and
FIG. 5 depicts a block diagram of an illustrative computer system operating in accordance with examples of the invention.



DETAILED DESCRIPTION
Described herein are methods and systems for hash-based load balancing implemented by bonded network interfaces.
In the below description and examples, references are made to Open Systems Interconnection (OSI) model layers, including data link layer (layer 2) and network (layer 3), as defined by Recommendation X.200 (07/94) by International Telecommunications Union (ITU). A “frame” herein shall refer to a unit of transmission in a data link layer protocol, including a link-layer header followed by a data packet. The data link layer provides local delivery of frames between devices on the same local area network (LAN). Functions of data link layer protocols include local delivery, addressing, and media arbitration. Examples of data link protocols include Ethernet, Infiniband, or Wi-Fi. The network layer provides the functional and procedural means of transferring variable-length data sequences from a source to a destination host via one or more networks, while maintaining the quality of service functions. Functions of network layer protocols include host addressing and message forwarding.
“Network interface controller” (NIC) herein refers to a computer hardware component that connects a computer to a computer network. A NIC may comprise electronic circuitry required to communicate with other networked devices using specific physical layer and data link layer standards.
Network interface controller bonding herein refers to a method of aggregating multiple NICs into a single logical interface that may be available to applications via a corresponding driver. Outgoing data link layer frames may be transmitted to an external recipient (e.g., a switch) via one of the NICs of the boded interface, referred to as “egress NIC.” The egress NIC may be selected by a method that facilitates load balancing among the NICs participating in the bonded interface.
In certain implementations, the interface bonding technique may be employed in a virtualized environment, wherein a hypervisor may implement a data link layer bridge to aggregate traffic to/from two or more virtual NICs (vNICs) associated with one or more virtual machines. The bridged vNICs may communicate to two or more NICs of the host computer via a bonded interface that employs the hash-based load balancing technique, as described in more details herein below.
In accordance with one or more aspects of the present disclosure, the selection of a NIC for outgoing frame transmission may be performed based on a hash function. Responsive to receiving an outgoing data link layer frame, the bonded interface may identify an egress NIC of the bonded interface by calculating a value of the hash function. Arguments of the hash function may include the identifier of the virtual machine that has originated the data link layer frame and one or more addresses extracted from the headers of the data link layer frame (e.g., the destination Media Access Control (MAC) address of the data link layer frame and/or the destination network layer address of the network layer packet comprised by the data link layer frame). In certain implementations, the virtual machine identifier may be represented by an arbitrary value assigned to a virtual machine by the hypervisor upon the virtual machine's creation or start up. Alternatively, the virtual machine identifier may be provided by an identifier of the virtual network interface that has originated the data link layer frame.
Calculating the hash function may include performing one or more addition and/or exclusive disjunction (XOR) operations. Calculating the hash function may further include calculating a cyclic redundancy check (CRC) value.
Employing, for identifying an egress NIC of a bonded interface, a hash function whose value is dependent on the destination address (e.g., the MAC or network layer address) allows even a single active virtual machine utilize two or more NICs of the host computer system simultaneously. Employing a hash function whose value is dependent on an identifier of the virtual machine that has originated the frame allows better load balancing among two or more virtual machines utilizing similar traffic patterns.
Various aspects of the above referenced methods and systems are described in details herein below by way of examples, rather than by way of limitation.
FIG. 1 depicts a high-level component diagram of an examples computer system operating in accordance with one or more aspects of the present disclosure. Example computer system 100 may comprise one or more processing devices 120A-120B communicatively coupled to one or more memory devices 130 and two or more NICs 140A-140B via a system bus 150.
“Processor” or “processing device” herein refers to a device capable of executing instructions encoding arithmetic, logical, or I/O operations. In one illustrative example, a processor may follow Von Neumann architectural model and may comprise an arithmetic logic unit (ALU), a control unit, and a plurality of registers. In a further aspect, a processor may be a single core processor which is typically capable of executing one instruction at a time (or process a single pipeline of instructions), or a multi-core processor which may simultaneously execute multiple instructions. In another aspect, a processor may be implemented as a single integrated circuit, two or more integrated circuits, or may be a component of a multi-chip module (e.g., in which individual microprocessor dies are included in a single integrated circuit package and hence share a single socket). A processor may also be referred to as a central processing unit (CPU). “Memory device” herein refers to a volatile or non-volatile memory device, such as RAM, ROM, EEPROM, or any other device capable of storing data. “I/O device” herein refers to a device capable of providing an interface between a processor and an external device capable of inputting and/or outputting binary data.
In various implementations, computer system 100 may further comprise various other devices, such as peripheral device controllers, which are omitted from FIG. 1 for clarity and conciseness.
Computer system 100 may be employed as a host system configured to run multiple virtual machines 170, by executing a software layer 180, often referred to as “hypervisor,” above the hardware and below the virtual machines. In one illustrative example, hypervisor 180 may be a component of an operating system 185 executed by host computer system 100. Alternatively, hypervisor 180 may be provided by an application running under host operating system 185, or may run directly on host computer system 100 without an operating system beneath it. Hypervisor 180 may abstract the physical layer, including processors, memory, and I/O devices, and present this abstraction to virtual machines 170 as virtual devices.
Virtual machine 170 may comprise one or more virtual processors 190. Processor virtualization may be implemented by hypervisor 180 scheduling time slots on one or more physical processors 120 such that from the guest operating system's perspective those time slots are scheduled on virtual processor 190. Virtual machine 170 may execute guest operating system 196 which may utilize the underlying virtual devices, including virtual memory 192, virtual I/O devices 195, and vNICs 194. One or more applications 198 may be running on virtual machine 170 under guest operating system 196.
In certain implementations, computer system 100 may include a bonding driver 182 configured to aggregate two or more host NICs 140A-140Z into a bonded interface 220 acting as a data link layer logical network interface that may be employed by various applications being executed by computer system 100. “Driver” herein refers to an executable code module that provides a software interface to one or more physical or logical devices, thus enabling the operating systems and application programs to access the underlying device functions. In an illustrative example, bonding driver 182 may be implemented by an executable code module (e.g., a kernel loadable module or a user space module) executed by operating system 185.
FIG. 2 schematically illustrates an example networking configuration implemented by host computer system 100, in accordance with one or more aspects of the present disclosure. As schematically illustrated by FIG. 2, each virtual machine 170 may comprise a vNIC 194. Host computer system 100 may implement a data link layer bridge 210 to forward data link layer frames between the bridged vNICs 194A-194N and bonded interface 220 aggregating two or more NICs 140A-140Z into a single data link layer logical interface. In certain implementations, bridge 210 may be implemented by a bridge driver 184 (e.g., a code module being executed within the context of hypervisor 180).
In an illustrative example, each of two or more host NICs 140A-140Z may be connected to a corresponding switch port of the same data link layer switch (not shown in FIG. 2), thus increasing the overall throughput of bonded interface 220. In another illustrative example, two or more NICs 140A-140Z may be connected to switch ports of two or more data link layer switches, thus increasing both the overall throughput and reliability of bonded interface 220, as bonded interface 220 would still be fully functional even in the event of a failure of one or more data link layer switches to which NICs 140A-140Z are connected.
Virtual machine 170 may transmit outgoing data link layer frames (e.g., Ethernet frames) via a vNIC 194. Responsive to determining that a data link layer frame transmitted by a virtual machine 170 is addressed to another virtual machine connected to the same data link layer bridge 210, bridge driver 184 may deliver the data link layer frame to the destination vNIC. Otherwise, if the data link layer frame transmitted by a virtual machine 170 is addressed to a recipient residing outside of host computer system 100, bridge driver 184 may deliver the outgoing data link layer frame to bonded interface 220.
Bonding driver 182 may select an egress NICs for outgoing frame transmission by calculating a value of a hash function 300 constructed in accordance with one or more aspects of the present disclosure. An example hash function 300 is described in more details herein below with reference to FIG. 3.
FIG. 3 schematically illustrates an example hash function that may be employed for performing hash-based load balancing by a bonded network interface, in accordance with one or more aspects of the present disclosure. As schematically illustrated by FIG. 3, arguments of the hash function 300 may include an identifier 310 of the virtual machine that has originated the data link layer frame and one or more addresses 320 of the data link layer frame (e.g., the destination Media Access Control (MAC) address of the data link layer frame and/or the destination network layer address of the network layer packet comprised by the data link layer frame). The hash function value 330 may identify the egress NIC to be employed for the outgoing frame transmission. Calculating the hash function may include performing one or more addition and/or exclusive disjunction (XOR) operations. Calculating the hash function may further include calculating a cyclic redundancy check (CRC) value.
In the illustrative example of FIG. 3, the hash function is defined as
((virtual machine ID) XOR (destination MAC address)) mod (number of NICs aggregated by the bonded interface),
wherein virtual machine ID denotes an identifier of the virtual machine, XOR denotes the exclusive disjunction operation, and mod denotes the modulo operation.
In certain implementations, the virtual machine identifier may be represented by an arbitrary value assigned to a virtual machine by the hypervisor upon the virtual machine's creation or start up. Alternatively, the virtual machine identifier may be provided by an identifier of the virtual network interface that has originated the data link layer frame.
Employing, for identifying an egress NIC of a bonded interface, a hash function whose value is dependent on the destination address (e.g., the MAC or network layer address) allows even a single active virtual machine utilize two or more NICs of the host computer system simultaneously. Employing a hash function whose value is dependent on an identifier of the virtual machine that has originated the frame allows better load balancing among two or more virtual machines utilizing similar traffic patterns.
Referring again to FIG. 2, responsive to receiving an outgoing data link layer frame, bonding driver 182 interface may identify an egress network interface controller (NIC) of the bonded interface by calculating a value of hash function 300. Bonding driver 182 may then transmit the outgoing frame via the selected NIC.
In certain implementations, bonded interface 220 may be configured to substitute the source MAC address of the outgoing data link layer frame with a MAC address of the identified egress NIC before transmitting the outgoing data link layer frame. In order to facilitate the delivery of incoming data link layer frames addressed to virtual machines 170, bonded interface 220 may be configured to respond to Address Resolution Protocol (ARP) requests with respect to network layer addresses assigned to the vNICs 194A-194N. Such an ARP response may comprise the MAC address of one of the NICs of the bonded interface. Incoming data link layer frames may thus be addressed to a NIC of the bonded interface and may then be routed by the bonded interface based on the network layer addresses.
Alternatively, bonded interface 220 may be configured to transmit the outgoing data link layer frame without substituting the source MAC address. In order to facilitate the delivery of incoming data link layer frames addressed to vNICs 194, bonded interface 220 may be configured to respond to Address Resolution Protocol (ARP) requests with respect to network layer addresses assigned to the vNICs 194A-194N. Such an ARP response may comprise the MAC address of the vNIC to which the network layer address is assigned. Host NICs 140 may be configured to receive, in the promiscuous mode, data link layer frames addressed to MAC addresses assigned to one or more vNICs 194A-194N. The received incoming data link layer frames may then be routed by the bonded interface to the destination vNIC 194 based on the MAC addresses.
“Promiscuous mode” herein refers to a mode of NIC operation in which the NIC passes to its driver all received data link layer frames, rather than dropping the data link layer frames that are not addressed to the particular NIC by a broadcast, multicast or unicast address.
FIG. 4 depicts a flow diagram of an example method 400 for hash-based load balancing implemented by bonded network interfaces, in accordance with one or more aspects of the present disclosure. Method 400 may be performed by a computer system that may comprise hardware (e.g., circuitry, dedicated logic, and/or programmable logic), software (e.g., instructions executable on a computer system to perform hardware simulation), or a combination thereof. Method 400 and/or each of its individual functions, routines, subroutines, or operations may be performed by one or more processors of the computer system executing the method. In certain implementations, method 400 may be performed by a single processing thread. Alternatively, method 400 may be performed by two or more processing threads, each thread executing one or more individual functions, routines, subroutines, or operations of the method. In an illustrative example, the processing threads implementing method 400 may be synchronized (e.g., using semaphores, critical sections, and/or other thread synchronization mechanisms). Alternatively, the processing threads implementing method 400 may be executed asynchronously with respect to each other.
At block 410, the bonding driver being executed by the example host computer system may receive an outgoing data link layer frame transmitted by a virtual machine via a data link layer bridge, as described in more details herein above.
At block 420, the bonding driver may select an egress NICs for outgoing frame transmission by calculating a value of a hash function constructed in accordance with one or more aspects of the present disclosure. Arguments of the hash function may include an identifier of the virtual machine that has originated the data link layer frame and one or more addresses of the data link layer frame (e.g., the destination Media Access Control (MAC) address of the data link layer frame and/or the destination network layer address of the network layer packet comprised by the data link layer frame), as described in more details herein above.
At block 430, the bonding driver may transmit the outgoing data link layer frame via the identified egress NIC. Responsive to completing operations described with reference to block 430, the method may loop back to block 410.
FIG. 5 depicts an example computer system 1000 which can perform any one or more of the methods described herein. In an illustrative example, computer system 1000 may correspond to host computer system 100 of FIG. 1.
In certain implementations, computer system 1000 may be connected (e.g., via a network, such as a Local Area Network (LAN), an intranet, an extranet, or the Internet) to other computer systems. Computer system 1000 may operate in the capacity of a server or a client computer in a client-server environment, or as a peer computer in a peer-to-peer or distributed network environment. Computer system 1000 may be provided by a personal computer (PC), a tablet PC, a set-top box (STB), a Personal Digital Assistant (PDA), a cellular telephone, a web appliance, a server, a network router, switch or bridge, or any device capable of executing a set of instructions (sequential or otherwise) that specify actions to be taken by that device. Further, the term “computer” shall include any collection of computers that individually or jointly execute a set (or multiple sets) of instructions to perform any one or more of the methods described herein.
In a further aspect, the computer system 1000 may include a processor 1002, a volatile memory 1004 (e.g., random access memory (RAM)), a non-volatile memory 1006 (e.g., read-only memory (ROM) or electrically-erasable programmable ROM (EEPROM)), and a secondary memory 1016 (e.g., a data storage device), which may communicate with each other via a bus 1008.
Processor 1002 may be provided by one or more processing devices such as a general purpose processor (such as, for example, a complex instruction set computing (CISC) microprocessor, a reduced instruction set computing (RISC) microprocessor, a very long instruction word (VLIW) microprocessor, a microprocessor implementing other types of instruction sets, or a microprocessor implementing a combination of types of instruction sets) or a specialized processor (such as, for example, an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a digital signal processor (DSP), or a network processor).
Computer system 1000 may further include a network interface controller 1022. Computer system 1000 also may include a video display unit 1010 (e.g., an LCD), an alphanumeric input device 1012 (e.g., a keyboard), a pointing device 1014 (e.g., a mouse), and an audio output device 1020 (e.g., a speaker).
Secondary memory 1016 may include a non-transitory computer-readable storage medium 1024 on which may be stored instructions 1054 encoding any one or more of the methods or functions described herein, including instructions encoding bonding driver 182 of FIG. 1 implementing method 400 for hash-based load balancing implemented by bonded network interfaces.
Instructions 1054 may also reside, completely or partially, within main memory 1004 and/or within processor 1002 during execution thereof by computer system 1000, hence, main memory 1004 and processor 1002 may also constitute machine-readable storage media.
While computer-readable storage medium 1024 is shown in the illustrative examples as a single medium, the term “computer-readable storage medium” shall include a single medium or multiple media (e.g., a centralized or distributed database, and/or associated caches and servers) that store the one or more sets of executable instructions. The term “computer-readable storage medium” shall also include any tangible medium that is capable of storing or encoding a set of instructions for execution by a computer that cause the computer to perform any one or more of the methods described herein. The term “computer-readable storage medium” shall include, but not be limited to, solid-state memories, optical media, and magnetic media.
The methods, components, and features described herein may be implemented by discrete hardware components or may be integrated in the functionality of other hardware components such as ASICS, FPGAs, DSPs or similar devices. In addition, the methods, components, and features may be implemented by firmware modules or functional circuitry within hardware devices. Further, the methods, components, and features may be implemented in any combination of hardware devices and software components, or only in software.
Unless specifically stated otherwise, terms such as “updating”, “identifying”, “determining”, “sending”, “assigning”, or the like, refer to actions and processes performed or implemented by computer systems that manipulates and transforms data represented as physical (electronic) quantities within the computer system registers and memories into other data similarly represented as physical quantities within the computer system memories or registers or other such information storage, transmission or display devices. Also, the terms “first,” “second,” “third,” “fourth,” etc. as used herein are meant as labels to distinguish among different elements and may not necessarily have an ordinal meaning according to their numerical designation.
Examples described herein also relate to an apparatus for performing the methods described herein. This apparatus may be specially constructed for performing the methods described herein, or it may comprise a general purpose computer system selectively programmed by a computer program stored in the computer system. Such a computer program may be stored in a computer-readable tangible storage medium.
The methods and illustrative examples described herein are not inherently related to any particular computer or other apparatus. Various general purpose systems may be used in accordance with the teachings described herein, or it may prove convenient to construct more specialized apparatus to perform method 400 and/or each of its individual functions, routines, subroutines, or operations. Examples of the structure for a variety of these systems are set forth in the description above.
The above description is intended to be illustrative, and not restrictive. Although the present disclosure has been described with references to specific illustrative examples and implementations, it will be recognized that the present disclosure is not limited to the examples and implementations described. The scope of the disclosure should be determined with reference to the following claims, along with the full scope of equivalents to which the claims are entitled.

## Claims

1. A method, comprising:
receiving, by a bonded interface of a computer system, a data link layer frame originated by a virtual machine;
identifying, by a processor, a network interface controller (NIC) of the bonded interface by calculating a value of a hash function of an identifier of the virtual machine and at least one of: a destination Media Access Control (MAC) address of the data link layer frame or a destination network layer address of a network layer packet comprised by the data link layer frame; and
transmitting the data link layer frame via the identified NIC.

2. The method of claim 1, wherein calculating the value of the hash function comprises performing at least one of: an addition operation or an exclusive disjunction (XOR) operation.

3. The method of claim 1, wherein calculating the value of the hash function comprises calculating a cyclic redundancy check (CRC) value.

4. The method of claim 1, further comprising:
retrieving, by a hypervisor running managing the virtual machine, the identifier of the virtual machine from a memory accessible by the hypervisor.

5. The method of claim 1, further comprising:
assigning, by a hypervisor managing the virtual machine, the identifier to the virtual machine.

6. The method of claim 1, wherein the identifier of the virtual machine is provided by an identifier of a virtual network interface that has originated the data link layer frame.

7. The method of claim 1, wherein transmitting the data link layer frame further comprises:
substituting a source MAC address of the data link layer frame with a MAC address of the identified NIC.

8. The method of claim 1, wherein transmitting the data link layer frame is performed without substituting a source MAC address of the data link layer frame.

9. A computer system comprising:
a memory; and
a processor, operatively coupled to the memory, to:
receive, by a bonded interface, a data link layer frame originated by a virtual machine;
identify a network interface controller (NIC) of the bonded interface by calculating a value of a hash function of an identifier of the virtual machine and at least one of: a destination Media Access Control (MAC) address of the data link layer frame or a destination network layer address of a network layer packet comprised by the data link layer frame; and
transmit the data link layer frame via the identified NIC.

10. The computer system of claim 9, wherein to calculate the value of the hash function, the processor is to perform at least one of: an addition operation or an exclusive disjunction (XOR) operation.

11. The computer system of claim 9, wherein to calculate the value of the hash function, the processor is to calculate a cyclic redundancy check (CRC) value.

12. The computer system of claim 9, wherein the processor is further to:
retrieve, by a hypervisor running managing the virtual machine, the identifier of the virtual machine from a memory accessible by the hypervisor.

13. The computer system of claim 9, wherein the processor is further to:
assign, by a hypervisor managing the virtual machine, the identifier to the virtual machine.

14. The computer system of claim 9, wherein to transmit the data link layer frame, the processor is further to:
substitute a source MAC address of the data link layer frame with a MAC address of the identified NIC.

15. The computer system of claim 9, wherein the processor is to transmit the data link layer frame without substituting a source MAC address of the data link layer frame.

16. A computer-readable non-transitory storage medium comprising executable instructions that, when executed by a processor, cause the processor:
receive, by a bonded interface, a data link layer frame originated by a virtual machine;
identify, by the processor, a network interface controller (NIC) of the bonded interface by calculating a value of a hash function of an identifier of the virtual machine and at least one of: a destination Media Access Control (MAC) address of the data link layer frame or a destination network layer address of a network layer packet comprised by the data link layer frame; and
transmit the data link layer frame via the identified NIC.

17. The computer-readable non-transitory storage medium of claim 16, further comprising executable instructions causing the processor to perform at least one of: an addition operation or an exclusive disjunction (XOR) operation.

18. The computer-readable non-transitory storage medium of claim 16, further comprising executable instructions causing the processor to calculate a cyclic redundancy check (CRC) value.

19. The computer-readable non-transitory storage medium of claim 16, further comprising executable instructions causing the processor to:
retrieve, by a hypervisor running managing the virtual machine, the identifier of the virtual machine from a memory accessible by the hypervisor.

20. The computer-readable non-transitory storage medium of claim 16, further comprising executable instructions causing the processor to:
assign, by a hypervisor managing the virtual machine, the identifier to the virtual machine.