summaryrefslogtreecommitdiffstats
path: root/tools/bpf/bpftool/map.c
diff options
context:
space:
mode:
authorQuentin Monnet2017-10-23 18:24:14 +0200
committerDavid S. Miller2017-10-24 02:25:09 +0200
commit004b45c0e51a8b6f20320181a946ba2d1bd3548b (patch)
treee532c699b273f8d0f937bd04cc02dacd1f840f28 /tools/bpf/bpftool/map.c
parenttools: bpftool: turn err() and info() macros into functions (diff)
downloadkernel-qcow2-linux-004b45c0e51a8b6f20320181a946ba2d1bd3548b.tar.gz
kernel-qcow2-linux-004b45c0e51a8b6f20320181a946ba2d1bd3548b.tar.xz
kernel-qcow2-linux-004b45c0e51a8b6f20320181a946ba2d1bd3548b.zip
tools: bpftool: provide JSON output for all possible commands
As all commands can now return JSON output (possibly just a "null" value), output of `bpftool --json batch file FILE` should also be fully JSON compliant. Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/bpf/bpftool/map.c')
-rw-r--r--tools/bpf/bpftool/map.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 86c128c433ba..a611f31f574f 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -651,6 +651,8 @@ exit_free:
free(value);
close(fd);
+ if (!err && json_output)
+ jsonw_null(json_wtr);
return err;
}
@@ -812,16 +814,28 @@ exit_free:
free(key);
close(fd);
+ if (!err && json_output)
+ jsonw_null(json_wtr);
return err;
}
static int do_pin(int argc, char **argv)
{
- return do_pin_any(argc, argv, bpf_map_get_fd_by_id);
+ int err;
+
+ err = do_pin_any(argc, argv, bpf_map_get_fd_by_id);
+ if (!err && json_output)
+ jsonw_null(json_wtr);
+ return err;
}
static int do_help(int argc, char **argv)
{
+ if (json_output) {
+ jsonw_null(json_wtr);
+ return 0;
+ }
+
fprintf(stderr,
"Usage: %s %s show [MAP]\n"
" %s %s dump MAP\n"