Re: [PATCH bpf-next 5/7] selftest/bpf: Simple test for fentry/fexit

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

 



On Sat, Nov 2, 2019 at 3:04 PM Alexei Starovoitov <ast@xxxxxxxxxx> wrote:
>
> Add simple test for fentry and fexit programs around eth_type_trans.
>
> Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
> ---

LGTM, but please fix formatting.

Acked-by: Andrii Nakryiko <andriin@xxxxxx>

>  .../selftests/bpf/prog_tests/kfree_skb.c      | 37 +++++++++++--
>  tools/testing/selftests/bpf/progs/kfree_skb.c | 52 +++++++++++++++++++
>  2 files changed, 86 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/kfree_skb.c b/tools/testing/selftests/bpf/prog_tests/kfree_skb.c
> index 430b50de1583..d3402261bbae 100644
> --- a/tools/testing/selftests/bpf/prog_tests/kfree_skb.c
> +++ b/tools/testing/selftests/bpf/prog_tests/kfree_skb.c
> @@ -30,15 +30,17 @@ void test_kfree_skb(void)
>                 .file = "./kfree_skb.o",
>         };
>
> +       struct bpf_link *link = NULL, *link_fentry = NULL, *link_fexit = NULL;
> +       struct bpf_program *prog, *fentry, *fexit;
>         struct bpf_object *obj, *obj2 = NULL;
>         struct perf_buffer_opts pb_opts = {};
>         struct perf_buffer *pb = NULL;
> -       struct bpf_link *link = NULL;
> -       struct bpf_map *perf_buf_map;
> -       struct bpf_program *prog;
> +       struct bpf_map *perf_buf_map, *global_data;
>         __u32 duration, retval;
>         int err, pkt_fd, kfree_skb_fd;
>         bool passed = false;
> +       const int zero = 0;
> +       bool test_ok[2];
>
>         err = bpf_prog_load("./test_pkt_access.o", BPF_PROG_TYPE_SCHED_CLS, &obj, &pkt_fd);

too long ;)

>         if (CHECK(err, "prog_load sched cls", "err %d errno %d\n", err, errno))
> @@ -51,9 +53,26 @@ void test_kfree_skb(void)
>         prog = bpf_object__find_program_by_title(obj2, "tp_btf/kfree_skb");
>         if (CHECK(!prog, "find_prog", "prog kfree_skb not found\n"))
>                 goto close_prog;
> +       fentry = bpf_object__find_program_by_title(obj2, "fentry/eth_type_trans");
> +       if (CHECK(!fentry, "find_prog", "prog eth_type_trans not found\n"))
> +               goto close_prog;
> +       fexit = bpf_object__find_program_by_title(obj2, "fexit/eth_type_trans");
> +       if (CHECK(!fexit, "find_prog", "prog eth_type_trans not found\n"))
> +               goto close_prog;
> +
> +       global_data = bpf_object__find_map_by_name(obj2, "kfree_sk.bss");
> +       if (CHECK(!global_data, "find global data", "not found\n"))
> +               goto close_prog;
> +
>         link = bpf_program__attach_raw_tracepoint(prog, NULL);
>         if (CHECK(IS_ERR(link), "attach_raw_tp", "err %ld\n", PTR_ERR(link)))
>                 goto close_prog;
> +       link_fentry = bpf_program__attach_trace(fentry);
> +       if (CHECK(IS_ERR(link_fentry), "attach fentry", "err %ld\n", PTR_ERR(link_fentry)))
> +               goto close_prog;
> +       link_fexit = bpf_program__attach_trace(fexit);
> +       if (CHECK(IS_ERR(link_fexit), "attach fexit", "err %ld\n", PTR_ERR(link_fexit)))

checkpatch.pl?

> +               goto close_prog;
>

[...]



[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