diff options
author | Benjamin Coddington <bcodding@redhat.com> | 2016-04-27 12:53:04 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2016-04-27 13:24:40 -0400 |
commit | 623f537916a67f96decda3ce9ed8d70edf92c0cd (patch) | |
tree | fee02e82233e16b6ad6ab0e26e29b30353fedc89 /utils | |
parent | bf12e1fa9f48e8ee91a2869e69484c70595b5160 (diff) | |
download | nfs-utils-623f537916a67f96decda3ce9ed8d70edf92c0cd.tar.gz nfs-utils-623f537916a67f96decda3ce9ed8d70edf92c0cd.tar.xz nfs-utils-623f537916a67f96decda3ce9ed8d70edf92c0cd.zip |
mount.nfs: skip server address resolution on remount
A remount might fail if name resolution returns a different
server address, as might occur if there are multiple name
records for the server. Since we cannot change the server's
address on a remount anyway, skip the lookup and remove
any set addresses in the options.
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/mount/stropts.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c index 320dde2..d60b484 100644 --- a/utils/mount/stropts.c +++ b/utils/mount/stropts.c @@ -383,13 +383,26 @@ static int nfs_validate_options(struct nfsmount_info *mi) if (!nfs_nfs_proto_family(mi->options, &family)) return 0; - hint.ai_family = (int)family; - error = getaddrinfo(mi->hostname, NULL, &hint, &mi->address); - if (error != 0) { - nfs_error(_("%s: Failed to resolve server %s: %s"), - progname, mi->hostname, gai_strerror(error)); - mi->address = NULL; - return 0; + /* + * A remount is not going to be able to change the server's address, + * nor should we try to resolve another address for the server as we + * may end up with a different address. + */ + if (mi->flags & MS_REMOUNT) { + po_remove_all(mi->options, "addr"); + } else { + hint.ai_family = (int)family; + error = getaddrinfo(mi->hostname, NULL, &hint, &mi->address); + if (error != 0) { + nfs_error(_("%s: Failed to resolve server %s: %s"), + progname, mi->hostname, gai_strerror(error)); + mi->address = NULL; + return 0; + } + + if (!nfs_append_addr_option(mi->address->ai_addr, + mi->address->ai_addrlen, mi->options)) + return 0; } if (!nfs_set_version(mi)) @@ -398,10 +411,6 @@ static int nfs_validate_options(struct nfsmount_info *mi) if (!nfs_append_sloppy_option(mi->options)) return 0; - if (!nfs_append_addr_option(mi->address->ai_addr, - mi->address->ai_addrlen, mi->options)) - return 0; - return 1; } |