Re: [RFC PATCH bpf-next 2/7] bpf: Add enum bpf_capability

From: Song Liu
Date: Thu Jan 16 2025 - 17:57:01 EST


On Thu, Jan 16, 2025 at 11:43 AM Juntong Deng <juntong.deng@xxxxxxxxxxx> wrote:
>
> This patch adds enum bpf_capability, currently only for proof
> of concept.
>
> Signed-off-by: Juntong Deng <juntong.deng@xxxxxxxxxxx>
> ---
> include/uapi/linux/bpf.h | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 2acf9b336371..94c21d4eb786 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -1058,6 +1058,21 @@ enum bpf_prog_type {
> __MAX_BPF_PROG_TYPE
> };
>
> +enum bpf_capability {
> + BPF_CAP_NONE = 0,
> + BPF_CAP_TEST_1,
> + BPF_CAP_TEST_2,
> + BPF_CAP_TEST_3,
> + BPF_CAP_SCX_ANY,
> + BPF_CAP_SCX_KF_UNLOCKED,
> + BPF_CAP_SCX_KF_CPU_RELEASE,
> + BPF_CAP_SCX_KF_DISPATCH,
> + BPF_CAP_SCX_KF_ENQUEUE,
> + BPF_CAP_SCX_KF_SELECT_CPU,
> + BPF_CAP_SCX_KF_REST,
> + __MAX_BPF_CAP
> +};
> +

I don't think we need to handle these in the core verifier.
Instead, we can put the same logic in:

fetch_kfunc_meta =>
btf_kfunc_id_set_contains =>
__btf_kfunc_id_set_contains =>
hook_filter->filters[i]()

Thanks,
Song

> enum bpf_attach_type {
> BPF_CGROUP_INET_INGRESS,
> BPF_CGROUP_INET_EGRESS,
> --
> 2.39.5
>