1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# drgn ./contrib/bpf_inspect.py i
For help, type help(drgn).
>>> import drgn
>>> from drgn import NULL, Object, cast, container_of, execscript, offsetof, reinterpret, sizeof, stack_trace
>>> from drgn.helpers.common import *
>>> from drgn.helpers.linux import *
>>> list_bpf_progs()
2: BPF_PROG_TYPE_TRACING hid_tail_call
2295: BPF_PROG_TYPE_EXT entry tail_call_reachable
2400: BPF_PROG_TYPE_EXT entry tail_call_reachable
4235: BPF_PROG_TYPE_SCHED_CLS entry1
>>> p = get_bpf_prog_by_id(2400)
>>> print(p.prog.format_())
*(struct bpf_prog *)0xffffb2e08075a000 = {
.pages = (u16)1,
.jited = (u16)1,
.jit_requested = (u16)1,
.gpl_compatible = (u16)1,
.cb_access = (u16)1,
.dst_needed = (u16)0,
.blinding_requested = (u16)0,
.blinded = (u16)0,
.is_func = (u16)0,
.kprobe_override = (u16)0,
.has_callchain_buf = (u16)0,
.enforce_expected_attach_type = (u16)0,
.call_get_stack = (u16)0,
.call_get_func_ip = (u16)0,
.tstamp_type_access = (u16)0,
.type = (enum bpf_prog_type)BPF_PROG_TYPE_EXT,
.expected_attach_type = (enum bpf_attach_type)BPF_CGROUP_INET_INGRESS,
.len = (u32)20,
.jited_len = (u32)74,
.tag = (u8 [8]){ 12, 15, 76, 36, 19, 239, 25, 177 },
.stats = (struct bpf_prog_stats *)0x4a590,
.active = (int *)0x4a24c,
.bpf_func = (unsigned int (*)(const void *, const struct bpf_insn *))0xffffffffc00af864,
.aux = (struct bpf_prog_aux *)0xffff9902bbdbb800,
.orig_prog = (struct sock_fprog_kern *)0x0,
.__empty_insns = (struct <anonymous>){},
.insns = (struct sock_filter []){},
.__empty_insnsi = (struct <anonymous>){},
.insnsi = (struct bpf_insn []){},
}
>>> print(p.prog.aux.format_())
*(struct bpf_prog_aux *)0xffff9902bbdbb800 = {
.refcnt = (atomic64_t){
.counter = (s64)1,
},
.used_map_cnt = (u32)2,
// ...
.stack_depth = (u32)0,
.id = (u32)2400,
// ...
.name = (char [16])"entry",
// ...
}
|