diff options
author | Jakub Kicinski <jakub.kicinski@netronome.com> | 2018-06-20 11:42:46 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-06-21 23:07:13 +0200 |
commit | bfee71fb7376081349117fdc89f685a9e14a58c2 (patch) | |
tree | f8f65c36f80791edb98c219fa98f24c904d28741 /tools | |
parent | 957f9a13df6c70aac31a1dade5e417c286d6d258 (diff) | |
download | talos-op-linux-bfee71fb7376081349117fdc89f685a9e14a58c2.tar.gz talos-op-linux-bfee71fb7376081349117fdc89f685a9e14a58c2.zip |
tools: bpftool: remember to close the libbpf object after prog load
Remembering to close all descriptors and free memory may not seem
important in a user space tool like bpftool, but if we were to run
in batch mode the consumed resources start to add up quickly. Make
sure program load closes the libbpf object (which unloads and frees
it).
Fixes: 49a086c201a9 ("bpftool: implement prog load command")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bpf/bpftool/prog.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 12b694fe0404..959aa53ab678 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -695,12 +695,18 @@ static int do_load(int argc, char **argv) } if (do_pin_fd(prog_fd, argv[1])) - return -1; + goto err_close_obj; if (json_output) jsonw_null(json_wtr); + bpf_object__close(obj); + return 0; + +err_close_obj: + bpf_object__close(obj); + return -1; } static int do_help(int argc, char **argv) |