lkml.org 
[lkml]   [2020]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH bpf-next 1/2] bpf: Change error code when ops is NULL
Date
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
\
 
 \ /
  Last update: 2020-04-22 10:29    [W:0.148 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site