2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 18:07:40 +00:00

64 Commits

Author SHA1 Message Date
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
Ben Pfaff
f3b1ab6f9d socket-util: Use CONST_CAST in send_iovec_and_fs().
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
2013-01-11 10:38:06 -08:00
Ben Pfaff
ed36537ebf packets: Change IP_ARGS interface to take an ovs_be32 instead of a pointer.
An ovs_be32 is a more obvious way to represent an IP address than a
pointer to one.  It is also more type-safe, especially since "sparse" is
able to check that the argument is in network byte order.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2012-12-12 15:26:21 -08:00
Ben Pfaff
24f974c481 socket-util: Remove get_socket_error().
It has no remaining users.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2012-11-20 15:01:12 -08:00
Ben Pfaff
d6cedfd9d2 socket-util: Avoid using SO_ERROR.
ESX doesn't implement it, and there's another approach that should work
everywhere, so drop back to that.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2012-11-20 15:01:03 -08:00
Ben Pfaff
ce78d135fc socket-util: Report fd of -1 on error in inet_open_active().
inet_open_active() is documented to report a fd of -1 when an error occurs.
All three of its callers rely on this, by checking only the fd to determine
whether there was an error.  This means that if the call to
set_nonblocking() or set_dscp() or connect() failed, then the callers would
try to use a fd that had already been closed, wreaking havoc.

This fixes a bug introduced in commit a4efa3fc5d (socket-util: Close socket
on failed dscp modification.)

Bug #13750.
Reported-by: Scott Hendricks <shendricks@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2012-11-07 12:55:53 -08:00
Ethan Jackson
361906b1e2 config: Add explicit support for building on ESX.
The ESX userspace looks quite a bit like linux, but has some key
differences which need to be specially handled in the build.  To
distinguish between ESX and systems which use the linux datapath
module, this patch adds two new macros "ESX" and "LINUX_DATAPATH".
It uses these macros to disable building code on ESX which only
applies to a true Linux environment.  In addition, it adds a new
route-table-stub implementation which is required for the build to
complete successfully on ESX.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-10-09 15:23:47 -07: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
Isaku Yamahata
6b9c1eab52 socket-util: export set_dscp()
It will be used later for dynamic dscp change to listening socket.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-26 10:05:39 -07:00
Ed Maste
a7a27d0719 lib: Add header #include for writev
This fixes a warning on FreeBSD.

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-08-08 12:27:21 -07:00
Ed Maste
eb0cb3161f Use int type for setsockopt IP_TOS value
FreeBSD requires that setsockopt(..., IP_TOS, ...) be passed an int
value.  Linux accepts either int or char types (and has since at least
kernel 2.6.12) so just use int type unconditionally.

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-30 15:31:38 -07:00
Justin Pettit
293d49bdd6 Fix "*tivty" typos.
Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-07-25 10:12:57 -07:00
Ben Pfaff
fd94a42c43 socket-util: Add functions for sending fds over Unix domain sockets.
These will be used in upcoming commits.

This commit also adds corresponding definitions to the "sparse" header,
so that sparse still works.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-18 10:29:21 -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
Ben Pfaff
5ca92d1d5d socket-util: Remove 'passcred' parameter from make_unix_socket().
Nothing in the tree ever tries to send or receive credentials over a Unix
domain socket so there's no point in configuring them to be received.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-18 10:29:20 -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
Ethan Jackson
cea1576889 vswitch: Use consistent representation of DSCP bits.
There are two sensible ways to represent the 6 DSCP bits of an IP
packet.  One could represent them as an integer in the range 0 to
63.  Or one could represent them as they would appear in the tos
field (0 to 63) << 2.  Before this patch, OVS had used the former
method for the DSCP bits in the Queue Table, and the latter for the
DSCP in the Controller and Manager tables.  Since the ability to
set DSCP bits in the Controller and Manager tables is so new that
it hasn't been released yet, this patch changes it to use the
existing style employed in the Queue table.  Hopefully this should
make the code and configuration less confusing.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-04-17 13:36:01 -07:00
Ethan Jackson
ef8a3d1497 socket-util: Remove DSCP_INVALID.
The DSCP_INVALID flag allowed callers to prevent socket-util from
modify the DSCP bits of newly created sockets.  However, the two
really important callers (implementations of the controller and
manager tables) never used it.  Furthermore, the other callers
would be fine always setting the DSCP bits to zero.  This patch
removes the DSCP_INVALID option in an effort to simplify the code.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-04-17 13:15:17 -07:00
Ethan Jackson
a4efa3fc5d socket-util: Close socket on failed dscp modification.
If socket-util failed to modify the dscp bits of an active
connection, it would fail to close the file descriptor potentially
causing a leak. Found by inspection.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-04-17 13:03:06 -07:00
Mehak Mahajan
f125905cdd Allow configuring DSCP on controller and manager connections.
The changes allow the user to specify a separate dscp value for the
controller connection and the manager connection. The value will take
effect on resetting the connections. If no value is specified a default
value of 192 is chosen for each of the connections.

Feature #10074
Requested-by: Rajiv Ramanathan <rramanathan@nicira.com>
Signed-off-by: Mehak Mahajan <mmahajan@nicira.com>
2012-03-23 18:13:08 -07:00
Ben Pfaff
e36d0b530a socket-util: Unlink Unix domain sockets that bind but fail to connect.
The error handling path here failed to clean up bound sockets, by removing
them.  This fixes the problem.

It was easy to observe this bug by running "ovs-vsctl" without
"ovsdb-server" running.

Bug #9811.
Bug #9769.
Reported-by: Michael <mhu@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-07 16:33:14 -08:00
Ben Pfaff
041dc07fd2 socket-util: Don't try to listen to a UDP socket.
The "listen" system call doesn't work and isn't necessary for UDP, but
inet_open_passive() would still try to call it (and fail).

This doesn't fix a real bug because the two existing callers both use
inet_open_passive() to listen for TCP connections.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2011-12-19 14:53:31 -08:00
Ben Pfaff
ca286ba95b socket-util: Correctly return negative values for errors.
The comment on this function says that negative values indicate errors, and
the callers assume that too, but in fact it was returning positive errno
values, which are indistinguishable from valid fd numbers.

It really seems to me that this should have been found pretty quickly in
the field, since stream-tcp and stream-ssl both use inet_open_passive to
implement their passive listeners.  I'm surprised that no one has reported
it.
2011-12-07 08:38:16 -08:00
Ben Pfaff
c1c19657f4 socket-util: New function get_socket_rcvbuf().
This will be used in an upcoming commit.
2011-10-14 14:08:44 -07:00
Ethan Jackson
995337c4fc socket-util: inet_parse_passive() had incorrect argument type.
This patch fixes the following compiler warning:

lib/socket-util.c:621:5: error: comparison is always false due to
limited range of data type [-Werror=type-limits]
2011-09-13 14:29:41 -07:00
Ethan Jackson
6d8ffe1898 socket-util: Suppress valgrind uninitialized use warning. 2011-08-26 17:18:26 -07:00
Ben Pfaff
13f2ef9709 socket-util: New function lookup_hostname().
This is equivalent to lookup_ip() except that it accepts DNS names also.
2011-07-27 16:02:12 -07:00
Ben Pfaff
d98fa5032e socket-util: Factor inet_parse_passive() out of inet_open_passive(). 2011-07-27 16:02:11 -07:00
Ben Pfaff
dbba996be2 Convert remaining network-byte-order "uint<N>_t"s into "ovs_be<N>"s.
I looked at almost every uint<N>_t in the tree to determine whether it was
really in network byte order, and converted the ones that were.

The only remaining ones, modulo my mistakes, are in openflow.h.  I'm not
sure whether we should convert those, because there might be some value
in remaining close to upstream for this header.
2011-05-16 13:40:47 -07:00
Ben Pfaff
f89ffb0e2f poll-loop: Make wakeup logging more portable and easier to understand.
Until now, when the poll_loop module's log level was turned up to "debug",
it would log a backtrace of the call stack for the event that caused poll()
to wake up in poll_block().  This was pretty useful from time to time to
find out why ovs-vswitchd was using more CPU than expected, because we
could find out what was causing it to wake up.

But there were some issues.  One is simply that the backtrace was printed
as a series of hexadecimal numbers, so GDB or another debugger was needed
to translate it into human-readable format.  Compiler optimizations meant
that even the human-readable backtrace wasn't, in my experience, as helpful
as it could have been.  And, of course, one needed to have the binary to
interpret the backtrace.  When the backtrace couldn't be interpreted or
wasn't meaningful, there was essentially nothing to fall back on.

This commit changes the way that "debug" logging for poll_block() wakeups
works.  Instead of logging a backtrace, it logs the source code file name
and line number of the call to a poll_loop function, using __FILE__ and
__LINE__.  This is by itself much more meaningful than a sequence of
hexadecimal numbers, since no additional interpretation is necessary.  It
can be useful even if the Open vSwitch version is only approximately known.

In addition to the file and line, this commit adds, for wakeups caused by
file descriptors, information about the file descriptor itself: what kind
of file it is (regular file, directory, socket, etc.), the name of the file
(on Linux only), and the local and remote endpoints for socket file
descriptors.

Here are a few examples of the new output format:

932-ms timeout at ../ofproto/in-band.c:507
[POLLIN] on fd 20 (192.168.0.20:35388<->192.168.0.3:6633) at ../lib/stream-fd.c:149
[POLLIN] on fd 7 (FIFO pipe:[48049]) at ../lib/fatal-signal.c:168
2011-05-13 14:38:15 -07:00
Ben Pfaff
2cb351e851 socket-util: Use portable solution for setting Unix socket permissions.
Requested-by: Jesse Gross <jesse@nicira.com>
2011-04-21 12:00:38 -07:00
Ben Pfaff
e2bd05933f socket-util: Properly set socket permissions in make_unix_socket().
Under Linux, at least, bind and fchmod interact for Unix sockets in a way
that surprised me.  Calling fchmod() on a Unix socket successfully sets the
permissions for the socket's own inode.  But that has no effect on any
inode that has already been created in the file system by bind(), because
that inode is not the same as the one for the Unix socket itself.

However, if you bind() *after* calling fchmod(), then the bind() takes the
permissions for the new inode from the Unix socket inode, which has the
desired effect.

This also adds a more portable fallback for non-Linux systems.

Reported-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
2011-04-19 11:26:01 -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
71d7c22f54 util: New function ovs_strzcpy().
Static analyzers hate strncpy().  This new function shares its property of
initializing an entire buffer, without its nasty habit of failing to
null-terminate long strings.

Coverity #10697,10696,10695,10694,10693,10692,10691,10690.
2011-02-22 16:33:58 -08:00
Justin Pettit
08871bf6f0 socket-util: Free strings in make_sockaddr_un() error handling.
Coverity #10721,10720
2011-02-22 09:40:01 -08:00
Justin Pettit
d31f1109f1 nicira-ext: Support matching IPv6 traffic.
Provides ability to match over IPv6 traffic in the same manner as IPv4.
Currently, the matching fields include:

    - IPv6 source and destination addresses (ipv6_src and ipv6_dst)
    - Traffic Class (nw_tos)
    - Next Header (nw_proto)
    - ICMPv6 Type and Code (icmp_type and icmp_code)
    - TCP and UDP Ports over IPv6 (tp_src and tp_dst)

When defining IPv6 rules, the Nicira Extensible Match (NXM) extension to
OVS must be used.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2011-02-02 12:53:26 -08:00
Ben Pfaff
db5ce51427 Fix non-static instances of "struct vlog_rate_limit" and add check.
A non-static vlog_rate_limit is not actually going to rate-limit anything.
2011-01-12 09:22:12 -08:00
Ben Pfaff
6e170b4c78 socket-util: Work around Unix domain socket path name limits on Linux.
Many Open vSwitch tests fail on Debian's automatic build machines because
the builds occur in deeply nested directories with long names.  OVS tries
to bind and connect to Unix domain sockets using absolute path names, which
in combination with long directory names means that the socket's name
exceeds the limit for Unix domain socket names (108 bytes on Linux).

This commit works around the problem on Linux by indirecting through
/proc/self/fd/<dirfd>/<basename> when names exceed the maximum that can be
used directly.

Reported-by: Hector Oron <hector.oron@gmail.com>
Reported-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Reported-by: Roger Leigh <rleigh@codelibre.net>
Debian bug #602891.
Debian bug #602911.
2010-11-10 10:56:01 -08:00
Ben Pfaff
e61c056cb9 socket-util: Define LINUX macro at top of file.
This will be used further in the following commit.
2010-11-10 10:56:01 -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
Joe Perches
d295e8e97a treewide: Remove trailing whitespace
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Jesse Gross <jesse@nicira.com>
2010-08-30 13:23:08 -07:00
Bryan Phillippe
50d2d532ed socket-util: Suppress uninitialized variable warning with old GCC. 2010-08-20 10:43:35 -07:00
Bryan Phillippe
95bfc0b856 socket-util: Remove stray printf() from make_unix_socket(). 2010-08-20 10:43:33 -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
Ben Pfaff
0ec6cfb13b socket-util: Tolerate missing RLIM_SAVED_CUR and RLIM_SAVED_MAX.
POSIX requires these macros, but FreeBSD 8.0 doesn't have them.
2010-05-26 15:27:01 -07:00
Ben Pfaff
3762274e63 Add some missing "#include"s.
These are required to build on FreeBSD 8.0.
2010-05-26 15:27:01 -07:00
Ben Pfaff
26efd2563b socket-util: Move get_mtime() here from stream-ssl.
An upcoming commit will add a new user for this function in another file,
so export it and move it to a common library file.
2010-04-26 11:29:32 -07:00
Ben Pfaff
52f8a75e1b socket-util: Factor out new function inet_parse_active().
An upcoming commit needs to parse connection strings without connecting to
them, so this change enables that.
2010-04-26 11:02:12 -07:00
Ben Pfaff
8e71cf88b7 ovsdb: Factor out code to fsync a file's containing directory.
In an upcoming commit, another function wants to do the same thing, so
break it out into a helper function.
2010-02-15 11:31:34 -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