From nobody Sat Nov 12 00:01:31 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N8G2M2RDzz4dC6F; Sat, 12 Nov 2022 00:01:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N8G2M1mf6z3jcT; Sat, 12 Nov 2022 00:01:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668211291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RECFcj8Vh7XVp+P5EJpJEpw8kNKdAOpR5uc62eq9OAs=; b=wfzKBE1wD6NIB3aKRuCFQS++Xx+EAkFc33Cu+QFpoMVVYM6i2/3TQZl0K6vdgEcMPKfRkE TSzskSkLUCAU/7dvRMCM7neCaEWt3hg2V6ple85fdaOfwpnZC6QzVmwlNjj1AlNpLEPWw0 J3H6kDjDD/o1MfdYn6SBAb/PZWt3eTMkUPg4E8KZL6eBpyNprywL+2eTxDpTTN1oAcWhls Jvkjq6faR9sjvfj7qQr6OVs6clzCyoAxdY1yHW8I63U8fAOj/gyU+iUZ6QTXQfjp6PF4LR jhyvFAwVy4Gj0V7vHBySiKDYfiXBFKdEWRiVTYcfpCkkGKjAGK7yW7UbFm934Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668211291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RECFcj8Vh7XVp+P5EJpJEpw8kNKdAOpR5uc62eq9OAs=; b=gsd6ucgfE0mRn/BAs8kucTDG3392iS6sWdNd7wyBKL6meoke6a36iGb87nSBN7f0dSyzWd SyipO9Nhjy0mioRXLPirqv2HL3R1eEsw8U+2j5XLvKqfwyWj7ugvTnrefvD/n0Pcm5z+mC d+p5REEf7EJ73SMZc+S0tQZpyqq5DPEMjyk53uG/kAANzzVtNBGV3uEtrkVbmPJF7gWt27 uZ6B27WVoV2BmsN3r8DHHrPpiHsGaOuVwrAuWvwGaUY0B6qhypgVUIHM/+3w2OupY/bzdv 7dA2vK3r6b3YnoZB5S0C4Eb8yPmzq9VcQoEGoYVHUIQl2PjRcwqRDtL8okfScQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668211291; a=rsa-sha256; cv=none; b=xPnANfzpZLOyVySu+3MlevZf7wbPavVuHcjif/nTt6Fd0yXuq7z8ngtzscodBrGgLsdPmR WQKQacoo+J79HNp9vP6MRp22j69i6zWhUjJn3IV77d/BoXb8N6sTT6ROqyfSKJ2buucg4/ qwIkN7A8fxX1Fe3b5MdquuAJnn9SfyOxjpMStsq1DJ4Q8iItfawZ0BxrKndz5DLTO697Db 9ax0PXcWITnpPj8yTIqT28RxIAPQk1JqDlndpxvjrRHLM0p9LbeNA0bJNNYeD+14jjuGvl zyIEDRGTXN1E+Sfg3B4veakX9MpHCTEjr5V+2XaXY0c9RBS3OAwu2FZEbqNAew== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N8G2M0rLqz12tT; Sat, 12 Nov 2022 00:01:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AC01V4N072584; Sat, 12 Nov 2022 00:01:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AC01VCM072583; Sat, 12 Nov 2022 00:01:31 GMT (envelope-from git) Date: Sat, 12 Nov 2022 00:01:31 GMT Message-Id: <202211120001.2AC01VCM072583@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 5920f99d2136 - main - ktls: Inline ktls_cleanup() into ktls_destroy(). List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5920f99d2136aa55ddb2bf1910c5757ee0ef6dc7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5920f99d2136aa55ddb2bf1910c5757ee0ef6dc7 commit 5920f99d2136aa55ddb2bf1910c5757ee0ef6dc7 Author: John Baldwin AuthorDate: 2022-11-12 00:01:02 +0000 Commit: John Baldwin CommitDate: 2022-11-12 00:01:02 +0000 ktls: Inline ktls_cleanup() into ktls_destroy(). Reviewed by: gallatin, markj Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D37353 --- sys/kern/uipc_ktls.c | 136 ++++++++++++++++++++++++--------------------------- 1 file changed, 64 insertions(+), 72 deletions(-) diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c index 8f3a204cbd84..3df1f2843c32 100644 --- a/sys/kern/uipc_ktls.c +++ b/sys/kern/uipc_ktls.c @@ -297,7 +297,6 @@ SYSCTL_COUNTER_U64(_kern_ipc_tls_toe, OID_AUTO, chacha20, CTLFLAG_RD, static MALLOC_DEFINE(M_KTLS, "ktls", "Kernel TLS"); -static void ktls_cleanup(struct ktls_session *tls); #if defined(INET) || defined(INET6) static void ktls_reset_receive_tag(void *context, int pending); static void ktls_reset_send_tag(void *context, int pending); @@ -784,76 +783,6 @@ ktls_clone_session(struct ktls_session *tls, int direction) return (tls_new); } -#endif - -static void -ktls_cleanup(struct ktls_session *tls) -{ - - counter_u64_add(ktls_offload_active, -1); - switch (tls->mode) { - case TCP_TLS_MODE_SW: - switch (tls->params.cipher_algorithm) { - case CRYPTO_AES_CBC: - counter_u64_add(ktls_sw_cbc, -1); - break; - case CRYPTO_AES_NIST_GCM_16: - counter_u64_add(ktls_sw_gcm, -1); - break; - case CRYPTO_CHACHA20_POLY1305: - counter_u64_add(ktls_sw_chacha20, -1); - break; - } - break; - case TCP_TLS_MODE_IFNET: - switch (tls->params.cipher_algorithm) { - case CRYPTO_AES_CBC: - counter_u64_add(ktls_ifnet_cbc, -1); - break; - case CRYPTO_AES_NIST_GCM_16: - counter_u64_add(ktls_ifnet_gcm, -1); - break; - case CRYPTO_CHACHA20_POLY1305: - counter_u64_add(ktls_ifnet_chacha20, -1); - break; - } - if (tls->snd_tag != NULL) - m_snd_tag_rele(tls->snd_tag); - if (tls->rx_ifp != NULL) - if_rele(tls->rx_ifp); - break; -#ifdef TCP_OFFLOAD - case TCP_TLS_MODE_TOE: - switch (tls->params.cipher_algorithm) { - case CRYPTO_AES_CBC: - counter_u64_add(ktls_toe_cbc, -1); - break; - case CRYPTO_AES_NIST_GCM_16: - counter_u64_add(ktls_toe_gcm, -1); - break; - case CRYPTO_CHACHA20_POLY1305: - counter_u64_add(ktls_toe_chacha20, -1); - break; - } - break; -#endif - } - if (tls->ocf_session != NULL) - ktls_ocf_free(tls); - if (tls->params.auth_key != NULL) { - zfree(tls->params.auth_key, M_KTLS); - tls->params.auth_key = NULL; - tls->params.auth_key_len = 0; - } - if (tls->params.cipher_key != NULL) { - zfree(tls->params.cipher_key, M_KTLS); - tls->params.cipher_key = NULL; - tls->params.cipher_key_len = 0; - } - explicit_bzero(tls->params.iv, sizeof(tls->params.iv)); -} - -#if defined(INET) || defined(INET6) #ifdef TCP_OFFLOAD static int @@ -1864,6 +1793,7 @@ ktls_modify_txrtlmt(struct ktls_session *tls, uint64_t max_pacing_rate) void ktls_destroy(struct ktls_session *tls) { + MPASS(tls->refcount == 0); if (tls->sequential_records) { struct mbuf *m, *n; @@ -1879,7 +1809,69 @@ ktls_destroy(struct ktls_session *tls) } } } - ktls_cleanup(tls); + + counter_u64_add(ktls_offload_active, -1); + switch (tls->mode) { + case TCP_TLS_MODE_SW: + switch (tls->params.cipher_algorithm) { + case CRYPTO_AES_CBC: + counter_u64_add(ktls_sw_cbc, -1); + break; + case CRYPTO_AES_NIST_GCM_16: + counter_u64_add(ktls_sw_gcm, -1); + break; + case CRYPTO_CHACHA20_POLY1305: + counter_u64_add(ktls_sw_chacha20, -1); + break; + } + break; + case TCP_TLS_MODE_IFNET: + switch (tls->params.cipher_algorithm) { + case CRYPTO_AES_CBC: + counter_u64_add(ktls_ifnet_cbc, -1); + break; + case CRYPTO_AES_NIST_GCM_16: + counter_u64_add(ktls_ifnet_gcm, -1); + break; + case CRYPTO_CHACHA20_POLY1305: + counter_u64_add(ktls_ifnet_chacha20, -1); + break; + } + if (tls->snd_tag != NULL) + m_snd_tag_rele(tls->snd_tag); + if (tls->rx_ifp != NULL) + if_rele(tls->rx_ifp); + break; +#ifdef TCP_OFFLOAD + case TCP_TLS_MODE_TOE: + switch (tls->params.cipher_algorithm) { + case CRYPTO_AES_CBC: + counter_u64_add(ktls_toe_cbc, -1); + break; + case CRYPTO_AES_NIST_GCM_16: + counter_u64_add(ktls_toe_gcm, -1); + break; + case CRYPTO_CHACHA20_POLY1305: + counter_u64_add(ktls_toe_chacha20, -1); + break; + } + break; +#endif + } + if (tls->ocf_session != NULL) + ktls_ocf_free(tls); + if (tls->params.auth_key != NULL) { + zfree(tls->params.auth_key, M_KTLS); + tls->params.auth_key = NULL; + tls->params.auth_key_len = 0; + } + if (tls->params.cipher_key != NULL) { + zfree(tls->params.cipher_key, M_KTLS); + tls->params.cipher_key = NULL; + tls->params.cipher_key_len = 0; + } + explicit_bzero(tls->params.iv, sizeof(tls->params.iv)); + uma_zfree(ktls_session_zone, tls); }