aboutsummaryrefslogtreecommitdiffstats
path: root/tools/bpf/bpftool/prog.c
diff options
context:
space:
mode:
authorQuentin Monnet <[email protected]>2017-10-23 16:24:14 +0000
committerDavid S. Miller <[email protected]>2017-10-24 00:25:09 +0000
commit004b45c0e51a8b6f20320181a946ba2d1bd3548b (patch)
treee532c699b273f8d0f937bd04cc02dacd1f840f28 /tools/bpf/bpftool/prog.c
parenttools: bpftool: turn err() and info() macros into functions (diff)
downloadkernel-004b45c0e51a8b6f20320181a946ba2d1bd3548b.tar.gz
kernel-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 <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'tools/bpf/bpftool/prog.c')
-rw-r--r--tools/bpf/bpftool/prog.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 41bd5390b4fc..e07f35ff80d1 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -602,11 +602,21 @@ err_free:
static int do_pin(int argc, char **argv)
{
- return do_pin_any(argc, argv, bpf_prog_get_fd_by_id);
+ int err;
+
+ err = do_pin_any(argc, argv, bpf_prog_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 [PROG]\n"
" %s %s dump xlated PROG [{ file FILE | opcodes }]\n"