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 c2af551355ce859a20516d8c7dbeab8be4cb6a9d Author: Masayuki Ishikawa <[email protected]> AuthorDate: Fri Jun 30 14:57:33 2023 +0900 fs: nfs: Introduce CONFIG_NFS_DONT_BIND_TCP_SOCKET Summary: - Some network drivers such as GS2200M do not support to bind a local port for TCP client socket. In this case, this config disables to bind the port. - See also https://github.com/apache/nuttx/pull/3707 Impact: - None Testing: - Tested with spresense:wifi_smp (Kconfig will be updated later) - Tested with sabre-6quad:netnsh_smp (QEMU) Signed-off-by: Masayuki Ishikawa <[email protected]> --- fs/nfs/Kconfig | 9 +++++++++ fs/nfs/rpc_clnt.c | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig index 5d030caa7c..56f4ab409a 100644 --- a/fs/nfs/Kconfig +++ b/fs/nfs/Kconfig @@ -13,6 +13,15 @@ config NFS #if NFS +config NFS_DONT_BIND_TCP_SOCKET + bool + default n + depends on NFS + ---help--- + Some network drivers such as GS2200M do not support to bind + a local port for TCP client socket. In this case, this config + disables to bind the port. + config NFS_STATISTICS bool "NFS Statistics" default n diff --git a/fs/nfs/rpc_clnt.c b/fs/nfs/rpc_clnt.c index 9be474b88b..66a6db773a 100644 --- a/fs/nfs/rpc_clnt.c +++ b/fs/nfs/rpc_clnt.c @@ -240,6 +240,13 @@ static int rpcclnt_socket(FAR struct rpcclnt *rpc, in_port_t rport) goto bad; } +#ifdef CONFIG_NFS_DONT_BIND_TCP_SOCKET + if (rpc->rc_sotype == SOCK_STREAM) + { + goto connect; + } +#endif + /* 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. @@ -263,6 +270,10 @@ static int rpcclnt_socket(FAR struct rpcclnt *rpc, in_port_t rport) goto bad; } +#ifdef CONFIG_NFS_DONT_BIND_TCP_SOCKET +connect: +#endif + /* Protocols that do not require connections could be optionally left * unconnected. That would allow servers to reply from a port other than * the NFS_PORT.
