Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1392259rdb; Mon, 2 Oct 2023 08:13:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGA1pdn41PiWZDjjLEjf/zs0HQ3tGda/stozu8T+c3b7hm7+wqeFhoTKVNVtPPpVHddoKwt X-Received: by 2002:a17:902:d3d5:b0:1c5:de4c:f079 with SMTP id w21-20020a170902d3d500b001c5de4cf079mr8742078plb.33.1696259600634; Mon, 02 Oct 2023 08:13:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696259600; cv=none; d=google.com; s=arc-20160816; b=pcqiSo07WXn/2b468iniGZXByiuU4lqcTT1dq4OkTKsqFH42h2B5lCyixb33oghzqL cqe4Z1pZqUyQUkCs4b17Pz9i7nWdpeN6Hw4SJvbEQf3E85mhaL8CmJGPFwV2rjpx50aF U0C29dqwnXhQOCi5YteXI4P/TnaXOba0fdE2yoHpUeP2C3uumqiKlBD775SgMQOclDPh Yk1h/sD47YOLKLWcCfucNs7RYcTPkBBaRwKWkeTsLB1rcttsI5fqLE6+7NRqS5ZmTAvS Pc6/hQsmlapAlzvhlM7xSv8xYOYqMSquPJyLNRtqrRt0ezDP3LQbGp/BH5gD6vEL1brw 8TqQ== 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=HOEtzF5tm+dANeSl5C2v9J7r17xeesmkQ1xSHkTGH2A=; fh=v8a13lpFSZWlL4AptTEJnmXnlqoWXhGCGCgvrcnCT9I=; b=A7OfvQCQ7sArGTQffHC1iVnrg9JA/dtoJYRubJUwy+94Lqb1VgDYA5wXRkSxfKugVN Fewzz0jdontUEeeuD1tvLHJCCzsForWfRvyyg/5VigpGTh3RHa//Odbp0IEGqQnSmfBz yGI4FO122/OWgdBmwsZU1B4Xry6OMUl7pHAmxWll939HjlPpU+tzKvWWkyv2riPRiCYy nij6iOlyh2bzcVPGb7hIp8KQWwj6JZEtD7LApGVq5ObjtmB4B49yPXaDnnfc4buoYERa Nw5BICA5628NMg1BsaHLAiKAJN9OJ9Ds5rKsoNNzPTpPXI98x6UWXizJJvjhcGfSmW5D JlTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q+Os+IIE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id u2-20020a17090341c200b001bde8c9800esi20891176ple.459.2023.10.02.08.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 08:13:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q+Os+IIE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A02EC80763E8; Mon, 2 Oct 2023 07:51:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237882AbjJBOvX (ORCPT + 99 others); Mon, 2 Oct 2023 10:51:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237884AbjJBOvV (ORCPT ); Mon, 2 Oct 2023 10:51:21 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BB7FB7 for ; Mon, 2 Oct 2023 07:51:19 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED346C433C7; Mon, 2 Oct 2023 14:51:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696258279; bh=tPyXOm6nZ7FsqosSypBjv4U+82u+bOPrneDVb78W5GA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=q+Os+IIEUiUYfCqTRAMzqvtStgVgnehnPfVX9cb8ZiwIYqyUsGJjyX1ab6wCd4IZt EYJ9OTWwuyUI9yCLKRhz8DNlBTmyqjQE2MhPf6iSYATDjnyMhPzwSHvHFeqVLdoWCz B6++QBLANG1kcBAw/Lf+FS9AiEElCHy5EbfzhJXQWYJXaD/qVljcrY+DOdc2S2oQA/ lxccVSTiwcwS0hnU+ds9nNCBExKzTOmWCkRi/2VYsWzcPfwp0BTpcJKCHMdtBePwIg foEv/lDH9TnO1Hln3oGKfSW10WL/kOxS2obeuJ1+0vYl5Az9AGm/Ekjgc1uyygWAQT VknKjUvc9EL0Q== Subject: [PATCH v1 1/4] NFSD: Add a utility function for encoding sessionid4 objects From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 02 Oct 2023 10:51:17 -0400 Message-ID: <169625827794.1640.6920815972016494390.stgit@klimt.1015granger.net> In-Reply-To: <169625819958.1640.14102064750083176117.stgit@klimt.1015granger.net> References: <169625819958.1640.14102064750083176117.stgit@klimt.1015granger.net> 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=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 02 Oct 2023 07:51:23 -0700 (PDT) From: Chuck Lever There is more than one NFSv4 operation that needs to encode a sessionid4, so extract that data type into a separate helper. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 59ac16985775..e41e46213444 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3881,6 +3881,14 @@ nfsd4_encode_stateid4(struct xdr_stream *xdr, const stateid_t *sid) return nfs_ok; } +static __be32 +nfsd4_encode_sessionid4(struct xdr_stream *xdr, + const struct nfs4_sessionid *sessionid) +{ + return nfsd4_encode_opaque_fixed(xdr, sessionid->data, + NFS4_MAX_SESSIONID_LEN); +} + static __be32 nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, union nfsd4_op_u *u) @@ -3902,17 +3910,16 @@ static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp, { struct nfsd4_bind_conn_to_session *bcts = &u->bind_conn_to_session; struct xdr_stream *xdr = resp->xdr; - __be32 *p; - p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 8); - if (!p) + /* bctsr_sessid */ + nfserr = nfsd4_encode_sessionid4(xdr, &bcts->sessionid); + if (nfserr != nfs_ok) + return nfserr; + /* bctsr_dir */ + if (xdr_stream_encode_u32(xdr, bcts->dir) != XDR_UNIT) return nfserr_resource; - p = xdr_encode_opaque_fixed(p, bcts->sessionid.data, - NFS4_MAX_SESSIONID_LEN); - *p++ = cpu_to_be32(bcts->dir); - /* Upshifting from TCP to RDMA is not supported */ - *p++ = cpu_to_be32(0); - return 0; + /* bctsr_use_conn_in_rdma_mode */ + return nfsd4_encode_bool(xdr, false); } static __be32