-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added bpf support for maps so map key/value types can be retrieved by user space introspection tool to pretty print map key/values. To associate maps with its key/value types, the below macro BPF_ANNOTATE_KV_PAIR(name, type_key, type_val) is used, similar to usage in kernel tools/testing/selftests/bpf and tools/lib/bpf. Currently, some map types (e.g, PERF_EVENT_ARRAY) do not support pretty print. But common [per_cpu] hash/array maps are supported. Currently, bcc create maps before llvm compilation. To support pretty printing of maps, map creation needs have key/value type id's which can only be obtained after compilation. Therefore, during rewriting, fake map fd is used. After compilation, btf is first loaded and maps are created. With latest bpf-next and latest trunk llvm, bpftool is able to pretty print bcc tool map key/values as below: ; running tcptop.py in one window $ tcptop.py ; running bpftool in another window $ bpftool m s ... 343: hash name ipv4_send_bytes flags 0x0 key 16B value 8B max_entries 10240 memlock 1003520B 344: hash name ipv4_recv_bytes flags 0x0 key 16B value 8B max_entries 10240 memlock 1003520B 345: hash name ipv6_send_bytes flags 0x0 key 64B value 8B max_entries 10240 memlock 1495040B 346: hash name ipv6_recv_bytes flags 0x0 key 64B value 8B max_entries 10240 memlock 1495040B $ bpftool m d id 345 ... },{ "key": { "pid": 5511, "saddr": 0x100007fffff00000000000000000000, "daddr": 0x100007fffff00000000000000000000, "lport": 2378, "dport": 52602 }, "value": 49 },{ "key": { "pid": 2823, "saddr": 0x4e000000cefa7bb0300000db0124, "daddr": 0x60000000cefa7bb0300000db0124, "lport": 2406, "dport": 49348 }, "value": 36 } ... Signed-off-by: Yonghong Song <yhs@fb.com>
- Loading branch information
1 parent
b374be8
commit 2787ff7
Showing
13 changed files
with
190 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.