Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2341170pxb; Thu, 4 Nov 2021 18:58:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfrXal0zrPr4y1L1YVKsM0oAjpFNbLIgUj788lTZa5vycP1jj7359IhugGDRi6AmoL/dCh X-Received: by 2002:a17:906:6089:: with SMTP id t9mr70241390ejj.323.1636077509937; Thu, 04 Nov 2021 18:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636077509; cv=none; d=google.com; s=arc-20160816; b=GdFF9Q2Q6hsYNGUpuQy8e/hkqCCGTi/Y3zcUbZOlm1gJxFSbFKfzzHcdyPef0kD/Lt fQbc/F/lF7M8Sdk3v3qJJ7L75tJCXw2h/t/0plObcWJ9e93bWpquIQ6fQsCLKWctl7Ki Kykn5xr5Iw9+Nvu9WodJ/+DATX6OC4QrepvFddc3+lsbQMqLPIW6xGY64sklkznYvDQg xkm1wddxZK4Z5pjPeBROJM9VByXco9T+//k8lEH2xZCNO3RFQg5ckRqF/qiDrYZNy1uA yYMBMOlj7evk8WKsHBy35UO/uDFiyO5wHQAmBeL/wPj7GUiKq8QM5x+R9Te5XfiSopfP C0wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=4CjTDS7XmZyHu4AFPq6nvsk3QBZ5u4iMo3sZwE0ixCE=; b=RRZTQ3W6otFOYCaqwbROHQBA4h2XzgKo6fmABf68ETroYV7QbBRyzAHIQTlogogJEE e7cxfXzFSJdUgUGoWSgK3s1nwHHfkha8IrnHDvLpOrsmqzZrPeyZZldzw92Eo+j2T6oh BeJtynpdMPRbPLNDu/iYK1fPYV26AFJ/zs3kczUmSx2FcqA0hzq1kHfaTPfzxBwYXk7y 5UENdufIR07M+GRHwS/KhJeX/Jf3UjDfaIVh7hYP/Db1ZhvyqKnKioMp0byXDgZ4jgfj ne7Eyr1zieko2Ocft381PHK7Ib0YcgUX7qIMM66PSD5g8rwl1vjDAQhyopLxAzLgnKhI l8WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RXbeI0ak; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qb30si13823612ejc.256.2021.11.04.18.58.06; Thu, 04 Nov 2021 18:58:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RXbeI0ak; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230345AbhKEB4N (ORCPT + 99 others); Thu, 4 Nov 2021 21:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbhKEB4N (ORCPT ); Thu, 4 Nov 2021 21:56:13 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59BA9C061714; Thu, 4 Nov 2021 18:53:34 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id f7-20020a1c1f07000000b0032ee11917ceso5539050wmf.0; Thu, 04 Nov 2021 18:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=4CjTDS7XmZyHu4AFPq6nvsk3QBZ5u4iMo3sZwE0ixCE=; b=RXbeI0akSQ8QNRTOzIPZwzNA3RzCzV8CH6572hS18+y2nYefY8Jembn+jF/MwXWf70 L3qXsDMV4okYcLPInHULpM7J3GVfkVQWth5BposOZR85q3HbOzK2+oWaE9IY+eKvW9M/ U55DTjKH/pK49w9c67aoaYzAPStCeqPF7Aas65Y5MVNUDHPSSVFMGsQxTSo0JWwNwcVl I1F7L59/Uoj16wVWa95xMH00Qy5IS83AXXEjHU69vn21lfWpqACtxEssySgpI/REfixs Tecy+kihmrPwDM9p0Hk5kNqTBqkR1/KH34L91pyccObZ+SUdmLNqgRDu1lgQQjo/6cZt wZFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=4CjTDS7XmZyHu4AFPq6nvsk3QBZ5u4iMo3sZwE0ixCE=; b=KomNRKJDJr1z2z7u1NypBWenIn7gDFTl47h7vuS+BQCG0FBzOWwo948tDKFo+WXp/z xyZydQc4vKASSvO5qDqzUibZ1gWLZheaq+odDh8xk6Vxt+jI/NM6zx8lInZ3O3zGlnnQ E3kkPPncT/DIB404yJS3NPqFYXw+f0m8TfHad2C2x3agKHnx9YHIGVU5tccEqN6oLFkR YivyOX+61Dg37dlYNB3IiGiffh0MW0/lHbdKGPW+zl/NxlbdyOlWyOknUlad9BsPcTHh OX1kH0bccd+FUl2YOll1CMIt/aLf+wsbL4pE3EkhFPwG7tgeBxmOcJBZp5GaXgic+UoF q24A== X-Gm-Message-State: AOAM5322hH6dk+pVJwDuO8t7kys0hKz1bx/i3qP7v/4Jy5lLl0TIIgLW +Kx5rUEmWQEIJEW+AxvSAXs41vkNiXA= X-Received: by 2002:a05:600c:a45:: with SMTP id c5mr27123377wmq.79.1636077213048; Thu, 04 Nov 2021 18:53:33 -0700 (PDT) Received: from ?IPV6:2a02:8084:e84:2480:228:f8ff:fe6f:83a8? ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id q4sm6597595wrs.56.2021.11.04.18.53.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Nov 2021 18:53:32 -0700 (PDT) Message-ID: <816d5018-6cc5-78c4-4c13-f92927ad23f7@gmail.com> Date: Fri, 5 Nov 2021 01:53:31 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v2 06/25] tcp: authopt: Compute packet signatures Content-Language: en-US To: Leonard Crestez , David Ahern , Eric Dumazet Cc: "David S. Miller" , Herbert Xu , Kuniyuki Iwashima , Hideaki YOSHIFUJI , Jakub Kicinski , Yuchung Cheng , Francesco Ruggeri , Mat Martineau , Christoph Paasch , Ivan Delalande , Priyaranjan Jha , netdev@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan References: <5245f35901015acc6a41d1da92deb96f3e593b7c.1635784253.git.cdleonard@gmail.com> From: Dmitry Safonov <0x7f454c46@gmail.com> In-Reply-To: <5245f35901015acc6a41d1da92deb96f3e593b7c.1635784253.git.cdleonard@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 11/1/21 16:34, Leonard Crestez wrote: [..] > +static int skb_shash_frags(struct shash_desc *desc, > + struct sk_buff *skb) > +{ > + struct sk_buff *frag_iter; > + int err, i; > + > + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { > + skb_frag_t *f = &skb_shinfo(skb)->frags[i]; > + u32 p_off, p_len, copied; > + struct page *p; > + u8 *vaddr; > + > + skb_frag_foreach_page(f, skb_frag_off(f), skb_frag_size(f), > + p, p_off, p_len, copied) { > + vaddr = kmap_atomic(p); > + err = crypto_shash_update(desc, vaddr + p_off, p_len); > + kunmap_atomic(vaddr); > + if (err) > + return err; > + } > + } > + > + skb_walk_frags(skb, frag_iter) { > + err = skb_shash_frags(desc, frag_iter); > + if (err) > + return err; > + } > + > + return 0; > +} This seems quite sub-optimal: IIUC, shash should only be used for small amount of hashing. That's why tcp-md5 uses ahash with scatterlists. Which drives me to the question: why not reuse tcp_md5sig_pool code? And it seems that you can avoid TCP_AUTHOPT_ALG_* enum and just supply to crypto the string from socket option (like xfrm does). Here is my idea: https://lore.kernel.org/all/20211105014953.972946-6-dima@arista.com/T/#u Thanks, Dmitry