Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2563651lqt; Mon, 22 Apr 2024 14:43:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmMj6/+NSnzppNEfBwS6y0iTmJIKXVPJcD91jTzIs9u1azkws6ZRol49TBqAMoUEIVudRjiCLH9FUiykXcFygPJS9EsOLPlOuQgAAUIw== X-Google-Smtp-Source: AGHT+IHPwk+1j7l0SPONqFzZ5HRBk3TthO6Qr6rSXfD4YCmSP3LX6QUJCh5dfw+AFXG4VWSp2dUn X-Received: by 2002:a05:6a20:de94:b0:1ac:e07f:e3aa with SMTP id la20-20020a056a20de9400b001ace07fe3aamr6454499pzb.48.1713822220507; Mon, 22 Apr 2024 14:43:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713822220; cv=pass; d=google.com; s=arc-20160816; b=nGtoHC+I7igJpmhdahsFevN5Y/iLIG6jp0Bq9rjjXPCjRrcihSXbCfytA/bnaK3h01 IT+iRdRhtVOP/5gb9QCs5FIHiQBme0evyNVm1KKQ1zW072c3IgBxYS2WfZwkyzafpl4V 3Fu+WY0Uh4ACXdbqmxPumYJ9OcKiaTrDLRdqJcx4/CW5iyWwbaXN/QYHnnweN4RKw95n /EnxSgR05iMDx2f8V10jiEwtvglxXcHWEXMEmL16HUoytRCuV3+4TLgzBjNGEBUoKs8H XRUf9SFh4EWT3ppaIhWr9TTid0jvnZQ0B5bQIYLVTvWhl3Xw6B2SitKt/SSgz2Ntbf8e FVCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=B1jpWzTuiZI+ImKer+LozaEgfhA2ALBaIlWPA+Onbjc=; fh=PTpWmL0o/QdoSExo64T2bczctT6EPkGz4x7f1Q+l8Gk=; b=0u6Es+HsiDSFCoWJR/lj8qxG0GLAAuGk3zpeb7uwoRJwUgb86Ns9r0nrtSu9KhIsIw I5IXzVQua/1dXz4kZDhmBa78RdPlWdhY+cmHtZ1qmoBXMUQu1d41byV61N5IfydoO1fp 9XTtHse9y4K3f//ea3R+kh5N0iQfFPKQkfaTMCy/2VaXhrzYvYBgnoMpIiLR9Dl8xwOy CWbtTo8trF+0D3qoljz+KsCsQM6fSvGU3w/jeOr+pq0avazJQBAkJpZ8p2VCgx0fCDNi QfQeuVqmADKq6xDlBPPn+mtoGLqicMNJXdTsx6UYow8L5gTCoO3gIZ6q9MlcniWFrWZ2 rRTw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iNvJhfzS; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-crypto+bounces-3776-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id w20-20020a639354000000b006034c56d5a1si252748pgm.647.2024.04.22.14.43.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 14:43:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3776-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iNvJhfzS; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-crypto+bounces-3776-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D577BB2161A for ; Mon, 22 Apr 2024 21:42:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5B681D54D; Mon, 22 Apr 2024 21:42:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="iNvJhfzS" X-Original-To: linux-crypto@vger.kernel.org Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A4971CD20 for ; Mon, 22 Apr 2024 21:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713822141; cv=none; b=rNTnWOvgegMf5wnX33bTXxj6aYeHygx3+259O78APf7nvRCzG2yerBRajtDu836+zsORPDzE55vSf4NEQb7VbUpgZHdH3/O4g3Nw3sWpBheOQM3v01S3U7vdlEQ/ZHe2i9E5fTYIeptYaGY6kQu621ubu73RneqPqmajkeccnPY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713822141; c=relaxed/simple; bh=4hA5sBeUci6cwYvvfoMdxfwPxqjWRzzNuWkrAp4FGEY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EwYSUr9tEy40UGqzJmCwyMGbj5ARbRtGvhtSfa2Flq9+/tG7pXwBK8aesdyNnMt6+tEzq9eV+CV+4jDN5wKb0mFryXmaN3C3bwHuSEivhWqH0nAsbo5Ns/vJbKsHQMYAPewLLnHtzookEDM7+JeNaBzt9m3qtLhJSk7GbxX5leQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=iNvJhfzS; arc=none smtp.client-ip=91.218.175.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <1a9240ba-7279-405d-be37-2cdacb518579@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713822136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B1jpWzTuiZI+ImKer+LozaEgfhA2ALBaIlWPA+Onbjc=; b=iNvJhfzSEGGGCd4ihcbSBtRsPtJtjk27hxQ4mm6gABgsUJt4mXpFYnSc+lZAGamICZYeZd BwiWJ+xh05eO37FO2jc7puSgxeeDfcOp5/mCY1yV2vi9YDrAoII0ohzCYQpG/EHY59vEYE w3omx/TdHHj/2aR0VXA+3csiMK/AZjI= Date: Mon, 22 Apr 2024 14:42:11 -0700 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v9 1/4] bpf: make common crypto API for TC/XDP programs To: Vadim Fedorenko , Vadim Fedorenko Cc: Jakub Kicinski , Andrii Nakryiko , Alexei Starovoitov , Mykola Lysenko , Herbert Xu , netdev@vger.kernel.org, linux-crypto@vger.kernel.org, bpf@vger.kernel.org References: <20240416204004.3942393-1-vadfed@meta.com> <20240416204004.3942393-2-vadfed@meta.com> <89a92b51-fbfe-4eab-840c-c27174b7f3a1@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: <89a92b51-fbfe-4eab-840c-c27174b7f3a1@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 4/19/24 5:24 PM, Vadim Fedorenko wrote: >>> +/** >>> + * bpf_crypto_ctx_create() - Create a mutable BPF crypto context. >>> + * >>> + * Allocates a crypto context that can be used, acquired, and released by >>> + * a BPF program. The crypto context returned by this function must either >>> + * be embedded in a map as a kptr, or freed with bpf_crypto_ctx_release(). >>> + * As crypto API functions use GFP_KERNEL allocations, this function can >>> + * only be used in sleepable BPF programs. >>> + * >>> + * bpf_crypto_ctx_create() allocates memory for crypto context. >>> + * It may return NULL if no memory is available. >>> + * @params: pointer to struct bpf_crypto_params which contains all the >>> + *          details needed to initialise crypto context. >>> + * @err:    integer to store error code when NULL is returned. >>> + */ >>> +__bpf_kfunc struct bpf_crypto_ctx * >>> +bpf_crypto_ctx_create(const struct bpf_crypto_params *params, int *err) >> >> Add a "u32 params__sz" arg in case that the params struct will have addition. >> Take a look at how opts__sz is checked in nf_conntrack_bpf.c. >> > > nf_conntrack uses hard-coded value, while xfrm code uses > sizeof(struct bpf_xfrm_state_opts), which one is better? If it is about the enum NF_BPF_CT_OPTS_SZ in nf_conntrack, I don't think it is a must have. bpf_core_type_size() should have the same effect to figure out the sizeof a struct in the running kernel. afaik, sizeof() should do.