Commit Graph

911 Commits (04cdb72bb1a147c2d732dcca5f87e5e3bd2e2252)

Author SHA1 Message Date
Max Kellermann 2b3c164db2 lib/pdu: don't clear pointers in rpc_free_pdu()
Pointless, because the containing object is going to be freed.
2017-02-09 12:53:45 +01:00
Max Kellermann 2f703bd84d lib/pdu: fix memory leaks in rpc_allocate_*()
All error code paths must contain cleanup for all allocations until
that point in the function.  Yay for plain C.
2017-02-09 12:52:22 +01:00
Max Kellermann a027637cf6 configure.ac: use AC_SYS_LARGEFILE
Let autoconf in all its wisdom decide what needs to be done for large
file support.  Hard-coding it to _FILE_OFFSET_BITS=64 is fragile.
2017-02-09 12:52:22 +01:00
Ronnie Sahlberg 906d09f32f Merge pull request #168 from MaxKellermann/cloexec
Use SOCK_CLOEXEC
2017-02-08 17:28:41 -08:00
Ronnie Sahlberg eadb7a0533 Merge pull request #169 from MaxKellermann/remove
init: remove pdu from list before invoking callback
2017-02-08 17:27:50 -08:00
Max Kellermann 31cb099f50 init: remove pdu from list before invoking callback
If the callback does anything fishy that modifies the linked list,
libnfs may crash after returning.  So doing any pending list removals
before invoking the callbacks is safer.
2017-02-08 12:14:52 +01:00
Max Kellermann 26d90c0663 lib/socket: use SOCK_CLOEXEC in create_socket() 2017-02-08 11:53:00 +01:00
Max Kellermann 46448bccb4 lib/socket: add function create_socket()
Prepare for SOCK_CLOEXEC support.
2017-02-08 11:52:32 +01:00
Ronnie Sahlberg 1d6600652c Merge pull request #167 from MaxKellermann/static
init: move static to beginning of declaration
2017-02-04 17:34:44 -08:00
Ronnie Sahlberg 17dc62ada9 Merge pull request #166 from MaxKellermann/const_void
Allow passing void* buffers, and make write buffers const
2017-02-04 17:34:19 -08:00
Max Kellermann ddc37a365e init: move static to beginning of declaration
Fixes gcc's -Wold-style-declaration.

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
2017-02-03 19:56:35 +01:00
Max Kellermann 03ac15de5e Allow passing void* buffers, and make write buffers const
Enables callers to pass any opaque data chunk without having to cast
it explicitly.

A write never modifies the source buffer, and thus the pointer should
be const.

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
2017-02-03 19:42:12 +01:00
Ronnie Sahlberg d6a21b2bda Make rpc_set{g|u}id() public
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-01-30 17:47:18 -08:00
Ronnie Sahlberg 337290c471 Merge pull request #163 from plieven/for_upstream
For upstream
2017-01-21 16:03:35 -08:00
Peter Lieven 25ce137d45 socket: Batch pdu read in rpc_read_from_socket
rpc_read_from_socket can currently only read one PDU in each rpc_service invocation even
if there is more data available on the socket. This patch reads all PDUs until the socket
would block.

Signed-off-by: Peter Lieven <pl@kamp.de>
2017-01-12 14:52:51 +01:00
Peter Lieven c711c568c1 rpc: track the number of pdus in the waitpdu queues
Signed-off-by: Peter Lieven <pl@kamp.de>
2017-01-12 14:38:11 +01:00
Ronnie Sahlberg 25dc54da93 Merge pull request #162 from plieven/for_upstream
Revert "socket: batch pdu read in function rpc_read_from_socket"
2017-01-07 08:49:50 -08:00
Peter Lieven bd16e8db5c Revert "socket: batch pdu read in function rpc_read_from_socket"
The ioctl version breaks Qemu. I will post an updated once we found
a good solution in libiscsi and then adapt it to libnfs.

This reverts commit 003b3c7ce2.
2017-01-05 12:13:56 +01:00
Ronnie Sahlberg 43cde9daf6 Merge pull request #160 from kevin-vigor/master
Return ESTALE for NFS3ERR_STALE, not EIO.
2016-12-27 15:39:28 -08:00
Kevin Vigor c2cd9fdec1 Return ESTALE for NFS3ERR_STALE, not EIO.
ESTALE is retryable in many circumstances, EIO is not.
2016-12-27 16:10:11 -07:00
Ronnie Sahlberg 77ae1fbed4 Merge pull request #158 from plieven/for_upstream
For upstream
2016-12-26 17:22:34 -08:00
Ronnie Sahlberg 01ca79972a WIN32: SO_TYPE is a char on windows not int.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 17:05:01 -08:00
Ronnie Sahlberg ca67c18db2 Fix compiler warning for min/max version being unset (which can not happen)
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 16:51:28 -08:00
Ronnie Sahlberg 46d63f13b7 PORTMAP: Remove buf variable where we do not use/need it from the generated files
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 16:48:49 -08:00
Ronnie Sahlberg b06b37ec99 NFS4: Remove the buf variable from the generated c code as it is unused.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 16:42:51 -08:00
Ronnie Sahlberg d93cc94d1b WIN32: VS does not like the spurious int i; that rpcgen sometimes generate
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 16:26:14 -08:00
Ronnie Sahlberg 85853ae9f0 WIN32: Add nfs4 to the visual studio project files
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 16:09:36 -08:00
Peter Lieven 003b3c7ce2 socket: batch pdu read in function rpc_read_from_socket
rpc_read_from_socket can currently only read one PDU in each rpc_service invocation even
if there is more data available on the socket. This patch reads all PDUs available on
the socket when rpc_read_from_socket is entered.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-12-22 15:43:58 +01:00
Peter Lieven a22464c380 socket: avoid to realloc the rpc->inbuf
we always read 4 bytes to get the PDU size and than realloc
these 4 bytes to the full size of the PDU. Avoid this by
using a static buf for the record marker.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-12-22 15:43:54 +01:00
Peter Lieven a0249fe9a6 socket: don't leak buf in case of rpc_process_pdu error
Signed-off-by: Peter Lieven <pl@kamp.de>
2016-12-22 15:43:49 +01:00
Ronnie Sahlberg 0a4f9cd8a8 EXAMPLE: nfs4-cat-talloc
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 17:42:35 -08:00
Ronnie Sahlberg adf158bb23 Update README and mention NFSv4 and general RPC server support.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 85aca36e02 EXAMPLE: portmapper server
Example showing how to build a RPC server using libnfs.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 2cffb48c9d Add PMAP2 UNSET support to the portmapper client
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 34926e9d94 Add support for PMAP2 SET operation to the portmapper client
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 6d397028ba EXAMPLE: Add nfs4-cat example
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 2d348242c5 Make zdr_malloc() visible outside of libnfs-zdr.c
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 57a9bd8565 Automatically detect if a server context fd is a UDP socket or not
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg eb6b39125c Initial rpc server support
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 6f860fd874 Add ZDR* and void* as arguments to zr_void so that it can be used as a zdrproc_t
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg be2c87c2cd Update portmap.x to use nicer names for procedure arguments and responses
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg f4273cf9ff Change type of zdrproc_t to return uint32_t instead of int
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 7596d0f300 Use a static sockaddr_storage for rpc.udp_dest
There is no need to allocate and deallocate this structue every time
we update the udp destinateion.

For the client side, where we set the destination just once per lifetime
of the context it might not matter too much but once we add udp server support
we will need to update the sockaddr for every rpc we receive.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 853474d387 Add NFSv4 protocol definitions
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 9eaa36c4bf Remove sockaddr argument to rpc_connect_sockaddr_async
We always use the rpc->s as the sockaddr so no need to pass it by argument

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-01 15:02:46 -08:00
Ronnie Sahlberg dccffb86ee Create a new helper function to set the sockaddr for a rpc context
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-01 15:02:34 -08:00
Ronnie Sahlberg 6f8b2f85ca socketsize is of type socklen_t not int
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-01 08:37:55 -08:00
Ronnie Sahlberg 11f85665fc Add a PDU flag for discard after sending.
Add a flags field to rpc_pdu and add a flag that indicates that the PDU
should be discarded as soon as it has been written to the socket.
We do not put it on the waitpdu queue nor do we wait for a reply.

This will later be used for when we are sending replies back to a client
when operating in a server context.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-11-29 05:12:03 -08:00
Ronnie Sahlberg 6f27daf6d4 Create a generic RPC NULL function
This allows us to use the NULL function for any arbitrary
program/version from rpc_connect_program() instead of the hardcoded support
for mount v3 and nfs v3

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-11-27 12:50:06 -08:00
Ronnie Sahlberg 468424c475 ZDR_ARRAY: remove the check for element-size * num-objects
In zdr_array we can not use the check that num_elements * element_size
will fit inside the remaining bytes in the ZDR buffer.
The reason for this is that IF it is an array of unions, then
element-size will have the size of the largest arm in that union.

If the array consists of union items that are smaller than the largest arm,
then it becomes likely that this will pack in less than num_elements *
element_size and this it is possible that the array WILL fir in the remaining
bytes.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-11-25 14:47:00 -08:00