Re: [PATCH v4 bpf-next 07/22] selftests/bpf: Test for btf_load command.

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

 



On Fri, May 7, 2021 at 8:48 PM Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> From: Alexei Starovoitov <ast@xxxxxxxxxx>
>
> Improve selftest to check that btf_load is working from bpf program.
>
> Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
> ---
>  tools/testing/selftests/bpf/progs/syscall.c | 48 +++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>

[...]

>  SEC("syscall")
>  int bpf_prog(struct args *ctx)
>  {
> @@ -33,6 +73,8 @@ int bpf_prog(struct args *ctx)
>                 .map_type = BPF_MAP_TYPE_HASH,
>                 .key_size = 8,
>                 .value_size = 8,
> +               .btf_key_type_id = 1,
> +               .btf_value_type_id = 2,
>         };
>         static union bpf_attr map_update_attr = { .map_fd = 1, };
>         static __u64 key = 12;
> @@ -43,7 +85,13 @@ int bpf_prog(struct args *ctx)
>         };
>         int ret;
>
> +       ret = btf_load();

Maybe let's move patch #11 (bpf_sys_close() helper) in front of these
selftests and call bpf_sys_close() appropriately on error and (if
success) after map is created?



> +       if (ret < 0)
> +               return ret;
> +
>         map_create_attr.max_entries = ctx->max_entries;
> +       map_create_attr.btf_fd = ret;
> +
>         prog_load_attr.license = (long) license;
>         prog_load_attr.insns = (long) insns;
>         prog_load_attr.log_buf = ctx->log_buf;
> --
> 2.30.2
>



[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