summaryrefslogtreecommitdiff
path: root/lib/socket-util.c
Commit message (Collapse)AuthorAgeFilesLines
* ovsdb-server: Fix handling of DNS name for listener configuration.Frode Nordahl2023-02-101-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 08e9e5337383 fixed proper initialization of the dns-resolve module, and made DNS resolution asynchronous. A side effect of that change revealed a long standing logic bug which broke ovsdb-server listener configuration using DNS names. Previously this worked because the DNS resolution would block, now that DNS resolution is asynchronous the code before this change would assume the error from jsonrpc_pstream_open meant the remote was a specification for an active outgoing connection, even when that was not the case. To fix this a couple of changes was made to socket-util: 1) Pass optional result of dns resolution from inet_parse_passive. When (re-)configuring listeners that use DNS names, we may need to know whether the provided connection string is invalid or if the provided DNS name has finished resolving. 2) Check dns resolution status in inet_open_passive. If the connection string is valid, and contains a DNS name, inet_open_passive will now return -EAGAIN if dns resolution failed. DNS resolution failure may either mean the asynchronous resolver has not completed yet, or that the name does not resolve. Reported-at: https://bugs.launchpad.net/bugs/1998781 Fixes: 08e9e5337383 ("ovsdb: raft: Fix inability to read the database with DNS host names.") Fixes: 771680d96fb6 ("DNS: Add basic support for asynchronous DNS resolving") Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* ovsdb: raft: Fix inability to read the database with DNS host names.Ilya Maximets2022-03-301-13/+26
| | | | | | | | | | | | | | | | | | | | | | | | | Clustered OVSDB allows to use DNS names as addresses of raft members. However, if DNS resolution fails during the initial database read, this causes a fatal failure and exit of the ovsdb-server process. Also, if DNS name of a joining server is not resolvable for one of the followers, this follower will reject append requests for a new server to join until the name is successfully resolved. This makes a follower effectively non-functional while DNS is unavailable. To fix the problem relax the address verification. Allowing validation to pass if only name resolution failed and the address is valid otherwise. This will allow addresses to be added to the database, so connections could be established later when the DNS is available. Additionally fixing missed initialization of the dns-resolve module. Without it, DNS requests are blocking. This causes unexpected delays in runtime. Fixes: 771680d96fb6 ("DNS: Add basic support for asynchronous DNS resolving") Reported-at: https://bugzilla.redhat.com/2055097 Acked-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* socket-util: Emulate recvmmsg() and sendmmsg() on Linux only.Ben Pfaff2020-01-141-5/+3
| | | | | | | | | | | | These functions failed to build on OS X because MSG_WAITFORONE is not defined there. There are pitfalls for trying to define our own MSG_* constants, since it's hard to pick a constant that is not used by the system already. Because OVS only uses recvmmsg() and sendmmsg() on Linux, it seems easiest to just emulate them there. Reported-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ilya Maximets <i.maximets@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
* socket-util: Introduce emulation and wrapper for recvmmsg().Ben Pfaff2020-01-091-0/+56
| | | | | | | | | | | Not every system will have recvmmsg(), so introduce compatibility code that will allow it to be used blindly from the rest of the tree. This assumes that recvmmsg() and sendmmsg() are either both present or both absent in system libraries and headers. CC: Yi Yang <yangyi01@inspur.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* treewide: Get rid of // comments, even inside comments.Ben Pfaff2019-01-251-1/+1
| | | | | | | | | | | | | Just a style fix. With this patch, the following reports no hits: git ls-files | grep '\.[ch]$' | grep -vE 'datapath|sflow' \ | xargs grep -n // | grep -vE "http|s/|'|\"" Acked-by: Ilya Maximets <i.maximets@samsung.com> Reported-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* socket-util: Report POLLHUP as an error while connection completion checking.Ilya Maximets2018-12-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Otherwise failed non-blocking connection could be reported as connected. This causes errors in all following operations with the socket. At least this is true on FreeBSD, where POLLHUP could be set without POLLERR. For example, stream_open_block() tests fails with the following error reporting successful connection to the 'WRONG_PORT': ./ovsdb-idl.at:1817: $PYTHON2 $srcdir/test-stream.py tcp:127.0.0.1:$WRONG_PORT stdout: ./ovsdb-idl.at:1817: exit code was 0, expected 1 2399. ovsdb-idl.at:1817: FAILED (ovsdb-idl.at:1817) Also added new tests to track this issue in C library: 'Check Stream open block - C - tcp' 'Check Stream open block - C - tcp6' CC: Numan Siddique <nusiddiq@redhat.com> Fixes: c1aa16d191d2 ("ovs python: ovs.stream.open_block() returns success even if the remote is unreachable") Fixes: d6cedfd9d29d ("socket-util: Avoid using SO_ERROR.") Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovn-nbctl: Fix the ovn-nbctl test "LBs - daemon" which fails during rpm buildNuman Siddique2018-11-051-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When 'make check' is called by the mock rpm build (which disables networking), the test "ovn-nbctl: LBs - daemon" fails when it runs the command "ovn-nbctl lb-add lb0 30.0.0.1a 192.168.10.10:80,192.168.10.20:80". ovn-nbctl extracts the vip by calling the socket util function 'inet_parse_active()', and this function blocks when libunbound function ub_resolve() is called further down. ub_resolve() is a blocking function without timeout and all the ovs/ovn utilities use this function. As reported by Timothy Redaelli, the issue can also be reproduced by running the below commands $ sudo unshare -mn -- sh -c 'ip addr add dev lo 127.0.0.1 && \ mount --bind /dev/null /etc/resolv.conf && runuser $SUDO_USER' $ make sandbox SANDBOXFLAGS="--ovn" $ ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.1a \ 192.168.10.10:80,192.168.10.20:80 To address this issue, this patch adds a new bool argument 'resolve_host' to the function inet_parse_active() to resolve the host only if it is 'true'. ovn-nbctl/ovn-northd will pass 'false' when it calls this function to parse the load balancer values. Reported-by: Timothy Redaelli <tredaelli@redhat.com> Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1641672 Signed-off-by: Numan Siddique <nusiddiq@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* socket-util: Rate limit logs for bind attempts.Ben Pfaff2018-08-201-1/+2
| | | | | | | | This reduces the amount of logging when higher-level code retries binding ports that are in use. Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
* DNS: Add basic support for asynchronous DNS resolvingYifeng Sun2018-07-061-7/+41
| | | | | | | | | | | | | | | | | | | | | | This patch is a simple implementation for the proposal discussed in https://mail.openvswitch.org/pipermail/ovs-dev/2017-August/337038.html and https://mail.openvswitch.org/pipermail/ovs-dev/2017-October/340013.html. It enables ovs-vswitchd and other utilities to use DNS names when specifying OpenFlow and OVSDB remotes. Below are some of the features and limitations of this patch: - Resolving is asynchornous in daemon context, avoiding blocking main loop; - Resolving is synchronous in general utility context; - Both IPv4 and IPv6 are supported; - The resolving API is thread-safe; - Depends on the unbound library; - When multiple ip addresses are returned, only the first one is used; - /etc/nsswitch.conf isn't respected as unbound library doesn't look at it; - For async-resolving, caller need to retry later; there is no callback. Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* socket-util: Elaborate inet_parse_active comment.Darrell Ball2018-05-091-1/+3
| | | | | | | | | | | The function inet_parse_active() is an external API and used as one stop shopping for parsing ip address and L4 port combinations from many other modules. Hence, the function header is extended to describe the special cases that it handles. Signed-off-by: Darrell Ball <dlu998@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* socket-util: Improve comments on (host,port) parsing functions.Ben Pfaff2018-04-171-2/+2
| | | | | | Fixes: 0b043300dbad ("Make <host>:<port> parsing uniform treewide.") Suggested-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* socket-util: Add more functions for IPv[46] sockaddr and sockaddr_storage.Ben Pfaff2018-04-161-38/+100
| | | | | | | | | | | | | The existing functions for working with sockaddr_storage that contain an IPv4 or IPv6 address are useful. This commit adds more functions for working with them, as well as a parallel set of functions for struct sockaddr. This also adds an initial user for some of the new sockaddr functions in netdev.c. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
* Make <host>:<port> parsing uniform treewide.Ben Pfaff2018-04-161-56/+84
| | | | | | | | | | | | | | | | I didn't realize until now that the tree had two different ways of parsing strings in the form <host>:<port> and <port>:<host>. There are the long-standing inet_parse_active() and inet_parse_passive() functions, and more recently the ipv46_parse() function. This commit eliminates the latter and changes the code to use the former. The two implementations interpreted some input differently. In particular, the older functions required IPv6 addresses to be [bracketed], but the newer ones do not. For compatibility this patch changes the merged code to use the more liberal interpretation. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
* socket-util: Make inet_parse_active() and inet_parse_passive() more alike.Ben Pfaff2018-04-161-7/+7
| | | | | | | | | | | | | | Until now, the default_port parameters to these functions have had different types and different behavior. There is a reason for this, since it makes sense to listen on a kernel-selected port but it does not make sense to connect to a kernel-selected port, but this overlooks the possibility that a caller might want to parse a string in the format understood by inet_parse_active() without actually using it to connect to a remote host. This commit makes the behavior consistent and updates all the callers to work with the new semantics. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
* socket-util: New function inet_parse_address().Ben Pfaff2018-04-161-0/+26
| | | | | | | This will acquire its first user in an upcoming commit. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
* ovn-northd: Use common code for sockaddr_storage.Ben Pfaff2018-04-161-6/+22
| | | | | | | | This better reuses existing code. It does require adding a slight variant on ss_format_address(), but it still seems like a net win. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
* socket-util: Make address parser check for trailing garbage.Ben Pfaff2018-04-161-0/+6
| | | | | Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
* socket-util: Fix error in comment on ss_format_address().Ben Pfaff2018-04-161-2/+1
| | | | | | | | The output for this function is a dynamic string and doesn't have a fixed buffer size, so the comment was wrong. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
* sparse: Add guards to prevent FreeBSD-incompatible #include order.Ben Pfaff2017-12-221-0/+2
| | | | | | | | | | FreeBSD insists that <sys/types.h> be included before <netinet/in.h> and that <netinet/in.h> be included before <arpa/inet.h>. This adds guards to the "sparse" headers to yield a warning if this order is violated. This commit also adjusts the order of many #includes to suit this requirement. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* lib: Move lib/poll-loop.h to include/openvswitchXiao Liang2017-11-031-1/+1
| | | | | | | | 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>
* socket-util: Make parse_bracketed_token() public, as inet_parse_token().Ben Pfaff2017-10-241-7/+7
| | | | | | | 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>
* Support IPv6 link-local address scopes on Linux.Ben Pfaff2017-07-171-9/+56
| | | | | | | | | | | | | | | | I hadn't even heard of this feature before, but it seems to be at least semi-standard to support Linux link-local address scopes via a % suffix, e.g. fe80::1234%eth0 for a link-local address scoped to eth0. This commit adds support. I'd appreciate feedback from folks who understand this feature better than me. Reported-by: Ali Volkan Atli <Volkan.Atli@argela.com.tr> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Darrell Ball <dlu998@gmail.com> Tested-by: Numan Siddique <nusiddiq@redhat.com> Acked-by: Numan Siddique <nusiddiq@redhat.com>
* socket-util: Change ss_format_address() to take a dynamic string.Ben Pfaff2017-07-171-20/+16
| | | | | | | | | | | | | | 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>
* socket-util: Fix recursion issue in sendmmsgZhenyu Gao2017-07-141-0/+3
| | | | | | | | The wrap_sendmmsg has infinite recursion issue. Fix it by undef sendmmsg. Signed-off-by: Zhenyu Gao <sysugaozhenyu@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* socket-util: Avoid using sendmsg on WindowsAlin Serdean2017-07-131-0/+2
| | | | | | | | | | | | | | | | Sendmsg is not used under Windows. While it does have a sort of equivalent called `WSASendMsg` (https://msdn.microsoft.com/en-us/library/windows/desktop/ms741692(v=vs.85).aspx) it uses a different structure `WSAMSG` instead of the normal msghdr which in turn will have to be mapped properly (this goes further to iovec/wsabuf in the structure itself). Fixes broken build on Windows. Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Shashank Ram <rams@vmware.com>
* socket-util: Support sendmmsg() regardless of platform.Ben Pfaff2017-07-121-0/+38
| | | | | | This will have its first user in an upcoming commit. Signed-off-by: Ben Pfaff <blp@ovn.org>
* windows: WSAPoll broken on windowsAlin Serdean2017-01-271-1/+17
| | | | | | | | | | | | | Unfortunately, WSAPoll misbehaves on Windows please view detailed behavior on: https://github.com/openvswitch/ovs-issues/issues/117 We replace the WSAPoll with select looking only for errors and write events. Reported-at: https://github.com/openvswitch/ovs-issues/issues/117 Reported-by: Yin Lin <linyi@vmware.com> Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Acked-by: Sairam Venugopal <vsairam@vmware.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* lib: Fix error reporting in parse_sockaddr_components() for bad port.Huang Lei2016-04-221-0/+1
| | | | | | | | | Bad port number error is ignored in parse_sockaddr_components(), if port number is invalid, it ouputs a error log and set port to 0. Signed-off-by: Huang Lei <lhuang8@ebay.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/dynamic-string.h to include/openvswitch directoryBen Warren2016-03-191-1/+1
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Use ip_parse() and ipv6_parse() and variants in more places.Ben Pfaff2015-12-151-5/+5
| | | | | | | | | | | This saves some code and improves clarity, in my opinion. Some of these changes just change an inet_pton() call into a similar ip_parse() or ipv6_parse() call. In those cases the benefit is better type safety, since inet_pton()'s output parameter is type "void *". Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* lib: add ipv6 helper functions for tnl_configJiri Benc2015-11-101-0/+9
| | | | | | | | 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>
* socket-util: Use correct address family in set_dscp(), instead of guessing.Ben Pfaff2015-02-201-24/+20
| | | | | | | | | | | | | | | | | 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>
* lib: Move vlog.h to <openvswitch/vlog.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | 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>
* stream-tcp: Call setsockopt TCP_NODELAY after TCP is connected.Gurucharan Shetty2014-10-231-0/+14
| | | | | | | | | | | | | | | | | | | | | 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>
* socket-util: Disable dscp setting on Windows.Gurucharan Shetty2014-06-111-8/+5
| | | | | | | | | | | | | | According to msdn documentation, one is discouraged from using IP_TOS for ipv4 sockets (it apparently does not actually set anything). Also, IPV6_TCLASS does not work in Windows (it always returns an error and also is undocumented). Looks like Microsoft recommends QoS2 APIs to achieve the same. Till we add those API calls, simply return on Windows. (Noticed while running unit tests for ipv6. set_dscp would fail.) Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* socket-util: Log the kernel assigned port number when asked.Gurucharan Shetty2014-05-281-3/+7
| | | | | | | | | | | | | | | 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>
* socket-util: Refactor unix specific code to a new file.Gurucharan Shetty2014-05-271-377/+0
| | | | | Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* socket-util: Fix an inverted use of LINUXYAMAMOTO Takashi2014-03-201-1/+1
| | | | | | | | Fix a regression introduced by commit fce314cd. ("socket-util: Fix definition of LINUX.") Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* socket-util: Fix dscp error check for Windows.Gurucharan Shetty2014-03-181-0/+8
| | | | | Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* socket-util: Fix definition of LINUX.Ben Pfaff2014-03-171-2/+2
| | | | | | Reported-by: Mukesh Hira <mhira@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Pritesh Kothari <pritesh.kothari@cisco.com>
* Use __linux__ instead of LINUX_DATAPATH in C code.Ben Pfaff2014-03-051-9/+11
| | | | | | | | | | | 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>
* socket-util: pipe for Windows.Gurucharan Shetty2014-02-261-0/+2
| | | | | | | | | | | | 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>
* socket-util: Fix set_dscp for IPv6YAMAMOTO Takashi2014-02-261-1/+18
| | | | | | | | | | | | | | | | | | | 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>
* socket-util: Avoid using the identical message for different errorsYAMAMOTO Takashi2014-02-261-2/+2
| | | | | Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* socket-util: drain_rcvbuf() for Windows.Gurucharan Shetty2014-02-241-1/+4
| | | | | | | | | | | | | 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>
* lib/process, socket-util: Update necessary headersYAMAMOTO Takashi2014-02-221-1/+0
| | | | | | | | 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>
* socket-util: Move get_null_fd() to daemon.c.Gurucharan Shetty2014-02-211-22/+0
| | | | | | | | | | 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>
* socket-util: poll() for Windows.Gurucharan Shetty2014-02-211-5/+9
| | | | | | | | | | 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>
* Replace inet_aton() with inet_pton().Gurucharan Shetty2014-02-211-2/+2
| | | | | | | | 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>
* socket-util: Move get_max_fds() to process.c.Gurucharan Shetty2014-02-211-43/+0
| | | | | | | | | | 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>