From patchwork Wed Feb 24 17:55:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 8410681 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C6949C0553 for ; Wed, 24 Feb 2016 17:56:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECA0320222 for ; Wed, 24 Feb 2016 17:56:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E756520265 for ; Wed, 24 Feb 2016 17:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755385AbcBXR4Y (ORCPT ); Wed, 24 Feb 2016 12:56:24 -0500 Received: from mx143.netapp.com ([216.240.21.24]:46899 "EHLO mx143.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757026AbcBXR4X (ORCPT ); Wed, 24 Feb 2016 12:56:23 -0500 X-IronPort-AV: E=Sophos;i="5.22,494,1449561600"; d="scan'208";a="98912579" Received: from vmwexchts04-prd.hq.netapp.com ([10.122.105.32]) by mx143-out.netapp.com with ESMTP; 24 Feb 2016 09:56:23 -0800 Received: from smtp2.corp.netapp.com (10.57.159.114) by VMWEXCHTS04-PRD.hq.netapp.com (10.122.105.32) with Microsoft SMTP Server id 15.0.1156.6; Wed, 24 Feb 2016 09:56:23 -0800 Received: from localhost.localdomain (andros-new.vpn.netapp.com [10.55.66.190]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id u1OHuKGd010356; Wed, 24 Feb 2016 09:56:22 -0800 (PST) From: To: CC: , Andy Adamson Subject: [PATCH 2/2] NFS add multiaddr mount option Date: Wed, 24 Feb 2016 12:55:59 -0500 Message-ID: <1456336559-17334-3-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1456336559-17334-1-git-send-email-andros@netapp.com> References: <1456336559-17334-1-git-send-email-andros@netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andy Adamson Signed-off-by: Andy Adamson --- utils/mount/stropts.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c index 75646f6..041bbcd 100644 --- a/utils/mount/stropts.c +++ b/utils/mount/stropts.c @@ -365,6 +365,60 @@ static int nfs_set_version(struct nfsmount_info *mi) return 1; } +/** + * Returns 1 if multiaddr= opttion appended successfully + * otherwise zero + */ +static int +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, failed = 1; + + if (!multinames) + return 0; + + 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; + } + failed = 0; + if (comma == NULL) + name = NULL; + else { + name = comma +1; + comma = strchr(name, ','); + } + } + + if (failed == 1) + return 0; + else + return 1; +} + /* * Set up mandatory non-version specific NFS mount options. * @@ -403,6 +457,11 @@ 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)) + if (!nfs_append_multiaddr_option(mi->multinames, mi->options, + family)) + return 0; + return 1; }