2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00

49 Commits

Author SHA1 Message Date
Bhanuprakash Bodireddy
0fee518560 process: Extend get_process_info() for additional fields.
This commit enables the fields relating to process name and the core
number the process was last scheduled. The fields will be used by keepalive
monitoring framework in future commits.

This commit also fixes the following "sparse" warning:

  lib/process.c:439:16: error: use of assignment suppression and length
  modifier together in gnu_scanf format [-Werror=format=].

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-11-28 15:55:15 -08:00
Xiao Liang
fd016ae3fb lib: Move lib/poll-loop.h to include/openvswitch
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>
2017-11-03 10:47:55 -07:00
Bhanuprakash Bodireddy
ff1d2c1626 process: Consolidate process related APIs.
As part of retrieving system statistics, process status APIs along with
helper functions were implemented. Some of them are very generic and can
be reused by other subsystems.

Move the APIs in system-stats.c to process.c and util.c and make them
available. This patch doesn't change any functionality.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-07-13 10:44:22 -07:00
Ben Warren
417e7e66e1 list: Rename all functions in list.h with ovs_ prefix.
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>
2016-03-30 13:04:32 -07:00
Ben Warren
b19bab5b20 list: Remove lib/list.h completely.
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>
2016-03-30 13:01:21 -07:00
Ben Warren
3e8a2ad145 Move lib/dynamic-string.h to include/openvswitch directory
Signed-off-by: Ben Warren <ben@skyportsystems.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-03-19 10:02:12 -07:00
Thomas Graf
e6211adce4 lib: Move vlog.h to <openvswitch/vlog.h>
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>
2014-12-15 14:15:19 +01:00
Thomas Graf
55951e15e5 lib: Expose struct ovs_list definition in <openvswitch/list.h>
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>
2014-12-15 14:15:16 +01:00
Thomas Graf
ca6ba70092 list: Rename struct list to struct ovs_list
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>
2014-12-15 14:15:12 +01:00
Ansis Atteka
1481a7551d process: block signals while spawning child processes
Between fork() and execvp() calls in the process_start()
function both child and parent processes share the same
file descriptors.  This means that, if a child process
received a signal during this time interval, then it could
potentially write data to a shared file descriptor.

One such example is fatal signal handler, where, if
child process received SIGTERM signal, then it would
write data into pipe.  Then a read event would occur
on the other end of the pipe where parent process is
listening and this would make parent process to incorrectly
believe that it was the one who received SIGTERM.
Also, since parent process never reads data from this
pipe, then this bug would make parent process to consume
100% CPU by immediately waking up from the event loop.

This patch will help to avoid this problem by blocking
signals until child closes all its file descriptors.

Signed-off-by: Ansis Atteka <aatteka@nicira.com>
Reported-by: Suganya Ramachandran <suganyar@vmware.com>
Issue: 1255110
2014-05-30 10:06:10 -07:00
YAMAMOTO Takashi
194db781b3 lib/process, socket-util: Update necessary headers
Fix the regression introduced by commit 4f57ad10.
("socket-util: Move get_max_fds() to process.c")

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
2014-02-22 06:31:54 -08:00
Gurucharan Shetty
4f57ad100f socket-util: Move get_max_fds() to process.c.
get_max_fds() is used only from process.c. Move it there
along with rlim_is_finite(). Since process_start() can only
be called before any additional threads are created, we
no longer need the thread safety checks in get_max_fds().

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-21 14:44:31 -08:00
Gurucharan Shetty
41064650be process: Make changes for Windows.
As of now, we are using the process subsystem in
ovsdb-server to handle the "--run" command line
option. That particular option is not used often
and till deemed necessary, make it unsupported on
Windows platform.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-19 14:24:26 -08:00
Jarno Rajahalme
6e274d49c4 Remove unused variables and functions.
Found by Clang.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-09-27 16:27:24 -07:00
Ben Pfaff
10a89ef04d Replace all uses of strerror() by ovs_strerror(), for thread safety.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-28 16:09:38 -07:00
Ben Pfaff
728a8b141f ovs-thread: Add support for various thread-related assertions.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-06-28 16:09:37 -07:00
Ben Pfaff
ff412c8c09 process: Add thread safety comments.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-10 13:48:12 -07:00
Ben Pfaff
57d90319a6 process: Make signal handling thread-safe.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-10 13:48:12 -07:00
Ben Pfaff
e1208bc494 process: Remove unused features from process_start().
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-06-10 13:48:11 -07:00
Ben Pfaff
21f0192507 process: Remove process_run(), process_run_capture(), and related code.
They are unused.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ansis Atteka <aatteka@nicira.com>
2013-06-10 13:48:08 -07:00
Ben Pfaff
eee8089cbe signals: Make signal_name() thread-safe.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-05 12:46:59 -07:00
Ben Pfaff
92829687b4 Use pthread_sigmask() in place of sigprocmask(), for thread safety.
POSIX says that multithreaded programs must not use sigprocmask() but must
use pthread_sigmask() instead.  This commit makes that replacement.

The actual use of signals in Open vSwitch is still not thread safe
following this commit, but this change is a necessary prerequisite for
fixing the other problems.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-02 13:55:45 -07:00
Ben Pfaff
e93af6a479 process: Check return value of set_nonblocking().
It's unlikely to fail but checking it can't hurt.

Found by Coverity.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-02-01 14:26:59 -08:00
Ben Pfaff
cb22974d77 Replace most uses of assert by ovs_assert.
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>
2013-01-16 16:03:37 -08:00
Ed Maste
c0d95206c0 lib: Add xpipe_nonblocking helper
Signed-off-by: Ed Maste <emaste@adaranet.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-28 14:21:52 -07:00
Ben Pfaff
a0505c49dd socket-util: New function xset_nonblocking().
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-18 10:29:21 -07:00
Raju Subramanian
e0edde6fee Global replace of Nicira Networks.
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>
2012-05-02 17:08:02 -07:00
Ben Pfaff
691ac3d8c5 process: Let process_run_capture() caller set maximum capture size.
An upcoming patch needs a larger value.
2011-06-07 17:05:42 -07:00
Ben Pfaff
279c9e0308 Log anything that could prevent a daemon from starting.
If a daemon doesn't start, we need to know why.  Being able to
consistently consult the log to find out is helpful.
2011-04-04 10:58:55 -07:00
Ben Pfaff
b725cf028c signals: New function signal_name().
This will acquire a new user in an upcoming commit.
2011-04-04 10:58:55 -07:00
Ben Pfaff
fe81a2987a process: Avoid late failure if /dev/null cannot be opened.
It is (very slightly) risky to open /dev/null every time that we need it,
because open can fail.  So this commit opens /dev/null in advance instead.

Coverity #10719.
2011-02-23 15:14:42 -08:00
Ben Pfaff
d76f09ea77 coverage: Make the coverage counters catalog program-specific.
Until now, the collection of coverage counters supported by a given OVS
program was not specific to that program.  That means that, for example,
even though ovs-dpctl does not have anything to do with mac_learning, it
still has a coverage counter for it.  This is confusing, at best.

This commit fixes the problem on some systems, in particular on ones that
use GCC and the GNU linker.  It uses the feature of the GNU linker
described in its manual as:

    If an orphaned section's name is representable as a C identifier then
    the linker will automatically see PROVIDE two symbols: __start_SECNAME
    and __end_SECNAME, where SECNAME is the name of the section.  These
    indicate the start address and end address of the orphaned section
    respectively.

Systems that don't support these features retain the earlier behavior.

This commit also fixes the annoyance that files that include coverage
counters must be listed on COVERAGE_FILES in lib/automake.mk.

This commit also fixes the annoyance that modifying any source file that
includes a coverage counter caused all programs that link against
libopenvswitch.a to relink, even programs that the source file was not
linked into.  For example, modifying ofproto/ofproto.c (which includes
coverage counters) caused tests/test-aes128 to relink, even though
test-aes128 does not link again ofproto.o.
2010-11-30 10:30:30 -08:00
Ben Pfaff
d98e600755 vlog: Make client supply semicolon for VLOG_DEFINE_THIS_MODULE.
It's kind of odd for VLOG_DEFINE_THIS_MODULE to supply its own semicolon,
so this commit switches to the more common form.
2010-10-29 09:48:47 -07:00
Ben Pfaff
4e8e4213a8 Switch many macros from using CONTAINER_OF to using OBJECT_CONTAINING.
These macros require one fewer argument by switching, which makes code
that uses them shorter and more readable.
2010-10-01 10:25:29 -07:00
Ben Pfaff
2a022368f4 Avoid shadowing local variable names.
All of these changes avoid using the same name for two local variables
within a same function.  None of them are actual bugs as far as I can tell,
but any of them could be confusing to the casual reader.

The one in lib/ovsdb-idl.c is particularly brilliant: inner and outer
loops both using (different) variables named 'i'.

Found with GCC -Wshadow.
2010-09-20 09:39:54 -07:00
Ben Pfaff
5136ce492c vlog: Introduce VLOG_DEFINE_THIS_MODULE for declaring vlog module in use.
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.
2010-07-21 15:47:09 -07:00
Justin Pettit
7aee8e5a0a Properly escape quotes in process_escape_args() library function 2010-03-01 22:26:27 -08:00
Ben Pfaff
c69ee87c10 Merge "master" into "next".
The main change here is the need to update all of the uses of UNUSED in
the next branch to OVS_UNUSED as it is now spelled on "master".
2010-02-11 11:11:23 -08:00
Ben Pfaff
67a4917b07 Rename UNUSED macro to OVS_UNUSED to avoid naming conflict.
Requested by Jean Tourrilhes <jt@hpl.hp.com>.
2010-02-11 10:59:47 -08:00
Ben Pfaff
651471fda8 process: Remove pointless, redundant assignments from stream_read().
Found by Clang (http://clang-analyzer.llvm.org/).
2010-02-11 10:35:28 -08:00
Jesse Gross
d8b3070205 fatal-signal: Run signal hooks outside of actual signal handlers.
Rather than running signal hooks directly from the actual signal
handler, simply record the fact that the signal occured and run
the hook next time around the poll loop.  This allows significantly
more freedom as to what can actually be done in the signal hooks.
2010-01-06 09:11:58 -05:00
Justin Pettit
18b9283b98 Clean-up compiler warnings about ignoring return values
Some systems complain when certain functions' return values are not
checked.  This commit fixes those warnings.

Creating ignore() function suggested by Ben Pfaff.
2009-12-15 00:14:32 -08:00
Ben Pfaff
ec6fde61c8 Add new function xzalloc(n) as a shorthand for xcalloc(1, n). 2009-11-04 14:52:32 -08:00
Ben Pfaff
b5dae6846a process: New function process_run_capture().
In an upcoming commit, ovs-brcompatd will need to create a subprocess and
capture both its stdout and stderr separately, which one cannot do with
simple interfaces such as popen().  This function provides that ability.
2009-07-16 09:17:06 -07:00
Ben Pfaff
1fa39e1d50 process: Factor code out of process_start() into helper functions.
An upcoming commit will add a new function that can also use these helper
functions.
2009-07-16 09:17:06 -07:00
Ben Pfaff
52dc2ef41b process: Fix races on fatal signal handling in process_start().
To prevent fatal signals in a child process from causing the parent
process's pidfile, etc. to be deleted, we need to block fatal signals
around fork and call fatal_signal_fork() in the child process.

This problem was noticed through code inspection; it has not been observed
in practice.
2009-07-16 09:17:06 -07:00
Ben Pfaff
a8b5f8b423 Add function get_null_fd(), to reduce code redundancy. 2009-07-16 09:17:03 -07:00
Ben Pfaff
a14bc59fb8 Update primary code license to Apache 2.0. 2009-06-15 15:11:30 -07:00
Ben Pfaff
064af42167 Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45. 2009-07-08 13:19:16 -07:00