> Allow kprobe tracepoint events creation through legacy interface, as the > kprobe dynamic PMUs support, used by default, was only created in v4.17. > > This enables CO.RE support for older kernels. > > Signed-off-by: Rafael David Tinoco <rafaeldtinoco@xxxxxxxxx> Related to: https://github.com/libbpf/libbpf/issues/317 > --- > tools/lib/bpf/libbpf.c | 125 ++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 123 insertions(+), 2 deletions(-) > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index 1e04ce724240..72a22c4d8295 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c [snip] > static int bpf_link__detach_perf_event(struct bpf_link *link) > { > int err; > @@ -10152,6 +10197,12 @@ static int bpf_link__detach_perf_event(struct bpf_link *link) > err = -errno; > > close(link->fd); It needed the perf event fd closure for the ‘kprobe_events’ to allow releasing. > + > + if (link->legacy.name) { > + remove_kprobe_event_legacy(link->legacy.name, link->legacy.retprobe); > + free(link->legacy.name); > + } > + > return libbpf_err(err); > } [snip] Tested with: https://github.com/rafaeldtinoco/portablebpf (w/ CO.RE) in kernels 5.8 and 4.15.