2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-23 18:37:36 +00:00

97 Commits

Author SHA1 Message Date
Ben Pfaff
fce314cdb3 socket-util: Fix definition of LINUX.
Reported-by: Mukesh Hira <mhira@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Pritesh Kothari <pritesh.kothari@cisco.com>
2014-03-17 13:00:46 -07:00
Ben Pfaff
2f51a7ebda Use __linux__ instead of LINUX_DATAPATH in C code.
The LINUX_DATAPATH C preprocessor symbol was originally meant to be used as
a signal for whether the Linux datapath module could be used, but it was
used as a proxy for a lot of other stuff that is really just Linux
specific.  This commit switches all of these users to just test for
__linux__, which is more straightforward and should have the same result.

CC: Luigi Rizzo <rizzo@iet.unipi.it>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2014-03-05 07:51:55 -08:00
Gurucharan Shetty
a19a3a9fc3 socket-util: pipe for Windows.
Windows does have pipes (the interface is a little different).
We mostly use pipes in Linux to synchronize between parent and
children and also to handle fatal signals and then wake from poll_loop().

For Windows, we are using events for the same purpose. So don't
implement pipes for Windows.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-26 12:39:55 -08:00
YAMAMOTO Takashi
92ae5930c2 socket-util: Fix set_dscp for IPv6
Try IPPROTO_IPV6/IPV6_TCLASS socket option as well as IPPROTO_IP/IP_TOS
so that this can work for IPv6 sockets.

IPPROTO_IP/IP_TOS socket option is, as it's SOL indicates, for IPv4.
What happens when it's used for IPv6 sockets?  On Linux, it seems to
be forwarded to IPv4 code and affects IPv4 part of the socket.
(e.g. non-V6ONLY case)  But it doesn't seem to be the intention of
this function.  On other platforms including NetBSD, it just fails
with ENOPROTOOPT.

Probably this function should take the address family but passing
it around lib/*stream*.c would be a bigger change.

Cc: Arun Sharma <arun.sharma@calsoftinc.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2014-02-26 08:18:03 -08:00
YAMAMOTO Takashi
909dad2b1f socket-util: Avoid using the identical message for different errors
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2014-02-26 08:16:37 -08:00
Gurucharan Shetty
5d5ffe9cb3 socket-util: drain_rcvbuf() for Windows.
Netlink sockets are created as blocking sockets. So, we can't
afford to remove MSG_DONTWAIT for Linux.

drain_rcvbuf() is currently called from netlink-socket.c and
netdev-linux.c. As of now, I don't see it being used for Windows.

Bug #1200865.
Reported-by: Len Gao <leng@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-24 10:21:12 -08: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
fb14862dcf socket-util: Move get_null_fd() to daemon.c.
get_null_fd() is only called from daemon.c.
It does not need thread safety features anymore as
it is called either through daemonize_start() or
indirectly through daemonize_complete() once.

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
1bada7ab12 socket-util: poll() for Windows.
Also, Windows does not have a MSG_DONTWAIT. Get rid of it
as we always use non-blocking sockets.

Co-authored-by: Linda Sun <lsun@vmware.com>
Signed-off-by: Linda Sun <lsun@vmware.com>
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
1bbd172824 Replace inet_aton() with inet_pton().
Windows does not have inet_aton(), but does have a inet_pton().
inet_aton() is not defined in POSIX. But inet_pton() is.

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
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
7ff04d9244 socket-util: Unix socket related calls for non-windows platform.
Don't try to compile Unix socket related functions for Windows.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
2014-02-21 14:44:31 -08:00
Gurucharan Shetty
866f3e677e socket-util: af_inet_ioctl() for Windows.
There is no direct mapping for the ioctl function in
Windows.  As of now, af_inet_ioctl() is being used for Linux
and BSD. So, don't try to compile it for Windows.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-21 08:25:42 -08:00
Gurucharan Shetty
54a1cfb536 socket-util: Describe fd for Windows.
In windows there is no clear way to distinguish between a
socket fd and a file fd.

We use the function, describe_fd() mostly for debugging.
For now, return a generic statement.

Co-authored-by: Linda Sun <lsun@vmware.com>
Signed-off-by: Linda Sun <lsun@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-21 08:22:12 -08:00
Gurucharan Shetty
cbf414e501 socket-util: fsync directory for Windows.
There is no corresponding function for Windows.
open() does not work on directories.
There is a function _commit(fd), but that is only meant
for files.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-21 08:17:24 -08:00
Gurucharan Shetty
7009a5941e socket-util: closesocket() for Windows.
For Windows sockets, one has to call closesocket() to
close the sockets.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-21 08:12:53 -08:00
Gurucharan Shetty
99ad8ba8ce socket-util: getaddrinfo return values for Windows.
Couple of return values need changes.
* EAI_NODATA is the same as EAI_NONAME. So we prevent duplicate cases.
* Windows does not have a EAI_SYSTEM.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-21 07:58:18 -08:00
Gurucharan Shetty
de8bd5976a socket-util: set_nonblocking for Windows.
Co-authored-by: Linda Sun <lsun@vmware.com>
Signed-off-by: Linda Sun <lsun@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-21 07:47:09 -08:00
Gurucharan Shetty
0f0b5401fe socket-util: Move sock_errno() to socket-util.
And add more users.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-21 07:35:18 -08:00
Gurucharan Shetty
315ea327a6 util: Pre-allocate buffer for ovs_lasterror_to_string().
This lets us call ovs_lasterror_to_string() and not having
to do an extra call of LocalFree() on the returned string.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-14 08:46:05 -08:00
Gurucharan Shetty
b26f46a401 socket-util: error number to string for sockets.
For winsock2 functions, error number has to be converted to string
using FormatMessage().

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-11 09:55:47 -08:00
Arun Sharma
e731d71bf4 Add IPv6 support for OpenFlow, OVSDB, NetFlow, and sFlow.
Does not add IPv6 support for in-band control.

Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Nandan Nivgune <nandan.nivgune@calsoftinc.com>
Signed-off-by: Abhijit Bhopatkar <abhijit.bhopatkar@calsoftinc.com>
Signed-off-by: Arun Sharma <arun.sharma@calsoftinc.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2014-02-06 16:08:34 -08:00
Ben Pfaff
f87d3302c4 socket-util: Remove unused functions.
A Windows porter mentioned to me that these functions caused special
trouble in the Windows port.  However, they are no longer used, so we
might as well remove them.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
2014-01-31 11:31:24 -08:00
Alin Serdean
34582733d9 Avoid printf type modifiers not supported by MSVC C runtime library.
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>
2013-11-25 23:38:59 -08:00
YAMAMOTO Takashi
5b5d1836dd socket-util: Add symlink based workaround for long pathnames.
The existing /proc workaround only works on Linux.  Symlinks are more
widely available.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-17 21:13:40 -07:00
Ben Pfaff
259e0b1ad1 netdev-linux, netdev-bsd: Make access to AF_INET socket thread-safe.
The only uses of 'af_inet_sock', in both drivers, were ioctls, so it seemed
like a good abstraction to write a function that just does such an ioctl,
and to factor out shared code into socket-util.

Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
2013-08-09 21:14:23 -07:00
Alex Wang
db5a101931 clang: Fix the alignment warning.
This commit fixes the warning issued by 'clang' when pointer is casted
to one with greater alignment.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-23 12:34:41 -07:00
Ben Pfaff
1d4fd3a5e7 socket-util: Make get_max_fds() and get_null_fd() thread-safe.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
2013-07-23 11:37:51 -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
Ed Maste
44f645a583 socket-util: restore building on FreeBSD.
FreeBSD does not have EAI_ADDRFAMILY or EAI_NODATA and thus failed to build
after commit 3cbb5dc7e89df2b40bb6f715873cf2b6b25a7054 "socket-util: Use
getaddrinfo() instead of gethostbyname() for thread safety."

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-03 13:32:47 -07:00
Ben Pfaff
3cbb5dc7e8 socket-util: Use getaddrinfo() instead of gethostbyname() for thread safety.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-02 14:34:45 -07:00
Ben Pfaff
df451457ad socket-util: Log kernel-chosen bound ports in inet_open_passive().
Usually, for passive sockets, one wishes to bind a particular well-known
port, so that clients can easily connect.  But automated tests cannot
necessarily bind a well-known port, because that would cause multiple
concurrent tests to interfere with each other or with a real instance of
the service running on the system.  They could bind to a randomly selected
port chosen by the user (the Open vSwitch automated tests currently do this)
but this leads to occasional "false negative" test failures when the port
selected happens to be in use.

The best alternative for automated tests is to let the kernel choose a
port that is not otherwise in use, which can be accomplished by specifying
port 0.  But in that case there is no easy way for other software to know
what port the kernel chose.  This commit fixes that problem one way by
logging the bound port when it is chosen by the kernel.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-04-18 16:43:15 -07:00
Ben Pfaff
b36db11489 socket-util: Use set_nonblocking() helper function.
There's no reason to inline this when we have a helper for it.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-02-01 14:54:15 -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
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