]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
nfs-utils patch for mount-reserved-port
authorTalpey, Thomas <Thomas.Talpey@netapp.com>
Mon, 12 Mar 2007 15:55:17 +0000 (11:55 -0400)
committerNeil Brown <neilb@suse.de>
Tue, 13 Mar 2007 03:54:25 +0000 (14:54 +1100)
Only create a mount-time reserved port socket for kernels
which require it (pre-2.1.32/nfs_mount_version 1).

Signed-off-by: Tom Talpey <tmt@netapp.com>
Signed-off-by: Neil Brown <neilb@suse.de>
utils/mount/nfsmount.c

index 2ad7b35fb149f027a2f2236c4e72b3517b20a869..f21c81c4a583c077facab4c4b105b0ed84f00c65 100644 (file)
@@ -835,14 +835,14 @@ nfsmount(const char *spec, const char *node, int *flags,
                     *nfs_pmap = &nfs_server.pmap;
        struct pmap  save_mnt, save_nfs;
 
-       int fsock;
+       int fsock = -1;
 
        mntres_t mntres;
 
        struct stat statbuf;
        char *s;
        int bg, retry;
-       int retval;
+       int retval = EX_FAIL;
        time_t t;
        time_t prevt;
        time_t timeout;
@@ -853,8 +853,6 @@ nfsmount(const char *spec, const char *node, int *flags,
                *nfs_mount_vers = find_kernel_nfs_mount_version();
        nfs_mount_version = *nfs_mount_vers;
 
-       retval = EX_FAIL;
-       fsock = -1;
        if (strlen(spec) >= sizeof(hostdir)) {
                fprintf(stderr, _("mount: "
                                  "excessively long host:dir argument\n"));
@@ -1122,20 +1120,22 @@ noauth_flavors:
 #endif
        }
 
-       /* create nfs socket for kernel */
-
-       if (nfs_pmap->pm_prot == IPPROTO_TCP)
-               fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-       else
-               fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-       if (fsock < 0) {
-               perror(_("nfs socket"));
-               goto fail;
-       }
-       if (bindresvport(fsock, 0) < 0) {
-               perror(_("nfs bindresvport"));
-               goto fail;
+       if (nfs_mount_version == 1) {
+               /* create nfs socket for kernel */
+               if (nfs_pmap->pm_prot == IPPROTO_TCP)
+                       fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+               else
+                       fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+               if (fsock < 0) {
+                       perror(_("nfs socket"));
+                       goto fail;
+               }
+               if (bindresvport(fsock, 0) < 0) {
+                       perror(_("nfs bindresvport"));
+                       goto fail;
+               }
        }
+
 #ifdef NFS_MOUNT_DEBUG
        printf(_("using port %d for nfs deamon\n"), nfs_pmap->pm_port);
 #endif
@@ -1145,7 +1145,7 @@ noauth_flavors:
         * to avoid problems with multihomed hosts.
         * --Swen
         */
-       if (linux_version_code() <= 66314
+       if (linux_version_code() <= 0x01030a && fsock != -1
            && connect(fsock, (struct sockaddr *) nfs_saddr,
                       sizeof (*nfs_saddr)) < 0) {
                perror(_("nfs connect"));