* [PATCH] tools/bpftool: Fix error return code in do_skeleton()
@ 2020-07-15 3:13 YueHaibing
2020-07-15 16:49 ` Quentin Monnet
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: YueHaibing @ 2020-07-15 3:13 UTC (permalink / raw)
To: ast, daniel, kafai, songliubraving, yhs, andriin, john.fastabend,
kpsingh
Cc: netdev, bpf, linux-kernel, YueHaibing
The error return code should be PTR_ERR(obj) other than
PTR_ERR(NULL).
Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
tools/bpf/bpftool/gen.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index 10de76b296ba..35f62273cdbd 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -305,8 +305,9 @@ static int do_skeleton(int argc, char **argv)
opts.object_name = obj_name;
obj = bpf_object__open_mem(obj_data, file_sz, &opts);
if (IS_ERR(obj)) {
+ err = PTR_ERR(obj);
+ p_err("failed to open BPF object file: %ld", err);
obj = NULL;
- p_err("failed to open BPF object file: %ld", PTR_ERR(obj));
goto out;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] tools/bpftool: Fix error return code in do_skeleton()
2020-07-15 3:13 [PATCH] tools/bpftool: Fix error return code in do_skeleton() YueHaibing
@ 2020-07-15 16:49 ` Quentin Monnet
2020-07-15 19:23 ` Daniel Borkmann
2020-07-17 12:30 ` [PATCH v2] tools/bpftool: Fix error handing " YueHaibing
2 siblings, 0 replies; 5+ messages in thread
From: Quentin Monnet @ 2020-07-15 16:49 UTC (permalink / raw)
To: YueHaibing, ast, daniel, kafai, songliubraving, yhs, andriin,
john.fastabend, kpsingh
Cc: netdev, bpf, linux-kernel
2020-07-15 11:13 UTC+0800 ~ YueHaibing <yuehaibing@huawei.com>
> The error return code should be PTR_ERR(obj) other than
> PTR_ERR(NULL).
>
> Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tools/bpftool: Fix error return code in do_skeleton()
2020-07-15 3:13 [PATCH] tools/bpftool: Fix error return code in do_skeleton() YueHaibing
2020-07-15 16:49 ` Quentin Monnet
@ 2020-07-15 19:23 ` Daniel Borkmann
2020-07-17 12:30 ` [PATCH v2] tools/bpftool: Fix error handing " YueHaibing
2 siblings, 0 replies; 5+ messages in thread
From: Daniel Borkmann @ 2020-07-15 19:23 UTC (permalink / raw)
To: YueHaibing, ast, kafai, songliubraving, yhs, andriin,
john.fastabend, kpsingh
Cc: netdev, bpf, linux-kernel
On 7/15/20 5:13 AM, YueHaibing wrote:
> The error return code should be PTR_ERR(obj) other than
> PTR_ERR(NULL).
>
> Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> tools/bpf/bpftool/gen.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index 10de76b296ba..35f62273cdbd 100644
> --- a/tools/bpf/bpftool/gen.c
> +++ b/tools/bpf/bpftool/gen.c
> @@ -305,8 +305,9 @@ static int do_skeleton(int argc, char **argv)
> opts.object_name = obj_name;
> obj = bpf_object__open_mem(obj_data, file_sz, &opts);
> if (IS_ERR(obj)) {
> + err = PTR_ERR(obj);
> + p_err("failed to open BPF object file: %ld", err);
> obj = NULL;
> - p_err("failed to open BPF object file: %ld", PTR_ERR(obj));
> goto out;
Instead of just the error number, could we dump something useful to the user here
via libbpf_strerror() given you touch this line? Also, I think the convention in
do_skeleton() is to just return {0,-1} given this is propagated as return code
for bpftool.
> }
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] tools/bpftool: Fix error handing in do_skeleton()
2020-07-15 3:13 [PATCH] tools/bpftool: Fix error return code in do_skeleton() YueHaibing
2020-07-15 16:49 ` Quentin Monnet
2020-07-15 19:23 ` Daniel Borkmann
@ 2020-07-17 12:30 ` YueHaibing
2020-07-21 19:36 ` Alexei Starovoitov
2 siblings, 1 reply; 5+ messages in thread
From: YueHaibing @ 2020-07-17 12:30 UTC (permalink / raw)
To: ast, daniel, kafai, songliubraving, yhs, andriin, john.fastabend,
kpsingh, quentin
Cc: netdev, bpf, linux-kernel, YueHaibing
Fix pass 0 to PTR_ERR, also dump more err info using
libbpf_strerror.
Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
---
v2: use libbpf_strerror
---
tools/bpf/bpftool/gen.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index b59d26e89367..8a4c2b3b0cd6 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -302,8 +302,11 @@ static int do_skeleton(int argc, char **argv)
opts.object_name = obj_name;
obj = bpf_object__open_mem(obj_data, file_sz, &opts);
if (IS_ERR(obj)) {
+ char err_buf[256];
+
+ libbpf_strerror(PTR_ERR(obj), err_buf, sizeof(err_buf));
+ p_err("failed to open BPF object file: %s", err_buf);
obj = NULL;
- p_err("failed to open BPF object file: %ld", PTR_ERR(obj));
goto out;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] tools/bpftool: Fix error handing in do_skeleton()
2020-07-17 12:30 ` [PATCH v2] tools/bpftool: Fix error handing " YueHaibing
@ 2020-07-21 19:36 ` Alexei Starovoitov
0 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2020-07-21 19:36 UTC (permalink / raw)
To: YueHaibing
Cc: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh,
Quentin Monnet, Network Development, bpf, LKML
On Fri, Jul 17, 2020 at 5:31 AM YueHaibing <yuehaibing@huawei.com> wrote:
>
> Fix pass 0 to PTR_ERR, also dump more err info using
> libbpf_strerror.
>
> Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Applied. Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-21 19:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 3:13 [PATCH] tools/bpftool: Fix error return code in do_skeleton() YueHaibing
2020-07-15 16:49 ` Quentin Monnet
2020-07-15 19:23 ` Daniel Borkmann
2020-07-17 12:30 ` [PATCH v2] tools/bpftool: Fix error handing " YueHaibing
2020-07-21 19:36 ` Alexei Starovoitov
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).