Re: [PATCH bpf-next 2/9] bpf: Move func_models from bpf_struct_ops to bpf_struct_ops_desc
From: Alexei Starovoitov
Date: Wed Nov 27 2024 - 21:43:57 EST
On Wed, Nov 27, 2024 at 11:20 AM Thomas Weißschuh <linux@xxxxxxxxxxxxxx> wrote:
>
> --- a/net/bpf/bpf_dummy_struct_ops.c
> +++ b/net/bpf/bpf_dummy_struct_ops.c
> @@ -129,7 +129,7 @@ extern const struct bpf_link_ops bpf_struct_ops_link_lops;
> int bpf_struct_ops_test_run(struct bpf_prog *prog, const union bpf_attr *kattr,
> union bpf_attr __user *uattr)
> {
> - const struct bpf_struct_ops *st_ops = &bpf_bpf_dummy_ops;
> + static typeof_member(struct bpf_struct_ops_desc, func_models) func_models;
> const struct btf_type *func_proto;
> struct bpf_dummy_ops_test_args *args;
> struct bpf_tramp_links *tlinks = NULL;
> @@ -175,7 +175,7 @@ int bpf_struct_ops_test_run(struct bpf_prog *prog, const union bpf_attr *kattr,
>
> op_idx = prog->expected_attach_type;
> err = bpf_struct_ops_prepare_trampoline(tlinks, link,
> - &st_ops->func_models[op_idx],
> + &func_models[op_idx],
This is sad. You didn't bother running the tests.
Above is producing garbage.
That's why so many BPF CI tests are failing.
Overall I think it's a minimal positive value to constify struct_ops.
Unless other bpf developers see a huge value
I'd prefer to keep the code as-is.
pw-bot: cr