From: Daniel Xu <dxu@dxuuu.xyz>
To: daniel@iogearbox.net, davem@davemloft.net, edumazet@google.com,
Herbert Xu <herbert@gondor.apana.org.au>,
ast@kernel.org, john.fastabend@gmail.com, kuba@kernel.org,
steffen.klassert@secunet.com, pabeni@redhat.com, hawk@kernel.org,
antony.antony@secunet.com, alexei.starovoitov@gmail.com,
yonghong.song@linux.dev, eddyz87@gmail.com,
eyal.birger@gmail.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, devel@linux-ipsec.org
Subject: [PATCH bpf-next v5 2/9] bpf: xfrm: Add bpf_xdp_xfrm_state_release() kfunc
Date: Mon, 11 Dec 2023 13:20:06 -0700 [thread overview]
Message-ID: <45124c8da4d96f4e87da540dfe41b3fd7aea878e.1702325874.git.dxu@dxuuu.xyz> (raw)
In-Reply-To: <cover.1702325874.git.dxu@dxuuu.xyz>
This kfunc releases a previously acquired xfrm_state from
bpf_xdp_get_xfrm_state().
Co-developed-by: Antony Antony <antony.antony@secunet.com>
Signed-off-by: Antony Antony <antony.antony@secunet.com>
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---
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 21630974c27d..b84adec4451c 100644
--- a/net/xfrm/xfrm_state_bpf.c
+++ b/net/xfrm/xfrm_state_bpf.c
@@ -96,10 +96,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
next prev parent reply other threads:[~2023-12-11 20:20 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 20:20 [PATCH bpf-next v5 0/9] Add bpf_xdp_get_xfrm_state() kfunc Daniel Xu
2023-12-11 20:20 ` [PATCH bpf-next v5 1/9] bpf: xfrm: " Daniel Xu
2023-12-11 21:39 ` Eyal Birger
2023-12-11 22:26 ` Daniel Xu
2023-12-14 0:02 ` Martin KaFai Lau
2023-12-11 20:20 ` Daniel Xu [this message]
2023-12-11 20:20 ` [PATCH bpf-next v5 3/9] libbpf: Add BPF_CORE_WRITE_BITFIELD() macro Daniel Xu
2023-12-11 20:20 ` [PATCH bpf-next v5 4/9] bpf: selftests: test_loader: Support __btf_path() annotation Daniel Xu
2023-12-11 20:20 ` [PATCH bpf-next v5 5/9] bpf: selftests: Add verifier tests for CO-RE bitfield writes Daniel Xu
2023-12-13 23:58 ` Martin KaFai Lau
2023-12-14 0:20 ` Daniel Xu
2023-12-11 20:20 ` [PATCH bpf-next v5 6/9] bpf: selftests: test_tunnel: Setup fresh topology for each subtest Daniel Xu
2023-12-11 20:20 ` [PATCH bpf-next v5 7/9] bpf: selftests: test_tunnel: Use vmlinux.h declarations Daniel Xu
2023-12-11 20:20 ` [PATCH bpf-next v5 8/9] bpf: selftests: Move xfrm tunnel test to test_progs Daniel Xu
2023-12-11 20:20 ` [PATCH bpf-next v5 9/9] bpf: xfrm: Add selftest for bpf_xdp_get_xfrm_state() Daniel Xu
2023-12-11 21:39 ` Eyal Birger
2023-12-11 22:31 ` Daniel Xu
2023-12-11 23:13 ` Eyal Birger
2023-12-11 23:49 ` Daniel Xu
2023-12-12 0:25 ` Eyal Birger
2023-12-12 16:17 ` Daniel Xu
2023-12-12 16:44 ` Alexei Starovoitov
2023-12-12 19:00 ` Daniel Xu
2023-12-12 19:52 ` Daniel Xu
2023-12-12 23:13 ` Kumar Kartikeya Dwivedi
2023-12-13 23:15 ` Daniel Xu
2023-12-13 23:49 ` Eyal Birger
2023-12-14 16:08 ` Kumar Kartikeya Dwivedi
2023-12-14 16:16 ` Kumar Kartikeya Dwivedi
2023-12-14 18:23 ` Daniel Xu
2023-12-14 20:24 ` Daniel Xu
2023-12-14 20:53 ` Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45124c8da4d96f4e87da540dfe41b3fd7aea878e.1702325874.git.dxu@dxuuu.xyz \
--to=dxu@dxuuu.xyz \
--cc=alexei.starovoitov@gmail.com \
--cc=antony.antony@secunet.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=devel@linux-ipsec.org \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=eyal.birger@gmail.com \
--cc=hawk@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=steffen.klassert@secunet.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®