diff options
author | Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> | 2017-11-07 23:55:48 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-10 22:35:41 -0500 |
commit | 4990f1f4610b483a60397ed2768d268df228a551 (patch) | |
tree | 7a720763c6ec3710eeeb333c4d502f25139f7576 /tools/bpf/bpftool/prog.c | |
parent | 1852719658c0f853b5481c9eaed862f1a9355edc (diff) |
tools: bpftool: show filenames of pinned objects
Added support to show filenames of pinned objects.
For example:
root@test# ./bpftool prog
3: tracepoint name tracepoint__irq tag f677a7dd722299a3
loaded_at Oct 26/11:39 uid 0
xlated 160B not jited memlock 4096B map_ids 4
pinned /sys/fs/bpf/softirq_prog
4: tracepoint name tracepoint__irq tag ea5dc530d00b92b6
loaded_at Oct 26/11:39 uid 0
xlated 392B not jited memlock 4096B map_ids 4,6
root@test# ./bpftool --json --pretty prog
[{
"id": 3,
"type": "tracepoint",
"name": "tracepoint__irq",
"tag": "f677a7dd722299a3",
"loaded_at": "Oct 26/11:39",
"uid": 0,
"bytes_xlated": 160,
"jited": false,
"bytes_memlock": 4096,
"map_ids": [4
],
"pinned": ["/sys/fs/bpf/softirq_prog"
]
},{
"id": 4,
"type": "tracepoint",
"name": "tracepoint__irq",
"tag": "ea5dc530d00b92b6",
"loaded_at": "Oct 26/11:39",
"uid": 0,
"bytes_xlated": 392,
"jited": false,
"bytes_memlock": 4096,
"map_ids": [4,6
],
"pinned": []
}
]
root@test# ./bpftool map
4: hash name start flags 0x0
key 4B value 16B max_entries 10240 memlock 1003520B
pinned /sys/fs/bpf/softirq_map1
5: hash name iptr flags 0x0
key 4B value 8B max_entries 10240 memlock 921600B
root@test# ./bpftool --json --pretty map
[{
"id": 4,
"type": "hash",
"name": "start",
"flags": 0,
"bytes_key": 4,
"bytes_value": 16,
"max_entries": 10240,
"bytes_memlock": 1003520,
"pinned": ["/sys/fs/bpf/softirq_map1"
]
},{
"id": 5,
"type": "hash",
"name": "iptr",
"flags": 0,
"bytes_key": 4,
"bytes_value": 8,
"max_entries": 10240,
"bytes_memlock": 921600,
"pinned": []
}
]
Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/bpf/bpftool/prog.c')
-rw-r--r-- | tools/bpf/bpftool/prog.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index d3ab808dc882..8f94b8ac2e63 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c | |||
@@ -272,6 +272,18 @@ static void print_prog_json(struct bpf_prog_info *info, int fd) | |||
272 | if (info->nr_map_ids) | 272 | if (info->nr_map_ids) |
273 | show_prog_maps(fd, info->nr_map_ids); | 273 | show_prog_maps(fd, info->nr_map_ids); |
274 | 274 | ||
275 | if (!hash_empty(prog_table.table)) { | ||
276 | struct pinned_obj *obj; | ||
277 | |||
278 | jsonw_name(json_wtr, "pinned"); | ||
279 | jsonw_start_array(json_wtr); | ||
280 | hash_for_each_possible(prog_table.table, obj, hash, info->id) { | ||
281 | if (obj->id == info->id) | ||
282 | jsonw_string(json_wtr, obj->path); | ||
283 | } | ||
284 | jsonw_end_array(json_wtr); | ||
285 | } | ||
286 | |||
275 | jsonw_end_object(json_wtr); | 287 | jsonw_end_object(json_wtr); |
276 | } | 288 | } |
277 | 289 | ||
@@ -331,6 +343,16 @@ static void print_prog_plain(struct bpf_prog_info *info, int fd) | |||
331 | if (info->nr_map_ids) | 343 | if (info->nr_map_ids) |
332 | show_prog_maps(fd, info->nr_map_ids); | 344 | show_prog_maps(fd, info->nr_map_ids); |
333 | 345 | ||
346 | if (!hash_empty(prog_table.table)) { | ||
347 | struct pinned_obj *obj; | ||
348 | |||
349 | printf("\n"); | ||
350 | hash_for_each_possible(prog_table.table, obj, hash, info->id) { | ||
351 | if (obj->id == info->id) | ||
352 | printf("\tpinned %s\n", obj->path); | ||
353 | } | ||
354 | } | ||
355 | |||
334 | printf("\n"); | 356 | printf("\n"); |
335 | } | 357 | } |
336 | 358 | ||
@@ -360,6 +382,8 @@ static int do_show(int argc, char **argv) | |||
360 | int err; | 382 | int err; |
361 | int fd; | 383 | int fd; |
362 | 384 | ||
385 | build_pinned_obj_table(&prog_table, BPF_OBJ_PROG); | ||
386 | |||
363 | if (argc == 2) { | 387 | if (argc == 2) { |
364 | fd = prog_parse_fd(&argc, &argv); | 388 | fd = prog_parse_fd(&argc, &argv); |
365 | if (fd < 0) | 389 | if (fd < 0) |