From patchwork Wed Apr 27 15:36:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 8959321 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 32D699F372 for ; Wed, 27 Apr 2016 15:37:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C23420125 for ; Wed, 27 Apr 2016 15:37:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8EC9F20259 for ; Wed, 27 Apr 2016 15:37:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753154AbcD0PhM (ORCPT ); Wed, 27 Apr 2016 11:37:12 -0400 Received: from mx144.netapp.com ([216.240.21.25]:38288 "EHLO mx144.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752897AbcD0PhL (ORCPT ); Wed, 27 Apr 2016 11:37:11 -0400 X-IronPort-AV: E=Sophos;i="5.24,542,1455004800"; d="scan'208";a="113019784" Received: from vmwexchts01-prd.hq.netapp.com ([10.122.105.12]) by mx144-out.netapp.com with ESMTP; 27 Apr 2016 08:37:12 -0700 Received: from smtp1.corp.netapp.com (10.57.156.124) by VMWEXCHTS01-PRD.hq.netapp.com (10.122.105.12) with Microsoft SMTP Server id 15.0.1156.6; Wed, 27 Apr 2016 08:37:07 -0700 Received: from localhost.localdomain (andros-new.vpn.netapp.com [10.55.74.31]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id u3RFb811015071; Wed, 27 Apr 2016 08:37:10 -0700 (PDT) From: To: CC: , , Andy Adamson Subject: [PATCH Version 3 2/2] NFS add multiaddr mount option Date: Wed, 27 Apr 2016 11:36:47 -0400 Message-ID: <1461771407-16423-3-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1461771407-16423-1-git-send-email-andros@netapp.com> References: <1461771407-16423-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=-7.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 | 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; }