aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/super.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 038b20b38b22..ef1aad774e6c 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -600,6 +600,25 @@ static void nfs_umount_begin(struct vfsmount *vfsmnt, int flags)
600} 600}
601 601
602/* 602/*
603 * Set the port number in an address. Be agnostic about the address family.
604 */
605static void nfs_set_port(struct sockaddr *sap, unsigned short port)
606{
607 switch (sap->sa_family) {
608 case AF_INET: {
609 struct sockaddr_in *ap = (struct sockaddr_in *)sap;
610 ap->sin_port = htons(port);
611 break;
612 }
613 case AF_INET6: {
614 struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
615 ap->sin6_port = htons(port);
616 break;
617 }
618 }
619}
620
621/*
603 * Sanity-check a server address provided by the mount command. 622 * Sanity-check a server address provided by the mount command.
604 * 623 *
605 * Address family must be initialized, and address must not be 624 * Address family must be initialized, and address must not be
@@ -629,6 +648,7 @@ static int nfs_parse_mount_options(char *raw,
629 struct nfs_parsed_mount_data *mnt) 648 struct nfs_parsed_mount_data *mnt)
630{ 649{
631 char *p, *string; 650 char *p, *string;
651 unsigned short port = 0;
632 652
633 if (!raw) { 653 if (!raw) {
634 dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); 654 dfprintk(MOUNT, "NFS: mount options string was NULL.\n");
@@ -731,7 +751,7 @@ static int nfs_parse_mount_options(char *raw,
731 return 0; 751 return 0;
732 if (option < 0 || option > 65535) 752 if (option < 0 || option > 65535)
733 return 0; 753 return 0;
734 mnt->nfs_server.address.sin_port = htons(option); 754 port = option;
735 break; 755 break;
736 case Opt_rsize: 756 case Opt_rsize:
737 if (match_int(args, &mnt->rsize)) 757 if (match_int(args, &mnt->rsize))
@@ -973,6 +993,8 @@ static int nfs_parse_mount_options(char *raw,
973 } 993 }
974 } 994 }
975 995
996 nfs_set_port((struct sockaddr *)&mnt->nfs_server.address, port);
997
976 return 1; 998 return 1;
977 999
978out_nomem: 1000out_nomem:
@@ -1023,7 +1045,7 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args,
1023 /* 1045 /*
1024 * autobind will be used if mount_server.port == 0 1046 * autobind will be used if mount_server.port == 0
1025 */ 1047 */
1026 sin.sin_port = htons(args->mount_server.port); 1048 nfs_set_port((struct sockaddr *)&sin, args->mount_server.port);
1027 1049
1028 /* 1050 /*
1029 * Now ask the mount server to map our export path 1051 * Now ask the mount server to map our export path