Re: libbpf - why find_program_by_title ?
From: Andrii Nakryiko <hidden>
Date: 2021-10-28 16:56:27
On Thu, Oct 28, 2021 at 5:02 AM Jesper Dangaard Brouer [off-list ref] wrote:
Hi Andrii, The libbpf API bpf_program__title() is getting depricated (which is great BTW). (p.s. Instead use bpf_program__section_name()). Why do we still have bpf_object__find_program_by_title() ? Shouldn't we also deprecate that?
Yes, we should and we plan, see [0]. The only reason why it's not yet marked as deprecated is because there are still a lot of uses of find_program_by_title in selftests and we need to clean that up first. It would be great to get help with that, of course. [0] https://github.com/libbpf/libbpf/issues/292
And introduce bpf_object__find_program_by_section_name().
I didn't plan to because there is (in general) more than one program for the same section name (section names are not unique identifiers for a while now), so which program this API would return: first, last, random? It's just wrong API with wrong assumptions. The right way to go about this is to do a loop over all programs with bpf_object__for_each_program(prog, obj) and compare bpf_program__section_name() explicitly. And then do whatever your application needs to do with every instance of the program with matching section name.
--Jesper