diff mbox series

[bpf] bpftool: Flush tracelog output

Message ID CAHMuVOC1bwuY_X5doyWEZfw2yTb=cB-J5dYK2SnDGzD0=fAbew@mail.gmail.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series [bpf] bpftool: Flush tracelog output | expand

Checks

Context Check Description
bpf/vmtest-bpf-PR fail merge-conflict
netdev/tree_selection success Clearly marked for bpf
netdev/apply fail Patch does not apply to bpf

Commit Message

Paul Chaignon Dec. 16, 2021, 9:30 p.m. UTC
The output of bpftool prog tracelog is currently buffered, which is
inconvenient when piping the output into other commands. A simple
tracelog | grep will typically not display anything. This patch fixes it
by flushing the tracelog output after each line from the trace_pipe file.

Fixes: 30da46b5dc3a ("tools: bpftool: add a command to dump the trace pipe")
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Paul Chaignon <paul@isovalent.com>
---
 tools/bpf/bpftool/tracelog.c | 1 +
 1 file changed, 1 insertion(+)

--
2.25.1
diff mbox series

Patch

diff --git a/tools/bpf/bpftool/tracelog.c b/tools/bpf/bpftool/tracelog.c
index e80a5c79b38f..b310229abb07 100644
--- a/tools/bpf/bpftool/tracelog.c
+++ b/tools/bpf/bpftool/tracelog.c
@@ -158,6 +158,7 @@  int do_tracelog(int argc, char **argv)
                        jsonw_string(json_wtr, buff);
                else
                        printf("%s", buff);
+               fflush(stdout);
        }

        fclose(trace_pipe_fd);