[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <A0B730F5-758F-4F28-9543-4ED08F0BDECB@fb.com>
Date: Tue, 30 Mar 2021 01:23:15 +0000
From: Song Liu <songliubraving@...com>
To: Jiri Olsa <jolsa@...nel.org>
CC: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andriin@...com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"bpf@...r.kernel.org" <bpf@...r.kernel.org>,
Martin Lau <kafai@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...omium.org>,
Toke Høiland-Jørgensen <toke@...hat.com>
Subject: Re: [RFC PATCH bpf-next 2/4] selftests/bpf: Add re-attach test to
fentry_test
> On Mar 28, 2021, at 4:26 AM, Jiri Olsa <jolsa@...nel.org> wrote:
>
> Adding the test to re-attach (detach/attach again) tracing
> fentry programs, plus check that already linked program can't
> be attached again.
>
> Fixing the number of check-ed results, which should be 8.
>
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
>
[...]
> +
> +void test_fentry_test(void)
> +{
> + struct fentry_test *fentry_skel = NULL;
> + struct bpf_link *link;
> + int err;
> +
> + fentry_skel = fentry_test__open_and_load();
> + if (CHECK(!fentry_skel, "fentry_skel_load", "fentry skeleton failed\n"))
> + goto cleanup;
> +
> + err = fentry_test__attach(fentry_skel);
> + if (CHECK(err, "fentry_attach", "fentry attach failed: %d\n", err))
> + goto cleanup;
> +
> + err = fentry_test(fentry_skel);
> + if (CHECK(err, "fentry_test", "fentry test failed: %d\n", err))
> + goto cleanup;
> +
> + fentry_test__detach(fentry_skel);
> +
> + /* Re-attach and test again */
> + err = fentry_test__attach(fentry_skel);
> + if (CHECK(err, "fentry_attach", "fentry re-attach failed: %d\n", err))
> + goto cleanup;
> +
> + link = bpf_program__attach(fentry_skel->progs.test1);
> + if (CHECK(!IS_ERR(link), "attach_fentry re-attach without detach",
> + "err: %ld\n", PTR_ERR(link)))
nit: I guess we shouldn't print PTR_ERR(link) when link is not an error code?
This shouldn't break though.
Thanks,
Song
> + goto cleanup;
> +
> + err = fentry_test(fentry_skel);
> + CHECK(err, "fentry_test", "fentry test failed: %d\n", err);
> +
> cleanup:
> fentry_test__destroy(fentry_skel);
> }
> --
> 2.30.2
>
Powered by blists - more mailing lists