2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-23 10:28:00 +00:00

57 Commits

Author SHA1 Message Date
Ben Pfaff
ce04c33d8b socket-util: Make parse_bracketed_token() public, as inet_parse_token().
An upcoming commit will introduce a new user outside socket-util.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
2017-10-24 16:09:16 -07:00
Ben Pfaff
fd245f1da9 socket-util: Change ss_format_address() to take a dynamic string.
It's occasionally convenient to format into a fixed-size buffer, but
as the use cases, and the text to be formatted, get more sophisticated,
it becomes easier to deal with "struct ds *" than a buffer pointer and
length pair.  An upcoming commit will make ss_format_address() do more
work, and I think that this is the point at which it becomes easier to
take a dynamic string.  This commit makes the parameter type change
without yet changing what is formatted.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Numan Siddique <nusiddiq@redhat.com>
Acked-by: Numan Siddique <nusiddiq@redhat.com>
2017-07-17 10:05:54 -07:00
Ben Pfaff
8a8c1b93b1 socket-util: Support sendmmsg() regardless of platform.
This will have its first user in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-07-12 17:38:33 -07:00
Thadeu Lima de Souza Cascardo
dd23522f68 stream-unix: only use path-based socket names
FreeBSD returns a socklen of sockaddr_storage when doing an accept on an unix
STREAM socket. The current code will assume it means a sun_path larger than 0.

That breaks some tests like the one below which don't expect to find "unix::" on
the logs.

As a Linux abstract address would not have a more useful name either, it's
better to check that sun_path starts with a non-zero byte and return 0 length in
case it doesn't.

402: ovs-ofctl replace-flows with --bundle      FAILED (ovs-ofctl.at:2928)
2016-07-08T12:44:30.068Z|00020|vconn|DBG|unix:: sent (Success): OFPT_HELLO (OF1.6) (xid=0x1):

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-07-19 20:06:45 -07:00
Jiri Benc
9835576bc1 lib: add ipv6 helper functions for tnl_config
These functions will be used by the next patches.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2015-11-10 10:00:04 -08:00
Alin Serdean
a35f3d61c7 Undefined symbol make_unix_socket
syslog_direct_create defined in (lib/syslog-direct.c) uses make_unix_socket
which is currently undefined on the windows build.

We either can remove the new file from the chain but this patch proposes
to define a wrapper to make_unix_socket in which we return EINVAL.

This will avoid this kind of problems in the future.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
2015-07-10 20:33:09 -07:00
Ben Pfaff
afc1d53674 socket-util: Use correct address family in set_dscp(), instead of guessing.
The set_dscp() function, until now, tried to set the DSCP as IPv4 and as
IPv6. This worked OK on Linux, where an ENOPROTOOPT error made it really
clear which one was wrong, but FreeBSD uses EINVAL instead, which has
multiple meanings and which it therefore seems somewhat risky to ignore.
Instead, this commit just tries to set the correct address family's DSCP
option.

Tested by Alex Wang on FreeBSD 9.3.

Reported-by: Atanu Ghosh <atanu@acm.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Co-authored-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Tested-by: Alex Wang <alexw@nicira.com>
2015-02-20 11:36:12 -08:00
Gurucharan Shetty
b7cefbf7e5 stream-tcp: Call setsockopt TCP_NODELAY after TCP is connected.
On Windows platform, TCP_NODELAY can only be set when TCP is established.
(This is an observed behavior and not written in any MSDN documentation.)
The current code does not create any problems while running unit tests
(because connections get established immediately) but is reportedly
observed while connecting to a different machine.

commit 8b76839(Move setsockopt TCP_NODELAY to when TCP is connected.)
made changes to call setsockopt with TCP_NODELAY after TCP is connected
only in lib/stream-ssl.c. We need the same change for stream-tcp too and
this commit does that.

Currently, a failure of setting TCP_NODELAY results in reporting
the error and then closing the socket. This commit changes that
behavior such that an error is reported if setting TCP_NODELAY
fails, but the connection itself is not torn down.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-10-23 11:07:32 -07:00
Gurucharan Shetty
b52ecd9610 socket-util: Log the kernel assigned port number when asked.
So far, we log the kernel assigned port number when the port number is
not specified. On Windows, this happens multiple times because "unix"
sockets are implemented internally via TCP ports. This means that many tests,
specially the ovs-ofctl monitor tests, need to filter out the
additional messages. Doing that is not a big deal, but I think it will
keep manifesting in future tests added by Linux developers.

With this commit, we simply don't print the kernel assigned TCP ports
on Windows when done for "unix" sockets.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-05-28 08:34:28 -07:00
Gurucharan Shetty
7f1e1c7ffa socket-util: Refactor unix specific code to a new file.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-05-27 10:09:07 -07: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
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
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
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
9390ef7fd5 socket-util: getsockopt for Windows.
Windows defines the 'optval' argument as char * instead of void *.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-21 08:20:38 -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
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
5ea1366bc9 stream-ssl: Add support for Windows platform.
This commit creates events and through poll_fd_wait_event()
associates them with socket file descriptors to get woken up
from poll_block().

Some other changes:

* Windows does not have sys/fcntl.h but has a fcntl.h
On Linux, there is fctnl.h too.

* include <openssl/applink.c> to handle different C-Runtime linking
of OVS and openssl libraries as suggested at
https://www.openssl.org/support/faq.html#PROG2

The above include will not be needed if we compile Open vSwitch with
/MD compiler option.

* SHUT_RDWR is equivalent to SD_BOTH on Windows.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-02-11 09:55:48 -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
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
YAMAMOTO Takashi
14235530fa include some headers to satisfy header file dependencies on NetBSD-6
while this change don't seem to be necessary on NetBSD-current,
NetBSD-6 is the latest release at this point.

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-04-22 08:52:37 -07: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
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
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
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
c1c19657f4 socket-util: New function get_socket_rcvbuf().
This will be used in an upcoming commit.
2011-10-14 14:08:44 -07:00
Simon Horman
72af4a857c Include <sys/time.h> in socket-util.h
sys/time.h appears to be required for a definition of timespec on Android.

Observed when compiling using the Android NDK r6b (Android API level 13).
2011-09-22 09:02:57 -07:00
Simon Horman
8e47be7756 Include <sys/socket.h> in socket-util.h
This appears to be necessary to get a definition of socket_t
when compiling using the Android NDK r6b (Android API level 13).
2011-09-22 09:02:54 -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
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
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
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
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
36775dad35 socket-util: Make inet_open_passive() pass back the bound address.
This feature is useful in an upcoming commit.
2010-01-07 15:00:47 -08:00
Ben Pfaff
e1bd3bee5c socket-util: Allow binding without a port number in inet_open_passive().
The test-vconn program binds a socket to a nonspecific port number.  To
add SSL support to this program, it needs to be able to use SSL, and the
stream library is the easiest way to do that.  But the stream library
can't bind to a nonspecific port.  This commit adds that feature, by adding
it to the function that the stream SSL library uses as a building block.
2010-01-07 11:12:36 -08:00