From: Geliang Tang <geliang@kernel.org>
To: Alan Maguire <alan.maguire@oracle.com>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Mykola Lysenko <mykolal@fb.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>
Cc: Geliang Tang <tanggeliang@kylinos.cn>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/3] selftests/bpf: Null checks for links in bpf_tcp_ca
Date: Wed, 10 Jul 2024 21:07:40 +0800 [thread overview]
Message-ID: <e04d98fcde8276aced7c9d16a76693566912e53e.camel@kernel.org> (raw)
In-Reply-To: <2f6ee147-2868-493f-bf2e-09d771d2e259@oracle.com>
On Wed, 2024-07-10 at 12:25 +0100, Alan Maguire wrote:
> On 09/07/2024 11:45, Geliang Tang wrote:
> > From: Geliang Tang <tanggeliang@kylinos.cn>
> >
> > Run bpf_tcp_ca selftests (./test_progs -t bpf_tcp_ca) on a
> > Loongarch
> > platform, some "Segmentation fault" errors occur:
> >
> > '''
> > test_dctcp:PASS:bpf_dctcp__open_and_load 0 nsec
> > test_dctcp:FAIL:bpf_map__attach_struct_ops unexpected error: -524
> > #29/1 bpf_tcp_ca/dctcp:FAIL
> > test_cubic:PASS:bpf_cubic__open_and_load 0 nsec
> > test_cubic:FAIL:bpf_map__attach_struct_ops unexpected error: -524
> > #29/2 bpf_tcp_ca/cubic:FAIL
> > test_dctcp_fallback:PASS:dctcp_skel 0 nsec
> > test_dctcp_fallback:PASS:bpf_dctcp__load 0 nsec
> > test_dctcp_fallback:FAIL:dctcp link unexpected error: -524
> > #29/4 bpf_tcp_ca/dctcp_fallback:FAIL
> > test_write_sk_pacing:PASS:open_and_load 0 nsec
> > test_write_sk_pacing:FAIL:attach_struct_ops unexpected error: -524
> > #29/6 bpf_tcp_ca/write_sk_pacing:FAIL
> > test_update_ca:PASS:open 0 nsec
> > test_update_ca:FAIL:attach_struct_ops unexpected error: -524
> > settcpca:FAIL:setsockopt unexpected setsockopt: \
> > actual -1 == expected -1
> > (network_helpers.c:99: errno: No such file or directory) \
> > Failed to call
> > post_socket_cb
> > start_test:FAIL:start_server_str unexpected start_server_str: \
> > actual -1 == expected -1
> > test_update_ca:FAIL:ca1_ca1_cnt unexpected ca1_ca1_cnt: \
> > actual 0 <= expected 0
> > #29/9 bpf_tcp_ca/update_ca:FAIL
> > #29 bpf_tcp_ca:FAIL
> > Caught signal #11!
> > Stack trace:
> > ./test_progs(crash_handler+0x28)[0x5555567ed91c]
> > linux-vdso.so.1(__vdso_rt_sigreturn+0x0)[0x7ffffee408b0]
> > ./test_progs(bpf_link__update_map+0x80)[0x555556824a78]
> > ./test_progs(+0x94d68)[0x5555564c4d68]
> > ./test_progs(test_bpf_tcp_ca+0xe8)[0x5555564c6a88]
> > ./test_progs(+0x3bde54)[0x5555567ede54]
> > ./test_progs(main+0x61c)[0x5555567efd54]
> > /usr/lib64/libc.so.6(+0x22208)[0x7ffff2aaa208]
> > /usr/lib64/libc.so.6(__libc_start_main+0xac)[0x7ffff2aaa30c]
> > ./test_progs(_start+0x48)[0x55555646bca8]
> > Segmentation fault
> > '''
> >
> > This is because BPF trampoline is not implemented on Loongarch yet,
> > "link" returned by bpf_map__attach_struct_ops() is NULL. test_progs
> > crashs when this NULL link passes to bpf_link__update_map(). This
> > patch adds NULL checks for all links in bpf_tcp_ca to fix these
> > errors.
> > If "link" is NULL, goto the newly added label "out" to destroy the
> > skel.
> >
> > v2:
> > - use "goto out" instead of "return" as Eduard suggested.
> >
> > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
>
> Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
>
> Maybe I'm missing it, but I'm not seeing this series on
> patchwork.kernel.org/project/netdevbpf, so we don't have an
> associated
> CI run (the series is in the kselftest patchwork however). Is there
> some
> patchwork bot magic that will do this?
Thanks for your review. I want to do a small update for this patch, so
I changed this set as "Changes Requested". So they are not showed in
patchwork. v2 will be sent soon. I will add your "reviewed-by" tag in
it.
Thanks,
-Geliang
>
> > ---
> > .../selftests/bpf/prog_tests/bpf_tcp_ca.c | 21 +++++++++++++--
> > ----
> > 1 file changed, 15 insertions(+), 6 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
> > b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
> > index d842ff64bc2a..efc1bf2ff7de 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
> > @@ -411,7 +411,8 @@ static void test_update_ca(void)
> > return;
> >
> > link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
> > - ASSERT_OK_PTR(link, "attach_struct_ops");
> > + if (!ASSERT_OK_PTR(link, "attach_struct_ops"))
> > + goto out;
> >
> > do_test(&opts);
> > saved_ca1_cnt = skel->bss->ca1_cnt;
> > @@ -425,6 +426,7 @@ static void test_update_ca(void)
> > ASSERT_GT(skel->bss->ca2_cnt, 0, "ca2_ca2_cnt");
> >
> > bpf_link__destroy(link);
> > +out:
> > tcp_ca_update__destroy(skel);
> > }
> >
> > @@ -447,7 +449,8 @@ static void test_update_wrong(void)
> > return;
> >
> > link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
> > - ASSERT_OK_PTR(link, "attach_struct_ops");
> > + if (!ASSERT_OK_PTR(link, "attach_struct_ops"))
> > + goto out;
> >
> > do_test(&opts);
> > saved_ca1_cnt = skel->bss->ca1_cnt;
> > @@ -460,11 +463,13 @@ static void test_update_wrong(void)
> > ASSERT_GT(skel->bss->ca1_cnt, saved_ca1_cnt,
> > "ca2_ca1_cnt");
> >
> > bpf_link__destroy(link);
> > +out:
> > tcp_ca_update__destroy(skel);
> > }
> >
> > static void test_mixed_links(void)
> > {
> > + struct bpf_link *link = NULL, *link_nl = NULL;
> > struct cb_opts cb_opts = {
> > .cc = "tcp_ca_update",
> > };
> > @@ -473,7 +478,6 @@ static void test_mixed_links(void)
> > .cb_opts = &cb_opts,
> > };
> > struct tcp_ca_update *skel;
> > - struct bpf_link *link, *link_nl;
> > int err;
> >
> > skel = tcp_ca_update__open_and_load();
> > @@ -481,10 +485,12 @@ static void test_mixed_links(void)
> > return;
> >
> > link_nl = bpf_map__attach_struct_ops(skel-
> > >maps.ca_no_link);
> > - ASSERT_OK_PTR(link_nl, "attach_struct_ops_nl");
> > + if (!ASSERT_OK_PTR(link_nl, "attach_struct_ops_nl"))
> > + goto out;
> >
> > link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
> > - ASSERT_OK_PTR(link, "attach_struct_ops");
> > + if (!ASSERT_OK_PTR(link, "attach_struct_ops"))
> > + goto out;
> >
> > do_test(&opts);
> > ASSERT_GT(skel->bss->ca1_cnt, 0, "ca1_ca1_cnt");
> > @@ -492,6 +498,7 @@ static void test_mixed_links(void)
> > err = bpf_link__update_map(link, skel->maps.ca_no_link);
> > ASSERT_ERR(err, "update_map");
> >
> > +out:
> > bpf_link__destroy(link);
> > bpf_link__destroy(link_nl);
> > tcp_ca_update__destroy(skel);
> > @@ -536,7 +543,8 @@ static void test_link_replace(void)
> > bpf_link__destroy(link);
> >
> > link = bpf_map__attach_struct_ops(skel->maps.ca_update_2);
> > - ASSERT_OK_PTR(link, "attach_struct_ops_2nd");
> > + if (!ASSERT_OK_PTR(link, "attach_struct_ops_2nd"))
> > + goto out;
> >
> > /* BPF_F_REPLACE with a wrong old map Fd. It should fail!
> > *
> > @@ -559,6 +567,7 @@ static void test_link_replace(void)
> >
> > bpf_link__destroy(link);
> >
> > +out:
> > tcp_ca_update__destroy(skel);
> > }
> >
next prev parent reply other threads:[~2024-07-10 13:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-09 10:45 [PATCH bpf-next 0/3] BPF selftests misc fixes Geliang Tang
2024-07-09 10:45 ` [PATCH bpf-next 1/3] selftests/bpf: Null checks for links in bpf_tcp_ca Geliang Tang
2024-07-10 11:25 ` Alan Maguire
2024-07-10 13:07 ` Geliang Tang [this message]
2024-07-09 10:45 ` [PATCH bpf-next 2/3] selftests/bpf: Check ASSERT_OK(err) in dummy_st_ops Geliang Tang
2024-07-10 14:01 ` Alan Maguire
2024-07-09 10:45 ` [PATCH bpf-next 3/3] selftests/bpf: Close obj in error paths in xdp_adjust_tail Geliang Tang
2024-07-10 14:54 ` Alan Maguire
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e04d98fcde8276aced7c9d16a76693566912e53e.camel@kernel.org \
--to=geliang@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tanggeliang@kylinos.cn \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox