From: Mao Wenan <maowenan@huawei.com>
To: <ast@kernel.org>, <daniel@iogearbox.net>, <kafai@fb.com>,
<songliubraving@fb.com>, <yhs@fb.com>, <andriin@fb.com>,
<john.fastabend@gmail.com>, <kpsingh@chromium.org>
Cc: <netdev@vger.kernel.org>, <bpf@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: [PATCH bpf-next 1/2] bpf: Change error code when ops is NULL
Date: Wed, 22 Apr 2020 16:30:09 +0800 [thread overview]
Message-ID: <20200422083010.28000-2-maowenan@huawei.com> (raw)
In-Reply-To: <20200422083010.28000-1-maowenan@huawei.com>
There is one error printed when use type
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 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index d85f37239540..f67bc063bf75 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -112,9 +112,11 @@ 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);
+ }
if (ops->map_alloc_check) {
err = ops->map_alloc_check(attr);
if (err)
--
2.20.1
next prev parent reply other threads:[~2020-04-22 8:28 UTC|newest]
Thread overview: 8+ 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 ` Mao Wenan [this message]
2020-04-22 9:33 ` [PATCH bpf-next 1/2] bpf: Change error code when ops is NULL Dan Carpenter
2020-04-24 5:10 ` 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=20200422083010.28000-2-maowenan@huawei.com \
--to=maowenan@huawei.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®