diff options
author | Andrii Nakryiko <andriin@fb.com> | 2020-07-31 20:28:27 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-08-02 05:38:28 +0200 |
commit | 2e49527e52486dac910460b1b3f6fce6e21c6b48 (patch) | |
tree | 49e845274097de42bf2d254945120233936f196a /tools/lib/bpf/bpf.c | |
parent | bpf: Add support for forced LINK_DETACH command (diff) | |
download | linux-2e49527e52486dac910460b1b3f6fce6e21c6b48.tar.xz linux-2e49527e52486dac910460b1b3f6fce6e21c6b48.zip |
libbpf: Add bpf_link detach APIs
Add low-level bpf_link_detach() API. Also add higher-level bpf_link__detach()
one.
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200731182830.286260-3-andriin@fb.com
Diffstat (limited to 'tools/lib/bpf/bpf.c')
-rw-r--r-- | tools/lib/bpf/bpf.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index e1bdf214f75f..eab14c97c15d 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -603,6 +603,16 @@ int bpf_link_create(int prog_fd, int target_fd, return sys_bpf(BPF_LINK_CREATE, &attr, sizeof(attr)); } +int bpf_link_detach(int link_fd) +{ + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.link_detach.link_fd = link_fd; + + return sys_bpf(BPF_LINK_DETACH, &attr, sizeof(attr)); +} + int bpf_link_update(int link_fd, int new_prog_fd, const struct bpf_link_update_opts *opts) { |