[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#2482: Enhancement for nfsmount.c - deal with multihomed hosts...



Package: mount
Version: 2.5g

Mount has a problem with multihomed hosts: if I happen to use the "wrong"
interface, mount will hang forever, sending packets to this interface and
expecting them back from the same interface and ignoring all the valid
replies from the "right" i.e. nearest interface. This is generally a
problem with the kernel. The kernel was fixed in 1.3.11, but in order to
take advantage of this fix, mount has to be changed, too. The call
to connect() in nfsmount.c is no longer needed, so it should be ommited.
The following patch takes care of this.

Greetings, Swen


diff -ru mount-2.5g.orig/nfsmount.c mount-2.5g/nfsmount.c
--- mount-2.5g.orig/nfsmount.c	Sun Feb 25 19:14:57 1996
+++ mount-2.5g/nfsmount.c	Fri Mar  8 17:50:49 1996
@@ -26,6 +26,7 @@
 #include <rpc/pmap_clnt.h>
 #include <sys/socket.h>
 #include <sys/time.h>
+#include <sys/utsname.h>
 #include <string.h>
 #include <netdb.h>
 #include <arpa/inet.h>
@@ -52,6 +53,21 @@

 static char *nfs_strerror(int stat);

+static int
+linux_version_code(void)
+{
+  struct utsname my_utsname;
+  int release = 0;
+
+  if (0 == uname(&my_utsname))
+    {
+      release = 65536 * atoi(strtok(my_utsname.release, "."))
+               +  256 * atoi(strtok(NULL, "."))
+               +        atoi(strtok(NULL, ".")) ;
+    }
+  return release;
+}
+
 int nfsmount(const char *spec, const char *node, int *flags,
 	     char **extra_opts, char **mount_opts)
 {
@@ -387,7 +403,12 @@
 	printf("using port %d for nfs deamon\n", port);
 #endif
 	server_addr.sin_port = htons(port);
-	if (connect(fsock, (struct sockaddr *) &server_addr,
+        /*
+         * connect() the socket for kernels 1.3.10 and below only,
+         * to avoid problems with multihomed hosts.
+         * --Swen
+         */
+	if (linux_version_code() <= 66314 && connect(fsock, (struct sockaddr *) &server_addr,
 	    sizeof (server_addr)) < 0) {
 		perror("nfs connect");
 		goto fail;


Reply to: