Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 79632
b: refs/heads/master
c: 04dcd6e
h: refs/heads/master
v: v3
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Jan 30, 2008
1 parent 870f702 commit d441d60
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cdcd7f9abc8c95524376835fbe8e11c5f7bf588e
refs/heads/master: 04dcd6e3aceedff9fcc96ce3014688d5b642d627
26 changes: 24 additions & 2 deletions trunk/fs/nfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,25 @@ static void nfs_umount_begin(struct vfsmount *vfsmnt, int flags)
rpc_killall_tasks(rpc);
}

/*
* Set the port number in an address. Be agnostic about the address family.
*/
static void nfs_set_port(struct sockaddr *sap, unsigned short port)
{
switch (sap->sa_family) {
case AF_INET: {
struct sockaddr_in *ap = (struct sockaddr_in *)sap;
ap->sin_port = htons(port);
break;
}
case AF_INET6: {
struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
ap->sin6_port = htons(port);
break;
}
}
}

/*
* Sanity-check a server address provided by the mount command.
*
Expand Down Expand Up @@ -629,6 +648,7 @@ static int nfs_parse_mount_options(char *raw,
struct nfs_parsed_mount_data *mnt)
{
char *p, *string;
unsigned short port = 0;

if (!raw) {
dfprintk(MOUNT, "NFS: mount options string was NULL.\n");
Expand Down Expand Up @@ -731,7 +751,7 @@ static int nfs_parse_mount_options(char *raw,
return 0;
if (option < 0 || option > 65535)
return 0;
mnt->nfs_server.address.sin_port = htons(option);
port = option;
break;
case Opt_rsize:
if (match_int(args, &mnt->rsize))
Expand Down Expand Up @@ -973,6 +993,8 @@ static int nfs_parse_mount_options(char *raw,
}
}

nfs_set_port((struct sockaddr *)&mnt->nfs_server.address, port);

return 1;

out_nomem:
Expand Down Expand Up @@ -1023,7 +1045,7 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args,
/*
* autobind will be used if mount_server.port == 0
*/
sin.sin_port = htons(args->mount_server.port);
nfs_set_port((struct sockaddr *)&sin, args->mount_server.port);

/*
* Now ask the mount server to map our export path
Expand Down

0 comments on commit d441d60

Please sign in to comment.