Commit Graph

70 Commits (1eea1c4647263322fd62020bfd72813868b8ecea)

Author SHA1 Message Date
Mike Cui ac76768170 set_tcp_sockopt should be static, otherwise it prevents linking with libiscsi
which has function of the same name, also not static.

Same fix needs to go in to libiscsi.
2015-01-05 09:25:27 -08:00
Ronnie Sahlberg cc3e372de4 socket.c: we need netinet/in.h on some platforms 2014-08-14 18:56:39 -07:00
Mike Frysinger 10a1a78115 fix implicit decl warnings
Include the proper headers to fix warnings like:
libnfs-sync.c:1529:3: warning: implicit declaration of function 'gettimeofday' [-Wimplicit-function-declaration]
libnfs-zdr.c:506:2: warning: implicit declaration of function 'getuid' [-Wimplicit-function-declaration]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

sys/time.h needs to be protected with an ifdef

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-08-11 06:08:05 -07:00
Petr Salinger 18c94b4633 Use sockaddr_in6 instead of sockaddr6_in 2014-07-19 18:07:13 +02:00
Peter Lieven 7a750aea1c socket: fix broken connect for non broadcast traffic
commit 1c1e09a completely broke connects for non broadcast
traffic since it forgot to copy the server address into
the socket_storage struct.

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-06-08 14:20:12 +02:00
Ronnie Sahlberg a87bb233a8 Merge branch 'xid-hash' 2014-04-10 19:59:28 -07:00
Memphiz 74b037ec46 [socket] - disable linger by setting SO_LINGER to 0 seconds 2014-04-10 20:34:11 +02:00
Mark Hills 63f36a0923 Track waiting requests in a hash table, by xid
NFS servers can respond to requests in any order, and they do. In our
tests there is also some clustering to the responses; it could be
because eg. requests are served synchronously if the data is in the cache.

Introduce a hash table so that we are able to find the pdu quickly in
all cases, assuming random distribution of the responses.
2014-04-03 17:52:21 -07:00
Mark Hills aec45c6274 Optimisations to the pdu queues
When making many concurrent requests (as is likely in any performance
criticial application), the use of SLIST_REMOVE and SLIST_ADD_END are
a severe bottleneck because of their linear search.

I considered using a double-linked list but it was unnecessary to
allocate the additional memory for each list entry.

Instead, continue to use a single-linked list but retain:

* a pointer to the end of the list; and
* a pointer to the previous entry during a linear search.

The former would makes append operations O(1) time, and the latter
does the same for removal. We can do this because removal only happens
within the linear search, and there is no random access to the queue.
2014-04-03 17:51:04 -07:00
Ronnie Sahlberg 1c1e09ad51 IPV6: Add basic IPv6 support
This adds basic IPv6 support to libnfs.
Since libnfs currently only support PORTMAPPER protocol up to version 2
the IPv6 support only works if the server runs Both MOUNT and NFS protocols
on the same ports for IPv6 as for IPv4.

To get full IPv6 support we need to add support for PORTMAPPER version 3
and use it for discovery when using IPv6
2014-03-19 18:25:49 -07:00
Arne Redlich 60af7e19d1 rpc_read_from_socket: fix use-after-free due to missing return
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:59:44 -08:00
Arne Redlich 8907aea9eb socket.c: fix format string issues (too few arguments)
These were uncovered by the previously added __attribute__((format(printf))).

Emacs also removed trailing whitespace while at it.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:59:17 -08:00
Ronnie Sahlberg 6ec481d3fa Add a rpc_set_fd() fucntion which can be used to swap the underlying socket file descriptor
This is mainly needed when having to track and control the file descriptors that are used by libnfs, for example when trying to emulate dup2() ontop
of libnfs.
2014-02-02 08:45:21 -08:00
Peter Lieven d43a8953f5 make adjustments for v6 of the qemu NFS driver
Signed-off-by: Peter Lieven <pl@kamp.de>
2014-01-13 11:22:21 +01:00
Peter Lieven 1c8b4547ce add tcp-syncnt URL param to adjust TCP_SYNCNT sockopt
This allows indirect support for a configurable connect timeout.

Linux uses a exponential backoff for SYN retries starting
with 1 second.

This means for a value n for TCP_SYNCNT, the connect will
effectively timeout after 2^(n+1)-1 seconds.

Example:
 examples/nfs-ls nfs://10.0.0.1/export?tcp-syncnt=1

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-23 14:03:18 +01:00
Ronnie Sahlberg 751770fd43 Dont leak every single buffer we read from the socket. 2013-10-30 18:15:03 -07:00
Ronnie Sahlberg dd97d43aad Reset the receive buffer processing the received PDU.
This allows us to have recursive eventloops and do synchronous
rpc calls from a callback.
2013-10-20 13:16:45 -07:00
Ronnie Sahlberg c022471e52 Add configure test for arpa/inet.h 2013-05-28 21:25:08 -07:00
Ronnie Sahlberg bff8fe460d Some more configure checks for headers 2013-05-28 17:54:12 -07:00
Ronnie Sahlberg 7057e733c1 Add configure checks for sys/socket.h 2013-05-28 17:43:47 -07:00
Ronnie Sahlberg cb5b8be2eb Try making the initial port used a little more random 2013-05-28 17:22:28 -07:00
Ronnie Sahlberg 00748f36c5 more header include cleanups 2013-04-14 10:11:48 -07:00
Ronnie Sahlberg 2142af5d47 WIN32: More ifdef cleanups 2013-04-14 09:02:23 -07:00
Ronnie Sahlberg 622489d36e WIN32: get rid of some ifdefs 2013-04-14 08:50:38 -07:00
Ronnie Sahlberg 099be710b6 SOCKET: Use recv/send for all socket io on all platforms
instead of only on windows and aros  and read/write on the others
2013-04-14 08:43:59 -07:00
Ronnie Sahlberg 9a9126c3d9 AROS: add inet_pton emulation and make sure we use recv/send and not read/write 2013-04-13 07:40:46 -07:00
Ronnie Sahlberg d7c6e9aaa9 Initial AROS support.
The test app doesnt link yet since we are missing a bunch of symbols

but it is a start
2013-04-10 20:28:40 -07:00
Ronnie Sahlberg f816bf4c76 Merge branch 'zdr'
Manually fixyp some merge conflicts in :
	lib/init.c
	lib/pdu.c
	lib/socket.c
	nfs/Makefile.am
	nfs/nfs.x
	nlm/Makefile.am
2012-11-27 18:22:27 -08:00
Ronnie Sahlberg f3a7507806 Add an assert to track if we try to use an rpc_context after it has been destroyed 2012-11-24 08:18:54 -08:00
Ronnie Sahlberg 2811861b96 Dont leak addrinfo in error path 2012-11-24 08:14:12 -08:00
Rudi Ihle 456c0b147a Fixed errno processing for connect() on Windows. 2012-11-24 08:12:45 -08:00
Rudi Ihle 2521374f70 Modified mechanism to assign privileged ports and enable it for Windows as well 2012-11-24 08:12:31 -08:00
Ronnie Sahlberg 4a2b08768a Add an assert to track if we try to use an rpc_context after it has been destroyed 2012-11-21 17:10:05 -08:00
Ronnie Sahlberg be7f59339e Dont leak addrinfo in error path 2012-11-17 10:14:19 -08:00
Rudi Ihle f96b24fada Fixed errno processing for connect() on Windows. 2012-09-18 08:33:41 +02:00
Rudi Ihle ac559609a3 Modified mechanism to assign privileged ports and enable it for Windows as well 2012-09-18 08:32:40 +02:00
Ronnie Sahlberg d14e28387f squelch compiler warnings in socket.c about integer sizes 2012-07-05 07:21:48 +10:00
Ronnie Sahlberg 763cd6e3e2 ZDR: New builtin replacement for RPC/XDR called ZDR
This patch switches libnfs over to use precompiled rpcgen files
and using ZDR.  ZDR is a trivial reimplementation of XDR that is built in
into libnfs.

This removes the dependencies of rpc/xdr completely and allow us to build on any
system, even systems where rpcgen and librpc/libxdr are not generally available.
2012-07-04 16:53:12 +10:00
Ronnie Sahlberg e6cac86f77 Try to rotate the ports we assign when root better so we dont reuse
a port htat is in time-wait too frequently
2012-01-03 07:25:25 +11:00
Ronnie Sahlberg 59f298f5bf Improve an error message to show the errno value 2012-01-03 07:18:56 +11:00
Ronnie Sahlberg 183451cff5 Remove all [s]size_t / off_t and replace with [u]int64_t making libnfs 64-bit pure 2011-11-27 14:49:08 +11:00
Ronnie Sahlberg b990de23c6 Only call the "connect callback" if the callback is set to non-NULL 2011-10-09 19:00:24 +11:00
Ronnie Sahlberg 1744ef9011 Autoreconnect: autoreconnect was completely broken. Reimplement it so that it reconnects properly on session failure. 2011-10-04 11:25:10 +11:00
Memphiz fcc42bfe85 [win32] - completed win32 port 2011-09-12 19:53:33 +02:00
Ronnie Sahlberg 4e9dcb7665 remove debug message 2011-09-12 22:20:56 +10:00
Ronnie Sahlberg 07fd0cbc65 when creating a socket, spin over a number of low-numbered ports
and try to bind to a system port in case the user is root or the
binary has the CAP_NET_BIND_SERVICE capability

this removes the need to use 'insecure' on the server
2011-09-12 22:14:26 +10:00
Ronnie Sahlberg 83aa785d92 Add a call to find the queue-length so we can see how many I/O we have in flight from the application layer. 2011-09-11 21:32:48 +10:00
unknown 4b0e8df9a9 [fix] - fix connect for win32 - return values are inverted 2011-09-03 15:31:56 +10:00
unknown 99c14c9b81 [add] - implement set_non_blocking for socket 2011-09-03 15:30:01 +10:00
Memphiz a8a1b85846 [win32] - make it compile on win32 2011-09-03 15:08:48 +10:00