summaryrefslogtreecommitdiff
path: root/lib/stp.c
Commit message (Collapse)AuthorAgeFilesLines
* stp: Initialize mutex whenever we register unixctl command.Ben Pfaff2016-05-201-12/+15
| | | | | | | | | | | | The stp/tcn command, which locks the mutex, was being registered without initializing the mutex, so calling stp/tcn before STP was enabled on the switch caused a crash. This commit fixes the bug by initializing the mutex at the same time we register the stp/tcn command. Reported-by: Ding Zhi <zhi.ding@6wind.com> Reported-at: http://openvswitch.org/pipermail/dev/2016-May/071381.html Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Quentin Monnet <quentin.monnet@6wind.com>
* Move lib/ofpbuf.h to include/openvswitch directoryBen Warren2016-03-301-1/+1
| | | | | | 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-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>
* userspace: Define and use struct eth_addr.Jarno Rajahalme2015-08-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* dp-packet: Remove 'frame' member.Daniele Di Proietto2015-05-181-1/+1
| | | | | | | | | | | | | | In 'struct ofpbuf' the 'frame' pointer was used to parse different kinds of data (Ethernet, OpenFlow, Netlink attributes). For Ethernet packets the 'frame' pointer was supposed to have the same value as the 'data' pointer. Since 'struct dp_packet' is only used for Ethernet packets, there's no need for a separate 'frame' pointer: we can use the 'data' pointer instead. Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* dp-packet: Remove ofpbuf dependency.Pravin B Shelar2015-03-031-9/+10
| | | | | | | | | | | | | 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/+2
| | | | | | | | 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>
* stp,rstp: disable learning and forwarding in STP/RSTP disabled state.Daniele Venturino2014-11-141-8/+4
| | | | | | | | | | | | | There is a difference between a port with STP/RSTP protocol enabled and a disabled role and a port which has a disabled role because STP/RSTP is not active. This commit ensure to make such distinction. Standard 802.1D claims that the Topology Change state machine (17.31) treats a Port as no longer active when it becomes an Alternate, Backup, or Disabled Port and stops learning from received frames. Signed-off-by: Daniele Venturino <daniele.venturino@m3s.it> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* lib/stp: Some debugging support.Jarno Rajahalme2014-09-091-1/+6
| | | | | | | | | | | Set the stp port name before enabling it, so that debugging messages have the name to print out. Do not treat the first state initialization as a state change. Zero is not a valid state, so changing from zero to STP_DISABLED is not a state change. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Daniele Venturino <daniele.venturino@m3s.it>
* stp: Add more logging points for debug.Alex Wang2014-07-221-0/+31
| | | | | | | | This commit adds more logging points in stp module for debugging. Also, it makes the log print out the port name. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* stp: Make stp-disabled port forward stp bpdu packets.Alex Wang2014-07-161-4/+9
| | | | | | | | | | | | | | | | | | | | | Commit 0d1cee123a84 (stp: Fix bpdu tx problem in listening state) makes ovs drop the stp bpdu packets if stp is not enabled on the input port. However, when pif bridge is used and stp is enabled on the integration bridge. The flow translation of stp bpdu packets will go through a level of resubmission which changes the input port to the corresponding peer port. Since, the patch port on the pif bridge does not have stp enabled, the flow translation will drop the bpdu packets. This commit fixes the issue by making ovs forward stp bpdu packets on stp-disabled port. VMware-BZ: #1284695 Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com> Acked-by: Joe Stringer <joestringer@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>
* ofpbuf: Abstract 'l2' pointer and document usage conventions.Jarno Rajahalme2014-04-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | Rename 'l2' to 'frame' and add new ofpbuf_set_frame() and ofpbuf_l2(). ofpbuf_set_frame() alse resets all the layer offsets. ofpbuf_l2() returns NULL if the packet has no Ethernet header, as indicated either by unset l3 offset or NULL frame pointer. Callers of ofpbuf_l2() are supposed to check the return value, unless they can otherwise be sure that the packet has a valid Ethernet header. The recent commit 437d0d22 made some assumptions that were not valid regarding the use of the 'l2' pointer in rconn module and by compose_rarp(). This is now fixed as follows: rconn now relies on the fact that once OpenFlow messages are given to rconn for transport, the frame pointer is no longer needed to refer to the OpenFlow header; and compose_rarp() now sets the frame pointer and offsets as expected. In addition to storing network frames, ofpbufs are also used for handling OpenFlow messages and action lists. lib/ofpbuf.h now has a comment documenting the current usage conventions and invariants. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Ben Pfaff <blp@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/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* stp: Fix bpdu tx problem in listening statekmindg2014-03-151-0/+9
| | | | | | | | | | | | | | | | The restriction only allows to send bpdu in forwarding state in compose_output_action__. But a port could send bpdu in listening and learning state according to comments in lib/stp.h(State of an STP port). Until this commit, OVS did not send out BPDUs in listening and learning states. But those two states are temporary, the stp port will be in forwarding state and send out BPDUs eventually (In the default configuration listening and learning states last 15+15 second). Therefore, this bug increased convergence time but did not entirely break STP. Signed-off-by: kmindg <kmindg@gmail.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-2/+2
| | | | | | | | 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/+5
| | | | | | | | | | | | | | | | | | 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>
* Avoid printf type modifiers not supported by MSVC C runtime library.Alin Serdean2013-11-251-3/+3
| | | | | | | | | | | | | The MSVC C library printf() implementation does not support the 'z', 't', 'j', or 'hh' format specifiers. This commit changes the Open vSwitch code to avoid those format specifiers, switching to standard macros from <inttypes.h> where available and inventing new macros resembling them where necessary. It also updates CodingStyle to specify the macros' use and adds a Makefile rule to report violations. Signed-off-by: Alin Serdean <aserdean@cloudbasesolutions.com> Co-authored-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Ben Pfaff <blp@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-1/+1
| | | | | | | | 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-70/+70
| | | | | | | | 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>
* stp: Make the STP module thread safe.Ethan Jackson2013-08-011-109/+312
| | | | | 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-3/+6
| | | | | Signed-off-by: Linda Sun <lsun@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Replace most uses of assert by ovs_assert.Ben Pfaff2013-01-161-4/+3
| | | | | | | | 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>
* util: New macro CONST_CAST.Ben Pfaff2012-08-031-2/+2
| | | | | | | | | | | | | | Casts are sometimes necessary. One common reason that they are necessary is for discarding a "const" qualifier. However, this can impede maintenance: if the type of the expression being cast changes, then the presence of the cast can hide a necessary change in the code that does the cast. Using CONST_CAST, instead of a bare cast, makes these changes visible. Inspired by my own work elsewhere: http://git.savannah.gnu.org/cgit/pspp.git/tree/src/libpspp/cast.h#n80 Signed-off-by: Ben Pfaff <blp@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>
* 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>
* stp: Log topology change events.Ethan Jackson2012-02-021-0/+3
| | | | Signed-off-by: Ethan Jackson <ethan@nicira.com>
* stp: Allow manual topology change events.Ethan Jackson2012-01-251-0/+54
| | | | | | | | Users may want to force the network to flush its MAC tables by manually triggering a topology change event due to some event in the system. Signed-off-by: Ethan Jackson <ethan@nicira.com>
* stp: Flush MAC table on topology change.Ethan Jackson2012-01-251-0/+16
| | | | Signed-off-by: Ethan Jackson <ethan@nicira.com>
* stp: Fix tick remainder calculation.Justin Pettit2011-11-151-10/+1
| | | | | | | | | | | | | | | | The spanning tree library keeps track of time to know how often it should update its state and send out BPDUs. OVS is able to track time in milliseconds, but STP uses a coarser-grained count (256 ticks per second). To prevent losing milliseconds that didn't account for an entire tick, the library keeps track of these remaining milliseconds. A bug miscalculated the remainder and made it too high, which caused the library to think time was passing more quickly than it was. This bug wasn't noticeable on a quiet system, since STP only asks to be woken every second. However, a system with a lot of activity would wake OVS more frequently and have it call the subsystems' "run" functions. Bug #8283
* stp: Track BPDU tx and rx counts.Justin Pettit2011-11-151-0/+21
| | | | | | | | | When debugging spanning tree, it's useful to have counters about how many BPDUs have been sent and received. This commit keeps track of these counters and stores them in a new "statistics" column of the Port table. Feature #8103
* Various bug fixes and cleanups to STP library.Justin Pettit2011-10-221-14/+85
| | | | | | | | | | | | - Don't apply endian conversions to flags, which are 8 bits. - Use #defines for default times for use outside library. - Clarify our behavior when in STP_DISABLED state. - Add "aux" member to STP port struct to be able to refer back to the owning port. - Define macros to print STP bridge and port ids. - New helper function to get port id. - New helper function to convert speed to cost. - New functions to describe current role of port.
* Add back 802.1D Spanning Tree Protocol (STP) library code.Justin Pettit2011-10-221-0/+1231
| | | | | | | | | | | | At one point, the OVS distribution contained an IEEE 802.1D Spanning Tree Protocol (STP) library written by Ben Pfaff and based on the 802.1D-1998 reference code. It was never integrated into ovs-vswitchd, so it was removed as part of commit ba18611 (Remove vestigial support for Spanning Tree Protocol.) This commit reintroduces the library, cleans up a few spots, and makes it build cleanly against new code. A future commit will have ovs-vswitchd use this library.
* Remove vestigial support for Spanning Tree Protocol.Ben Pfaff2010-08-131-1233/+0
| | | | | | | | | Open vSwitch has never properly supported IEEE 802.1D Spanning Tree Protocol (STP), but it has various bits and pieces that claim to support it. This commit deletes them, to reduce the amount of dead code in the tree. We can always reintroduce it later if it proves to be a good idea. Bug #1175.
* vlog: Introduce VLOG_DEFINE_THIS_MODULE for declaring vlog module in use.Ben Pfaff2010-07-211-2/+4
| | | | | | | Adding a macro to define the vlog module in use adds a level of indirection, which makes it easier to change how the vlog module must be defined. A followup commit needs to do that, so getting these widespread changes out of the way first should make that commit easier to review.
* Merge "master" into "next".Ben Pfaff2010-02-241-0/+2
|\
| * Work around bugs in system headers.Ben Pfaff2010-02-121-1/+3
| | | | | | | | | | | | | | On some system, at least, one must include <sys/types.h> before <netinet/in.h>, and <netinet/in.h> before <arpa/inet.h> or <net/if.h>. From Jean Tourrilhes <jt@hpl.hp.com>.
* | stp: Fix memory leak.Ben Pfaff2010-02-021-2/+5
| | | | | | | | Found with valgrind.
* | Add new function xzalloc(n) as a shorthand for xcalloc(1, n).Ben Pfaff2009-11-041-1/+1
|/
* Update primary code license to Apache 2.0.Ben Pfaff2009-06-151-10/+10
|
* Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.v0.90.0Ben Pfaff2009-07-081-0/+1226