Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a new NF to our collection, the Load Balancer NF. The Load Balancer NF is an L3, round-robin load balancer that distributes network traffic across multiple backend servers. This NF takes advantage of the ONVM NFLib Flow Table to maintain a list of network flows. Using the flow table and the source NIC port of a packet, the Load Balancer NF is able to decide how to route it: either load balancer to backend server or vice versa. If incoming traffic does not have a pre-existing entry in the flow table, one will be created and subsequent traffic in that flow will be routed accordingly. For detailed information about using the NF and how it works, please read the corresponding README in the NF directory. The Load Balancer NF performs advanced operation on the network traffic to determine how to route them. With this requirement, we add several new APIs to the OpenNetVM NFLib to aid NF development. New NFLib APIs: * `int onvm_pkt_parse_ip(char* ip_str, uint32_t* dest)` - Parses IP Addresses in dotted decimal form (192.168.1.1) to decimal form (3232235777) * `int onvm_pkt_parse_mac(char * mac_str, uint8_t* dest)` - Parses MAC Addresses in string form (11:22:33:44:55:66) to an array of six octets * `uint32 onvm_pkt_get_checksum_offload_flags(uint8_t port_id)` - Determine if the NIC port supports checksum offloading * `void onvm_pkt_set_checksums(struct rte_mbuf* pkt)` - Recalculate and set packet checksums * `static uint16_t calculate_tcpudp_cksum(const struct ipv4_hdr *ip, const void *l4_hdr, const uint32_t l3_len, uint8_t protocol)` - Calculates the TCP or UDP checksum based on the provided headers * `static uint16_t calculate_ip_cksum(const struct ipv4_hdr *ip, const uint32_t l3_len)` - Calculates the IP checksum based on the provided headers * `#define ONVM_PKT_GET_FLAGS(tcp, flags)` - Gets the TCP flags from the provided header * `#define ONVM_PKT_SET_FLAGS(tcp, flags)` - Sets the TCP flags of the provided header Commit log: * Initial commit for load_balancer NF - Layer 3 round-robin load balancer - Using onvm_flow_table to keep track of flows - Using tcp_helper for pkt checksum recalculation - Config values are currently hard coded in the .c file - Still has testing values and debug prints * Added basic config file parsing - Config file has Number of entries -- Each entry has ip and mac or backend server * Removed debug printing, added some comments * Added config filename parsing, more error checks * Better code structure, style fixes * Remove hard coded mac for client * Added client/server iface name args - Added parsing of the interface information, mathing interface to onvm ports id - Multiple name changes - This removes hard coded port values * Minor updates * README, config example * Clearing up flow entries after expiration timeout - This mimics the flow_tracker NF logic of terminatin old flows - Old flow termination happens when flow table gets full, should also be cleaned up on some timeout * Change flow_table returns, fixed mac iface id bug - Change return of table_lookup to int value, flow_info is now passed as an argument - Fixed mac iface mac comparison with onvm_mgr - Fixed wrong client/server port id refernces in packet_handler * Added arp table print * Minor printing changes * Moved to a no-modification client ip style - This allows the load balancer to handle multiple clients - Now instead of modifying the client ip to send it to the backend server we add a routing rule to the backend server - Remove hard coded port switching with !port * Documentation for the NF * Moved global variables to loadbalance struct * Moved checksum helper function to onvm_pkt_helper * Change year in Makefile * Requested changes: macro functions, readme changes * Removed unused pkt_copy func * Parse ip/mac functions, change macro functions
- Loading branch information