[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzZg7rSaRJ5GkcEoOvV2TKTA5etsr0xn_dYMtQL7Ly-w_w@mail.gmail.com>
Date: Wed, 16 Sep 2020 13:44:55 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Toke Høiland-Jørgensen <toke@...hat.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
Andrii Nakryiko <andriin@...com>,
John Fastabend <john.fastabend@...il.com>,
Jiri Olsa <jolsa@...hat.com>,
Eelco Chaudron <echaudro@...hat.com>,
KP Singh <kpsingh@...omium.org>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH bpf-next v5 8/8] selftests/bpf: Adding test for arg
dereference in extension trace
On Tue, Sep 15, 2020 at 5:50 PM Toke Høiland-Jørgensen <toke@...hat.com> wrote:
>
> From: Jiri Olsa <jolsa@...nel.org>
>
> Adding test that setup following program:
>
> SEC("classifier/test_pkt_md_access")
> int test_pkt_md_access(struct __sk_buff *skb)
>
> with its extension:
>
> SEC("freplace/test_pkt_md_access")
> int test_pkt_md_access_new(struct __sk_buff *skb)
>
> and tracing that extension with:
>
> SEC("fentry/test_pkt_md_access_new")
> int BPF_PROG(fentry, struct sk_buff *skb)
>
> The test verifies that the tracing program can
> dereference skb argument properly.
>
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> Signed-off-by: Toke Høiland-Jørgensen <toke@...hat.com>
> ---
Looks good, with a minor CHECK() complaint below.
Acked-by: Andrii Nakryiko <andriin@...com>
> tools/testing/selftests/bpf/prog_tests/trace_ext.c | 113 ++++++++++++++++++++
> tools/testing/selftests/bpf/progs/test_trace_ext.c | 18 +++
> .../selftests/bpf/progs/test_trace_ext_tracing.c | 25 ++++
> 3 files changed, 156 insertions(+)
> create mode 100644 tools/testing/selftests/bpf/prog_tests/trace_ext.c
> create mode 100644 tools/testing/selftests/bpf/progs/test_trace_ext.c
> create mode 100644 tools/testing/selftests/bpf/progs/test_trace_ext_tracing.c
>
[...]
> + err = test_trace_ext_tracing__attach(skel_trace);
> + if (CHECK(err, "setup", "tracing/test_pkt_md_access_new attach failed: %d\n", err))
> + goto cleanup;
> +
> + /* trigger the test */
> + err = bpf_prog_test_run(pkt_fd, 1, &pkt_v4, sizeof(pkt_v4),
> + NULL, NULL, &retval, &duration);
> + CHECK(err || retval, "",
please don't use empty string here
> + "err %d errno %d retval %d duration %d\n",
> + err, errno, retval, duration);
who and why cares about duration here?..
> +
> + bss_ext = skel_ext->bss;
> + bss_trace = skel_trace->bss;
> +
> + len = bss_ext->ext_called;
> +
> + CHECK(bss_ext->ext_called == 0,
> + "check", "failed to trigger freplace/test_pkt_md_access\n");
> + CHECK(bss_trace->fentry_called != len,
> + "check", "failed to trigger fentry/test_pkt_md_access_new\n");
> + CHECK(bss_trace->fexit_called != len,
> + "check", "failed to trigger fexit/test_pkt_md_access_new\n");
> +
> +cleanup:
> + test_trace_ext_tracing__destroy(skel_trace);
> + test_trace_ext__destroy(skel_ext);
> + test_pkt_md_access__destroy(skel_pkt);
> +}
[...]
Powered by blists - more mailing lists