Skip to content

Commit

Permalink
bpftool: Fix bpftool net output
Browse files Browse the repository at this point in the history
Print `bpftool net` output to stdout instead of stderr. Only errors
should be printed to stderr. Regular output should go to stdout and this
is what all other subcommands of bpftool do, including --json and
--pretty formats of `bpftool net` itself.

Fixes: commit f6f3bac ("tools/bpf: bpftool: add net support")
Signed-off-by: Andrey Ignatov <rdna@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
Andrey Ignatov authored and Daniel Borkmann committed Sep 27, 2018
1 parent 1042caa commit 53d6eb0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tools/bpf/bpftool/netlink_dumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
jsonw_name(json_wtr, name); \
jsonw_start_object(json_wtr); \
} else { \
fprintf(stderr, "%s {", name); \
fprintf(stdout, "%s {", name); \
} \
}

Expand All @@ -25,15 +25,15 @@
if (json_output) \
jsonw_start_object(json_wtr); \
else \
fprintf(stderr, "{"); \
fprintf(stdout, "{"); \
}

#define NET_END_OBJECT_NESTED \
{ \
if (json_output) \
jsonw_end_object(json_wtr); \
else \
fprintf(stderr, "}"); \
fprintf(stdout, "}"); \
}

#define NET_END_OBJECT \
Expand All @@ -47,7 +47,7 @@
if (json_output) \
jsonw_end_object(json_wtr); \
else \
fprintf(stderr, "\n"); \
fprintf(stdout, "\n"); \
}

#define NET_START_ARRAY(name, fmt_str) \
Expand All @@ -56,7 +56,7 @@
jsonw_name(json_wtr, name); \
jsonw_start_array(json_wtr); \
} else { \
fprintf(stderr, fmt_str, name); \
fprintf(stdout, fmt_str, name); \
} \
}

Expand All @@ -65,31 +65,31 @@
if (json_output) \
jsonw_end_array(json_wtr); \
else \
fprintf(stderr, "%s", endstr); \
fprintf(stdout, "%s", endstr); \
}

#define NET_DUMP_UINT(name, fmt_str, val) \
{ \
if (json_output) \
jsonw_uint_field(json_wtr, name, val); \
else \
fprintf(stderr, fmt_str, val); \
fprintf(stdout, fmt_str, val); \
}

#define NET_DUMP_STR(name, fmt_str, str) \
{ \
if (json_output) \
jsonw_string_field(json_wtr, name, str);\
else \
fprintf(stderr, fmt_str, str); \
fprintf(stdout, fmt_str, str); \
}

#define NET_DUMP_STR_ONLY(str) \
{ \
if (json_output) \
jsonw_string(json_wtr, str); \
else \
fprintf(stderr, "%s ", str); \
fprintf(stdout, "%s ", str); \
}

#endif

0 comments on commit 53d6eb0

Please sign in to comment.