diff options
| author | Jakub Kicinski <[email protected]> | 2018-05-04 01:37:16 +0000 |
|---|---|---|
| committer | Daniel Borkmann <[email protected]> | 2018-05-04 21:41:04 +0000 |
| commit | f412eed9dfdeeb6becd7de2ffe8b5d0a8b3f81ca (patch) | |
| tree | c6cf7b305e343a73505d5d1d25ee300a46992147 /tools/bpf/bpftool/common.c | |
| parent | tools: bpftool: move get_possible_cpus() to common code (diff) | |
| download | kernel-f412eed9dfdeeb6becd7de2ffe8b5d0a8b3f81ca.tar.gz kernel-f412eed9dfdeeb6becd7de2ffe8b5d0a8b3f81ca.zip | |
tools: bpftool: add simple perf event output reader
Users of BPF sooner or later discover perf_event_output() helpers
and BPF_MAP_TYPE_PERF_EVENT_ARRAY. Dumping this array type is
not possible, however, we can add simple reading of perf events.
Create a new event_pipe subcommand for maps, this sub command
will only work with BPF_MAP_TYPE_PERF_EVENT_ARRAY maps.
Parts of the code from samples/bpf/trace_output_user.c.
Signed-off-by: Jakub Kicinski <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]>
Acked-by: Alexei Starovoitov <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Diffstat (limited to 'tools/bpf/bpftool/common.c')
| -rw-r--r-- | tools/bpf/bpftool/common.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c index 9c620770c6ed..32f9e397a6c0 100644 --- a/tools/bpf/bpftool/common.c +++ b/tools/bpf/bpftool/common.c @@ -331,6 +331,16 @@ char *get_fdinfo(int fd, const char *key) return NULL; } +void print_data_json(uint8_t *data, size_t len) +{ + unsigned int i; + + jsonw_start_array(json_wtr); + for (i = 0; i < len; i++) + jsonw_printf(json_wtr, "%d", data[i]); + jsonw_end_array(json_wtr); +} + void print_hex_data_json(uint8_t *data, size_t len) { unsigned int i; @@ -421,6 +431,15 @@ void delete_pinned_obj_table(struct pinned_obj_table *tab) } } +unsigned int get_page_size(void) +{ + static int result; + + if (!result) + result = getpagesize(); + return result; +} + unsigned int get_possible_cpus(void) { static unsigned int result; |
