From: maowenan <maowenan@huawei.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
Network Development <netdev@vger.kernel.org>,
bpf <bpf@vger.kernel.org>, <kernel-janitors@vger.kernel.org>,
Dan Carpenter <dan.carpenter@oracle.com>,
Andrii Nakryiko <andrii.nakryiko@gmail.com>
Subject: Re: [PATCH bpf-next v2 1/2] bpf: Change error code when ops is NULL
Date: Thu, 23 Apr 2020 14:25:22 +0800 [thread overview]
Message-ID: <bd36c161-8831-1f61-1531-063723a8d8c2@huawei.com> (raw)
In-Reply-To: <CAADnVQLfqLBzsjK0KddZM7WTL3unzWw+v18L0pw8HQnWsEVUzA@mail.gmail.com>
On 2020/4/23 13:43, Alexei Starovoitov wrote:
> On Wed, Apr 22, 2020 at 8:31 PM Mao Wenan <maowenan@huawei.com> wrote:
>>
>> There is one error printed when use BPF_MAP_TYPE_SOCKMAP to create map:
>> libbpf: failed to create map (name: 'sock_map'): Invalid argument(-22)
>>
>> This is because CONFIG_BPF_STREAM_PARSER is not set, and
>> bpf_map_types[type] return invalid ops. It is not clear to show the
>> cause of config missing with return code -EINVAL, so add pr_warn() and
>> change error code to describe the reason.
>>
>> Signed-off-by: Mao Wenan <maowenan@huawei.com>
>> ---
>> kernel/bpf/syscall.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
>> index d85f37239540..7686778457c7 100644
>> --- a/kernel/bpf/syscall.c
>> +++ b/kernel/bpf/syscall.c
>> @@ -112,9 +112,10 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr)
>> return ERR_PTR(-EINVAL);
>> type = array_index_nospec(type, ARRAY_SIZE(bpf_map_types));
>> ops = bpf_map_types[type];
>> - if (!ops)
>> - return ERR_PTR(-EINVAL);
>> -
>> + if (!ops) {
>> + pr_warn("map type %d not supported or kernel config not opened\n", type);
>> + return ERR_PTR(-EOPNOTSUPP);
>> + }
>
> I don't think users will like it when kernel spams dmesg.
> If you need this level of verbosity please teach consumer of libbpf to
> print them.
> It's not a job of libbpf either.
thanks for reviw, so is it better to delete redundant pr_warn()?
>
> .
>
next prev parent reply other threads:[~2020-04-23 6:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-22 8:30 [PATCH bpf-next 0/2] Change return code if failed to load object Mao Wenan
2020-04-22 8:30 ` [PATCH bpf-next 1/2] bpf: Change error code when ops is NULL Mao Wenan
2020-04-22 9:33 ` Dan Carpenter
2020-04-23 3:33 ` [PATCH bpf-next v2 0/2] Change return code if failed to load object Mao Wenan
2020-04-23 3:33 ` [PATCH bpf-next v2 1/2] bpf: Change error code when ops is NULL Mao Wenan
2020-04-23 5:43 ` Alexei Starovoitov
2020-04-23 6:25 ` maowenan [this message]
2020-04-23 16:07 ` Alexei Starovoitov
2020-04-24 1:13 ` maowenan
2020-04-23 3:33 ` [PATCH bpf-next v2 2/2] libbpf: Return err if bpf_object__load failed Mao Wenan
2020-04-24 5:10 ` [PATCH bpf-next 1/2] bpf: Change error code when ops is NULL kbuild test robot
2020-04-24 5:18 ` kbuild test robot
2020-04-30 2:04 ` kbuild test robot
2020-04-22 8:30 ` [PATCH bpf-next 2/2] libbpf: Return err if bpf_object__load failed Mao Wenan
2020-04-22 23:27 ` Andrii Nakryiko
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=bd36c161-8831-1f61-1531-063723a8d8c2@huawei.com \
--to=maowenan@huawei.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dan.carpenter@oracle.com \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kpsingh@chromium.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/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;
as well as URLs for NNTP newsgroup(s).