fs: nfs: Do not bind to a local port in TCP mode

Summary:
- Since binding to a local port is not necessary in TCP mode,
  it should be done only in UDP mode

Impact:
- None

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-12 13:58:20 +09:00
committed by Gustavo Henrique Nihei
parent 2873f33bc4
commit e1b14271c8
+3
View File
@@ -241,6 +241,8 @@ static int rpcclnt_socket(FAR struct rpcclnt *rpc, in_port_t rport)
goto bad; goto bad;
} }
if (rpc->rc_sotype == SOCK_DGRAM)
{
/* Some servers require that the client port be a reserved port /* Some servers require that the client port be a reserved port
* number. We always allocate a reserved port, as this prevents * number. We always allocate a reserved port, as this prevents
* filehandle disclosure through UDP port capture. * filehandle disclosure through UDP port capture.
@@ -263,6 +265,7 @@ static int rpcclnt_socket(FAR struct rpcclnt *rpc, in_port_t rport)
ferr("ERROR: psock_bind failed: %d\n", error); ferr("ERROR: psock_bind failed: %d\n", error);
goto bad; goto bad;
} }
}
/* Protocols that do not require connections could be optionally left /* Protocols that do not require connections could be optionally left
* unconnected. That would allow servers to reply from a port other than * unconnected. That would allow servers to reply from a port other than