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.