2020-04-22 08:30:09

by Mao Wenan

[permalink] [raw]
Subject: [PATCH bpf-next 0/2] Change return code if failed to load object

The first patch change return code from -EINVAL to -EOPNOTSUPP,
the second patch quote the err value returned by bpf_object__load().

Mao Wenan (2):
bpf: Change error code when ops is NULL
libbpf: Return err if bpf_object__load failed

kernel/bpf/syscall.c | 8 +++++---
tools/lib/bpf/libbpf.c | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)

--
2.20.1


2020-04-22 08:30:12

by Mao Wenan

[permalink] [raw]
Subject: [PATCH bpf-next 1/2] bpf: Change error code when ops is NULL

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 <[email protected]>
---
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

2020-04-22 08:31:33

by Mao Wenan

[permalink] [raw]
Subject: [PATCH bpf-next 2/2] libbpf: Return err if bpf_object__load failed

bpf_object__load() has various return code, when
it failed to load object, it must return err instead
of return -EINVAL.

Signed-off-by: Mao Wenan <[email protected]>
---
tools/lib/bpf/libbpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 8f480e29a6b0..8e1dc6980fac 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -7006,7 +7006,7 @@ int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,
err = bpf_object__load(obj);
if (err) {
bpf_object__close(obj);
- return -EINVAL;
+ return err;
}

*pobj = obj;
--
2.20.1

2020-04-22 09:36:15

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH bpf-next 1/2] bpf: Change error code when ops is NULL

On Wed, Apr 22, 2020 at 04:30:09PM +0800, Mao Wenan wrote:
> 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.

Since you're going to have to redo the commit any way, maybe you should
put the line breaks at 72 characters. I think you're using 65 character
line breaks, but that's only for the Subject.

>
> Signed-off-by: Mao Wenan <[email protected]>
> ---
> 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);

This pr_warn() will be badly formatted in dmesg because of the new line
and the tabs. I tried to add a checkpatch.pl warning for this but maybe
it only works with -f?...

regards,
dan carpenter

2020-04-22 23:28:35

by Andrii Nakryiko

[permalink] [raw]
Subject: Re: [PATCH bpf-next 2/2] libbpf: Return err if bpf_object__load failed

On Wed, Apr 22, 2020 at 1:30 AM Mao Wenan <[email protected]> wrote:
>
> bpf_object__load() has various return code, when
> it failed to load object, it must return err instead
> of return -EINVAL.
>
> Signed-off-by: Mao Wenan <[email protected]>
> ---

This patch looks good. The other one in this series - not so sure..

Acked-by: Andrii Nakryiko <[email protected]>

> tools/lib/bpf/libbpf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 8f480e29a6b0..8e1dc6980fac 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -7006,7 +7006,7 @@ int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,
> err = bpf_object__load(obj);
> if (err) {
> bpf_object__close(obj);
> - return -EINVAL;
> + return err;
> }
>
> *pobj = obj;
> --
> 2.20.1
>

2020-04-24 05:22:36

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH bpf-next 1/2] bpf: Change error code when ops is NULL

Hi Mao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]
[also build test ERROR on bpf/master net/master net-next/master v5.7-rc2 next-20200423]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Mao-Wenan/Change-return-code-if-failed-to-load-object/20200424-025339
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=sh

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <[email protected]>

All error/warnings (new ones prefixed by >>):

2452 | static const struct bpf_link_ops bpf_raw_tp_lops = {
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2256:34: note: previous declaration of 'bpf_raw_tp_lops' was here
2256 | static const struct bpf_link_ops bpf_raw_tp_lops;
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2453:13: error: initializer element is not constant
2453 | .release = bpf_raw_tp_link_release,
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2453:13: note: (near initialization for 'bpf_raw_tp_lops.release')
kernel/bpf/syscall.c:2454:13: error: initializer element is not constant
2454 | .dealloc = bpf_raw_tp_link_dealloc,
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2454:13: note: (near initialization for 'bpf_raw_tp_lops.dealloc')
kernel/bpf/syscall.c:2459:12: error: invalid storage class for function 'bpf_raw_tracepoint_open'
2459 | static int bpf_raw_tracepoint_open(const union bpf_attr *attr)
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2546:12: error: invalid storage class for function 'bpf_prog_attach_check_attach_type'
2546 | static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2564:1: error: invalid storage class for function 'attach_type_to_prog_type'
2564 | attach_type_to_prog_type(enum bpf_attach_type attach_type)
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2612:12: error: invalid storage class for function 'bpf_prog_attach'
2612 | static int bpf_prog_attach(const union bpf_attr *attr)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2671:12: error: invalid storage class for function 'bpf_prog_detach'
2671 | static int bpf_prog_detach(const union bpf_attr *attr)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2706:12: error: invalid storage class for function 'bpf_prog_query'
2706 | static int bpf_prog_query(const union bpf_attr *attr,
| ^~~~~~~~~~~~~~
kernel/bpf/syscall.c:2747:12: error: invalid storage class for function 'bpf_prog_test_run'
2747 | static int bpf_prog_test_run(const union bpf_attr *attr,
| ^~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2779:12: error: invalid storage class for function 'bpf_obj_get_next_id'
2779 | static int bpf_obj_get_next_id(const union bpf_attr *attr,
| ^~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2824:12: error: invalid storage class for function 'bpf_prog_get_fd_by_id'
2824 | static int bpf_prog_get_fd_by_id(const union bpf_attr *attr)
| ^~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2849:12: error: invalid storage class for function 'bpf_map_get_fd_by_id'
2849 | static int bpf_map_get_fd_by_id(const union bpf_attr *attr)
| ^~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c: In function 'bpf_map_get_fd_by_id':
kernel/bpf/syscall.c:2870:9: error: implicit declaration of function '__bpf_map_inc_not_zero'; did you mean 'bpf_map_inc_not_zero'? [-Werror=implicit-function-declaration]
2870 | map = __bpf_map_inc_not_zero(map, true);
| ^~~~~~~~~~~~~~~~~~~~~~
| bpf_map_inc_not_zero
kernel/bpf/syscall.c:2870:7: warning: assignment to 'struct bpf_map *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
2870 | map = __bpf_map_inc_not_zero(map, true);
| ^
kernel/bpf/syscall.c: In function 'find_and_alloc_map':
kernel/bpf/syscall.c:2885:30: error: invalid storage class for function 'bpf_map_from_imm'
2885 | static const struct bpf_map *bpf_map_from_imm(const struct bpf_prog *prog,
| ^~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2909:25: error: invalid storage class for function 'bpf_insn_prepare_dump'
2909 | static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
| ^~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2953:12: error: invalid storage class for function 'set_info_rec_size'
2953 | static int set_info_rec_size(struct bpf_prog_info *info)
| ^~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:2984:12: error: invalid storage class for function 'bpf_prog_get_info_by_fd'
2984 | static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3260:12: error: invalid storage class for function 'bpf_map_get_info_by_fd'
3260 | static int bpf_map_get_info_by_fd(struct bpf_map *map,
| ^~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3303:12: error: invalid storage class for function 'bpf_btf_get_info_by_fd'
3303 | static int bpf_btf_get_info_by_fd(struct btf *btf,
| ^~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3320:12: error: invalid storage class for function 'bpf_obj_get_info_by_fd'
3320 | static int bpf_obj_get_info_by_fd(const union bpf_attr *attr,
| ^~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3351:12: error: invalid storage class for function 'bpf_btf_load'
3351 | static int bpf_btf_load(const union bpf_attr *attr)
| ^~~~~~~~~~~~
kernel/bpf/syscall.c:3364:12: error: invalid storage class for function 'bpf_btf_get_fd_by_id'
3364 | static int bpf_btf_get_fd_by_id(const union bpf_attr *attr)
| ^~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3375:12: error: invalid storage class for function 'bpf_task_fd_query_copy'
3375 | static int bpf_task_fd_query_copy(const union bpf_attr *attr,
| ^~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3424:12: error: invalid storage class for function 'bpf_task_fd_query'
3424 | static int bpf_task_fd_query(const union bpf_attr *attr,
| ^~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3519:12: error: invalid storage class for function 'bpf_map_do_batch'
3519 | static int bpf_map_do_batch(const union bpf_attr *attr,
| ^~~~~~~~~~~~~~~~
kernel/bpf/syscall.c: In function 'bpf_map_do_batch':
kernel/bpf/syscall.c:3538:8: error: implicit declaration of function 'map_get_sys_perms' [-Werror=implicit-function-declaration]
3538 | !(map_get_sys_perms(map, f) & FMODE_CAN_READ)) {
| ^~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c: In function 'find_and_alloc_map':
kernel/bpf/syscall.c:3564:12: error: invalid storage class for function 'link_create'
3564 | static int link_create(union bpf_attr *attr)
| ^~~~~~~~~~~
kernel/bpf/syscall.c:3611:12: error: invalid storage class for function 'link_update'
3611 | static int link_update(union bpf_attr *attr)
| ^~~~~~~~~~~
In file included from kernel/bpf/syscall.c:8:
>> include/linux/syscalls.h:152:33: error: redeclaration of '__syscall_meta__bpf' with no linkage
152 | static struct syscall_metadata __syscall_meta_##sname; \
| ^~~~~~~~~~~~~~~
>> include/linux/syscalls.h:175:2: note: in expansion of macro 'SYSCALL_TRACE_EXIT_EVENT'
175 | SYSCALL_TRACE_EXIT_EVENT(sname); \
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/syscalls.h:224:2: note: in expansion of macro 'SYSCALL_METADATA'
224 | SYSCALL_METADATA(sname, x, __VA_ARGS__) \
| ^~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:136:33: note: previous declaration of '__syscall_meta__bpf' was here
136 | static struct syscall_metadata __syscall_meta_##sname; \
| ^~~~~~~~~~~~~~~
>> include/linux/syscalls.h:174:2: note: in expansion of macro 'SYSCALL_TRACE_ENTER_EVENT'
174 | SYSCALL_TRACE_ENTER_EVENT(sname); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/syscalls.h:224:2: note: in expansion of macro 'SYSCALL_METADATA'
224 | SYSCALL_METADATA(sname, x, __VA_ARGS__) \
| ^~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:152:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
152 | static struct syscall_metadata __syscall_meta_##sname; \
| ^~~~~~
>> include/linux/syscalls.h:175:2: note: in expansion of macro 'SYSCALL_TRACE_EXIT_EVENT'
175 | SYSCALL_TRACE_EXIT_EVENT(sname); \
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/syscalls.h:224:2: note: in expansion of macro 'SYSCALL_METADATA'
224 | SYSCALL_METADATA(sname, x, __VA_ARGS__) \
| ^~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:177:4: error: redeclaration of '__syscall_meta__bpf' with no linkage
177 | __syscall_meta_##sname = { \
| ^~~~~~~~~~~~~~~
>> include/linux/syscalls.h:224:2: note: in expansion of macro 'SYSCALL_METADATA'
224 | SYSCALL_METADATA(sname, x, __VA_ARGS__) \
| ^~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:152:33: note: previous declaration of '__syscall_meta__bpf' was here
152 | static struct syscall_metadata __syscall_meta_##sname; \
| ^~~~~~~~~~~~~~~
>> include/linux/syscalls.h:175:2: note: in expansion of macro 'SYSCALL_TRACE_EXIT_EVENT'
175 | SYSCALL_TRACE_EXIT_EVENT(sname); \
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/syscalls.h:224:2: note: in expansion of macro 'SYSCALL_METADATA'
224 | SYSCALL_METADATA(sname, x, __VA_ARGS__) \
| ^~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:176:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
176 | static struct syscall_metadata __used \
| ^~~~~~
>> include/linux/syscalls.h:224:2: note: in expansion of macro 'SYSCALL_METADATA'
224 | SYSCALL_METADATA(sname, x, __VA_ARGS__) \
| ^~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:38: warning: 'alias' attribute ignored [-Wattributes]
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~
include/linux/syscalls.h:116:25: note: in definition of macro '__SC_DECL'
116 | #define __SC_DECL(t, a) t a
| ^
include/linux/syscalls.h:110:35: note: in expansion of macro '__MAP2'
110 | #define __MAP3(m,t,a,...) m(t,a), __MAP2(m,__VA_ARGS__)
| ^~~~~~
include/linux/syscalls.h:114:22: note: in expansion of macro '__MAP3'
114 | #define __MAP(n,...) __MAP##n(__VA_ARGS__)
| ^~~~~
include/linux/syscalls.h:239:28: note: in expansion of macro '__MAP'
239 | asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
| ^~~~~
include/linux/syscalls.h:225:2: note: in expansion of macro '__SYSCALL_DEFINEx'
225 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:239:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
239 | asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
| ^~~~
include/linux/syscalls.h:225:2: note: in expansion of macro '__SYSCALL_DEFINEx'
225 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:242:21: error: invalid storage class for function '__do_sys_bpf'
242 | static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
| ^~~~~~~~
include/linux/syscalls.h:225:2: note: in expansion of macro '__SYSCALL_DEFINEx'
225 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:242:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
242 | static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
| ^~~~~~
include/linux/syscalls.h:225:2: note: in expansion of macro '__SYSCALL_DEFINEx'
225 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:244:18: error: static declaration of '__se_sys_bpf' follows non-static declaration
244 | asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
| ^~~~~~~~
include/linux/syscalls.h:225:2: note: in expansion of macro '__SYSCALL_DEFINEx'
225 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:243:18: note: previous declaration of '__se_sys_bpf' was here
243 | asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
| ^~~~~~~~
include/linux/syscalls.h:225:2: note: in expansion of macro '__SYSCALL_DEFINEx'
225 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
216 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:3661:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3661 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c: In function '__se_sys_bpf':
include/linux/syscalls.h:246:14: error: implicit declaration of function '__do_sys_bpf'; did you mean '__se_sys_bpf'? [-Werror=implicit-function-declaration]
246 | long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
| ^~~~~~~~
include/linux/syscalls.h:225:2: note: in expansion of macro '__SYSCALL_DEFINEx'
225 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'

vim +/__syscall_meta__bpf +152 include/linux/syscalls.h

8f0820183056ad2 Steven Rostedt 2010-04-20 134
fb34a08c3469b2b Jason Baron 2009-08-10 135 #define SYSCALL_TRACE_ENTER_EVENT(sname) \
3d56e331b653767 Steven Rostedt 2011-02-02 136 static struct syscall_metadata __syscall_meta_##sname; \
2425bcb9240f8c9 Steven Rostedt (Red Hat 2015-05-05 137) static struct trace_event_call __used \
fb34a08c3469b2b Jason Baron 2009-08-10 138 event_enter_##sname = { \
2239291aeb0379f Steven Rostedt 2010-04-21 139 .class = &event_class_syscall_enter, \
abb43f6998eb646 Mathieu Desnoyers 2014-04-09 140 { \
abb43f6998eb646 Mathieu Desnoyers 2014-04-09 141 .name = "sys_enter"#sname, \
abb43f6998eb646 Mathieu Desnoyers 2014-04-09 142 }, \
80decc70afc57c8 Steven Rostedt 2010-04-23 143 .event.funcs = &enter_syscall_print_funcs, \
31c16b13349970b Lai Jiangshan 2009-12-01 144 .data = (void *)&__syscall_meta_##sname,\
f4d5c029bd6731b Lai Jiangshan 2011-01-26 145 .flags = TRACE_EVENT_FL_CAP_ANY, \
53cf810b1934f08 Frederic Weisbecker 2010-11-18 146 }; \
2425bcb9240f8c9 Steven Rostedt (Red Hat 2015-05-05 147) static struct trace_event_call __used \
e4a9ea5ee7c8812 Steven Rostedt 2011-01-27 148 __attribute__((section("_ftrace_events"))) \
f4d5c029bd6731b Lai Jiangshan 2011-01-26 149 *__event_enter_##sname = &event_enter_##sname;
fb34a08c3469b2b Jason Baron 2009-08-10 150
fb34a08c3469b2b Jason Baron 2009-08-10 151 #define SYSCALL_TRACE_EXIT_EVENT(sname) \
3d56e331b653767 Steven Rostedt 2011-02-02 @152 static struct syscall_metadata __syscall_meta_##sname; \
2425bcb9240f8c9 Steven Rostedt (Red Hat 2015-05-05 153) static struct trace_event_call __used \
fb34a08c3469b2b Jason Baron 2009-08-10 154 event_exit_##sname = { \
2239291aeb0379f Steven Rostedt 2010-04-21 155 .class = &event_class_syscall_exit, \
abb43f6998eb646 Mathieu Desnoyers 2014-04-09 156 { \
abb43f6998eb646 Mathieu Desnoyers 2014-04-09 157 .name = "sys_exit"#sname, \
abb43f6998eb646 Mathieu Desnoyers 2014-04-09 158 }, \
80decc70afc57c8 Steven Rostedt 2010-04-23 159 .event.funcs = &exit_syscall_print_funcs, \
31c16b13349970b Lai Jiangshan 2009-12-01 160 .data = (void *)&__syscall_meta_##sname,\
f4d5c029bd6731b Lai Jiangshan 2011-01-26 161 .flags = TRACE_EVENT_FL_CAP_ANY, \
53cf810b1934f08 Frederic Weisbecker 2010-11-18 162 }; \
2425bcb9240f8c9 Steven Rostedt (Red Hat 2015-05-05 163) static struct trace_event_call __used \
e4a9ea5ee7c8812 Steven Rostedt 2011-01-27 164 __attribute__((section("_ftrace_events"))) \
f4d5c029bd6731b Lai Jiangshan 2011-01-26 165 *__event_exit_##sname = &event_exit_##sname;
fb34a08c3469b2b Jason Baron 2009-08-10 166
99e621f796d7f03 Al Viro 2013-03-05 167 #define SYSCALL_METADATA(sname, nb, ...) \
99e621f796d7f03 Al Viro 2013-03-05 168 static const char *types_##sname[] = { \
99e621f796d7f03 Al Viro 2013-03-05 169 __MAP(nb,__SC_STR_TDECL,__VA_ARGS__) \
99e621f796d7f03 Al Viro 2013-03-05 170 }; \
99e621f796d7f03 Al Viro 2013-03-05 171 static const char *args_##sname[] = { \
99e621f796d7f03 Al Viro 2013-03-05 172 __MAP(nb,__SC_STR_ADECL,__VA_ARGS__) \
99e621f796d7f03 Al Viro 2013-03-05 173 }; \
540b7b8d65575c8 Li Zefan 2009-08-19 @174 SYSCALL_TRACE_ENTER_EVENT(sname); \
540b7b8d65575c8 Li Zefan 2009-08-19 @175 SYSCALL_TRACE_EXIT_EVENT(sname); \
2e33af029556cb8 Steven Rostedt 2010-04-22 176 static struct syscall_metadata __used \
bed1ffca022cc87 Frederic Weisbecker 2009-03-13 177 __syscall_meta_##sname = { \
bed1ffca022cc87 Frederic Weisbecker 2009-03-13 178 .name = "sys"#sname, \
ba976970c79fd2f Ian Munsie 2011-02-03 179 .syscall_nr = -1, /* Filled in at boot */ \
bed1ffca022cc87 Frederic Weisbecker 2009-03-13 180 .nb_args = nb, \
99e621f796d7f03 Al Viro 2013-03-05 181 .types = nb ? types_##sname : NULL, \
99e621f796d7f03 Al Viro 2013-03-05 182 .args = nb ? args_##sname : NULL, \
540b7b8d65575c8 Li Zefan 2009-08-19 183 .enter_event = &event_enter_##sname, \
540b7b8d65575c8 Li Zefan 2009-08-19 184 .exit_event = &event_exit_##sname, \
2e33af029556cb8 Steven Rostedt 2010-04-22 185 .enter_fields = LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \
3d56e331b653767 Steven Rostedt 2011-02-02 186 }; \
3d56e331b653767 Steven Rostedt 2011-02-02 187 static struct syscall_metadata __used \
3d56e331b653767 Steven Rostedt 2011-02-02 188 __attribute__((section("__syscalls_metadata"))) \
3d56e331b653767 Steven Rostedt 2011-02-02 189 *__p_syscall_meta_##sname = &__syscall_meta_##sname;
cf5f5cea270655d Yonghong Song 2017-08-04 190
cf5f5cea270655d Yonghong Song 2017-08-04 191 static inline int is_syscall_trace_event(struct trace_event_call *tp_event)
cf5f5cea270655d Yonghong Song 2017-08-04 192 {
cf5f5cea270655d Yonghong Song 2017-08-04 193 return tp_event->class == &event_class_syscall_enter ||
cf5f5cea270655d Yonghong Song 2017-08-04 194 tp_event->class == &event_class_syscall_exit;
cf5f5cea270655d Yonghong Song 2017-08-04 195 }
cf5f5cea270655d Yonghong Song 2017-08-04 196
99e621f796d7f03 Al Viro 2013-03-05 197 #else
99e621f796d7f03 Al Viro 2013-03-05 198 #define SYSCALL_METADATA(sname, nb, ...)
cf5f5cea270655d Yonghong Song 2017-08-04 199
cf5f5cea270655d Yonghong Song 2017-08-04 200 static inline int is_syscall_trace_event(struct trace_event_call *tp_event)
cf5f5cea270655d Yonghong Song 2017-08-04 201 {
cf5f5cea270655d Yonghong Song 2017-08-04 202 return 0;
cf5f5cea270655d Yonghong Song 2017-08-04 203 }
99e621f796d7f03 Al Viro 2013-03-05 204 #endif
bed1ffca022cc87 Frederic Weisbecker 2009-03-13 205
1bd21c6c21e8489 Dominik Brodowski 2018-04-05 206 #ifndef SYSCALL_DEFINE0
bed1ffca022cc87 Frederic Weisbecker 2009-03-13 207 #define SYSCALL_DEFINE0(sname) \
99e621f796d7f03 Al Viro 2013-03-05 208 SYSCALL_METADATA(_##sname, 0); \
c9a211951c7c79c Howard McLauchlan 2018-03-21 209 asmlinkage long sys_##sname(void); \
c9a211951c7c79c Howard McLauchlan 2018-03-21 210 ALLOW_ERROR_INJECTION(sys_##sname, ERRNO); \
bed1ffca022cc87 Frederic Weisbecker 2009-03-13 211 asmlinkage long sys_##sname(void)
1bd21c6c21e8489 Dominik Brodowski 2018-04-05 212 #endif /* SYSCALL_DEFINE0 */
bed1ffca022cc87 Frederic Weisbecker 2009-03-13 213
6c5979631b4b03c Heiko Carstens 2009-02-11 214 #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
6c5979631b4b03c Heiko Carstens 2009-02-11 215 #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
6c5979631b4b03c Heiko Carstens 2009-02-11 216 #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
6c5979631b4b03c Heiko Carstens 2009-02-11 217 #define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
6c5979631b4b03c Heiko Carstens 2009-02-11 218 #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
6c5979631b4b03c Heiko Carstens 2009-02-11 219 #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
1a94bc34768e463 Heiko Carstens 2009-01-14 220
609320c8a22715b Yonghong Song 2017-09-07 221 #define SYSCALL_DEFINE_MAXARGS 6
609320c8a22715b Yonghong Song 2017-09-07 222
bed1ffca022cc87 Frederic Weisbecker 2009-03-13 223 #define SYSCALL_DEFINEx(x, sname, ...) \
99e621f796d7f03 Al Viro 2013-03-05 @224 SYSCALL_METADATA(sname, x, __VA_ARGS__) \
bed1ffca022cc87 Frederic Weisbecker 2009-03-13 225 __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
bed1ffca022cc87 Frederic Weisbecker 2009-03-13 226

:::::: The code at line 152 was first introduced by commit
:::::: 3d56e331b6537671c66f1b510bed0f1e0331dfc8 tracing: Replace syscall_meta_data struct array with pointer array

:::::: TO: Steven Rostedt <[email protected]>
:::::: CC: Steven Rostedt <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (28.66 kB)
.config.gz (53.41 kB)
Download all attachments

2020-04-24 05:23:58

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH bpf-next 1/2] bpf: Change error code when ops is NULL

Hi Mao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]
[also build test ERROR on bpf/master net/master net-next/master v5.7-rc2 next-20200423]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Mao-Wenan/Change-return-code-if-failed-to-load-object/20200424-025339
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: c6x-allyesconfig (attached as .config)
compiler: c6x-elf-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=c6x

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <[email protected]>

All error/warnings (new ones prefixed by >>):

kernel/bpf/syscall.c: In function 'find_and_alloc_map':
>> kernel/bpf/syscall.c:116:11: warning: missing terminating " character
116 | pr_warn("map type %d not supported or
| ^
kernel/bpf/syscall.c:117:31: warning: missing terminating " character
117 | kernel config not opened\n", type);
| ^
In file included from kernel/bpf/syscall.c:1551:
>> include/linux/bpf_types.h:120: error: unterminated argument list invoking macro "pr_warn"
120 | #endif
|
>> kernel/bpf/syscall.c:116:3: error: 'pr_warn' undeclared (first use in this function)
116 | pr_warn("map type %d not supported or
| ^~~~~~~
kernel/bpf/syscall.c:116:3: note: each undeclared identifier is reported only once for each function it appears in
>> kernel/bpf/syscall.c:116:10: error: expected ';' before '}' token
116 | pr_warn("map type %d not supported or
| ^
| ;
......
1554 | };
| ~
>> kernel/bpf/syscall.c:1556:12: error: invalid storage class for function 'find_prog_type'
1556 | static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog)
| ^~~~~~~~~~~~~~
In file included from include/linux/list.h:9,
from include/linux/timer.h:5,
from include/linux/workqueue.h:9,
from include/linux/bpf.h:9,
from kernel/bpf/syscall.c:4:
kernel/bpf/syscall.c: In function 'find_prog_type':
>> kernel/bpf/syscall.c:1560:25: error: 'bpf_prog_types' undeclared (first use in this function); did you mean 'bpf_prog_type'?
1560 | if (type >= ARRAY_SIZE(bpf_prog_types))
| ^~~~~~~~~~~~~~
include/linux/kernel.h:47:33: note: in definition of macro 'ARRAY_SIZE'
47 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^~~
In file included from include/linux/bits.h:23,
from include/linux/bitops.h:5,
from include/linux/kernel.h:12,
from include/linux/list.h:9,
from include/linux/timer.h:5,
from include/linux/workqueue.h:9,
from include/linux/bpf.h:9,
from kernel/bpf/syscall.c:4:
include/linux/build_bug.h:16:51: error: bit-field '<anonymous>' width not an integer constant
16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
| ^
include/linux/compiler.h:357:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
357 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
| ^~~~~~~~~~~~~~~~~
include/linux/kernel.h:47:59: note: in expansion of macro '__must_be_array'
47 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^~~~~~~~~~~~~~~
>> kernel/bpf/syscall.c:1560:14: note: in expansion of macro 'ARRAY_SIZE'
1560 | if (type >= ARRAY_SIZE(bpf_prog_types))
| ^~~~~~~~~~
In file included from include/linux/fdtable.h:13,
from kernel/bpf/syscall.c:14:
include/linux/build_bug.h:16:51: error: bit-field '<anonymous>' width not an integer constant
16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
| ^
include/linux/nospec.h:52:9: note: in definition of macro 'array_index_nospec'
52 | typeof(size) _s = (size); \
| ^~~~
include/linux/compiler.h:357:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
357 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
| ^~~~~~~~~~~~~~~~~
include/linux/kernel.h:47:59: note: in expansion of macro '__must_be_array'
47 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:1562:34: note: in expansion of macro 'ARRAY_SIZE'
1562 | type = array_index_nospec(type, ARRAY_SIZE(bpf_prog_types));
| ^~~~~~~~~~
include/linux/build_bug.h:16:51: error: bit-field '<anonymous>' width not an integer constant
16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
| ^
include/linux/nospec.h:52:21: note: in definition of macro 'array_index_nospec'
52 | typeof(size) _s = (size); \
| ^~~~
include/linux/compiler.h:357:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
357 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
| ^~~~~~~~~~~~~~~~~
include/linux/kernel.h:47:59: note: in expansion of macro '__must_be_array'
47 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:1562:34: note: in expansion of macro 'ARRAY_SIZE'
1562 | type = array_index_nospec(type, ARRAY_SIZE(bpf_prog_types));
| ^~~~~~~~~~
kernel/bpf/syscall.c: In function 'find_and_alloc_map':
>> kernel/bpf/syscall.c:1556:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
1556 | static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog)
| ^~~~~~
>> kernel/bpf/syscall.c:1586:13: error: invalid storage class for function 'bpf_audit_prog'
1586 | static void bpf_audit_prog(const struct bpf_prog *prog, unsigned int op)
| ^~~~~~~~~~~~~~
>> kernel/bpf/syscall.c:1627:12: error: invalid storage class for function 'bpf_prog_charge_memlock'
1627 | static int bpf_prog_charge_memlock(struct bpf_prog *prog)
| ^~~~~~~~~~~~~~~~~~~~~~~
>> kernel/bpf/syscall.c:1642:13: error: invalid storage class for function 'bpf_prog_uncharge_memlock'
1642 | static void bpf_prog_uncharge_memlock(struct bpf_prog *prog)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/bpf/syscall.c:1650:12: error: invalid storage class for function 'bpf_prog_alloc_id'
1650 | static int bpf_prog_alloc_id(struct bpf_prog *prog)
| ^~~~~~~~~~~~~~~~~
>> kernel/bpf/syscall.c:1693:13: error: invalid storage class for function '__bpf_prog_put_rcu'
1693 | static void __bpf_prog_put_rcu(struct rcu_head *rcu)
| ^~~~~~~~~~~~~~~~~~
>> kernel/bpf/syscall.c:1704:13: error: invalid storage class for function '__bpf_prog_put_noref'
1704 | static void __bpf_prog_put_noref(struct bpf_prog *prog, bool deferred)
| ^~~~~~~~~~~~~~~~~~~~
>> kernel/bpf/syscall.c:1716:13: error: invalid storage class for function '__bpf_prog_put'
1716 | static void __bpf_prog_put(struct bpf_prog *prog, bool do_idr_lock)
| ^~~~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/kernel.h:8,
from include/linux/list.h:9,
from include/linux/timer.h:5,
from include/linux/workqueue.h:9,
from include/linux/bpf.h:9,
from kernel/bpf/syscall.c:4:
>> kernel/bpf/syscall.c:1731:19: error: non-static declaration of 'bpf_prog_put' follows static declaration
1731 | EXPORT_SYMBOL_GPL(bpf_prog_put);
| ^~~~~~~~~~~~
include/linux/export.h:98:21: note: in definition of macro '___EXPORT_SYMBOL'
98 | extern typeof(sym) sym; \
| ^~~
include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")
| ^~~~~~~~~~~~~~~
include/linux/export.h:159:33: note: in expansion of macro '_EXPORT_SYMBOL'
159 | #define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "_gpl")
| ^~~~~~~~~~~~~~
>> kernel/bpf/syscall.c:1731:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
1731 | EXPORT_SYMBOL_GPL(bpf_prog_put);
| ^~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:1727:6: note: previous definition of 'bpf_prog_put' was here
1727 | void bpf_prog_put(struct bpf_prog *prog)
| ^~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/kernel.h:8,
from include/linux/list.h:9,
from include/linux/timer.h:5,
from include/linux/workqueue.h:9,
from include/linux/bpf.h:9,
from kernel/bpf/syscall.c:4:
include/linux/export.h:67:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
67 | static const struct kernel_symbol __ksymtab_##sym \
| ^~~~~~
include/linux/export.h:108:2: note: in expansion of macro '__KSYMTAB_ENTRY'
108 | __KSYMTAB_ENTRY(sym, sec)
| ^~~~~~~~~~~~~~~
include/linux/export.h:147:39: note: in expansion of macro '___EXPORT_SYMBOL'
147 | #define __EXPORT_SYMBOL(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns)
| ^~~~~~~~~~~~~~~~
include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")
| ^~~~~~~~~~~~~~~
include/linux/export.h:159:33: note: in expansion of macro '_EXPORT_SYMBOL'
159 | #define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "_gpl")
| ^~~~~~~~~~~~~~
>> kernel/bpf/syscall.c:1731:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
1731 | EXPORT_SYMBOL_GPL(bpf_prog_put);
| ^~~~~~~~~~~~~~~~~
>> kernel/bpf/syscall.c:1733:12: error: invalid storage class for function 'bpf_prog_release'
1733 | static int bpf_prog_release(struct inode *inode, struct file *filp)
| ^~~~~~~~~~~~~~~~
>> kernel/bpf/syscall.c:1741:13: error: invalid storage class for function 'bpf_prog_get_stats'
1741 | static void bpf_prog_get_stats(const struct bpf_prog *prog,
| ^~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:1766:13: error: invalid storage class for function 'bpf_prog_show_fdinfo'
1766 | static void bpf_prog_show_fdinfo(struct seq_file *m, struct file *filp)
| ^~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:1797:11: error: 'bpf_dummy_read' undeclared (first use in this function)
1797 | .read = bpf_dummy_read,
| ^~~~~~~~~~~~~~
kernel/bpf/syscall.c:1798:12: error: 'bpf_dummy_write' undeclared (first use in this function)
1798 | .write = bpf_dummy_write,
| ^~~~~~~~~~~~~~~
kernel/bpf/syscall.c:1813:25: error: invalid storage class for function '____bpf_prog_get'
1813 | static struct bpf_prog *____bpf_prog_get(struct fd f)
| ^~~~~~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/kernel.h:8,
from include/linux/list.h:9,
from include/linux/timer.h:5,
from include/linux/workqueue.h:9,
from include/linux/bpf.h:9,
from kernel/bpf/syscall.c:4:
kernel/bpf/syscall.c:1829:19: error: non-static declaration of 'bpf_prog_add' follows static declaration
1829 | EXPORT_SYMBOL_GPL(bpf_prog_add);
| ^~~~~~~~~~~~
include/linux/export.h:98:21: note: in definition of macro '___EXPORT_SYMBOL'
98 | extern typeof(sym) sym; \
| ^~~
include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")
| ^~~~~~~~~~~~~~~
include/linux/export.h:159:33: note: in expansion of macro '_EXPORT_SYMBOL'
159 | #define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "_gpl")
| ^~~~~~~~~~~~~~
kernel/bpf/syscall.c:1829:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
1829 | EXPORT_SYMBOL_GPL(bpf_prog_add);
| ^~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:1825:6: note: previous definition of 'bpf_prog_add' was here
1825 | void bpf_prog_add(struct bpf_prog *prog, int i)
| ^~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/kernel.h:8,
from include/linux/list.h:9,
from include/linux/timer.h:5,
from include/linux/workqueue.h:9,
from include/linux/bpf.h:9,
from kernel/bpf/syscall.c:4:
include/linux/export.h:67:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
67 | static const struct kernel_symbol __ksymtab_##sym \
| ^~~~~~
include/linux/export.h:108:2: note: in expansion of macro '__KSYMTAB_ENTRY'
108 | __KSYMTAB_ENTRY(sym, sec)
| ^~~~~~~~~~~~~~~
include/linux/export.h:147:39: note: in expansion of macro '___EXPORT_SYMBOL'
147 | #define __EXPORT_SYMBOL(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns)
| ^~~~~~~~~~~~~~~~
include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")
| ^~~~~~~~~~~~~~~
include/linux/export.h:159:33: note: in expansion of macro '_EXPORT_SYMBOL'
159 | #define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "_gpl")
| ^~~~~~~~~~~~~~
kernel/bpf/syscall.c:1829:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
1829 | EXPORT_SYMBOL_GPL(bpf_prog_add);
| ^~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:1840:19: error: non-static declaration of 'bpf_prog_sub' follows static declaration
1840 | EXPORT_SYMBOL_GPL(bpf_prog_sub);
| ^~~~~~~~~~~~
include/linux/export.h:98:21: note: in definition of macro '___EXPORT_SYMBOL'
98 | extern typeof(sym) sym; \
| ^~~
include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")
| ^~~~~~~~~~~~~~~
include/linux/export.h:159:33: note: in expansion of macro '_EXPORT_SYMBOL'
159 | #define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "_gpl")
| ^~~~~~~~~~~~~~
kernel/bpf/syscall.c:1840:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
1840 | EXPORT_SYMBOL_GPL(bpf_prog_sub);
| ^~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c:1831:6: note: previous definition of 'bpf_prog_sub' was here
1831 | void bpf_prog_sub(struct bpf_prog *prog, int i)
| ^~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/kernel.h:8,
from include/linux/list.h:9,
from include/linux/timer.h:5,
from include/linux/workqueue.h:9,
from include/linux/bpf.h:9,
from kernel/bpf/syscall.c:4:
include/linux/export.h:67:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
67 | static const struct kernel_symbol __ksymtab_##sym \
| ^~~~~~
include/linux/export.h:108:2: note: in expansion of macro '__KSYMTAB_ENTRY'
108 | __KSYMTAB_ENTRY(sym, sec)
| ^~~~~~~~~~~~~~~
include/linux/export.h:147:39: note: in expansion of macro '___EXPORT_SYMBOL'
147 | #define __EXPORT_SYMBOL(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns)
| ^~~~~~~~~~~~~~~~
include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")

vim +/pr_warn +120 include/linux/bpf_types.h

40077e0cf62206 Johannes Berg 2017-04-11 78
40077e0cf62206 Johannes Berg 2017-04-11 79 BPF_MAP_TYPE(BPF_MAP_TYPE_ARRAY, array_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 80 BPF_MAP_TYPE(BPF_MAP_TYPE_PERCPU_ARRAY, percpu_array_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 81 BPF_MAP_TYPE(BPF_MAP_TYPE_PROG_ARRAY, prog_array_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 82 BPF_MAP_TYPE(BPF_MAP_TYPE_PERF_EVENT_ARRAY, perf_event_array_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 83 #ifdef CONFIG_CGROUPS
40077e0cf62206 Johannes Berg 2017-04-11 84 BPF_MAP_TYPE(BPF_MAP_TYPE_CGROUP_ARRAY, cgroup_array_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 85 #endif
de9cbbaadba5ad Roman Gushchin 2018-08-02 86 #ifdef CONFIG_CGROUP_BPF
de9cbbaadba5ad Roman Gushchin 2018-08-02 87 BPF_MAP_TYPE(BPF_MAP_TYPE_CGROUP_STORAGE, cgroup_storage_map_ops)
b741f1630346de Roman Gushchin 2018-09-28 88 BPF_MAP_TYPE(BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE, cgroup_storage_map_ops)
de9cbbaadba5ad Roman Gushchin 2018-08-02 89 #endif
40077e0cf62206 Johannes Berg 2017-04-11 90 BPF_MAP_TYPE(BPF_MAP_TYPE_HASH, htab_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 91 BPF_MAP_TYPE(BPF_MAP_TYPE_PERCPU_HASH, htab_percpu_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 92 BPF_MAP_TYPE(BPF_MAP_TYPE_LRU_HASH, htab_lru_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 93 BPF_MAP_TYPE(BPF_MAP_TYPE_LRU_PERCPU_HASH, htab_lru_percpu_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 94 BPF_MAP_TYPE(BPF_MAP_TYPE_LPM_TRIE, trie_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 95 #ifdef CONFIG_PERF_EVENTS
144991602e6a14 Mauricio Vasquez B 2018-10-18 96 BPF_MAP_TYPE(BPF_MAP_TYPE_STACK_TRACE, stack_trace_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 97 #endif
40077e0cf62206 Johannes Berg 2017-04-11 98 BPF_MAP_TYPE(BPF_MAP_TYPE_ARRAY_OF_MAPS, array_of_maps_map_ops)
40077e0cf62206 Johannes Berg 2017-04-11 99 BPF_MAP_TYPE(BPF_MAP_TYPE_HASH_OF_MAPS, htab_of_maps_map_ops)
546ac1ffb70d25 John Fastabend 2017-07-17 100 #ifdef CONFIG_NET
546ac1ffb70d25 John Fastabend 2017-07-17 101 BPF_MAP_TYPE(BPF_MAP_TYPE_DEVMAP, dev_map_ops)
6f9d451ab1a337 Toke H?iland-J?rgensen 2019-07-26 102 BPF_MAP_TYPE(BPF_MAP_TYPE_DEVMAP_HASH, dev_map_hash_ops)
6ac99e8f23d4b1 Martin KaFai Lau 2019-04-26 103 BPF_MAP_TYPE(BPF_MAP_TYPE_SK_STORAGE, sk_storage_map_ops)
604326b41a6fb9 Daniel Borkmann 2018-10-13 104 #if defined(CONFIG_BPF_STREAM_PARSER)
174a79ff9515f4 John Fastabend 2017-08-15 105 BPF_MAP_TYPE(BPF_MAP_TYPE_SOCKMAP, sock_map_ops)
81110384441a59 John Fastabend 2018-05-14 106 BPF_MAP_TYPE(BPF_MAP_TYPE_SOCKHASH, sock_hash_ops)
546ac1ffb70d25 John Fastabend 2017-07-17 107 #endif
6710e1126934d8 Jesper Dangaard Brouer 2017-10-16 108 BPF_MAP_TYPE(BPF_MAP_TYPE_CPUMAP, cpu_map_ops)
fbfc504a24f53f Bj?rn T?pel 2018-05-02 109 #if defined(CONFIG_XDP_SOCKETS)
fbfc504a24f53f Bj?rn T?pel 2018-05-02 110 BPF_MAP_TYPE(BPF_MAP_TYPE_XSKMAP, xsk_map_ops)
fbfc504a24f53f Bj?rn T?pel 2018-05-02 111 #endif
5dc4c4b7d4e811 Martin KaFai Lau 2018-08-08 112 #ifdef CONFIG_INET
5dc4c4b7d4e811 Martin KaFai Lau 2018-08-08 113 BPF_MAP_TYPE(BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, reuseport_array_ops)
5dc4c4b7d4e811 Martin KaFai Lau 2018-08-08 114 #endif
6bdc9c4c31c816 John Fastabend 2017-08-16 115 #endif
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 116 BPF_MAP_TYPE(BPF_MAP_TYPE_QUEUE, queue_map_ops)
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 117 BPF_MAP_TYPE(BPF_MAP_TYPE_STACK, stack_map_ops)
85d33df357b634 Martin KaFai Lau 2020-01-08 118 #if defined(CONFIG_BPF_JIT)
85d33df357b634 Martin KaFai Lau 2020-01-08 119 BPF_MAP_TYPE(BPF_MAP_TYPE_STRUCT_OPS, bpf_struct_ops_map_ops)
85d33df357b634 Martin KaFai Lau 2020-01-08 @120 #endif

:::::: The code at line 120 was first introduced by commit
:::::: 85d33df357b634649ddbe0a20fd2d0fc5732c3cb bpf: Introduce BPF_MAP_TYPE_STRUCT_OPS

:::::: TO: Martin KaFai Lau <[email protected]>
:::::: CC: Alexei Starovoitov <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (22.09 kB)
.config.gz (51.37 kB)
Download all attachments

2020-04-30 01:57:47

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH bpf-next 1/2] bpf: Change error code when ops is NULL

Hi Mao,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on bpf-next/master]
[also build test WARNING on bpf/master net/master net-next/master ipvs/master v5.7-rc2 next-20200423]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Mao-Wenan/Change-return-code-if-failed-to-load-object/20200424-025339
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-191-gc51a0382-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
:::::: branch date: 19 hours ago
:::::: commit date: 19 hours ago

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <[email protected]>


sparse warnings: (new ones prefixed by >>)

>> kernel/bpf/syscall.c:117:0: sparse: sparse: missing terminating " character
kernel/bpf/syscall.c:118:0: sparse: sparse: missing terminating " character
>> kernel/bpf/syscall.c:686:1: sparse: sparse: directive in macro's argument list
kernel/bpf/syscall.c:772:1: sparse: sparse: directive in macro's argument list
kernel/bpf/syscall.c:979:1: sparse: sparse: directive in macro's argument list
kernel/bpf/syscall.c:1046:1: sparse: sparse: directive in macro's argument list
kernel/bpf/syscall.c:1111:1: sparse: sparse: directive in macro's argument list
kernel/bpf/syscall.c:1164:1: sparse: sparse: directive in macro's argument list
kernel/bpf/syscall.c:1341:1: sparse: sparse: directive in macro's argument list
kernel/bpf/syscall.c:1442:1: sparse: sparse: directive in macro's argument list
kernel/bpf/syscall.c:1504:1: sparse: sparse: directive in macro's argument list
kernel/bpf/syscall.c:1548:1: sparse: sparse: directive in macro's argument list
kernel/bpf/syscall.c:1550:1: sparse: sparse: directive in macro's argument list
kernel/bpf/syscall.c:1551:1: sparse: sparse: directive in macro's argument list
>> kernel/bpf/syscall.c:116:17: sparse: sparse: macro "pr_warn" passed 2 arguments, but takes just 2
>> include/linux/bpf_types.h:7:1: sparse: sparse: No right hand side of ','-expression
include/linux/bpf_types.h:7:1: sparse: sparse: Expected ; at end of statement
include/linux/bpf_types.h:7:1: sparse: sparse: got [
include/linux/bpf_types.h:121:0: sparse: sparse: Expected } at end of compound statement
include/linux/bpf_types.h:121:0: sparse: sparse: got end-of-input
include/linux/bpf_types.h:121:0: sparse: sparse: Expected } at end of function
include/linux/bpf_types.h:121:0: sparse: sparse: got end-of-input
kernel/bpf/syscall.c:116:17: sparse: sparse: undefined identifier 'pr_warn'
kernel/bpf/syscall.c:1560:21: sparse: sparse: undefined identifier 'bpf_prog_types'
kernel/bpf/syscall.c:1560:21: sparse: sparse: undefined identifier 'bpf_prog_types'
kernel/bpf/syscall.c:1562:16: sparse: sparse: undefined identifier 'bpf_prog_types'
kernel/bpf/syscall.c:1562:16: sparse: sparse: undefined identifier 'bpf_prog_types'
kernel/bpf/syscall.c:1562:16: sparse: sparse: undefined identifier 'bpf_prog_types'
kernel/bpf/syscall.c:1562:16: sparse: sparse: undefined identifier 'bpf_prog_types'
>> kernel/bpf/syscall.c:1562:16: sparse: sparse: cannot size expression
kernel/bpf/syscall.c:1563:15: sparse: sparse: undefined identifier 'bpf_prog_types'
kernel/bpf/syscall.c:1797:27: sparse: sparse: undefined identifier 'bpf_dummy_read'
kernel/bpf/syscall.c:1798:27: sparse: sparse: undefined identifier 'bpf_dummy_write'
kernel/bpf/syscall.c:2293:27: sparse: sparse: undefined identifier 'bpf_dummy_read'
kernel/bpf/syscall.c:2294:27: sparse: sparse: undefined identifier 'bpf_dummy_write'
kernel/bpf/syscall.c:2870:23: sparse: sparse: undefined identifier '__bpf_map_inc_not_zero'
kernel/bpf/syscall.c:3538:15: sparse: sparse: undefined identifier 'map_get_sys_perms'
kernel/bpf/syscall.c:3544:15: sparse: sparse: undefined identifier 'map_get_sys_perms'
kernel/bpf/syscall.c:3685:23: sparse: sparse: undefined identifier 'map_create'
kernel/bpf/syscall.c:3688:23: sparse: sparse: undefined identifier 'map_lookup_elem'
kernel/bpf/syscall.c:3691:23: sparse: sparse: undefined identifier 'map_update_elem'
kernel/bpf/syscall.c:3694:23: sparse: sparse: undefined identifier 'map_delete_elem'
kernel/bpf/syscall.c:3697:23: sparse: sparse: undefined identifier 'map_get_next_key'
kernel/bpf/syscall.c:3700:23: sparse: sparse: undefined identifier 'map_freeze'
kernel/bpf/syscall.c:3757:23: sparse: sparse: undefined identifier 'map_lookup_and_delete_elem'

# https://github.com/0day-ci/linux/commit/45c88e856945c443c39e3f519ad9740b8e487d8d
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 45c88e856945c443c39e3f519ad9740b8e487d8d
vim +117 kernel/bpf/syscall.c

a38845729ea398 Jakub Kicinski 2018-01-11 103
99c55f7d47c0dc Alexei Starovoitov 2014-09-26 104 static struct bpf_map *find_and_alloc_map(union bpf_attr *attr)
99c55f7d47c0dc Alexei Starovoitov 2014-09-26 105 {
1110f3a9bcf394 Jakub Kicinski 2018-01-11 106 const struct bpf_map_ops *ops;
9ef09e35e521bf Mark Rutland 2018-05-03 107 u32 type = attr->map_type;
99c55f7d47c0dc Alexei Starovoitov 2014-09-26 108 struct bpf_map *map;
1110f3a9bcf394 Jakub Kicinski 2018-01-11 109 int err;
99c55f7d47c0dc Alexei Starovoitov 2014-09-26 110
9ef09e35e521bf Mark Rutland 2018-05-03 111 if (type >= ARRAY_SIZE(bpf_map_types))
1110f3a9bcf394 Jakub Kicinski 2018-01-11 112 return ERR_PTR(-EINVAL);
9ef09e35e521bf Mark Rutland 2018-05-03 113 type = array_index_nospec(type, ARRAY_SIZE(bpf_map_types));
9ef09e35e521bf Mark Rutland 2018-05-03 114 ops = bpf_map_types[type];
45c88e856945c4 Mao Wenan 2020-04-22 115 if (!ops) {
45c88e856945c4 Mao Wenan 2020-04-22 @116 pr_warn("map type %d not supported or
45c88e856945c4 Mao Wenan 2020-04-22 @117 kernel config not opened\n", type);
45c88e856945c4 Mao Wenan 2020-04-22 118 return ERR_PTR(-EOPNOTSUPP);
45c88e856945c4 Mao Wenan 2020-04-22 119 }
1110f3a9bcf394 Jakub Kicinski 2018-01-11 120 if (ops->map_alloc_check) {
1110f3a9bcf394 Jakub Kicinski 2018-01-11 121 err = ops->map_alloc_check(attr);
1110f3a9bcf394 Jakub Kicinski 2018-01-11 122 if (err)
1110f3a9bcf394 Jakub Kicinski 2018-01-11 123 return ERR_PTR(err);
1110f3a9bcf394 Jakub Kicinski 2018-01-11 124 }
a38845729ea398 Jakub Kicinski 2018-01-11 125 if (attr->map_ifindex)
a38845729ea398 Jakub Kicinski 2018-01-11 126 ops = &bpf_map_offload_ops;
1110f3a9bcf394 Jakub Kicinski 2018-01-11 127 map = ops->map_alloc(attr);
99c55f7d47c0dc Alexei Starovoitov 2014-09-26 128 if (IS_ERR(map))
99c55f7d47c0dc Alexei Starovoitov 2014-09-26 129 return map;
1110f3a9bcf394 Jakub Kicinski 2018-01-11 130 map->ops = ops;
9ef09e35e521bf Mark Rutland 2018-05-03 131 map->map_type = type;
99c55f7d47c0dc Alexei Starovoitov 2014-09-26 132 return map;
99c55f7d47c0dc Alexei Starovoitov 2014-09-26 133 }
99c55f7d47c0dc Alexei Starovoitov 2014-09-26 134

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]