Skip to content

Commit

Permalink
Merge branch 'bpf-bpftool-json-fixes'
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Borkmann committed Feb 15, 2018
2 parents 9c481b9 + 9be6d41 commit 67e3a17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions tools/bpf/bpftool/prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 67e3a17

Please sign in to comment.