Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a new API GetBpfHelpers(), which accepts symbols (from /proc/kallsyms) and returns all bpf helper names used at present. The idea is to scan assembly code of each bpf functions (has suffix [bpf]) and gather all callees, which are bpf helpers. The steps are like: 1. Get all bpf progs: ``` # cat /proc/kallsyms | grep '\[bpf\]$' [...] ffffffffc0380af8 t bpf_prog_3cdf7f3879992857_tail_ipv4_to_endpoint [bpf] ffffffffc0382514 t bpf_prog_e214e82dc4b46fca_cil_from_container [bpf] ffffffffc0382870 t bpf_prog_773159d28c0ab73a_cil_to_container [bpf] [...] ``` 2. Get all callee addresses from each bpf prog: ``` # gdb -ex 'x/5000i 0xffffffffc0382870' -ex q vmlinux /proc/kcore | grep call [...] 0xffffffffc03829ee: call 0xffffffff9fb2ee50 0xffffffffc0382a47: call 0xffffffff9fb2fd20 0xffffffffc0382ad4: call 0xffffffffa0649120 [...] ``` 3. Convert addresses to symbols ``` # cat /proc/kallsyms | grep ffffffff9fb2ee50 ffffffff9fb2ee50 t htab_percpu_map_lookup_elem ``` Currently only x64 are taken care of. Signed-off-by: gray <gray.liang@isovalent.com>
- Loading branch information