Re: [PATCH bpf-next v1 2/8] libbpf: tie struct_ops programs to kernel BTF ids, not to local ids

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 28, 2024 at 3:31 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
>
> On Wed, 2024-02-28 at 15:28 -0800, Andrii Nakryiko wrote:
> [...]
>
> > > @@ -1134,8 +1134,27 @@ static int bpf_map__init_kern_struct_ops(struct bpf_map *map)
> > >
> > >                         if (mod_btf)
> > >                                 prog->attach_btf_obj_fd = mod_btf->fd;
> > > -                       prog->attach_btf_id = kern_type_id;
> > > -                       prog->expected_attach_type = kern_member_idx;
> > > +
> > > +                       /* if we haven't yet processed this BPF program, record proper
> > > +                        * attach_btf_id and member_idx
> > > +                        */
> > > +                       if (!prog->attach_btf_id) {
> > > +                               prog->attach_btf_id = kern_type_id;
> > > +                               prog->expected_attach_type = kern_member_idx;
> > > +                       }
> > > +
> > > +                       /* struct_ops BPF prog can be re-used between multiple
> > > +                        * .struct_ops & .struct_ops.link as long as it's the
> > > +                        * same struct_ops struct definition and the same
> > > +                        * function pointer field
> > > +                        */
> > > +                       if (prog->attach_btf_id != kern_type_id ||
> > > +                           prog->expected_attach_type != kern_member_idx) {
> > > +                               pr_warn("struct_ops reloc %s: cannot use prog %s in sec %s with type %u attach_btf_id %u expected_attach_type %u for func ptr %s\n",
> >
> > Martin already pointed out s/reloc/init_kern/, but I also find "cannot
> > use prog" a bit too unactionable. Maybe "invalid reuse of prog"?
> > "reuse" is the key here to point out that this program is used at
> > least twice, and that in some incompatible way?
>
> Ok, I'll change the wording.
> And split the line despite the coding standards.

please don't split format strings, it makes grepping harder





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux