summaryrefslogtreecommitdiff
path: root/ofproto/bond.c
Commit message (Collapse)AuthorAgeFilesLines
* json: Move from lib to include/openvswitch.Terry Wilson2016-07-221-2/+3
| | | | | | | | | | | | | | | To easily allow both in- and out-of-tree building of the Python wrapper for the OVS JSON parser (e.g. w/ pip), move json.h to include/openvswitch. This also requires moving lib/{hmap,shash}.h. Both hmap.h and shash.h were #include-ing "util.h" even though the headers themselves did not use anything from there, but rather from include/openvswitch/util.h. Fixing that required including util.h in several C files mostly due to OVS_NOT_REACHED and things like xmalloc. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* hmap: Add HMAP_FOR_EACH_POP.Daniele Di Proietto2016-04-261-6/+4
| | | | | | | Makes popping each member of the hmap a bit easier. Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Acked-by: Ben Pfaff <blp@ovn.org>
* Move lib/ofp-actions.h to include/openvswitch directoryBen Warren2016-04-141-11/+10
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/ofp-util.h to include/openvswitch directoryBen Warren2016-04-141-1/+1
| | | | | | | | This commit also adds several #include directives in source files in order to make the 'ofp-util.h' move possible Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/match.h to include/openvswitch directoryBen Warren2016-04-141-1/+1
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/ofpbuf.h to include/openvswitch directoryBen Warren2016-03-301-2/+2
| | | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Acked-by: Ryan Moats <rmoats@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* list: Rename all functions in list.h with ovs_ prefix.Ben Warren2016-03-301-19/+19
| | | | | | | This attempts to prevent namespace collisions with other list libraries Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* list: Remove lib/list.h completely.Ben Warren2016-03-301-1/+1
| | | | | | | | All code is now in include/openvswitch/list.h. Signed-off-by: Ben Warren <ben@skyportsystems.com> Acked-by: Ryan Moats <rmoats@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* bond: don't re-zero recirc_id when creating bondSimon Horman2016-03-231-2/+0
| | | | | | | | The bond structure is already zeroed as it is allocated using xzalloc so there is no need to re-zero the recirc_id field. Signed-off-by: Simon Horman <simon.horman@netronome.com> Acked-by: Ben Pfaff <blp@ovn.org>
* Move lib/dynamic-string.h to include/openvswitch directoryBen Warren2016-03-191-1/+1
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* bond: Use correct type for slave's change_seq.Jarno Rajahalme2015-12-041-1/+1
| | | | | | | | | | | | | | | seq values are 64-bit, and storing them to a 32-bit variable causes the stored value never to match actual seq value after the seq value gets big enough. This is a likely cause of OVS main thread using 100% CPU in a system using bonds after some runtime. VMware-BZ: #1564993 Reported-by: Hiram Bayless <hbayless@vmware.com> Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* ofproto/bond: simplify rebalancing logicAndy Zhou2015-09-221-18/+19
| | | | | | | | | | | | | | | | | | | The current bond relancing logic is more complicated than necessary. When considering a bucket for rebalancing, we just need to make sure post rebalancing traffic will be closer to the ideal traffic split than before. This patch implements the simplification. There is a bug is current algorithm that causes a heavyly loaded bucket to ping-pong for each reblancing interval. The simplied loigc also fixes this bug. Though not the main motivation for the change, computations are now done with integer math rather than floating math. Reported-by: Gregory Smith <gasmith@nutanix.com> tested-by: Gregory Smith <gasmith@nutanix.com> Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* userspace: Define and use struct eth_addr.Jarno Rajahalme2015-08-281-20/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Define struct eth_addr and use it instead of a uint8_t array for all ethernet addresses in OVS userspace. The struct is always the right size, and it can be assigned without an explicit memcpy, which makes code more readable. "struct eth_addr" is a good type name for this as many utility functions are already named accordingly. struct eth_addr can be accessed as bytes as well as ovs_be16's, which makes the struct 16-bit aligned. All use seems to be 16-bit aligned, so some algorithms on the ethernet addresses can be made a bit more efficient making use of this fact. As the struct fits into a register (in 64-bit systems) we pass it by value when possible. This patch also changes the few uses of Linux specific ETH_ALEN to OVS's own ETH_ADDR_LEN, and removes the OFP_ETH_ALEN, as it is no longer needed. This work stemmed from a desire to make all struct flow members assignable for unrelated exploration purposes. However, I think this might be a nice code readability improvement by itself. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
* odp-util: Share fields between odp and dpif_backer.Joe Stringer2015-07-061-1/+1
| | | | | | | | Datapath support for some flow key fields is used inside ofproto-dpif as well as odp-util. Share these fields using the same structure. Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
* ofproto-dpif: Restore metadata and registers on recirculation.Jarno Rajahalme2015-03-261-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | xlate_actions() now considers an optional recirculation context (via 'xin') and restores OpenFlow pipeline metadata (registers, 'metadata', etc.) based on it. The recirculation context may contain an action set and stack to be restored and further actions to be executed upon recirculation. It also contains a table_id number to be used for rule lookup in cases where no post-recirculation actions are used. The translation context internal metadata is restored using a new internal action: UNROLL_XLATE action stores the translation context data visible to OpenFlow controllers via PACKET_IN messages. This includes the current table number and the current rule cookie. UNROLL_XLATE actions are inserted only when the remaining actions may generate PACKET_IN messages. These changes allow the post-MPLS recirculation to properly continue with the pipeline metadata that existed at the time of recirculation. The internal table is still consulted for bonds. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* dp-packet: Remove ofpbuf dependency.Pravin B Shelar2015-03-031-3/+4
| | | | | | | | | | | | | Currently dp-packet make use of ofpbuf for managing packet buffers. That complicates ofpbuf, by making dp-packet independent of ofpbuf both libraries can be optimized for their own use case. This avoids mapping operation between ofpbuf and dp_packet in datapath upcalls. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ofproto/bond: Fix a race condition in updating post recirculation rulesAndy Zhou2015-02-171-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | When updating post recirc rules, rule management requires calls to hmap APIs, which requires proper locking to ensure mutual exclsion in accessing the hmap internal data structure. The locking currently is missing from the output_normal() xlate path, thus causing a race condition. The race condition leads to segfault crash of ovs-vswitchd, with the following stack trace: The crash was found by adding and deleting bond interfaces repeatedly with on-going traffic hitting the bond interfaces. The same test was ran over multiple days with this patch to ensure the same crash was not seen. The patch added the necessary lock annotation that would have caught the bug. Tested-by: Salvatore Cambria <salvatore.cambria@citrix.com> Reported-by: Salvatore Cambria <salvatore.cambria@citrix.com> Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib: Move vlog.h to <openvswitch/vlog.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | A new function vlog_insert_module() is introduced to avoid using list_insert() from the vlog.h header. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* list: Rename struct list to struct ovs_listThomas Graf2014-12-151-11/+11
| | | | | | | struct list is a common name and can't be used in public headers. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Fix misspellings of "OpenFlow".Ben Pfaff2014-11-121-1/+1
| | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Flavio Leitner <fbl@redhat.com>
* Use magic ETH_ADDR_LEN instead of 6 for Ethernet address length.Wang Sheng-Hui2014-10-221-3/+3
| | | | | | | | | ETH_ADDR_LEN is defined in lib/packets.h, valued 6. Use this macro instead of magic number 6 to represent the length of eth mac address. Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* bridge: Keep bond active slave selection across OVS restartAndy Zhou2014-10-061-0/+86
| | | | | | | | | | | | | | | | | | | | | Whenever OVS restarts, it pseudo-randomly picks an interface of a bond port to be the active slave. This can cause traffic disruption in case the upstream switch does not support LACP, or in case of multi-chassis switches that do not support mLACP. This patch helps the situation by always record the last active slave into ovsdb. When OVS restarts, the stored last active slave has the highest priority to be selected again. In case this interface is available, due to configuration changes or being offline, OVS then consider other interfaces with the bond as it does today. In a nutshell, this patch makes the active slave selection stickier across OVS restart. VMware-BZ: 1332235 Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* ofproto: Do not update stats on fake bond interface.Pravin B Shelar2014-09-151-59/+0
| | | | | | | | | | | There are couple of reasons to remove this support: * This is used in very old OVS use-case. It is much better to read stats directly from OVS. * Forthcoming commit will remove support for setting stats for vport. The stats update depends on stats-set. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Use ovs_refcount_unref_relaxed.Jarno Rajahalme2014-07-071-1/+1
| | | | | | | | | | After a quick analysis, in most cases the access to refcounted objects is clearly protected either with an explicit lock/mutex, or RCU. there are only a few places where I left a call to ovs_refcount_unref(). Upon closer analysis it may well be that those could also use the relaxed form. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ofproto-dpif: Add idle_timeout parameter to ofproto_dpif_add_internal_flow()Simon Horman2014-06-111-1/+1
| | | | | | | | | | | | This is in preparation for using the same helper as part of support for using recirculation in conjunction series of actions including with MPLS actions that are currently not able to be translated. In that scenario the idle timeout will be used to expire internal rules that are added to handle recirculation. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofproto-dpif: Move RECIRC_RULE_PRIORITY to common headerSimon Horman2014-06-111-1/+0
| | | | | | | | | This is in preparation for using this value in ofproto-dpif-xlate.c when composing recirculation actions added as a result of processing (MPLS) actions. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
* bond: fix a bug that disabled bond stats collectionAndy Zhou2014-05-071-3/+2
| | | | | | | Bug #1229225 Signed-off-by: Andy Zhou <azhou@nicira.com> Reviewed-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
* bond: fix uninitialized use of use_recirc variableAndy Zhou2014-04-291-1/+2
| | | | | | | | Caught by clang-3.5. Reported-by: Simon Horman <horms@verge.net.au> Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Pritesh Kothari <pritesh.kothari@cisco.com>
* ofproto-dpif: restore bond rebalance for non-recirc bondAndy Zhou2014-04-281-6/+15
| | | | | | | | | | | Bond rebalancing was disabled for bonds not using recirculation. The patch fixes this bug. While fixing the bug, the bond_rebalance() was also restructured slightly to move bond related logic back into ofproto/bond.c Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ofproto-bond: do not allow recirculation when we failed to allocate recirc_idAndy Zhou2014-04-281-1/+1
| | | | | | | | | | When recirc pool is exhausted, a new bond won't be allocate a new recirc_id. The bond->recirc_id will remain zero. This condition should prevent the bond from use recirculation. This check was missing before this patch. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ofproto-dpif: Rule lookup starts from table zero for non-recirc datapathAndy Zhou2014-04-201-2/+0
| | | | | | | | | | | | Currently, all packet lookup starts from internal table for possible matching of post recirculation rules. This is not necessary for datapath that does not support recirculation. This patch adds the ability to steering rule lookup starting table based on whether datapath supports recirculation. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* ofproto/bond: properly maintain hash entry pr_ruleAndy Zhou2014-04-161-22/+16
| | | | | | | | | This is a bug causing per hash entry's pr_rule pointer not properly maintained; they became NULL after each rebalancing. This patch fixes this bug. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* ofproto/bond: Keep hash entry slave valid.Andy Zhou2014-04-161-3/+0
| | | | | | | | | Bond recirculation needs to refresh the 'hidden rules' from time to time. Keep hash entry slave valid to prevent those hidden rules from being removed. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* ofproto/bond: only display hash entries with tx_byptes > 1KBAndy Zhou2014-04-161-2/+6
| | | | | | | | | | When recirculation is used to implement bond, all bond entries are always populated regardless whether there is traffic going through them or not. This change cuts down the noise when running 'ovs-appctl bond/show', by skipping '0KB' entries. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* ofproto/bond: Protect statistics with writelock.Joe Stringer2014-04-141-8/+14
| | | | | | | | | | | dcf00ba35a0 (ofproto/bond: Implement bond megaflow using recirculation) allowed bond_entry statistics to be modified while holding a readlock. This patch modifies bond_entry_account() to get a writelock before modifying the statistics and adds thread-safety annotations to these fields and relevant functions. Signed-off-by: Joe Stringer <joestringer@nicira.com> Signed-off-by: Andy Zhou <azhou@nicira.com>¬
* ofproto/bond: Minor cleanups.Joe Stringer2014-04-141-7/+7
| | | | | | | Add a constant for the number of bond buckets, and other minor cleanups. Signed-off-by: Joe Stringer <joestringer@nicira.com> Signed-off-by: Andy Zhou <azhou@nicira.com>¬
* ofproto/bond: Implement bond megaflow using recirculationAndy Zhou2014-04-071-10/+264
| | | | | | | | | | | | | | | | Infrastructure to enable megaflow support for bond ports using recirculation. This patch adds the following features: * Generate RECIRC action when bond can benefit from recirculation. * Populate post recirculation rules in a hidden table. Currently table 254. * Uses post recirculation rules for bond rebalancing * A recirculation implementation in dpif-netdev. The goal of this patch is to be able to megaflow bond outputs and thus greatly improve performance. However, this patch does not actually improve the megaflow generation. It is left for a later commit. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib/packet.h: add hash_mac()Andy Zhou2014-03-281-1/+1
| | | | | | | Add hash_mac() and apply it when appropriate. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovs-atomic: Delete atomic, atomic_flag, ovs_refcount destroy functions.Ben Pfaff2014-03-131-2/+1
| | | | | | | | None of the atomic implementations need a destroy function anymore, so it's "more standard" and more convenient for users to get rid of them. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
* bond: Change the way of assigning bond slave for unassigned bond entry.Alex Wang2014-02-111-9/+49
| | | | | | | | | | | Before this commit, ovs randomly selects a slave for unassigned bond entry. If the selected slave is not enabled, the active slave is chosen instead. In this commit, the slave is selected from the list of all enabled slaves in a round-robin fashion. This helps improve the consistency of bond behavior when new flows are added. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib: Add tpid parameter to eth_push_vlan()Simon Horman2014-01-161-1/+1
| | | | | | | | This is in preparation for pushing vlan tags using the TPID provided by the kernel via auxdata. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-atomic: Introduce a new 'struct ovs_refcount'.Ben Pfaff2014-01-081-14/+5
| | | | | | | | | | | This is a thin wrapper around an atomic_uint. It is useful anyhow because each ovs_refcount_ref() or ovs_refcount_unref() call saves a few lines of code. This commit also changes all the potential direct users over to use the new data structure. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-atomic: Add atomic_destroy() and use everywhere it is needed.Ben Pfaff2014-01-081-0/+1
| | | | | | | C11 is able to require that atomics don't need to be destroyed, but some of the OVS implementations do. Signed-off-by: Ben Pfaff <blp@nicira.com>
* Rename NOT_REACHED to OVS_NOT_REACHEDHarold Lim2013-12-171-3/+3
| | | | | | | | This allows other libraries to use util.h that has already defined NOT_REACHED. Signed-off-by: Harold Lim <haroldl@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* netdev: Globally track port status changesJoe Stringer2013-12-121-4/+4
| | | | | | | | | | | | | | | | | | | | Previously, we tracked status changes for ofports on a per-device basis. Each time in the main thread's loop, we would inspect every ofport to determine whether the status had changed for corresponding devices. This patch replaces the per-netdev change_seq with a global 'struct seq' which tracks status change for all ports. In the average case where ports are not constantly going up or down, this allows us to check the sequence once per main loop and not poll any ports. In the worst case, execution is expected to be similar to how it is currently. In a test environment of 5000 internal ports and 50 tunnel ports with bfd, this reduces average CPU usage of the main thread from about 40% to about 35%. Signed-off-by: Joe Stringer <joestringer@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* ofproto: Move bond files to ofprotoAndy Zhou2013-12-061-0/+1560
Relocating bond.[ch] to allow bond.c to make ofproto calls. This is needed for upcoming patches that enable megaflow support for bond ports. Signed-off-by: Andy Zhou <azhou@nicira.com>