Re: [PATCH v2 bpf-next 10/12] selftests/bpf: merge test_stub.c into testing_helpers.c

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

 



On Tue, Nov 9, 2021 at 6:38 PM Andrii Nakryiko
<andrii.nakryiko@xxxxxxxxx> wrote:
>
> On Tue, Nov 9, 2021 at 5:48 PM Alexei Starovoitov
> <alexei.starovoitov@xxxxxxxxx> wrote:
> >
> > On Wed, Nov 3, 2021 at 3:09 PM Andrii Nakryiko <andrii@xxxxxxxxxx> wrote:
> > >
> > > Move testing prog and object load wrappers (bpf_prog_test_load and
> > > bpf_test_load_program) into testing_helpers.{c,h} and get rid of
> > > otherwise useless test_stub.c. Make testing_helpers.c available to
> > > non-test_progs binaries as well.
> > >
> > > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
> > ...
> > > -int extra_prog_load_log_flags = 0;
> > > -
> > > -int bpf_prog_test_load(const char *file, enum bpf_prog_type type,
> > > -                      struct bpf_object **pobj, int *prog_fd)
> > > -{
> > > -       struct bpf_prog_load_attr attr;
> > > -
> > > -       memset(&attr, 0, sizeof(struct bpf_prog_load_attr));
> > > -       attr.file = file;
> > > -       attr.prog_type = type;
> > > -       attr.expected_attach_type = 0;
> > > -       attr.prog_flags = BPF_F_TEST_RND_HI32;
> > > -       attr.log_level = extra_prog_load_log_flags;
> > > -
> > > -       return bpf_prog_load_xattr(&attr, pobj, prog_fd);
> > > -}
> >
> > > +int extra_prog_load_log_flags = 0;
> > > +
> > > +int bpf_prog_test_load(const char *file, enum bpf_prog_type type,
> > > +                      struct bpf_object **pobj, int *prog_fd)
> > > +{
> > > +       struct bpf_object *obj;
> > > +       struct bpf_program *prog;
> > > +       int err;
> > > +
> > > +       obj = bpf_object__open(file);
> > > +       if (!obj)
> > > +               return -errno;
> > > +
> > > +       prog = bpf_object__next_program(obj, NULL);
> > > +       if (!prog) {
> > > +               err = -ENOENT;
> > > +               goto err_out;
> > > +       }
> > > +
> > > +       if (type != BPF_PROG_TYPE_UNSPEC)
> > > +               bpf_program__set_type(prog, type);
> > > +
> > > +       err = bpf_object__load(obj);
> > > +       if (err)
> > > +               goto err_out;
> > > +
> > > +       *pobj = obj;
> > > +       *prog_fd = bpf_program__fd(prog);
> > > +
> > > +       return 0;
> > > +err_out:
> > > +       bpf_object__close(obj);
> > > +       return err;
> > > +}
> >
> > Andrii,
> > That part of the commit broke verbose output in the test.
> > -v and -vv no longer work for tests that use bpf_prog_test_load()
> > because extra_prog_load_log_flags are ignored.
> >
> > Please fix.
>
> Ah, right, sorry, I should have used bpf_object__load_xattr() and
> passed those extra_prog_load_log_flags to it. I'll fix it.

Thanks. It's no rush.

> How important are BPF_F_TEST_RND_HI32 flags, btw? We need a
> bpf_program__set_extra_flags() to be able to set them, I'll add that
> as well. "extra" because they will be |'d with whatever the flags are
> determined by SEC_DEF().

I think it was useful in the past and recently RND_HI32 caused Martin
an extra day of painful debugging, but in the end, I think, it was
great that it was there.
Martin, pls correct me if I'm misremembering.



[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