summaryrefslogtreecommitdiff
path: root/lib/socket-util.c
Commit message (Collapse)AuthorAgeFilesLines
...
* socket-util: Unix socket related calls for non-windows platform.Gurucharan Shetty2014-02-211-0/+4
| | | | | | Don't try to compile Unix socket related functions for Windows. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
* socket-util: af_inet_ioctl() for Windows.Gurucharan Shetty2014-02-211-0/+2
| | | | | | | | | 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>
* socket-util: Describe fd for Windows.Gurucharan Shetty2014-02-211-0/+4
| | | | | | | | | | | | | 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>
* socket-util: fsync directory for Windows.Gurucharan Shetty2014-02-211-0/+2
| | | | | | | | | | 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>
* socket-util: closesocket() for Windows.Gurucharan Shetty2014-02-211-2/+2
| | | | | | | | 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>
* socket-util: getaddrinfo return values for Windows.Gurucharan Shetty2014-02-211-1/+3
| | | | | | | | | 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>
* socket-util: set_nonblocking for Windows.Gurucharan Shetty2014-02-211-0/+10
| | | | | | | 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>
* socket-util: Move sock_errno() to socket-util.Gurucharan Shetty2014-02-211-22/+27
| | | | | | | And add more users. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* util: Pre-allocate buffer for ovs_lasterror_to_string().Gurucharan Shetty2014-02-141-16/+3
| | | | | | | | 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>
* socket-util: error number to string for sockets.Gurucharan Shetty2014-02-111-0/+30
| | | | | | | | 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>
* Add IPv6 support for OpenFlow, OVSDB, NetFlow, and sFlow.Arun Sharma2014-02-061-115/+233
| | | | | | | | | | 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>
* socket-util: Remove unused functions.Ben Pfaff2014-01-311-254/+0
| | | | | | | | | 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>
* Avoid printf type modifiers not supported by MSVC C runtime library.Alin Serdean2013-11-251-3/+3
| | | | | | | | | | | | | 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>
* socket-util: Add symlink based workaround for long pathnames.YAMAMOTO Takashi2013-10-171-64/+151
| | | | | | | | | 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>
* netdev-linux, netdev-bsd: Make access to AF_INET socket thread-safe.Ben Pfaff2013-08-091-0/+40
| | | | | | | | | 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>
* clang: Fix the alignment warning.Alex Wang2013-07-231-2/+3
| | | | | | | | 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>
* socket-util: Make get_max_fds() and get_null_fd() thread-safe.Ben Pfaff2013-07-231-5/+13
| | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
* Replace all uses of strerror() by ovs_strerror(), for thread safety.Ben Pfaff2013-06-281-19/+21
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* socket-util: restore building on FreeBSD.Ed Maste2013-05-031-0/+4
| | | | | | | | | 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>
* socket-util: Use getaddrinfo() instead of gethostbyname() for thread safety.Ben Pfaff2013-05-021-11/+38
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* socket-util: Log kernel-chosen bound ports in inet_open_passive().Ben Pfaff2013-04-181-4/+12
| | | | | | | | | | | | | | | | | | | 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>
* socket-util: Use set_nonblocking() helper function.Ben Pfaff2013-02-011-7/+2
| | | | | | | 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>
* Replace most uses of assert by ovs_assert.Ben Pfaff2013-01-161-5/+4
| | | | | | | | 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>
* socket-util: Use CONST_CAST in send_iovec_and_fs().Ben Pfaff2013-01-111-1/+1
| | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Kyle Mestery <kmestery@cisco.com>
* packets: Change IP_ARGS interface to take an ovs_be32 instead of a pointer.Ben Pfaff2012-12-121-1/+1
| | | | | | | | | 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>
* socket-util: Remove get_socket_error().Ben Pfaff2012-11-201-13/+0
| | | | | | | It has no remaining users. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* socket-util: Avoid using SO_ERROR.Ben Pfaff2012-11-201-2/+11
| | | | | | | | 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>
* socket-util: Report fd of -1 on error in inet_open_active().Ben Pfaff2012-11-071-0/+1
| | | | | | | | | | | | | | | | 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>
* config: Add explicit support for building on ESX.Ethan Jackson2012-10-091-11/+9
| | | | | | | | | | | | | 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>
* lib: Add xpipe_nonblocking helperEd Maste2012-09-281-0/+8
| | | | | Signed-off-by: Ed Maste <emaste@adaranet.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* socket-util: export set_dscp()Isaku Yamahata2012-09-261-1/+1
| | | | | | | 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>
* lib: Add header #include for writevEd Maste2012-08-081-0/+1
| | | | | | | This fixes a warning on FreeBSD. Signed-off-by: Ed Maste <emaste@freebsd.org> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Use int type for setsockopt IP_TOS valueEd Maste2012-07-301-2/+4
| | | | | | | | | 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>
* Fix "*tivty" typos.Justin Pettit2012-07-251-1/+1
| | | | Signed-off-by: Justin Pettit <jpettit@nicira.com>
* socket-util: Add functions for sending fds over Unix domain sockets.Ben Pfaff2012-07-181-0/+255
| | | | | | | | | 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>
* socket-util: New function xset_nonblocking().Ben Pfaff2012-07-181-0/+8
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* socket-util: Remove 'passcred' parameter from make_unix_socket().Ben Pfaff2012-07-181-13/+2
| | | | | | | 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>
* Global replace of Nicira Networks.Raju Subramanian2012-05-021-1/+1
| | | | | | | | 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>
* vswitch: Use consistent representation of DSCP bits.Ethan Jackson2012-04-171-14/+34
| | | | | | | | | | | | | | | 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>
* socket-util: Remove DSCP_INVALID.Ethan Jackson2012-04-171-16/+10
| | | | | | | | | | | 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>
* socket-util: Close socket on failed dscp modification.Ethan Jackson2012-04-171-11/+4
| | | | | | | | 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>
* Allow configuring DSCP on controller and manager connections.Mehak Mahajan2012-03-231-4/+32
| | | | | | | | | | | 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>
* socket-util: Unlink Unix domain sockets that bind but fail to connect.Ben Pfaff2012-03-071-2/+2
| | | | | | | | | | | | | 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>
* socket-util: Don't try to listen to a UDP socket.Ben Pfaff2011-12-191-1/+1
| | | | | | | | | | 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>
* socket-util: Correctly return negative values for errors.Ben Pfaff2011-12-071-3/+4
| | | | | | | | | | | 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.
* socket-util: New function get_socket_rcvbuf().Ben Pfaff2011-10-141-17/+43
| | | | This will be used in an upcoming commit.
* socket-util: inet_parse_passive() had incorrect argument type.Ethan Jackson2011-09-131-1/+1
| | | | | | | 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]
* socket-util: Suppress valgrind uninitialized use warning.Ethan Jackson2011-08-261-1/+1
|
* socket-util: New function lookup_hostname().Ben Pfaff2011-07-271-0/+31
| | | | This is equivalent to lookup_ip() except that it accepts DNS names also.
* socket-util: Factor inet_parse_passive() out of inet_open_passive().Ben Pfaff2011-07-271-48/+67
|