* [PATCH net-next] bpf: fix return in load_bpf_file
@ 2017-07-04 21:51 Lawrence Brakmo
2017-07-04 22:14 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: Lawrence Brakmo @ 2017-07-04 21:51 UTC (permalink / raw)
To: netdev; +Cc: Kernel Team, Alexei Starovoitov, Daniel Borkmann
The function load_bpf_file ignores the return value of
load_and_attach(), so even if load_and_attach() returns an error,
load_bpf_file() will return 0.
Now, load_bpf_file() can call load_and_attach() multiple times and some
can succeed and some could fail. I think the correct behavor is to
return error on the first failed load_and_attach().
---
samples/bpf/bpf_load.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c
index a4be7cf..899f403 100644
--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -567,8 +567,12 @@ static int do_load_bpf_file(const char *path, fixup_map_cb fixup_map)
memcmp(shname, "perf_event", 10) == 0 ||
memcmp(shname, "socket", 6) == 0 ||
memcmp(shname, "cgroup/", 7) == 0 ||
- memcmp(shname, "sockops", 7) == 0)
- load_and_attach(shname, data->d_buf, data->d_size);
+ memcmp(shname, "sockops", 7) == 0) {
+ ret = load_and_attach(shname, data->d_buf,
+ data->d_size);
+ if (ret != 0)
+ goto done;
+ }
}
ret = 0;
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next] bpf: fix return in load_bpf_file
2017-07-04 21:51 [PATCH net-next] bpf: fix return in load_bpf_file Lawrence Brakmo
@ 2017-07-04 22:14 ` Daniel Borkmann
2017-07-04 22:55 ` Lawrence Brakmo
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Borkmann @ 2017-07-04 22:14 UTC (permalink / raw)
To: Lawrence Brakmo, netdev; +Cc: Kernel Team, Alexei Starovoitov
On 07/04/2017 11:51 PM, Lawrence Brakmo wrote:
> The function load_bpf_file ignores the return value of
> load_and_attach(), so even if load_and_attach() returns an error,
> load_bpf_file() will return 0.
>
> Now, load_bpf_file() can call load_and_attach() multiple times and some
> can succeed and some could fail. I think the correct behavor is to
> return error on the first failed load_and_attach().
Your SOB is missing.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] bpf: fix return in load_bpf_file
2017-07-04 22:14 ` Daniel Borkmann
@ 2017-07-04 22:55 ` Lawrence Brakmo
0 siblings, 0 replies; 3+ messages in thread
From: Lawrence Brakmo @ 2017-07-04 22:55 UTC (permalink / raw)
To: Daniel Borkmann, netdev; +Cc: Kernel Team, Alexei Starovoitov
On 7/4/17, 3:14 PM, "Daniel Borkmann" <daniel@iogearbox.net> wrote:
On 07/04/2017 11:51 PM, Lawrence Brakmo wrote:
> The function load_bpf_file ignores the return value of
> load_and_attach(), so even if load_and_attach() returns an error,
> load_bpf_file() will return 0.
>
> Now, load_bpf_file() can call load_and_attach() multiple times and some
> can succeed and some could fail. I think the correct behavor is to
> return error on the first failed load_and_attach().
Your SOB is missing.
Oops, thanks. New patch forthcoming.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-07-04 22:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-04 21:51 [PATCH net-next] bpf: fix return in load_bpf_file Lawrence Brakmo
2017-07-04 22:14 ` Daniel Borkmann
2017-07-04 22:55 ` Lawrence Brakmo
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).