Skip to content

Commit 4d56b23

Browse files
florianlKernel Patches Daemon
authored andcommitted
bpf: Add LINK_DETACH for iter and perf links
73b11c2 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 <[email protected]>
1 parent dbe33e3 commit 4d56b23

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

kernel/bpf/bpf_iter.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,12 @@ static void bpf_iter_link_release(struct bpf_link *link)
397397
iter_link->tinfo->reg_info->detach_target(&iter_link->aux);
398398
}
399399

400+
static int bpf_iter_link_detach(struct bpf_link *link)
401+
{
402+
bpf_iter_link_release(link);
403+
return 0;
404+
}
405+
400406
static void bpf_iter_link_dealloc(struct bpf_link *link)
401407
{
402408
struct bpf_iter_link *iter_link =
@@ -490,6 +496,7 @@ static int bpf_iter_link_fill_link_info(const struct bpf_link *link,
490496

491497
static const struct bpf_link_ops bpf_iter_link_lops = {
492498
.release = bpf_iter_link_release,
499+
.detach = bpf_iter_link_detach,
493500
.dealloc = bpf_iter_link_dealloc,
494501
.update_prog = bpf_iter_link_replace,
495502
.show_fdinfo = bpf_iter_link_show_fdinfo,

kernel/bpf/syscall.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3733,6 +3733,12 @@ static void bpf_perf_link_release(struct bpf_link *link)
37333733
fput(perf_link->perf_file);
37343734
}
37353735

3736+
static int bpf_perf_link_detach(struct bpf_link *link)
3737+
{
3738+
bpf_perf_link_release(link);
3739+
return 0;
3740+
}
3741+
37363742
static void bpf_perf_link_dealloc(struct bpf_link *link)
37373743
{
37383744
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,
40274033

40284034
static const struct bpf_link_ops bpf_perf_link_lops = {
40294035
.release = bpf_perf_link_release,
4036+
.detach = bpf_perf_link_detach,
40304037
.dealloc = bpf_perf_link_dealloc,
40314038
.fill_link_info = bpf_perf_link_fill_link_info,
40324039
.show_fdinfo = bpf_perf_link_show_fdinfo,

0 commit comments

Comments
 (0)