This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 221d919b77e06ce6c09b293daf86b9a885291303
Author: Masayuki Ishikawa <[email protected]>
AuthorDate: Fri Jun 30 14:07:07 2023 +0900

    Revert "fs: nfs: Do not bind to a local port in TCP mode"
    
    This reverts commit e1b14271c85f4aa0a23dfa2036afae7d53e9817c.
---
 fs/nfs/rpc_clnt.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/fs/nfs/rpc_clnt.c b/fs/nfs/rpc_clnt.c
index 1fbba587c3..9be474b88b 100644
--- a/fs/nfs/rpc_clnt.c
+++ b/fs/nfs/rpc_clnt.c
@@ -240,31 +240,28 @@ static int rpcclnt_socket(FAR struct rpcclnt *rpc, 
in_port_t rport)
       goto bad;
     }
 
-  if (rpc->rc_sotype == SOCK_DGRAM)
-    {
-      /* Some servers require that the client port be a reserved port
-       * number. We always allocate a reserved port, as this prevents
-       * filehandle disclosure through UDP port capture.
-       */
-
-      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);
+  /* Some servers require that the client port be a reserved port
+   * number. We always allocate a reserved port, as this prevents
+   * filehandle disclosure through UDP port capture.
+   */
 
-      if (error)
+  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);
-          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
    * unconnected.  That would allow servers to reply from a port other than

Reply via email to