Introduce BPF Program Snapshot helper (bps)
A simple program to list all bpf programs of a system.
[root@arch-fb-vm1 bcc]# ./build/introspection/bps -h
BPF Program Snapshot (bps):
List of all BPF programs loaded into the system.
Usage: bps [bpf-prog-id]
[bpf-prog-id] If specified, it shows the details info of the bpf-prog
* List all bpf programs *
[root@arch-fb-vm1 bcc]# ./build/introspection/bps
BID TYPE UID #MAPS LoadTime NAME
82 kprobe 0 1 Oct19/23:52 map_perf_test
83 kprobe 0 1 Oct19/23:52 map_perf_test
84 kprobe 0 1 Oct19/23:52 map_perf_test
85 kprobe 0 1 Oct19/23:52 map_perf_test
86 kprobe 0 4 Oct19/23:52 map_perf_test
87 kprobe 0 1 Oct19/23:52 map_perf_test
88 kprobe 0 1 Oct19/23:52 map_perf_test
89 kprobe 0 1 Oct19/23:52 map_perf_test
* List a particular bpf program *
[root@arch-fb-vm1 bcc]# ./build/introspection/bps 86
BID TYPE UID #MAPS LoadTime NAME
86 kprobe 0 4 Oct19/23:52 map_perf_test
MID TYPE FLAGS KeySz ValueSz MaxEnts NAME
120 lru hash 0x0 4 8 10000 lru_hash_map
129 lru hash 0x0 4 8 43 lru_hash_lookup
123 array of maps 0x0 4 4 1024 array_of_lru_ha
121 lru hash 0x2 4 8 10000 nocommon_lru_ha
* JIT disabled *
[root@arch-fb-vm1 bpf]# sysctl -w net.core.bpf_jit_enable=0
[root@arch-fb-vm1 bpf]# ./test_progs
[root@arch-fb-vm1 bcc]# ./build/introspection/bps
BID TYPE UID #MAPS LoadTime NAME
94- socket filter 0 1 Oct19/23:55 test_obj_id
95- socket filter 0 1 Oct19/23:55 test_obj_id
* Run without CAP_SYS_ADMIN *
[kafai@arch-fb-vm1 ~]$ ./bps 1
Require CAP_SYS_ADMIN capability. Please retry as root
* Older kernel *
[root@arch-fb-vm2 build]# uname -r
4.12.14
[root@arch-fb-vm2 build]# ./introspection/bps 1
Kernel does not support BPF introspection
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Showing
introspection/CMakeLists.txt
0 → 100644
introspection/bps.c
0 → 100644
Please register or sign in to comment