[PATCH Version 3 2/2] NFS add multiaddr mount option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andy Adamson <andros@xxxxxxxxxx>

Signed-off-by: Andy Adamson <andros@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux