Re: bpf: ability to attach freplace to multiple parents

Toke Høiland-Jørgensen
2020-05-12T08:35:06Z

Alexei Starovoitov <alexei.starovoitov@gmail.com> writes:

>> > Currently fentry/fexit/freplace progs have single prog->aux->linked_prog pointer.
>> > It just needs to become a linked list.
>> > The api extension could be like this:
>> > bpf_raw_tp_open(prog_fd, attach_prog_fd, attach_btf_id);
>> > (currently it's just bpf_raw_tp_open(prog_fd))
>> > The same pair of (attach_prog_fd, attach_btf_id) is already passed into prog_load
>> > to hold the linked_prog and its corresponding btf_id.
>> > I'm proposing to extend raw_tp_open with this pair as well to
>> > attach existing fentry/fexit/freplace prog to another target.
>> > Internally the kernel verify that btf of current linked_prog
>> > exactly matches to btf of another requested linked_prog and
>> > if they match it will attach the same prog to two target programs (in case of freplace)
>> > or two kernel functions (in case of fentry/fexit).
>>
>> API-wise this was exactly what I had in mind as well.
>
> perfect!

Hi Alexei

I don't suppose you've had a chance to whip up a patch for this, have
you? :)

-Toke