]> git.baikalelectronics.ru Git - kernel.git/commit
filter: bpf_asm: add minimal bpf asm tool
authorDaniel Borkmann <dborkman@redhat.com>
Wed, 11 Dec 2013 22:43:44 +0000 (23:43 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 12 Dec 2013 01:28:35 +0000 (20:28 -0500)
commitba068ab1bd09018b5c01793abd4190d268e340de
tree6f330ea61260191ce50d539f0b95f3c3b26d0a00
parent4b80ba08cf89b7d96f76c0cd616351a62e760b26
filter: bpf_asm: add minimal bpf asm tool

There are a couple of valid use cases for a minimal low-level bpf asm
like tool, for example, using/linking to libpcap is not an option, the
required BPF filters use Linux extensions that are not supported by
libpcap's compiler, a filter might be more complex and not cleanly
implementable with libpcap's compiler, particular filter codes should
be optimized differently than libpcap's internal BPF compiler does,
or for security audits of emitted BPF JIT code for prepared set of BPF
instructions resp. BPF JIT compiler development in general.

Then, in such cases writing such a filter in low-level syntax can be
an good alternative, for example, xt_bpf and cls_bpf users might have
requirements that could result in more complex filter code, or one that
cannot be expressed with libpcap (e.g. different return codes in
cls_bpf for flowids on various BPF code paths).

Moreover, BPF JIT implementors may wish to manually write test cases
in order to verify the resulting JIT image, and thus need low-level
access to BPF code generation as well. Therefore, complete the available
toolchain for BPF with this small bpf_asm helper tool for the tools/net/
directory. These 3 complementary minimal helper tools round up and
facilitate BPF development.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/net/Makefile
tools/net/bpf_asm.c [new file with mode: 0644]
tools/net/bpf_exp.l [new file with mode: 0644]
tools/net/bpf_exp.y [new file with mode: 0644]