From patchwork Tue Jan 3 18:42:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 3516 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4765526wrt; Tue, 3 Jan 2023 10:46:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXtxjlZsDqUkREz21WLKbf+5oWl9V41A/o8CWf8xjWYgCh1rnC/pXhBgygaGBp2Ep4NetCoG X-Received: by 2002:a05:6402:4506:b0:46d:35f6:5a9b with SMTP id ez6-20020a056402450600b0046d35f65a9bmr36859261edb.24.1672771575634; Tue, 03 Jan 2023 10:46:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672771575; cv=none; d=google.com; s=arc-20160816; b=gLnYCEhIXDSLl9FzTaoXK6eV/va+oQiEzu/dTzR5vKBIbxjZYPw1jeEY7lZEgkEPHJ bEERVu+aJrGt1qHM82NhufdmZaXEVDZ4jb2BQ+b6UCSUn8qxd6SyjDJg9qyOdgy3BjAh EVAZtll5fgcphjXSg9vBPFs/pjScOARlYtSR0475IKL0Tg+9ZAvmeNgzeiXZr/TOU/Yd VUCrw/f/a0WNRAauSttlVSLAwaln6whZJ0SjFFEs0C50E0tRr2GH/LlvZ5f2wICOqwmN MAZ0LFqJms9V9rEx1GaRYfPeeiZA7b23aLl7H5ugJrzJ6vk3eGg+Lhl31AGfZuDBnsjq WfLQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ORcDlteljIofXFtgj0WqFlIjM+SxLCEMXAOiyOwdfWw=; b=CB6QazOcA3vTLTwYgdVXemzcpkTDNy78WYPVmEO1MhAmgpN68aYN3Cxh+k41g4CHSL ndntSz5sESO+FcAFHpScEg+u1ms22sEHyfTL3pOLYZ91Tr89gFuNok1tibRvNBClICDd Kmf+9mUmI4Ns+IYh5cyoPspOgGiPqBS65a0E71Uhnp0LAcRZibOnJ8QTANG/6ef8lhna YPM7qREFuobDltgzinsPV4ZMz1tCR3LQxYNGinZbdMRM41qu4pJthf5O+cx6L/npJeeQ Xe7He9AVYeOOun7N+hVMsl/OinA+QDxfTw1zQyg+aL+7q9owfqDhRHIUW0y3oR1/40xq +zhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=eRrKrzeH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx24-20020a0564020b5800b004896ee4422bsi13148683edb.314.2023.01.03.10.45.52; Tue, 03 Jan 2023 10:46:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@arista.com header.s=google header.b=eRrKrzeH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233598AbjACSpC (ORCPT + 99 others); Tue, 3 Jan 2023 13:45:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238412AbjACSoh (ORCPT ); Tue, 3 Jan 2023 13:44:37 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25F4B140FA for ; Tue, 3 Jan 2023 10:43:06 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id bs20so28452861wrb.3 for ; Tue, 03 Jan 2023 10:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ORcDlteljIofXFtgj0WqFlIjM+SxLCEMXAOiyOwdfWw=; b=eRrKrzeH9JPmrdylEKetUwIDwtKQki35PdTSyQndAquat1galIBd6+8U+I1Q11mBPr 0l0YhzmfCzGTINPosuCM4Bwi7Z6qo/5D13ESpCQHGCZ66CY44UWTvlpX/SRg6at33CT/ 7gkmq+860ZIfztZbbqykNIgsuzT2BUhj9CjpjjBNBqZBqSDvdfgWCom8uNfkYVUyjyg7 UMSdxzBmSw5G0zRjjkJq+qUkGCNZjZwd4aWz3wnXEyNjJZHc2BCEFvhZ9SbCTUg+GtOE J5jd6g06TyTbA9GrzDVn8A1dXvludmeCxno0bt/S0c6YWncf2sUDr9jrJoxNPQfSpZme M61A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ORcDlteljIofXFtgj0WqFlIjM+SxLCEMXAOiyOwdfWw=; b=WfANSZuNOrN/cc91K6cMCrkutBD6uMUXimdB/TFdrEzCh2FQ6CC1Uy7Xs6YFO0AdoP SyeCFhc0X8efQ3b/yiO6zxh8qrtjh+lBnAjd7nXT31+7lQEMoPoW/8OzYbZQXYJmxG+7 dXo5a1btMrS9yGKcL4Uzqyrm9OHL9Log86brEU2O7UXBT/1n5jmlLBJ3kM/zTJ4FAzw8 FXittC23ScrAzOzcKHSbZTeKUxcaaSgzfFwEkhy2sdwp34S0yB5PR6VaLXln0xpIJPUQ FZS7sTaL6SAHynpyLFt/sbwJS+6u16uMhx42vOup3y1RQgs2DeOe2J/9zLTosKRZwLg8 RsVA== X-Gm-Message-State: AFqh2kpAmrHXyN+JeibrlYn0qv8tNwA/2zfOdHJDZDqeuV/6KFNZJIXu lKKi/AdMaoZaXizx06ViL5G52+lhSXX1mkaB X-Received: by 2002:a5d:61c7:0:b0:269:7b65:f20a with SMTP id q7-20020a5d61c7000000b002697b65f20amr28525156wrv.71.1672771384442; Tue, 03 Jan 2023 10:43:04 -0800 (PST) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id i18-20020a5d5232000000b0028e55b44a99sm13811578wra.17.2023.01.03.10.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:43:03 -0800 (PST) From: Dmitry Safonov To: linux-kernel@vger.kernel.org, David Ahern , Eric Dumazet , Herbert Xu , Jakub Kicinski , "David S. Miller" Cc: Dmitry Safonov , Andy Lutomirski , Bob Gilligan , Dmitry Safonov <0x7f454c46@gmail.com>, Hideaki YOSHIFUJI , Leonard Crestez , Paolo Abeni , Salam Noureddine , netdev@vger.kernel.org, linux-crypto@vger.kernel.org Subject: [PATCH v2 0/5] net/crypto: Introduce crypto_pool Date: Tue, 3 Jan 2023 18:42:52 +0000 Message-Id: <20230103184257.118069-1-dima@arista.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754028127700756147?= X-GMAIL-MSGID: =?utf-8?q?1754028127700756147?= Changes since v1 [1]: - Patches went through 3 iterations inside bigger TCP-AO patch set [2], now I'm splitting it apart and sending it once again as a stand-alone patch set to help reviewing it and make it easier to merge. It is second part of that big series, once it merges the next part will be TCP changes to add Authentication Option support (RFC5925), that use API provided by these patches. - Corrected kerneldoc-style comment near crypto_pool_reserve_scratch() (Reported-By: kernel test robot ) - Added short Documentation/ page for crypto_pool API Add crypto_pool - an API for allocating per-CPU array of crypto requests on slow-path (in sleep'able contexts) and for using them on a fast-path, which is RX/TX for net/* users. The design is based on the current implementations of md5sig_pool, which this patch set makes generic by separating it from TCP core, moving it to crypto/ and adding support for other hashing algorithms than MD5. It makes a generic implementation for a common net/ pattern. The initial motivation to have this API is TCP-AO, that's going to use the very same pattern as TCP-MD5, but for multiple hashing algorithms. Previously, I've suggested to add such API on TCP-AO patch submission [3], where Herbert kindly suggested to help with introducing new crypto API. See also discussion and motivation in crypto_pool-v1 [4]. The API will allow: - to reuse per-CPU ahash_request(s) for different users - to allocate only one per-CPU scratch buffer rather than a new one for each user - to have a common API for net/ users that need ahash on RX/TX fast path In this version I've wired up TCP-MD5 and IPv6-SR-HMAC as users. Potentially, xfrm_ipcomp and xfrm_ah can be converted as well. The initial reason for patches would be to have TCP-AO as a user, which would let it share per-CPU crypto_request for any supported hashing algorithm. [1]: https://lore.kernel.org/all/20220726201600.1715505-1-dima@arista.com/ [2]: https://lore.kernel.org/all/20221027204347.529913-1-dima@arista.com/T/#u [3]: http://lkml.kernel.org/r/20211106034334.GA18577@gondor.apana.org.au [4]: https://lore.kernel.org/all/26d5955b-3807-a015-d259-ccc262f665c2@arista.com/T/#u Cc: Andy Lutomirski Cc: Bob Gilligan Cc: David Ahern Cc: "David S. Miller" Cc: Dmitry Safonov <0x7f454c46@gmail.com> Cc: Eric Dumazet Cc: Herbert Xu Cc: Hideaki YOSHIFUJI Cc: Jakub Kicinski Cc: Leonard Crestez Cc: Paolo Abeni Cc: Salam Noureddine Cc: netdev@vger.kernel.org Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Dmitry Safonov (5): crypto: Introduce crypto_pool crypto/pool: Add crypto_pool_reserve_scratch() crypto/net/tcp: Use crypto_pool for TCP-MD5 crypto/net/ipv6: sr: Switch to using crypto_pool crypto/Documentation: Add crypto_pool kernel API Documentation/crypto/crypto_pool.rst | 33 +++ crypto/Kconfig | 12 + crypto/Makefile | 1 + crypto/crypto_pool.c | 338 +++++++++++++++++++++++++++ include/crypto/pool.h | 33 +++ include/net/seg6_hmac.h | 7 - include/net/tcp.h | 24 +- net/ipv4/Kconfig | 2 +- net/ipv4/tcp.c | 105 +++------ net/ipv4/tcp_ipv4.c | 92 +++++--- net/ipv4/tcp_minisocks.c | 21 +- net/ipv6/Kconfig | 2 +- net/ipv6/seg6.c | 3 - net/ipv6/seg6_hmac.c | 204 +++++++--------- net/ipv6/tcp_ipv6.c | 53 ++--- 15 files changed, 626 insertions(+), 304 deletions(-) create mode 100644 Documentation/crypto/crypto_pool.rst create mode 100644 crypto/crypto_pool.c create mode 100644 include/crypto/pool.h base-commit: 69b41ac87e4a664de78a395ff97166f0b2943210