Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4427033rwd; Tue, 23 May 2023 07:36:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4SSa8DgkhQLtSSMVj+zwTjs9kZASnrEAYCLaZx4aKDBZHLXMQxZDkmAxS05rQkBG9x+ulg X-Received: by 2002:a17:90a:9301:b0:255:4635:830c with SMTP id p1-20020a17090a930100b002554635830cmr8393041pjo.40.1684852592892; Tue, 23 May 2023 07:36:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684852592; cv=none; d=google.com; s=arc-20160816; b=e7vulicR/xixr8XxkySySnSIGDRNx3kriltjfepsXvneQLptF1I5MTBs4Rcfan/7HO R2m7CRxXi/eJihSNRCHmu1MYqWesQpCOg1fZ3cEJ20OoKJiUVThQyoojEMV8xMWVcokV iXtrYK5CF0LkvcKihHRe54wDIy7Qx2vdH7egAeWrQW22BvjkZBWwH+3jQEOdjNMxa7m9 ViOJ09xRDSs1b9d9xVQxwWZh8jXRCdrznZ4L8VEvFRUzWOyvixlsqolDXPVtfch17l/y L7Fj/0MSc5yfPvOWUTuIUwXrXamgqF2x0fcQUDoZQeBWdlnGTAbfBzRY/GLce7xbHd72 7IdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=GhOfI0Mc/DmLxcniO4CcXxaAvVqwcDUUeIv9P+KNUMI=; b=akqcgNB8WiWSbNRm2157I91rSXk6GTcrz89KcYyGByM8POyCvCI5Rs5r0VE1/pkSEU zlDHG9YK30DZHzHD34jw/Fdv7lb8WZNzZCNPR84F6jzX4xYAO2LBeKsf1qfkGSb/7ie8 JG+jUJT/G1Bu0DhCM8PmoVkWhso0jFURsthFGtkI6P1ioqHtPRtn+XgdFOOR/TTnnFmN JCQLKVFRtoHulEB/Y9AooygsQKCttrGNmObZgUcuqMJshxWTlGzVvC344I2w6TqVl0d9 WZcvmb0bNcIAm2DRaVNUi6MbvzCibZDpRJY0/GIHJwDx1d6LQcvwngTrl1iKs0AZLnqH X0tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r9kvZQWF; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a17090a974400b002472a818166si4312604pjw.96.2023.05.23.07.36.20; Tue, 23 May 2023 07:36:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r9kvZQWF; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237294AbjEWOav (ORCPT + 99 others); Tue, 23 May 2023 10:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235707AbjEWOau (ORCPT ); Tue, 23 May 2023 10:30:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BAD6133 for ; Tue, 23 May 2023 07:30:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DCE7A63324 for ; Tue, 23 May 2023 14:30:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2D93C433D2; Tue, 23 May 2023 14:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684852242; bh=QLJijva0Skh8Lw8HTuYurfuKSrgOa808Jcdr6DWqDVE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=r9kvZQWFieLf4kxMlAvZghwfukqOWeUy4agYG/HUnF/DNbj0IYg4SZKx2xnMIP4Xt 5fgWD9oBrECub4R2b55oXOSIHr7X4L9aHVO97Wt84duqsfIhMlNw01v/Amy1ymhqu4 Co6acsldvW83lolPBFoxBsRPeqkyuUUB8r4VV1jjY4ObZi4jWGY7WNKxrDGPP/1hQ9 1LS5KR0Mt/JsgDZpQR5IG2L4IOA1G7GT5lmYDtuyOt9L3KlZCW274W1IGv+9AaYTy3 VDmhUqXi7tQ3th4cDZxxaTS0o4fIVDkiY1lnL9gwBa4q3PzvHnJKZn+4djyPfn8Pq8 ANOanXBWQHxJw== Subject: [PATCH v2 02/11] SUNRPC: Plumb an API for setting transport layer security From: Chuck Lever To: anna.schumaker@netapp.com, trondmy@hammerspace.com Cc: Chuck Lever , Jeff Layton , jlayton@redhat.com, linux-nfs@vger.kernel.org, kernel-tls-handshake@lists.linux.dev Date: Tue, 23 May 2023 10:30:30 -0400 Message-ID: <168485222061.6613.10736477127034272000.stgit@oracle-102.nfsv4bat.org> In-Reply-To: <168485183242.6613.7025123558596119858.stgit@oracle-102.nfsv4bat.org> References: <168485183242.6613.7025123558596119858.stgit@oracle-102.nfsv4bat.org> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Chuck Lever Add an initial set of policies along with fields for upper layers to pass the requested policy down to the transport layer. Signed-off-by: Chuck Lever Reviewed-by: Jeff Layton --- include/linux/sunrpc/clnt.h | 2 ++ include/linux/sunrpc/xprt.h | 17 +++++++++++++++++ net/sunrpc/clnt.c | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 770ef2cb5775..063692cd2a60 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -58,6 +58,7 @@ struct rpc_clnt { cl_noretranstimeo: 1,/* No retransmit timeouts */ cl_autobind : 1,/* use getport() */ cl_chatty : 1;/* be verbose */ + struct xprtsec_parms cl_xprtsec; /* transport security policy */ struct rpc_rtt * cl_rtt; /* RTO estimator data */ const struct rpc_timeout *cl_timeout; /* Timeout strategy */ @@ -139,6 +140,7 @@ struct rpc_create_args { struct svc_xprt *bc_xprt; /* NFSv4.1 backchannel */ const struct cred *cred; unsigned int max_connect; + struct xprtsec_parms xprtsec; }; struct rpc_add_xprt_test { diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index b9f59aabee53..9e7f12c240c5 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -129,6 +129,21 @@ struct rpc_rqst { #define rq_svec rq_snd_buf.head #define rq_slen rq_snd_buf.len +/* RPC transport layer security policies */ +enum xprtsec_policies { + RPC_XPRTSEC_NONE = 0, + RPC_XPRTSEC_TLS_ANON, + RPC_XPRTSEC_TLS_X509, +}; + +struct xprtsec_parms { + enum xprtsec_policies policy; + + /* authentication material */ + key_serial_t cert_serial; + key_serial_t privkey_serial; +}; + struct rpc_xprt_ops { void (*set_buffer_size)(struct rpc_xprt *xprt, size_t sndsize, size_t rcvsize); int (*reserve_xprt)(struct rpc_xprt *xprt, struct rpc_task *task); @@ -229,6 +244,7 @@ struct rpc_xprt { */ unsigned long bind_timeout, reestablish_timeout; + struct xprtsec_parms xprtsec; unsigned int connect_cookie; /* A cookie that gets bumped every time the transport is reconnected */ @@ -333,6 +349,7 @@ struct xprt_create { struct svc_xprt *bc_xprt; /* NFSv4.1 backchannel */ struct rpc_xprt_switch *bc_xps; unsigned int flags; + struct xprtsec_parms xprtsec; }; struct xprt_class { diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index d2ee56634308..a18074f8edf2 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -385,6 +385,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, if (!clnt) goto out_err; clnt->cl_parent = parent ? : clnt; + clnt->cl_xprtsec = args->xprtsec; err = rpc_alloc_clid(clnt); if (err) @@ -532,6 +533,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) .addrlen = args->addrsize, .servername = args->servername, .bc_xprt = args->bc_xprt, + .xprtsec = args->xprtsec, }; char servername[48]; struct rpc_clnt *clnt; @@ -727,6 +729,7 @@ int rpc_switch_client_transport(struct rpc_clnt *clnt, struct rpc_clnt *parent; int err; + args->xprtsec = clnt->cl_xprtsec; xprt = xprt_create_transport(args); if (IS_ERR(xprt)) return PTR_ERR(xprt); @@ -3046,6 +3049,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, if (!xprtargs->ident) xprtargs->ident = ident; + xprtargs->xprtsec = clnt->cl_xprtsec; xprt = xprt_create_transport(xprtargs); if (IS_ERR(xprt)) { ret = PTR_ERR(xprt);