From patchwork Fri Jun 30 13:23:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9819629 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F41B8603F2 for ; Fri, 30 Jun 2017 13:24:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3994285EB for ; Fri, 30 Jun 2017 13:24:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D842328660; Fri, 30 Jun 2017 13:24:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A763285EB for ; Fri, 30 Jun 2017 13:24:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751560AbdF3NYe (ORCPT ); Fri, 30 Jun 2017 09:24:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50936 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751887AbdF3NYd (ORCPT ); Fri, 30 Jun 2017 09:24:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 34F64C0587D0; Fri, 30 Jun 2017 13:24:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 34F64C0587D0 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 34F64C0587D0 Received: from localhost (ovpn-116-222.ams2.redhat.com [10.36.116.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB9726CDCB; Fri, 30 Jun 2017 13:24:32 +0000 (UTC) From: Stefan Hajnoczi To: linux-nfs@vger.kernel.org Cc: Abbas Naderi , Anna Schumaker , Trond Myklebust , "J. Bruce Fields" , Jeff Layton , Chuck Lever , Stefan Hajnoczi Subject: [PATCH v3 10/14] NFS: add AF_VSOCK support to NFS client Date: Fri, 30 Jun 2017 14:23:48 +0100 Message-Id: <20170630132352.32133-11-stefanha@redhat.com> In-Reply-To: <20170630132352.32133-1-stefanha@redhat.com> References: <20170630132352.32133-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 30 Jun 2017 13:24:33 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds AF_VSOCK to the NFS client. Mounts can now use the "vsock" proto option and pass "vsock:" address strings, which are interpreted by sunrpc for xprt creation. Signed-off-by: Stefan Hajnoczi --- fs/nfs/client.c | 2 ++ fs/nfs/super.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index ee5ddbd..80688a7 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -447,6 +448,7 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto, switch (proto) { case XPRT_TRANSPORT_TCP: case XPRT_TRANSPORT_RDMA: + case XPRT_TRANSPORT_VSOCK: if (retrans == NFS_UNSPEC_RETRANS) to->to_retries = NFS_DEF_TCP_RETRANS; if (timeo == NFS_UNSPEC_TIMEO || to->to_retries == 0) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index eceb4ea..675404f 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -191,7 +191,7 @@ static const match_table_t nfs_mount_option_tokens = { enum { Opt_xprt_udp, Opt_xprt_udp6, Opt_xprt_tcp, Opt_xprt_tcp6, Opt_xprt_rdma, - Opt_xprt_rdma6, + Opt_xprt_rdma6, Opt_xprt_vsock, Opt_xprt_err }; @@ -203,6 +203,7 @@ static const match_table_t nfs_xprt_protocol_tokens = { { Opt_xprt_tcp6, "tcp6" }, { Opt_xprt_rdma, "rdma" }, { Opt_xprt_rdma6, "rdma6" }, + { Opt_xprt_vsock, "vsock" }, { Opt_xprt_err, NULL } }; @@ -964,6 +965,8 @@ static int nfs_verify_server_address(struct sockaddr *addr) struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr; return !ipv6_addr_any(sa); } + case AF_VSOCK: + return 1; } dfprintk(MOUNT, "NFS: Invalid IP address specified\n"); @@ -993,6 +996,7 @@ static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt) case XPRT_TRANSPORT_UDP: case XPRT_TRANSPORT_TCP: case XPRT_TRANSPORT_RDMA: + case XPRT_TRANSPORT_VSOCK: break; default: mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; @@ -1474,6 +1478,11 @@ static int nfs_parse_mount_options(char *raw, mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; xprt_load_transport(string); break; + case Opt_xprt_vsock: + protofamily = AF_VSOCK; + mnt->flags &= ~NFS_MOUNT_TCP; + mnt->nfs_server.protocol = XPRT_TRANSPORT_VSOCK; + break; default: dfprintk(MOUNT, "NFS: unrecognized " "transport protocol\n");