On 06/27/2019 12:15 AM, Andrii Nakryiko wrote: > On Wed, Jun 26, 2019 at 7:25 AM Daniel Borkmann <daniel@xxxxxxxxxxxxx> wrote: [...] >> What this boils down to is that this should get a proper abstraction, e.g. as >> in struct libbpf_event which holds the event object. There should be helper >> functions like libbpf_event_create_{kprobe,uprobe,tracepoint,raw_tracepoint} returning >> such an struct libbpf_event object on success, and a single libbpf_event_destroy() >> that does the event specific teardown. bpf_program__attach_event() can then take >> care of only attaching the program to it. Having an object for this is also more >> extensible than just a fd number. Nice thing is that this can also be completely >> internal to libbpf.c as with struct bpf_program and other abstractions where we >> don't expose the internals in the public header. > > Yeah, I totally agree, I think this is a great idea! I don't > particularly like "event" name, that seems very overloaded term. Do > you mind if I call this "bpf_hook" instead of "libbpf_event"? I've > always thought about these different points in the system to which one > can attach BPF program as hooks exposed from kernel :) > > Would it also make sense to do attaching to non-tracing hooks using > the same mechanism (e.g., all the per-cgroup stuff, sysctl, etc)? Not > sure how people do that today, will check to see how it's done, but I > think nothing should conceptually prevent doing that using the same > abstract bpf_hook way, right? I think if we abstract it this way, then absolutely. If I grok the naming conventions from the README right, then this would be under 'bpf_hook__' prefix. :) Thanks, Daniel