All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfs-utils - the problem about the "nfs bindresvport: Address already in use" in NFSv3
@ 2007-02-09  2:53 fj-shic
  0 siblings, 0 replies; only message in thread
From: fj-shic @ 2007-02-09  2:53 UTC (permalink / raw)
  To: nfs; +Cc: cluster-devel

Hi, All



When I did some NFSv3 mount operations, I found the problem abut the  "nfs 
binodresvport: Address already in use" in NFSv3.

I mounted NFSv3 in TCP protocol, after lots of continuous mount operations, 
the error "nfs bindresvport: Address already in use" always happened, as the 
count of the mounted NFS reaches about 500, even I added the "insecure" 
option to the exports entry of the NFS server.



My system is RHEL5 and the mount operation for NFSv3 is implemented in 
nfs-utils-1.0.9-10.

 I have investigated the problem, and found the cause was the limitation of 
the bindresvport in nfsmount.



 In nfsmount, nfsmount() will create a socket for NFS, and just bind the 
socket to a reserve port. For the bindresvport() just can use the port 
number in the range 512-1023, after the lots of continuous mount operations, 
the reserved ports will all be in TIME_WAIT during the mount storm but can 
not be released in time, then next mount operation will usually fails by 
bindresvport().



In NFS server exports configuration, the 'insecure' option allows clients 
with NFS implementations that don't use a reserved port for NFS, so I think 
the port range can be expended so the entire port space can be tried, for a 
reserved port is not always needed when the 'insecure' option is allowed.


 For the problem in the nfsmount, I have made the patch below for the 
limitation of the bindresvport, and make the socket can be bound to a 
non-reserve port when the bindresvport fails.
 I have tested it as the "insecure" is set, after the patch is applied, the 
limitation with "nfs binodresvport:" can be avoided.



Any idea for it is welcome!

Thanks

Regards

ShiChao
 signed-off-by:ShiChao <shic@nanjing-fnst.com>
--- nfs-utils-1.0.9-orig/utils/mount/nfsmount.c 2007-01-31 
17:12:26.000000000 -0500
+++ nfs-utils-1.0.9/utils/mount/nfsmount.c 2007-02-01 
05:13:48.000000000 -0500
@@ -851,6 +851,7 @@
  time_t t;
  time_t prevt;
  time_t timeout;
+  struct sockaddr_in laddr;

  /* The version to try is either specified or 0
     In case it is 0 we tell the caller what we tried */
@@ -1139,10 +1140,18 @@
   perror(_("nfs socket"));
   goto fail;
  }
+
  if (bindresvport(fsock, 0) < 0) {
-  perror(_("nfs bindresvport"));
-  goto fail;
- }
+  perror(_("nfs bindresvport fail, try a non-reserver port"));
+  laddr.sin_family = AF_INET;
+  laddr.sin_port = 0;
+  laddr.sin_addr.s_addr = htonl(INADDR_ANY);
+  if ( bind(fsock, (struct sockaddr *)&laddr, sizeof(laddr)) < 0 ){
+   perror(_("nfs bind"));
+   goto fail;
+  }
+  }
+
 #ifdef NFS_MOUNT_DEBUG
  printf(_("using port %d for nfs deamon\n"), nfs_pmap->pm_port);
 #endif




-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-02-09  2:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-09  2:53 [PATCH] nfs-utils - the problem about the "nfs bindresvport: Address already in use" in NFSv3 fj-shic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.