[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250801121053.7495-1-dev@der-flo.net>
Date: Fri, 1 Aug 2025 14:10:53 +0200
From: Florian Lehner <dev@...-flo.net>
To: bpf@...r.kernel.org
Cc: yonghong.song@...ux.dev,
ast@...nel.org,
daniel@...earbox.net,
andrii@...nel.org,
martin.lau@...ux.dev,
eddyz87@...il.com,
song@...nel.org,
john.fastabend@...il.com,
kpsingh@...nel.org,
sdf@...ichev.me,
haoluo@...gle.com,
jolsa@...nel.org,
davem@...emloft.net,
kuba@...nel.org,
hawk@...nel.org,
netdev@...r.kernel.org,
Florian Lehner <dev@...-flo.net>
Subject: [PATCH bpf-next] bpf: Add LINK_DETACH for iter and perf links
73b11c2a introduced LINK_DETACH and implemented it for some link types,
like xdp, netns and others.
This patch implements LINK_DETACH for perf and iter links, re-using
existing link release handling code.
Signed-off-by: Florian Lehner <dev@...-flo.net>
---
kernel/bpf/bpf_iter.c | 7 +++++++
kernel/bpf/syscall.c | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c
index 0cbcae727079..823dad09735d 100644
--- a/kernel/bpf/bpf_iter.c
+++ b/kernel/bpf/bpf_iter.c
@@ -397,6 +397,12 @@ static void bpf_iter_link_release(struct bpf_link *link)
iter_link->tinfo->reg_info->detach_target(&iter_link->aux);
}
+static int bpf_iter_link_detach(struct bpf_link *link)
+{
+ bpf_iter_link_release(link);
+ return 0;
+}
+
static void bpf_iter_link_dealloc(struct bpf_link *link)
{
struct bpf_iter_link *iter_link =
@@ -490,6 +496,7 @@ static int bpf_iter_link_fill_link_info(const struct bpf_link *link,
static const struct bpf_link_ops bpf_iter_link_lops = {
.release = bpf_iter_link_release,
+ .detach = bpf_iter_link_detach,
.dealloc = bpf_iter_link_dealloc,
.update_prog = bpf_iter_link_replace,
.show_fdinfo = bpf_iter_link_show_fdinfo,
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index e63039817af3..e89694f6874a 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -3733,6 +3733,12 @@ static void bpf_perf_link_release(struct bpf_link *link)
fput(perf_link->perf_file);
}
+static int bpf_perf_link_detach(struct bpf_link *link)
+{
+ bpf_perf_link_release(link);
+ return 0;
+}
+
static void bpf_perf_link_dealloc(struct bpf_link *link)
{
struct bpf_perf_link *perf_link = container_of(link, struct bpf_perf_link, link);
@@ -4027,6 +4033,7 @@ static void bpf_perf_link_show_fdinfo(const struct bpf_link *link,
static const struct bpf_link_ops bpf_perf_link_lops = {
.release = bpf_perf_link_release,
+ .detach = bpf_perf_link_detach,
.dealloc = bpf_perf_link_dealloc,
.fill_link_info = bpf_perf_link_fill_link_info,
.show_fdinfo = bpf_perf_link_show_fdinfo,
--
2.50.1
Powered by blists - more mailing lists