diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-12-11 23:43:43 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-12 02:28:35 +0100 |
commit | fd981e3c321a7e8661e06fa6077aea89e8228c3a (patch) | |
tree | b8bc8399aef71c13ed1f971288ac75d624c85e6c /tools/net/Makefile | |
parent | net: eth: cpsw: 64-bit phys_addr_t and sparse cleanup (diff) | |
download | linux-fd981e3c321a7e8661e06fa6077aea89e8228c3a.tar.xz linux-fd981e3c321a7e8661e06fa6077aea89e8228c3a.zip |
filter: bpf_dbg: add minimal bpf debugger
This patch adds a minimal BPF debugger that "emulates" the kernel's
BPF engine (w/o extensions) and allows for single stepping (forwards
and backwards through BPF code) or running with >=1 breakpoints through
selected or all packets from a pcap file with a provided user filter
in order to facilitate verification of a BPF program. When a breakpoint
is being hit, it dumps all register contents, decoded instructions and
in case of branches both decoded branch targets as well as other useful
information.
Having this facility is in particular useful to verify BPF programs
against given test traffic *before* attaching to a live system.
With the general availability of cls_bpf, xt_bpf, socket filters,
team driver and e.g. PTP code, all BPF users, quite often a single
more complex BPF program is being used. Reasons for a more complex
BPF program are primarily to optimize execution time for making a
verdict when multiple simple BPF programs are combined into one in
order to prevent parsing same headers multiple times. In particular,
for cls_bpf that can have various return paths for encoding flowids,
and xt_bpf to come to a fw verdict this can be the case.
Therefore, as this can result in more complex and harder to debug
code, it would be very useful to have this minimal tool for testing
purposes. It can also be of help for BPF JIT developers as filters
are "test attached" to the kernel on a temporary socket thus
triggering a JIT image dump when enabled. The tool uses an interactive
libreadline shell with auto-completion and history support.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/net/Makefile')
-rw-r--r-- | tools/net/Makefile | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/net/Makefile b/tools/net/Makefile index b4444d53b73f..0f30d923afa0 100644 --- a/tools/net/Makefile +++ b/tools/net/Makefile @@ -2,14 +2,19 @@ prefix = /usr CC = gcc -all : bpf_jit_disasm +all : bpf_jit_disasm bpf_dbg bpf_jit_disasm : CFLAGS = -Wall -O2 bpf_jit_disasm : LDLIBS = -lopcodes -lbfd -ldl bpf_jit_disasm : bpf_jit_disasm.o +bpf_dbg : CFLAGS = -Wall -O2 +bpf_dbg : LDLIBS = -lreadline +bpf_dbg : bpf_dbg.o + clean : - rm -rf *.o bpf_jit_disasm + rm -rf *.o bpf_jit_disasm bpf_dbg install : install bpf_jit_disasm $(prefix)/bin/bpf_jit_disasm + install bpf_dbg $(prefix)/bin/bpf_dbg |