From patchwork Tue Feb 7 08:18:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 651374 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBA26C636CD for ; Tue, 7 Feb 2023 08:19:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230290AbjBGITL (ORCPT ); Tue, 7 Feb 2023 03:19:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbjBGITL (ORCPT ); Tue, 7 Feb 2023 03:19:11 -0500 Received: from formenos.hmeau.com (167-179-156-38.a7b39c.syd.nbn.aussiebb.net [167.179.156.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEB701C315; Tue, 7 Feb 2023 00:19:08 -0800 (PST) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1pPJBU-008OYZ-Tl; Tue, 07 Feb 2023 16:18:38 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Tue, 07 Feb 2023 16:18:36 +0800 Date: Tue, 7 Feb 2023 16:18:36 +0800 From: Herbert Xu To: Jakub Kicinski Cc: Linux Crypto Mailing List , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, Tyler Hicks , ecryptfs@vger.kernel.org, Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org, Steffen Klassert , Jon Maloy , Ying Xue , Boris Pismenny , John Fastabend , David Howells , Jarkko Sakkinen , keyrings@vger.kernel.org Subject: [PATCH] tls: Pass rec instead of aead_req into tls_encrypt_done Message-ID: References: <20230206231521.712f53e5@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230206231521.712f53e5@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Feb 06, 2023 at 11:15:21PM -0800, Jakub Kicinski wrote: > > > aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_BACKLOG, > > - tls_encrypt_done, sk); > > + tls_encrypt_done, aead_req); > > ... let's just pass rec instead of aead_req here, then? Good point. Could we do this as a follow-up patch? Reposting the whole series would disturb a lot of people. Of course if other major issues crop up I can fold this into the existing patch. Thanks! ---8<--- The function tls_encrypt_done only uses aead_req to get ahold of the tls_rec object. So we could pass that in instead of aead_req to simplify the code. Suggested-by: Jakub Kicinski Signed-off-by: Herbert Xu diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 0515cda32fe2..6dfec2e8fdfa 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -430,18 +430,16 @@ int tls_tx_records(struct sock *sk, int flags) static void tls_encrypt_done(void *data, int err) { - struct aead_request *aead_req = data; struct tls_sw_context_tx *ctx; struct tls_context *tls_ctx; struct tls_prot_info *prot; + struct tls_rec *rec = data; struct scatterlist *sge; struct sk_msg *msg_en; - struct tls_rec *rec; bool ready = false; struct sock *sk; int pending; - rec = container_of(aead_req, struct tls_rec, aead_req); msg_en = &rec->msg_encrypted; sk = rec->sk; @@ -536,7 +534,7 @@ static int tls_do_encryption(struct sock *sk, data_len, rec->iv_data); aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tls_encrypt_done, aead_req); + tls_encrypt_done, rec); /* Add the record in tx_list */ list_add_tail((struct list_head *)&rec->list, &ctx->tx_list);