summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2018-02-15 12:01:06 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2018-02-15 12:01:06 +0300
commit67e3a172eba577f16ceae712d835b835b9718d61 (patch)
tree90fef11760b8c33974b2027dd1e25ff5d264de52
parent9c481b908b011398b1491752271cd1e2c9ad5758 (diff)
parent9be6d411b0c473d31f756993b8b41bb16b0679c1 (diff)
downloadlinux-67e3a172eba577f16ceae712d835b835b9718d61.tar.xz
Merge branch 'bpf-bpftool-json-fixes'
Quentin Monnet says: ==================== These are two minor fixes to avoid breaking JSON output in batch mode. The first one makes bpftool output a "null" JSON object, as expected in batch mode if nothing else is to be printed, when dumping program instructions into an output file. The second one replaces a call to "perror()" with something that does not break JSON when parsing input file for batch mode. ==================== Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r--tools/bpf/bpftool/main.c2
-rw-r--r--tools/bpf/bpftool/prog.c3
2 files changed, 4 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index 3a0396d87c42..185acfa229b5 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -244,7 +244,7 @@ static int do_batch(int argc, char **argv)
}
if (errno && errno != ENOENT) {
- perror("reading batch file failed");
+ p_err("reading batch file failed: %s", strerror(errno));
err = -1;
} else {
p_info("processed %d lines", lines);
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index e8e2baaf93c2..e549e329be82 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -774,6 +774,9 @@ static int do_dump(int argc, char **argv)
n < 0 ? strerror(errno) : "short write");
goto err_free;
}
+
+ if (json_output)
+ jsonw_null(json_wtr);
} else {
if (member_len == &info.jited_prog_len) {
const char *name = NULL;