Skip to content

Commit 54d30b1

Browse files
committed
man/bps: Add a man page for introspection/bps.c
This patch adds a man page for bps.c and also introduces bps in README.md Signed-off-by: Martin KaFai Lau <[email protected]>
1 parent f3bd860 commit 54d30b1

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ Examples:
171171
- examples/networking/[tunnel_monitor/](examples/networking/tunnel_monitor): Efficiently monitor traffic flows. [Example video](https://www.youtube.com/watch?v=yYy3Cwce02k).
172172
- examples/networking/vlan_learning/[vlan_learning.py](examples/networking/vlan_learning/vlan_learning.py) examples/[vlan_learning.c](examples/networking/vlan_learning/vlan_learning.c): Demux Ethernet traffic into worker veth+namespaces.
173173

174+
### BPF Introspection:
175+
176+
Tools that help to introspect BPF programs.
177+
178+
- introspection/[bps.c](introspection/bps.c): List all BPF programs loaded into the kernel. 'ps' for BPF programs. [Examples](introspection/bps_example.txt).
179+
174180
## Motivation
175181

176182
BPF guarantees that the programs loaded into the kernel cannot crash, and

introspection/bps_example.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
* List all BPF programs *
2+
# bps
3+
BID TYPE UID #MAPS LoadTime NAME
4+
82 kprobe 0 1 Oct19/23:52 map_perf_test
5+
83 kprobe 0 1 Oct19/23:52 map_perf_test
6+
84 kprobe 0 1 Oct19/23:52 map_perf_test
7+
85 kprobe 0 1 Oct19/23:52 map_perf_test
8+
86 kprobe 0 4 Oct19/23:52 map_perf_test
9+
87 kprobe 0 1 Oct19/23:52 map_perf_test
10+
88 kprobe 0 1 Oct19/23:52 map_perf_test
11+
89 kprobe 0 1 Oct19/23:52 map_perf_test
12+
13+
* List a particular BPF program and its maps *
14+
# bps 86
15+
BID TYPE UID #MAPS LoadTime NAME
16+
86 kprobe 0 4 Oct19/23:52 map_perf_test
17+
18+
MID TYPE FLAGS KeySz ValueSz MaxEnts NAME
19+
120 lru hash 0x0 4 8 10000 lru_hash_map
20+
129 lru hash 0x0 4 8 43 lru_hash_lookup
21+
123 array of maps 0x0 4 4 1024 array_of_lru_ha
22+
121 lru hash 0x2 4

man/man8/bps.8

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
.TH bps 8 "2017-10-19" "USER COMMANDS"
2+
.SH NAME
3+
bps \- List all BPF programs. 'ps' for BPF programs.
4+
.SH SYNOPSIS
5+
.B bps [bpf-prog-id]
6+
.SH DESCRIPTION
7+
.B bps
8+
lists all BPF programs loaded into the kernel. It is similar
9+
to the ps command but for the BPF programs.
10+
11+
Each loaded bpf program is identified by an unique integer (i.e.
12+
.B bpf-prog-id
13+
or simply BID). If
14+
a
15+
.B bpf-prog-id
16+
is specified, the maps used by
17+
.B bpf-prog-id
18+
will also be listed.
19+
20+
.SH EXAMPLES
21+
.TP
22+
List all BPF programs loaded into the kernel:
23+
.B bps
24+
.TP
25+
Show the details and maps of BID 6:
26+
.B bps 6
27+
.SH BPF PROGRAM FIELDS
28+
.TP
29+
.B BID
30+
BPF program ID. It ends with '-' if it is not jitted.
31+
.TP
32+
.B TYPE
33+
The type of a BPF program. e.g. kprobe, tracepoint, xdp...etc.
34+
.TP
35+
.B UID
36+
The user ID that loaded the BPF program.
37+
.TP
38+
.B #MAPS
39+
Total number of maps used by a BPF program.
40+
.TP
41+
.B LoadTime
42+
When was the BPF program loaded?
43+
.TP
44+
.B NAME
45+
The name of a BPF program. The user space library (like
46+
.B bcc
47+
) usually
48+
uses the C function name of the original BPF's source code as
49+
the program name. It could be empty if the user space did not
50+
provide a name.
51+
52+
.SH BPF MAP FIELDS
53+
.TP
54+
.B MID
55+
BPF map ID.
56+
.TP
57+
.B TYPE
58+
The type of a BPF map. e.g. hash, array, stack trace...etc.
59+
.TP
60+
.B FLAGS
61+
The flags used to create the BP map.
62+
.TP
63+
.B KeySz
64+
The key size of a BPF map.
65+
.TP
66+
.B ValueSz
67+
The value size of a BPF map.
68+
.TP
69+
.B MaxEnts
70+
The maximum number of entries of a map.
71+
.TP
72+
.B NAME
73+
The name of a BPF map. The user space library (like
74+
.B bcc
75+
) usually uses the C variable name of the BPF map as its name.
76+
It could be empty if the user space did not provide a name.
77+
78+
.SH SOURCE
79+
This is from bcc.
80+
.IP
81+
https://github.com/iovisor/bcc
82+
.SH OS
83+
Linux
84+
.SH STABILITY
85+
Unstable - in development.
86+
.SH AUTHOR
87+
Martin Lau

0 commit comments

Comments
 (0)