fs: nfs: Fix rpcclnt_send() in TCP mode

Summary:
- I noticed that NFS over TCP does not work with Ubuntu 18.04
- Finally, I found that the record marking packet should not
  be sent separately
- This commit fixes this issue

Impact:
- TCP mode only

Testing:
- Tested with NFS server on Ubuntu 18.04 (x86_64)
- Tested with spresense:rndis (defconfig will be updated later)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa 2021-05-11 10:25:26 +09:00 committed by Gustavo Henrique Nihei
parent 82fb188d02
commit f0372dde6a

View File

@ -297,22 +297,37 @@ bad:
static int rpcclnt_send(FAR struct rpcclnt *rpc, static int rpcclnt_send(FAR struct rpcclnt *rpc,
FAR void *call, int reqlen) FAR void *call, int reqlen)
{ {
struct iovec iov[2];
struct msghdr msg;
uint32_t mark; uint32_t mark;
int ret = OK; int ret = OK;
/* Send the record marking(RM) for stream only */
if (rpc->rc_sotype == SOCK_STREAM) if (rpc->rc_sotype == SOCK_STREAM)
{ {
mark = txdr_unsigned(0x80000000 | reqlen); /* Prepare the record marking(RM) and compose an RPC request
ret = psock_send(&rpc->rc_so, &mark, sizeof(mark), 0); * NOTE: Sending a separate packet does not work with Linux host
if (ret < 0) */
{
ferr("ERROR: psock_send mark failed: %d\n", ret);
return ret;
}
}
mark = txdr_unsigned(0x80000000 | (reqlen));
iov[0].iov_base = (FAR void *)&mark;
iov[0].iov_len = sizeof(mark);
iov[1].iov_base = (FAR void *)call;
iov[1].iov_len = reqlen;
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = iov;
msg.msg_iovlen = 2;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = 0;
ret = psock_sendmsg(&rpc->rc_so, &msg, 0);
ferr("ERROR: psock_sendmsg request failed: %d\n", ret);
}
else
{
/* Send the call message /* Send the call message
* *
* On success, psock_send returns the number of bytes sent; * On success, psock_send returns the number of bytes sent;
@ -320,9 +335,11 @@ static int rpcclnt_send(FAR struct rpcclnt *rpc,
*/ */
ret = psock_send(&rpc->rc_so, call, reqlen, 0); ret = psock_send(&rpc->rc_so, call, reqlen, 0);
ferr("ERROR: psock_send request failed: %d\n", ret);
}
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: psock_send request failed: %d\n", ret);
return ret; return ret;
} }