|
| 1 | +# Troubleshooting Guide |
| 2 | + |
| 3 | +# Checking bpftune support |
| 4 | + |
| 5 | +The first step is to determine if bpftune is supported on the system; this |
| 6 | +can be done via |
| 7 | + |
| 8 | +``` |
| 9 | +$ sudo bpftune -S |
| 10 | +bpftune: bpftune works in legacy mode |
| 11 | +bpftune: bpftune supports per-netns policy (via netns cookie) |
| 12 | +``` |
| 13 | + |
| 14 | +legacy mode will be used if there is no fentry/fexit, but it requires |
| 15 | +at a minimum raw tracepoint support, cgroup/sysctl BPF program support |
| 16 | +and BPF ring buffer support. So if any of these are missing, bpftune |
| 17 | +is not supported. If you see a "not supported" error, it is worth |
| 18 | +adding debug flags to dig deeper. For example, in this case, |
| 19 | +the libbpf used cannot read vmlinux BTF and as a result full bpftune |
| 20 | +support is not available: |
| 21 | + |
| 22 | +``` |
| 23 | +$ sudo bpftune -dS |
| 24 | +
|
| 25 | +bpftune: set caps (count 1) |
| 26 | +bpftune: set caps (count 2) |
| 27 | +bpftune: drop caps (count 1) |
| 28 | +bpftune: set caps (count 2) |
| 29 | +bpftune: libbpf: loading object 'probe_bpf' from buffer |
| 30 | +bpftune: libbpf: elf: section(3) fentry/setup_net, size 16, link 0, flags 6, type=1 |
| 31 | +bpftune: libbpf: sec 'fentry/setup_net': found program 'entry__setup_net' at insn offset 0 (0 bytes), code size 2 insns (16 bytes) |
| 32 | +bpftune: libbpf: elf: section(4) tp_btf/neigh_create, size 16, link 0, flags 6, type=1 |
| 33 | +bpftune: libbpf: sec 'tp_btf/neigh_create': found program 'bpftune_neigh_create' at insn offset 0 (0 bytes), code size 2 insns (16 bytes) |
| 34 | +bpftune: libbpf: elf: section(5) cgroup/sysctl, size 16, link 0, flags 6, type=1 |
| 35 | +bpftune: libbpf: sec 'cgroup/sysctl': found program 'sysctl_write' at insn offset 0 (0 bytes), code size 2 insns (16 bytes) |
| 36 | +bpftune: libbpf: elf: section(6) license, size 7, link 0, flags 3, type=1 |
| 37 | +bpftune: libbpf: license of probe_bpf is GPL v2 |
| 38 | +bpftune: libbpf: elf: section(7) .bss, size 25, link 0, flags 3, type=8 |
| 39 | +bpftune: libbpf: elf: section(8) .maps, size 112, link 0, flags 3, type=1 |
| 40 | +bpftune: libbpf: elf: section(15) .BTF, size 1670, link 0, flags 0, type=1 |
| 41 | +bpftune: libbpf: elf: section(17) .BTF.ext, size 160, link 0, flags 0, type=1 |
| 42 | +bpftune: libbpf: elf: section(24) .symtab, size 552, link 1, flags 0, type=2 |
| 43 | +bpftune: libbpf: looking for externs among 23 symbols... |
| 44 | +bpftune: libbpf: collected 0 externs total |
| 45 | +bpftune: libbpf: map 'ring_buffer_map': at sec_idx 8, offset 0. |
| 46 | +bpftune: libbpf: map 'ring_buffer_map': found type = 27. |
| 47 | +bpftune: libbpf: map 'ring_buffer_map': found max_entries = 131072. |
| 48 | +bpftune: libbpf: map 'netns_map': at sec_idx 8, offset 16. |
| 49 | +bpftune: libbpf: map 'netns_map': found type = 1. |
| 50 | +bpftune: libbpf: map 'netns_map': found key [12], sz = 8. |
| 51 | +bpftune: libbpf: map 'netns_map': found value [12], sz = 8. |
| 52 | +bpftune: libbpf: map 'netns_map': found max_entries = 65536. |
| 53 | +bpftune: libbpf: map 'last_event_map': at sec_idx 8, offset 48. |
| 54 | +bpftune: libbpf: map 'last_event_map': found type = 1. |
| 55 | +bpftune: libbpf: map 'last_event_map': found key [12], sz = 8. |
| 56 | +bpftune: libbpf: map 'last_event_map': found value [12], sz = 8. |
| 57 | +bpftune: libbpf: map 'last_event_map': found max_entries = 65536. |
| 58 | +bpftune: libbpf: map 'probe_hash_map': at sec_idx 8, offset 80. |
| 59 | +bpftune: libbpf: map 'probe_hash_map': found type = 1. |
| 60 | +bpftune: libbpf: map 'probe_hash_map': found key [12], sz = 8. |
| 61 | +bpftune: libbpf: map 'probe_hash_map': found value [12], sz = 8. |
| 62 | +bpftune: libbpf: map 'probe_hash_map': found max_entries = 65536. |
| 63 | +bpftune: libbpf: map 'probe_bp.bss' (global data): at sec_idx 7, offset 0, flags 400. |
| 64 | +bpftune: libbpf: map 4 is "probe_bp.bss" |
| 65 | +bpftune: libbpf: Unsupported BTF_KIND:19 |
| 66 | +bpftune: libbpf: loading kernel BTF '/sys/kernel/btf/vmlinux': -22 |
| 67 | +bpftune: libbpf: failed to find valid kernel BTF |
| 68 | +bpftune: libbpf: Error loading vmlinux BTF: -3 |
| 69 | +bpftune: libbpf: failed to load object 'probe_bpf' |
| 70 | +bpftune: libbpf: failed to load BPF skeleton 'probe_bpf': -3 |
| 71 | +bpftune: full bpftune support not available: Unknown error -3 |
| 72 | +... |
| 73 | +``` |
| 74 | + |
| 75 | +So we see the reason why; if bpftune cannot read kernel BTF, |
| 76 | +it cannot use fentry/fexit BPF programs which use BTF. |
| 77 | + |
| 78 | +# Debugging bpftune behaviour |
| 79 | + |
| 80 | +bpftune is run via service mostly, so examining logs in /var/log/messages |
| 81 | +can help here. However by default logging is only informational, so |
| 82 | +again debug messaging would have to be enabled by specifying the -d |
| 83 | +flag in /lib/systemd/system/bpftune.service and restarting. |
| 84 | + |
| 85 | +The -d flag is passed through to bpf programs also, so |
| 86 | + |
| 87 | +``` |
| 88 | +$ sudo cat /sys/kernel/debug/tracing/trace_pipe |
| 89 | +``` |
| 90 | +will show any bpftune_debug() messages emitted by BPF programs. |
| 91 | + |
| 92 | +# Checking bpf program attachment |
| 93 | + |
| 94 | +``` |
| 95 | +$ sudo bpftool prog |
| 96 | +``` |
| 97 | + |
| 98 | +...will show the bpf programs currently loaded; most bpftune |
| 99 | +programs will begin with bpftune_* |
| 100 | + |
| 101 | +``` |
| 102 | +$ sudo bpftool map |
| 103 | +``` |
| 104 | +...will show associated maps, and these can be dumped via |
| 105 | + |
| 106 | +``` |
| 107 | +$ sudo bpftool map dump id <id of map> |
| 108 | +``` |
| 109 | + |
| 110 | +...where the id is the number to the left of the ":"; i.e. |
| 111 | + |
| 112 | +``` |
| 113 | +$ sudo bpftool map |
| 114 | +... |
| 115 | +149: array name net_buff.bss flags 0x400 |
| 116 | + key 4B value 49B max_entries 1 memlock 8192B |
| 117 | + btf_id 269 |
| 118 | +... |
| 119 | +$ sudo bpftool map dump id 149 |
| 120 | +[{ |
| 121 | + "value": { |
| 122 | + ".bss": [{ |
| 123 | + "drop_count": 0 |
| 124 | + },{ |
| 125 | + "drop_interval_start": 0 |
| 126 | + },{ |
| 127 | + "flow_limit_cpu_bitmap": 0 |
| 128 | + },{ |
| 129 | + "bpftune_learning_rate": 4 |
| 130 | + },{ |
| 131 | + "tuner_id": 6 |
| 132 | + },{ |
| 133 | + "bpftune_pid": 129053 |
| 134 | + },{ |
| 135 | + "bpftune_init_net": 0 |
| 136 | + },{ |
| 137 | + "debug": true |
| 138 | + } |
| 139 | + ] |
| 140 | + } |
| 141 | + } |
| 142 | +] |
| 143 | +``` |
| 144 | + |
| 145 | +# General problem or tuner-specific problem? |
| 146 | + |
| 147 | +bpftune + libbpftune implement the general BPF load/attach and |
| 148 | +event handling, so bugs in these areas will likely be found |
| 149 | +there. Tuners consist of the tuner_name.c/tuner_name.bpf.c. |
| 150 | + |
| 151 | +Check the init()/fini() methods for setup/teardown issues, |
| 152 | +event_handler() for event handling issues. |
| 153 | + |
| 154 | +See ./CONTRIBUTING.md for more details on bpftune internals. |
| 155 | + |
| 156 | +# Running tests |
| 157 | + |
| 158 | +Tests can be a useful way to isolate tuner-specific issues. |
| 159 | + |
| 160 | +See ./TESTING.md to explore what tests are available. |
0 commit comments