summaryrefslogtreecommitdiff
path: root/lib/lacp.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>
* list: Rename all functions in list.h with ovs_ prefix.Ben Warren2016-03-301-2/+2
| | | | | | | 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>
* 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>
* userspace: Define and use struct eth_addr.Jarno Rajahalme2015-08-281-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* lacp: Remove packed attribute from struct lacp_pdu.Ben Pfaff2015-06-171-2/+1
| | | | | | | | | The packed annotation doesn't do anything here because all of the members in the structure are naturally aligned. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Flavio Leitner <fbl@sysclose.org> Acked-by: Ethan Jackson <ethan@nicira.com>
* hmap: Don't include ovs-atomic.h unnecessarily.Ben Pfaff2015-03-311-1/+2
| | | | | | | | | | | GNU C++ isn't too happy with ovs-atomic.h. We could fix that (maybe we should) but the report I received from a C++ user implied to me that it would be just as useful to just drop the unnecessary #include "ovs-atomic.h" from hmap.h. Reported-by: Michael Hu <humichael@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* dp-packet: Remove ofpbuf dependency.Pravin B Shelar2015-03-031-4/+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>
* 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>
* lib: Expose struct ovs_list definition in <openvswitch/list.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | Expose the struct ovs_list definition in <openvswitch/list.h>. Keep the list access API private for now. 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-3/+3
| | | | | | | 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>
* sflow: Export LAG, PORTNAME, and OPENFLOWPORT information also.Neil McKee2014-11-111-0/+62
| | | | | | | | | | | | | | | | | | | Export standard sFlow LAG, PORTNAME and OPENFLOWPORT structures with each counter-sample. Add unit-test for sFlow-LAG. Adjust other unit-tests to accommodate these new annotations. The sFlow-LAG structures are important for topology discovery, for troubleshooting LAG instability, and for correctly combining sFlow feeds from multiple sources. The OPENFLOWPORT and PORTNAME structures are important for systems that aim to combine sFlow monitoring with OpenFlow controls, as they provide straightforward mapping (1) between sFlow agent IP and OpenFlow datapath-id, and (2) between interface name,ifIndex and OpenFlow port number. Signed-off-by: Neil McKee <neil.mckee@inmon.com> Signed-off-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>
* lacp: Really fix mutex initialization.Ben Pfaff2014-05-071-32/+44
| | | | | | | | | | | | | | | | | | | | Commit 2a3fb0aa3c (lacp: Don't lock potentially uninitialized mutex in lacp_status().) fixed one bug related to acquiring the file scope 'mutex' without initializing it. However, there was at least one other, in lacp_unixctl_show(). One could just fix that one problem, but that leaves the possibility that I might have missed one or two more. This commit fixes the problem for good, by adding a helper that initializes the mutex and then acquires it. It's not entirely clear why 'mutex' is a recursive mutex. I think that it might be just because of the callback in lacp_run(). An alternate fix, therefore, would be to eliminate the callback and therefore the need for runtime initialization of the mutex. Bug #1245659. Reported-by: Jeffrey Merrick <jmerrick@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
* lacp: Don't lock potentially uninitialized mutex in lacp_status().Ben Pfaff2014-04-281-9/+9
| | | | | | | | If the 'lacp' parameter is nonnull, then we know that the file scope mutex has been initialized, since that's done as a side effect of creating a lacp object, but otherwise there's no guarantee. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofpbuf: Rename trivial _get_ functions without the "get".Jarno Rajahalme2014-04-031-1/+1
| | | | | | | | Code reads better without the "get", for example "ofpbuf_l3()" v.s. "ofpbuf_get_l3()". L4 payoad access functions still use the "get" (e.g., "ofpbuf_get_tcp_payload()"). Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
* ofpbuf: Introduce access api for base, data and size.Pravin Shelar2014-03-301-1/+1
| | | | | | | These functions will be used by later patches. Following patch does not change functionality. Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
* lib/ofpbuf: CompactJarno Rajahalme2014-03-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch shrinks the struct ofpbuf from 104 to 48 bytes on 64-bit systems, or from 52 to 36 bytes on 32-bit systems (counting in the 'l7' removal from an earlier patch). This may help contribute to cache efficiency, and will speed up initializing, copying and manipulating ofpbufs. This is potentially important for the DPDK datapath, but the rest of the code base may also see a little benefit. Changes are: - Remove 'l7' pointer (previous patch). - Use offsets instead of layer pointers for l2_5, l3, and l4 using 'l2' as basis. Usually 'data' is the same as 'l2', but this is not always the case (e.g., when parsing or constructing a packet), so it can not be easily used as the offset basis. Also, packet parsing is faster if we do not need to maintain the offsets each time we pull data from the ofpbuf. - Use uint32_t for 'allocated' and 'size', as 2^32 is enough even for largest possible messages/packets. - Use packed enum for 'source'. - Rearrange to avoid unnecessary padding. - Remove 'private_p', which was used only in two cases, both of which had the invariant ('l2' == 'data'), so we can temporarily use 'l2' as a private pointer. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-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>
* ovs-atomic: Introduce a new 'struct ovs_refcount'.Ben Pfaff2014-01-081-15/+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-1/+1
| | | | | | | | 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>
* ofproto-dpif: Don't poll ports when nothing changesJoe Stringer2013-12-121-0/+8
| | | | | | | | | | | | | | | | | | Previously, as part of ofproto-dpif run() processing, we would loop through all ports and poll for changes to carrier, bfd, cfm and lacp status. This information is used to determine whether bundles may be enabled, and to perform revalidation when needed. This patch makes the bfd, cfm, lacp and stp modules aware of the new global connectivity_seq, notifying on changes in port status. We can then use connectivity_seq to check if anything has changed before looping through all ports in ofproto-dpif. 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 35% to about 25%. Signed-off-by: Joe Stringer <joestringer@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* bond: Use active-backup mode on LACP failure.Ravi Kondamuru2013-11-121-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit bdebeece5 (lacp: Require successful LACP negotiations when configured.) makes successful LACP negotiation mandatory for the bond to come UP. This patch provides a configuration option to bring up the bond by falling back to active-backup mode on LACP negotiation failure. Several of the physical switches that support LACP block all traffic for ports that are configured to use LACP, until LACP is negotiated with the host. When configuring a LACP bond on a OVS host (eg: XenServer), this means that there will be an interruption of the network connectivity between the time the ports on the physical switch and the bond on the OVS host are configured. The interruption may be relatively long, if different people are responsible for managing the switches and the OVS host. Such network connectivity failure can be avoided if LACP can be configured on the OVS host before configuring the physical switch, and having the OVS host fall back to a bond mode (active-backup) till the physical switch LACP configuration is complete. An option "lacp-fallback-ab" is introduced with this patch to provide such behavior on openvswitch. Signed-off-by: Ravi Kondamuru <Ravi.Kondamuru@citrix.com> Signed-off-by: Dominic Curran <Dominic.Curran@citrix.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* Use "error-checking" mutexes in place of other kinds wherever possible.Ben Pfaff2013-08-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | We've seen a number of deadlocks in the tree since thread safety was introduced. So far, all of these are self-deadlocks, that is, a single thread acquiring a lock and then attempting to re-acquire the same lock recursively. When this has happened, the process simply hung, and it was somewhat difficult to find the cause. POSIX "error-checking" mutexes check for this specific problem (and others). This commit switches from other types of mutexes to error-checking mutexes everywhere that we can, that is, everywhere that we're not using recursive mutexes. This ought to help find problems more quickly in the future. There might be performance advantages to other kinds of mutexes in some cases. However, the existing mutex type choices were just guesses, so I'd rather go for easy detection of errors until we know that other mutex types actually perform better in specific cases. Also, I did a quick microbenchmark of glibc mutex types on my host and found that the error checking mutexes weren't any slower than the other types, at least when the mutex is uncontended. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* clang: Pass objects, not their addresses, to thread-safety macros.Alex Wang2013-08-091-2/+2
| | | | | | | | This commit changes the code such that arguments to thread-safety macros are not ampersanded. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* clang: Use OVS_REQUIRES() instead of OVS_REQ_WRLOCK() for plain mutex.Alex Wang2013-08-091-20/+20
| | | | | | | | This commit changes the code to use OVS_REQUIRES() instead of OVS_REQ_WRLOCK(), for plain mutex. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* lacp: Make the LACP module thread safe.Ethan Jackson2013-07-311-59/+138
| | | | | Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Make attribute packed equivalent for MSC compilers.Linda Sun2013-07-171-2/+4
| | | | | Signed-off-by: Linda Sun <lsun@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* lacp: Handle unknown slaves in lacp_process_packet().Ethan Jackson2013-07-071-2/+12
| | | | | | | | | | In future patches, ofproto-dpif-xlate may be temporarily out of sync with ofproto-dpif proper, and pass an unknown ofport to lacp_process_packet(). This patch handles that edge case gracefully. Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lacp: Reference count 'struct lacp'.Ethan Jackson2013-06-271-2/+21
| | | | | Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lacp: Remove unused lacp_slave_get_port_id().Ethan Jackson2013-06-241-8/+0
| | | | | Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Replace most uses of assert by ovs_assert.Ben Pfaff2013-01-161-3/+2
| | | | | | | | This is a straight search-and-replace, except that I also removed #include <assert.h> from each file where there were no assert calls left. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* lacp: Fix dumping of the aggregation key.Anoob Soman2013-01-021-1/+3
| | | | | | | | | While dumping lacp information using ovs-appctl, the "aggregation key" field displays the port_id even though the aggregation key is set using "other-config:lacp-aggregation-key". Signed-off-by: Anoob Soman <anoob.soman@citrix.com> Signed-off-by: Ethan Jackson <ethan@nicira.com>
* lacp: Print may_enable flag in appctl output.Ethan Jackson2012-06-071-5/+11
| | | | | | I would have found this helpful when debugging a problem recently. Signed-off-by: Ethan Jackson <ethan@nicira.com>
* Global replace of Nicira Networks.Raju Subramanian2012-05-021-1/+1
| | | | | | | | Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc. Feature #10593 Signed-off-by: Raju Subramanian <rsubramanian@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* lacp: Remove heartbeat mode.Ethan Jackson2012-04-171-15/+2
| | | | | | | | | The LACP heartbeat mode was used to monitor interfaces for connectivity. It turns out that LACP is inferior to CFM for this purpose. For the sake of simplicity this patch removes the feature. Signed-off-by: Ethan Jackson <ethan@nicira.com>
* lacp: Remove custom transmission intervals.Ethan Jackson2012-04-171-45/+10
| | | | | | | | | | Open vSwitch allowed users to set a custom LACP PDU transmission interval. This turned out to be an ill conceived idea which was more confusing than useful. This patch reverts Open vSwitch to the behavior supported in the LACP specification: two transmission intervals, fast and slow. Signed-off-by: Ethan Jackson <ethan@nicira.com>
* lacp: Notify LACP module when carrier changes.Ethan Jackson2012-03-071-4/+6
| | | | | | | | | | | | Without this patch, when a slave's carrier goes down, the LACP module (as evidenced by ovs-appctl lacp/show) would consider the slave current until it hadn't received LACP PDUs for the requisite amount of time. It should instead, immediately mark the slave expired. This shouldn't actually affect the behavior of LACP bonds because the bond module won't choose to send traffic out a slave whose carrier is down. Signed-off-by: Ethan Jackson <ethan@nicira.com>
* unixctl: New JSON RPC back-end.Ethan Jackson2012-02-211-2/+2
| | | | | | | | | | | | | The unixctl library had used the vde2 management protocol since the early days of Open vSwitch. As Open vSwitch has matured, several Python daemons have been added to the code base which would benefit from a unixctl implementations. Instead of implementing the old unixctl protocol in Python, this patch changes unixctl to use JSON RPC for which we already have an implementation in both Python and C. Future patches will need to implement a unixctl library in Python on top of JSON RPC. Signed-off-by: Ethan Jackson <ethan@nicira.com>
* lacp: Require successful LACP negotiations when configured.Ethan Jackson2012-01-231-15/+15
| | | | | | | | | | | In the original Open vSwitch LACP implementation, when no slaves found a LACP partner, the LACP module would attach all of them. This allowed the LACP bond to fall back to a standard bond when partnered with a non-LACP switch. In practice, this has caused confusion with marginal benefit, so this feature is removed with this patch. Signed-off-by: Ethan Jackson <ethan@nicira.com>
* unixctl: Implement quoting.Ben Pfaff2011-12-191-7/+7
| | | | | | | | | | | | | | | | | | | The protocol used by ovs-appctl has a long-standing bug that there is no way to distinguish "ovs-appctl a b c" from "ovs-appctl 'a b c'". This isn't a big deal because none of the current commands really want to accept arguments that include spaces, but it's kind of a silly limitation. At the same time, the internal API is awkward because every user is stuck doing its own argument parsing, which is no fun. This commit fixes both problems, by adding shell-like quoting to the protocol and modifying the internal API from one that passes a string to one that passes in an array of pre-parsed strings. Command implementations may now specify how many arguments they expect. This simplifies some command implementations significantly. Signed-off-by: Ben Pfaff <blp@nicira.com>
* lacp: Avoid valgrind warning in lacp_configure() if custom timing not used.Ben Pfaff2011-12-091-1/+3
| | | | | | | | | The caller currently doesn't fill in s->custom_time unless it actually wants a custom LACP time, but lacp_configure() still does a calculation with it, provoking a warning from valgrind. This eliminates the warning. The calculated value was not actually used in this case, so this commit does not fix a real bug.
* lacp: Sort slaves in appctl output.Ethan Jackson2011-11-301-0/+14
| | | | This will simplify unit tests added in a future patch.
* lacp: Remove trailing whitespace from appctl output.Ethan Jackson2011-11-301-10/+10
| | | | This will marginally simplify some unit tests in a future patch.
* lacp: Require non-zero system ID.Ethan Jackson2011-11-301-0/+2
| | | | | It's a bug if LACP is configured with a system ID of zero. This patch assert fails in this case.
* lacp: Make argument to ovs-appctl "lacp/show" command optional.Justin Pettit2011-09-291-47/+58
| | | | | If an argument isn't passed to "lacp/show", it will print information about all interfaces with LACP enabled.
* ovs-appctl: Print command arguments for "help".Justin Pettit2011-09-291-1/+1
|
* lacp: Clean up LACP module interface.Ethan Jackson2011-09-081-9/+66
| | | | | | | | There's no particular reason to force users of the LACP module to be aware of the lacp_pdu structure. This patch hides that information in the LACP module implementation. This results in slightly cleaner code which is more consistent with the CFM module.
* lacp: Loosen lacp_slave_is_current().Ethan Jackson2011-06-141-1/+1
| | | | | | | | | The lacp_slave_is_current() function is used to indicate to a controller failover status of the LACP module. However, the result of this function is more strict than the failover logic. Thus, the function will generally return false quite a bit before a failover actually happens. This patch loosens lacp_slave_is_current() so that it changes in-line with the failover logic.
* lacp: New "lacp-heartbeat" mode.Ethan Jackson2011-05-061-12/+13
| | | | | | | | This commit creates a new heartbeat mode for LACP. This mode treats LACP as a protocol simply for monitoring link status. It strips out most of the sanity checks built into the protocol. Addition of this mode makes "lacp-force-aggregatable" and "lacp-strict" options obsolete so they are removed.