mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
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:
committed by
Gustavo Henrique Nihei
parent
2873f33bc4
commit
e1b14271c8
+20
-17
@@ -241,28 +241,31 @@ static int rpcclnt_socket(FAR struct rpcclnt *rpc, in_port_t rport)
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some servers require that the client port be a reserved port
|
if (rpc->rc_sotype == SOCK_DGRAM)
|
||||||
* number. We always allocate a reserved port, as this prevents
|
|
||||||
* filehandle disclosure through UDP port capture.
|
|
||||||
*/
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
*lport = htons(--port);
|
/* Some servers require that the client port be a reserved port
|
||||||
error = psock_bind(&rpc->rc_so, (FAR struct sockaddr *)&laddr,
|
* number. We always allocate a reserved port, as this prevents
|
||||||
addrlen);
|
* filehandle disclosure through UDP port capture.
|
||||||
if (error < 0)
|
*/
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
*lport = htons(--port);
|
||||||
|
error = psock_bind(&rpc->rc_so, (FAR struct sockaddr *)&laddr,
|
||||||
|
addrlen);
|
||||||
|
if (error < 0)
|
||||||
|
{
|
||||||
|
ferr("ERROR: psock_bind failed: %d\n", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (error == -EADDRINUSE && port >= 512);
|
||||||
|
|
||||||
|
if (error)
|
||||||
{
|
{
|
||||||
ferr("ERROR: psock_bind failed: %d\n", error);
|
ferr("ERROR: psock_bind failed: %d\n", error);
|
||||||
|
goto bad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (error == -EADDRINUSE && port >= 512);
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
ferr("ERROR: psock_bind failed: %d\n", error);
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user