* [PATCH] bpf: bpftool: Setting error code in do_loader()
@ 2025-03-10 5:25 nswon
2025-03-10 13:28 ` Quentin Monnet
0 siblings, 1 reply; 3+ messages in thread
From: nswon @ 2025-03-10 5:25 UTC (permalink / raw)
To: Quentin Monnet, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa
Cc: nswon, bpf, linux-kernel
missing error code in do_loader()
bpf_object__open_file() failed, but return 0
This means the command's exit status code was successful, so make sure to return the correct error code.
Link: https://lore.kernel.org/bpf/d3b5b4b4-19bb-4619-b4dd-86c958c4a367@stanley.mountain/t/#u
Closes: https://github.com/libbpf/bpftool/issues/156
Signed-off-by: nswon <swnam0729@gmail.com>
---
tools/bpf/bpftool/prog.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index e71be67f1d86..641802e308f4 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -1928,6 +1928,7 @@ static int do_loader(int argc, char **argv)
obj = bpf_object__open_file(file, &open_opts);
if (!obj) {
+ err = libbpf_get_error(obj);
p_err("failed to open object file");
goto err_close_obj;
}
--
2.39.3 (Apple Git-146)
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] bpf: bpftool: Setting error code in do_loader()
2025-03-10 5:25 [PATCH] bpf: bpftool: Setting error code in do_loader() nswon
@ 2025-03-10 13:28 ` Quentin Monnet
2025-03-11 2:33 ` 남세원
0 siblings, 1 reply; 3+ messages in thread
From: Quentin Monnet @ 2025-03-10 13:28 UTC (permalink / raw)
To: nswon, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa
Cc: bpf, linux-kernel
2025-03-10 14:25 UTC+0900 ~ nswon <swnam0729@gmail.com>
> missing error code in do_loader()
> bpf_object__open_file() failed, but return 0
> This means the command's exit status code was successful, so make sure to return the correct error code.
>
> Link: https://lore.kernel.org/bpf/d3b5b4b4-19bb-4619-b4dd-86c958c4a367@stanley.mountain/t/#u
> Closes: https://github.com/libbpf/bpftool/issues/156
> Signed-off-by: nswon <swnam0729@gmail.com>
Thanks for this!
Others may correct me if I'm wrong, but I think you should sign off with
your full name here (although it doesn't strictly have to be a full
name, the patch submission docs mention in should be a "known identity"
so I'm not sure whether a GitHub handle, for example, is acceptable).
> ---
> tools/bpf/bpftool/prog.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
> index e71be67f1d86..641802e308f4 100644
> --- a/tools/bpf/bpftool/prog.c
> +++ b/tools/bpf/bpftool/prog.c
> @@ -1928,6 +1928,7 @@ static int do_loader(int argc, char **argv)
>
> obj = bpf_object__open_file(file, &open_opts);
> if (!obj) {
> + err = libbpf_get_error(obj);
This is the correct way to retrieve the error code, but given that
bpftool does nothing with this error code, could we instead simply
return -1 to remain consistent with the other locations where we call
bpf_object__open_file() in the tool, please?
Thanks,
Quentin
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] bpf: bpftool: Setting error code in do_loader()
2025-03-10 13:28 ` Quentin Monnet
@ 2025-03-11 2:33 ` 남세원
0 siblings, 0 replies; 3+ messages in thread
From: 남세원 @ 2025-03-11 2:33 UTC (permalink / raw)
To: Quentin Monnet, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Song Liu, Eduard Zingerman, Martin KaFai Lau,
Jiri Olsa, Yonghong Song, John Fastabend, KP Singh, Hao Luo,
Stanislav Fomichev
Cc: bpf, linux-kernel
Ngomhla ka-Mso, Mas 10, 2025 ngo-22:28 Quentin Monnet <qmo@kernel.org> wabhala:
>
> 2025-03-10 14:25 UTC+0900 ~ nswon <swnam0729@gmail.com>
> > missing error code in do_loader()
> > bpf_object__open_file() failed, but return 0
> > This means the command's exit status code was successful, so make sure to return the correct error code.
> >
> > Link: https://lore.kernel.org/bpf/d3b5b4b4-19bb-4619-b4dd-86c958c4a367@stanley.mountain/t/#u
> > Closes: https://github.com/libbpf/bpftool/issues/156
> > Signed-off-by: nswon <swnam0729@gmail.com>
>
>
> Thanks for this!
>
> Others may correct me if I'm wrong, but I think you should sign off with
> your full name here (although it doesn't strictly have to be a full
> name, the patch submission docs mention in should be a "known identity"
> so I'm not sure whether a GitHub handle, for example, is acceptable).
>
>
> > ---
> > tools/bpf/bpftool/prog.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
> > index e71be67f1d86..641802e308f4 100644
> > --- a/tools/bpf/bpftool/prog.c
> > +++ b/tools/bpf/bpftool/prog.c
> > @@ -1928,6 +1928,7 @@ static int do_loader(int argc, char **argv)
> >
> > obj = bpf_object__open_file(file, &open_opts);
> > if (!obj) {
> > + err = libbpf_get_error(obj);
>
>
> This is the correct way to retrieve the error code, but given that
> bpftool does nothing with this error code, could we instead simply
> return -1 to remain consistent with the other locations where we call
> bpf_object__open_file() in the tool, please?
>
> Thanks,
> Quentin
Thanks for the review!
I'll submit a v2 patch soon with the signature renamed :)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-11 2:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10 5:25 [PATCH] bpf: bpftool: Setting error code in do_loader() nswon
2025-03-10 13:28 ` Quentin Monnet
2025-03-11 2:33 ` 남세원
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox