bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* libbpf API: dynamically load(/unload/attach/detach) bpf programs question
@ 2022-01-11 12:33 Yaniv Agman
  2022-01-11 20:58 ` Andrii Nakryiko
  0 siblings, 1 reply; 5+ messages in thread
From: Yaniv Agman @ 2022-01-11 12:33 UTC (permalink / raw)
  To: bpf, Andrii Nakryiko; +Cc: michael.tcherniack

Hello!

I noticed that the bpf_program__load() API was deprecated since libbpf
0.6 saying that bpf_object__load() should be used instead.
This, however, doesn't seem to fit our use case of loading multiple
bpf programs (that also share the same maps) from one bpf object (elf
file), then unloading and loading them dynamically according to some
given needs.
I'm not sure it is possible to load one specific program from the bpf
object using bpf_object__load() API - is it?

Another question with the same context -
If I understand correctly, the purpose of detach is to "prevent
execution of a previously attached program from any future events"
(https://facebookmicrosites.github.io/bpf/blog/2018/08/31/object-lifetime.html),
which seems like something that I would want to do if I just wanted to
temporarily stop an event from triggering the program. But then I ask
myself - what is the meaning of detaching a link (and not
bpf_link__destroy() it) if there is no way to attach it back (without
re-creating the link object)? I don't see any function named
bpf_link__attach() that would do such a thing, or any other function
in libbpf API that can do something similar, am I right?
Also, It seems that using bpf_link__detach() does not fit all link
types. For example, when attaching a (non legacy) kprobe, detaching it
should probably happen using PERF_EVENT_IOC_DISABLE and not through
sys_bpf(BPF_LINK_DETACH), shouldn't it?

And one last question:
When using bpf_program__unload() on a program that is already
attached, should we first call bpf_link__detach() or does the kernel
already take care of this?

Thanks,
Yaniv

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-17  6:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 12:33 libbpf API: dynamically load(/unload/attach/detach) bpf programs question Yaniv Agman
2022-01-11 20:58 ` Andrii Nakryiko
2022-01-12 10:42   ` Yaniv Agman
2022-01-14 20:03     ` Andrii Nakryiko
2022-01-17  6:57       ` Yaniv Agman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).