Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1308107rdb; Fri, 1 Dec 2023 12:24:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqKlOUQrrwgFRUCnNUXqHrinuutJKWvc4ufbjAvJ4sROf8b2pVVK3LQDXbu38j0hnoQXme X-Received: by 2002:a05:6e02:dd2:b0:35d:59a2:2aa with SMTP id l18-20020a056e020dd200b0035d59a202aamr58744ilj.74.1701462247107; Fri, 01 Dec 2023 12:24:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701462247; cv=none; d=google.com; s=arc-20160816; b=Ac7ZTRjKgaIKvA24fw0o0o/wGnfKKXNblf0fRUPVkQb/ZZbJ9kVVwZIR5u6DTbzQMN BTu3iP5e4rvc4Tt9cxf1ngG2OT52U0DeeZaEpj7Aqm49G1fWGky6uhv9MQJ7rL4uCNXu jN5LLVZqt5q7R59/1+9sAaCDzElZdY8MIMR1zYVAQToOT2rItL0o+nWSh5oF1taXF5q/ EedE4vg0u4j9jIuFo5tUIT0Pv2y/yrDrtQK21bTogpdy7uxWXn1Qe2Ig8QEoAm7rQQUf ko4UV3o4UgIL24XkbwVZYxQjP3Zyi47Rub4SCWVuaWXsZcpXL3iLboLaCBwQpa/Iz+C/ bIcA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=gTC80DkbSwec6++klwVY+AjSyF2q8Jrio27MwPjAqCs=; fh=T8rLh7QwYEHI2JUvsunLrQ3LvszuszJaJzIJJOTwA0o=; b=sVdWtLhAYoz9RmqHYEbHDRIhP2NJWz9YgnxmInGykGMZEf76Ia+KG8waF+il8wlllx FlQGsUjfTL8zaBBPkAqEHPsd9G8FuE6n3OrC5algl89e47x0ONBqWtolBL9BLohvCxGz H2rldtVeD6y9qy2RpioRiY5s1Khv+dMpz0zwhJOG/bAAp76uiEycJPkCwhQEaibWQijv jcOQtXLwon4VOUHlz0qqgzaVpnvnJoSxYU0djCWjxSXGONMkg8eafHeZzqHr71YwPdQq KyEsp30+UkA6NQ2obp1T9tcV8YLjbqjeGO9QWsPExOcWdm6KZ8c2gKf/ztt3cfH4HiqM f/hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=N5qepEM+; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="Ddfw/66q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l13-20020a63570d000000b005be344b48dasi3886508pgb.805.2023.12.01.12.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 12:24:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=N5qepEM+; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="Ddfw/66q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DF3908134CFF; Fri, 1 Dec 2023 12:24:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379522AbjLAUXw (ORCPT + 99 others); Fri, 1 Dec 2023 15:23:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379478AbjLAUXt (ORCPT ); Fri, 1 Dec 2023 15:23:49 -0500 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73606F7; Fri, 1 Dec 2023 12:23:56 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id D42845C01E6; Fri, 1 Dec 2023 15:23:55 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 01 Dec 2023 15:23:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1701462235; x= 1701548635; bh=gTC80DkbSwec6++klwVY+AjSyF2q8Jrio27MwPjAqCs=; b=N 5qepEM+SjCrEYitQmzwC1hP/Ky4ABTGj/pnIWWXg/Rp9jZTTKwj1gXjEzONAf5Fa LbxVnTGkblBiwQ5wZNt8R0sgOMQOCZq37OTW2IbY+Drf3/dkW9pha0LFoS598FU5 7fc3x6q0CoiAoAPd9KjTKXbPM49WDVKDfeT/H50+xWKN2xq1yxgdfiC65Jt0Smd8 h7lvEA1DvX/AILJEU9Xh6NhmH53dCg9xydKxcJz8Ibqo43WX7Z+R967j5kUgNq0w P+yGvd/bNpSAD6cZ1tdOAke9qA8LBX02jv/wj/B57Uj3OQr4dRBvtmWAaqRZDiUH 1WI0X1fPm3Iale1ZTBWMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1701462235; x= 1701548635; bh=gTC80DkbSwec6++klwVY+AjSyF2q8Jrio27MwPjAqCs=; b=D dfw/66qLjQd0Zbq9BHdmH0TjFLXYjk2WsdKiNWnjEGPXy2XNWOFJObm7HeCX8tl2 GWw2xE71fPCi5eUUe4bTyVIgx85Kkp+zcSMK/fg6W6yg5L/ucEYovtVqkk1+Oa9g buDJqCJTFtVtZmooP9wM2lp2W9F0VOKzGc3CnLHAOdzuNrKKl2B3elmW6IJd7bc0 gyVXAdpD0ZZ9ZjTmiYqlj7CD3Ae67xkoDNGNP/FxtZ1LemWs3HKueZHJqeZn8PVZ 4fxgAD+K7wuOCKybWWnWYnmdCjygb3oOnha0snU80tBCYCsxKCWGruQCQKVi8mgG 8bnqrf/UEUcj/MDUGgo8g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeiledgudefjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculdefhedmnecujfgurhephffvvefufffkofgjfhgggfestdekredt redttdenucfhrhhomhepffgrnhhivghlucgiuhcuoegugihusegugihuuhhurdighiiiqe enucggtffrrghtthgvrhhnpefgfefggeejhfduieekvdeuteffleeifeeuvdfhheejleej jeekgfffgefhtddtteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 1 Dec 2023 15:23:54 -0500 (EST) From: Daniel Xu To: davem@davemloft.net, daniel@iogearbox.net, kuba@kernel.org, edumazet@google.com, ast@kernel.org, john.fastabend@gmail.com, steffen.klassert@secunet.com, hawk@kernel.org, pabeni@redhat.com, "Herbert Xu steffen . klassert @ secunet . com" , antony.antony@secunet.com, alexei.starovoitov@gmail.com, yonghong.song@linux.dev, eddyz87@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devel@linux-ipsec.org Subject: [PATCH ipsec-next v3 2/9] bpf: xfrm: Add bpf_xdp_xfrm_state_release() kfunc Date: Fri, 1 Dec 2023 13:23:13 -0700 Message-ID: X-Mailer: git-send-email 2.42.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 01 Dec 2023 12:24:06 -0800 (PST) This kfunc releases a previously acquired xfrm_state from bpf_xdp_get_xfrm_state(). Co-developed-by: Antony Antony Signed-off-by: Antony Antony Signed-off-by: Daniel Xu --- net/xfrm/xfrm_state_bpf.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/xfrm/xfrm_state_bpf.c b/net/xfrm/xfrm_state_bpf.c index 1681825db506..1485b9da9425 100644 --- a/net/xfrm/xfrm_state_bpf.c +++ b/net/xfrm/xfrm_state_bpf.c @@ -94,10 +94,26 @@ bpf_xdp_get_xfrm_state(struct xdp_md *ctx, struct bpf_xfrm_state_opts *opts, u32 return x; } +/* bpf_xdp_xfrm_state_release - Release acquired xfrm_state object + * + * This must be invoked for referenced PTR_TO_BTF_ID, and the verifier rejects + * the program if any references remain in the program in all of the explored + * states. + * + * Parameters: + * @x - Pointer to referenced xfrm_state object, obtained using + * bpf_xdp_get_xfrm_state. + */ +__bpf_kfunc void bpf_xdp_xfrm_state_release(struct xfrm_state *x) +{ + xfrm_state_put(x); +} + __bpf_kfunc_end_defs(); BTF_SET8_START(xfrm_state_kfunc_set) BTF_ID_FLAGS(func, bpf_xdp_get_xfrm_state, KF_RET_NULL | KF_ACQUIRE) +BTF_ID_FLAGS(func, bpf_xdp_xfrm_state_release, KF_RELEASE) BTF_SET8_END(xfrm_state_kfunc_set) static const struct btf_kfunc_id_set xfrm_state_xdp_kfunc_set = { -- 2.42.1