From: <andros@netapp.com>
To: <trond.myklebust@primarydata.com>
Cc: <steved@redhat.com>, <linux-nfs@vger.kernel.org>,
Andy Adamson <andros@netapp.com>
Subject: [PATCH Version 3 2/2] NFS add multiaddr mount option
Date: Wed, 27 Apr 2016 11:36:47 -0400 [thread overview]
Message-ID: <1461771407-16423-3-git-send-email-andros@netapp.com> (raw)
In-Reply-To: <1461771407-16423-1-git-send-email-andros@netapp.com>
From: Andy Adamson <andros@netapp.com>
Signed-off-by: Andy Adamson <andros@netapp.com>
---
utils/mount/stropts.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index 75646f6..334638b 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -365,6 +365,59 @@ static int nfs_set_version(struct nfsmount_info *mi)
return 1;
}
+/**
+ * Append any multiaddrs to the mount options to be used for session trunking.
+ *
+ * Do not fail the mount due to multiaddr processing.
+ *
+ * @multinames: comma separated multi-host list. NOTE: does not include the
+ * first host name which is used as the mount host.
+ */
+static void
+nfs_append_multiaddr_option(char *multinames, struct mount_options *options,
+ int family)
+{
+ struct addrinfo hint = {
+ .ai_protocol = (int)IPPROTO_UDP,
+ .ai_family = family,
+ };
+ char *comma, *name;
+ struct addrinfo *temp;
+ int error;
+
+ if (!multinames)
+ return;
+
+ name = multinames;
+ comma = strchr(name, ',');
+ while (name != NULL) {
+ if (comma != NULL)
+ *comma = '\0';
+
+ error = getaddrinfo(name, NULL, &hint, &temp);
+ if (error != 0) {
+ nfs_error(_("%s: Failed to resolve server %s: %s"),
+ progname, name, gai_strerror(error));
+ continue;
+ }
+
+ if (!nfs_append_generic_address_option(temp->ai_addr,
+ temp->ai_addrlen,
+ "multiaddr", options)) {
+ nfs_error(_("%s: Failed to append multiaddr %s"),
+ progname, name);
+ continue;
+ }
+ if (comma == NULL)
+ name = NULL;
+ else {
+ name = comma +1;
+ comma = strchr(name, ',');
+ }
+ }
+ return;
+}
+
/*
* Set up mandatory non-version specific NFS mount options.
*
@@ -403,6 +456,13 @@ static int nfs_validate_options(struct nfsmount_info *mi)
mi->address->ai_addrlen, mi->options))
return 0;
+ if ((mi->version.major == 4 && mi->version.minor > 0))
+ nfs_append_multiaddr_option(mi->multinames, mi->options,
+ family);
+ else
+ if (mi->multinames)
+ nfs_error(_("%s: warning: multiple hostnames not"
+ " supported"),progname);
return 1;
}
--
1.8.3.1
next prev parent reply other threads:[~2016-04-27 15:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-27 15:36 [PATCH Version 3 0/2] Add multihostname support for NFSv4.1,2 andros
2016-04-27 15:36 ` [PATCH Version 3 1/2] NFS parse NFSv4 multiple hostnames andros
2016-04-27 15:36 ` andros [this message]
2016-04-29 14:12 ` [PATCH Version 3 0/2] Add multihostname support for NFSv4.1,2 Steve Dickson
2016-04-29 14:27 ` Adamson, Andy
2016-04-29 14:46 ` Steve Dickson
2016-04-29 15:09 ` Adamson, Andy
2016-04-29 15:24 ` Chuck Lever
2016-04-29 15:50 ` Steve Dickson
2016-04-29 15:53 ` Anna Schumaker
2016-04-29 18:05 ` J. Bruce Fields
2016-04-29 19:39 ` Anna Schumaker
2016-04-29 20:03 ` J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461771407-16423-3-git-send-email-andros@netapp.com \
--to=andros@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
--cc=trond.myklebust@primarydata.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).