summaryrefslogtreecommitdiff
path: root/ofproto/ofproto-dpif-monitor.c
Commit message (Collapse)AuthorAgeFilesLines
* lib: Move lib/poll-loop.h to include/openvswitchXiao Liang2017-11-031-1/+1
| | | | | | | | Poll-loop is the core to implement main loop. It should be available in libopenvswitch. Signed-off-by: Xiao Liang <shaw.leon@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* json: Move from lib to include/openvswitch.Terry Wilson2016-07-221-1/+1
| | | | | | | | | | | | | | | 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>
* bfd: Allow setting OAM bit when encapsulated in tunnel.Jesse Gross2016-06-291-4/+6
| | | | | | | | | | | | | | | | | | | | | | Some tunnel protocols, such as Geneve, have a bit in the tunnel header to indicate that it is an OAM packet. This means that the packet should be processed as a tunnel control frame and not be passed onto connected links. When BFD is used inside of a tunnel it is often used in this control capacity, so this adds an option to enable marking the outer header when the output port is a tunnel that supports the OAM concept. It is also possible to use tunnels as point-to-point links that are simply carrying BFD as payload, so this is not always turned on. Conceptually, this may also apply to other types of packets locally generated by the switch, most obviously CFM. However, BFD seems to be most commonly used for this type of tunnel monitoring application so this only adds the option to BFD for the time being to avoid unnecessarily adding configuration knobs that might never get used. Signed-off-by: Jesse Gross <jesse@kernel.org> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* 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>
* userspace: Define and use struct eth_addr.Jarno Rajahalme2015-08-281-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* auto-attach: Add auto-attach support to ofproto layerDennis Flynn2015-03-031-15/+37
| | | | | | Signed-off-by: Ludovic Beliveau <ludovic.beliveau@windriver.com> Signed-off-by: Dennis Flynn <drflynn@avaya.com> Signed-off-by: Ben Pfaff <blp@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/+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-1/+1
| | | | | | | 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>
* ofproto-dpif-monitor: Fix deadlock.Alex Wang2014-05-021-44/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 6b59b543 (ovs-thread: Use fair (but nonrecursive) rwlocks on glibc.) changed the rwlocks to nonrecursive, writer-biased lock. It also made the following deadlock possible. Assume BFD is used on both end of a link. Consider the following events: 1. Handler at one end received the BFD control packet with POLL flag set while holding the read lock of 'xlate_rwlock'. Since a BFD control packet with FINAL flag set should be sent back immediately, it calls the ofproto_dpif_monitor_port_send_soon(), in which, it tries to grab the 'monitor_mutex'. 2. The main thread needs to configure the ofproto-dpif-xlate module. It tries to grab the write lock of 'xlate_rwlock' and is blocked by event 1. 3. The monitor thread, after acquired the 'monitor_mutex', wants to acquire the read lock of 'xlate_rwlock'. Since the rwlock is now writer-biased, the attempt of acquiring read lock in event 3 will be blocked by event 2. This will subsequently cause the block of event 1, since monitor thread is holding the 'monitor_mutex'. So the deadlock happens. This commit resolves the above issue by removing the requirement of acquiring 'monitor_mutex' in ofproto_dpif_monitor_port_send_soon(). Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovs-thread: Make caller provide thread name when creating a thread.Ben Pfaff2014-04-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thread names are occasionally very useful for debugging, but from time to time we've forgotten to set one. This commit adds the new thread's name as a parameter to the function to start a thread, to make that mistake impossible. This also simplifies code, since two function calls become only one. This makes a few other changes to the thread creation function: * Since it is no longer a direct wrapper around a pthread function, rename it to avoid giving that impression. * Remove 'pthread_attr_t *' param that every caller supplied as NULL. * Change 'pthread *' parameter into a return value, for convenience. The system-stats code hadn't set a thread name, so this fixes that issue. This patch is a prerequisite for making RCU report the name of a thread that is blocking RCU synchronization, because the easiest way to do that is for ovsrcu_quiesce_end() to record the current thread's name. ovsrcu_quiesce_end() is called before the thread function is called, so it won't get a name set within the thread function itself. Setting the thread name earlier, as in this patch, avoids the problem. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* ofproto-dpif-monitor: Change global rwlock into mutex.Ben Pfaff2014-01-161-17/+17
| | | | | | | Nothing ever took monitor_rwlock's read lock, so it might as well be a mutex. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofproto-dpif-monitor: Remove monitor_init().Alex Wang2013-12-301-16/+1
| | | | | | | | | | | Commit 881d47a9fa9 (monitor: Replace monitor_seq with periodic wakeup.) removes the global "struct seq" in ofproto-dpif-monitor module. This change makes the monitor_init() no longer needed. This commit removes the monitor_init() from ofproto-dpif-monitor.c. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* bfd: Send FINAL immediately after receiving POLL.Alex Wang2013-12-201-2/+27
| | | | | | | | | | | | Commit 307464a11 (ofproto-dpif-monitor: Use heap to order the mport wakeup time.) makes bfd only send packet at specified periodic instant. This fails to meet the RFC5880 requirement, which requires bfd send FINAL immediately after receiving POLL. This commit fixes the above issue by scheduling bfd to send FINAL within 100 ms after receiving POLL. Signed-off-by: Alex Wang <alexw@nicira.com>
* ofproto-dpif-monitor: Acquire write lock in monitor_run().Alex Wang2013-12-171-1/+1
| | | | | | | | | | | | Commit 307464a1 (ofproto-dpif-monitor: Use heap to order the mport wakeup time.) re-heapifies the heap in monitor_run(). So the monitor_run() should be protected by the write lock, rather than the read lock. This commit fixes the issue. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* monitor: Replace monitor_seq with periodic wakeupJoe Stringer2013-12-141-8/+10
| | | | | | | | | | | | | | | | | | | Currently, every time a monitoring port is added or reconfigured, the main thread notifies the monitoring thread to wake up immediately using monitor_seq. When adding a large number of ports at once, this causes contention as the threads fight over access to the monitor heap---one thread adding new ports, the other popping and processing the new ports. This patch removes this mechanism in favour of a simple periodic wakeup in the monitor thread. When configuring batches of 500 tunnels at once, up to a total of 5000 tunnels, this reduces configuration time by up to 35%. New port monitor port configuration may not take effect for as long as ~100ms, although it may be less if the timer has not recently timed out, or if a monitoring port is due to send a packet. Signed-off-by: Joe Stringer <joestringer@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* ofproto-dpif-monitor: Use heap to order the mport wakeup time.Alex Wang2013-10-161-10/+41
| | | | | | | | | | | | | | | Before this commit, each time ofproto-dpif-monitor thread wakes up, all monitored ports will be iterated over. This adds a huge overhead to the monitor thread. This commit uses a heap to order the wakeup time of monitored ports. So each time the monitor thread is waken up, it will only iterate those monitored ports that have timed out. This commit greatly increases the number of monitored interfaces openvswitch could support. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* ofproto-dpif-monitor: Run ofproto-dpif-monitor in a thread.Alex Wang2013-10-161-40/+83
| | | | | | | | | | | | | This commit moves the ofproto-dpif-monitor module into a dedicated thread. This helps eliminate the burden of main thread having to wake up very frequently for periodic interface monitoring (bfd, cfm). Thusly, this commit greatly increases the number of bfd/cfm sessions that can be supported by ovs. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* monitor: Fix improper use of stubs.Ethan Jackson2013-10-101-4/+6
| | | | | | | Stubs must be uninitialized when used in case they allocate memory. Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ofproto-dpif-monitor: Add ofproto-dpif-monitor module.Alex Wang2013-10-081-0/+199
This commit adds a new module ofproto-dpif-monitor in ofproto directory. This module is in charge of executing the periodic functions of monitoring code (e.g. bfd and cfm). Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>