On 5/3/23 3:53 PM, Aditi Ghag wrote:
This commit adds the ability to filter kfuncs to certain BPF program types, and thereby limits bpf_sock_destroy kfunc to progras with attach
s/progras/program/
type 'BPF_TRACE_ITER'. Previous patches introduced 'bpf_sock_destroy kfunc' that can only be called from BPF (sockets) iterator type programs. The reason being, the kfunc requires lock_sock to be done from the BPF context prior to calling the kfunc. To that end, the patch adds a callback filter to 'struct btf_kfunc_id_set'. The filter has access to the prog construct including other properties of the prog. For the bpf_sock_destroy case, the `expected_attached_type` property of a prog construct is used to allow access to the kfunc in the provided callback filter.
Please also cc "David Vernet <void@xxxxxxxxxxxxx>" in the next respin.