[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQLfqLBzsjK0KddZM7WTL3unzWw+v18L0pw8HQnWsEVUzA@mail.gmail.com>
Date: Wed, 22 Apr 2020 22:43:24 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Mao Wenan <maowenan@...wei.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>,
KP Singh <kpsingh@...omium.org>,
Network Development <netdev@...r.kernel.org>,
bpf <bpf@...r.kernel.org>, kernel-janitors@...r.kernel.org,
Dan Carpenter <dan.carpenter@...cle.com>,
Andrii Nakryiko <andrii.nakryiko@...il.com>
Subject: Re: [PATCH bpf-next v2 1/2] bpf: Change error code when ops is NULL
On Wed, Apr 22, 2020 at 8:31 PM Mao Wenan <maowenan@...wei.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@...wei.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.
Powered by blists - more mailing lists