docs: describe how to build bpf_jit_disasm
[netsniff-ng.git] / INSTALL
blob5bfba1f5ca4b69589d6a18cceb7c509a26ed2d09
1 Currently only operating systems running on Linux kernels with the option
2 CONFIG_PACKET_MMAP enabled. This feature can be found even back to the days of
3 2.4 kernels. Most operating systems ship pre-compiled kernels that have this
4 config option enabled and even the latest kernel versions got rid of this
5 option and have this functionality already built-in. However, we recommend a
6 kernel >= 2.6.31, because the TX_RING is officially integrated since then. In
7 any case, if you have the possibility, consider getting the latest kernel from
8 Linus' Git repository, tweak and compile it, and run this one!
10 A note for distribution package maintainers can be found at the end of the file.
12 What additional tools next to your build-chain are required?
14  - ccache (optional)
15  - gpg (optional)
17  - pkg-config:             all
18  - flex, bison:            bpfc, trafgen
20 What libraries are required?
22  - libncurses:             ifpps, flowtop
23  - libGeoIP >=1.4.8:       astraceroute, flowtop, netsniff-ng
24  - libz:                   astraceroute, flowtop, netsniff-ng
25  - libnacl:                curvetun
26  - libnetfilter-conntrack: flowtop
27  - libpcap:                mausezahn, netsniff-ng (tcpdump-like filters)
28  - liburcu:                flowtop
29  - libnl3:                 netsniff-ng, trafgen
30  - libcli:                 mausezahn
31  - libnet:                 mausezahn
33 What additional tools are recommended, but not mandatory after the build?
35  - cpp:                    trafgen
36  - ntpd:                   curvetun
37  - setcap:                 all
39 It is common, that these libraries are shipped as distribution packages
40 for an easy installation. We try to keep this as minimal as possible.
42 One-liner installation for *all* dependencies on Debian:
44   $ sudo apt-get install ccache flex bison libnl-3-dev \
45   libnl-genl-3-dev libgeoip-dev libnetfilter-conntrack-dev \
46   libncurses5-dev liburcu-dev libnacl-dev libpcap-dev \
47   zlib1g-dev libcli-dev libnet1-dev
49 One-liner installation for *all* dependencies on Fedora:
51   $ sudo yum install ccache flex bison ccache libnl3-devel \
52   GeoIP-devel libnetfilter_conntrack-devel ncurses-devel \
53   userspace-rcu-devel nacl-devel libpcap-devel zlib-devel \
54   libcli-devel libnet-devel
56 After downloading the netsniff-ng toolkit, you should change to the
57 repository root directory:
59   $ cd netsniff-ng/
61 The installation (deinstallation) process is fairly simple:
63   $ ./configure
64   $ make
65   # make install
67   (# make uninstall)
69 In order to remove all build files from the source tree:
71   $ make clean
73 To bring the source tree into a pristine state, there are two options.
74 The first one will remove all build and build config file, the latter
75 will also remove any manually added files:
77   $ make distclean
78   ($ make mrproper)
80 You can also build/install/uninstall only a particular tool, e.g.:
82   $ make trafgen
83   # make trafgen_install
85   (# make trafgen_uninstall)
87 If you want to build all tools, but {curvetun,mausezahn} (i.e. because you
88 don't need the tunneling software and the NaCl build process lasts quite long):
90   $ make allbutcurvetun               (allbutmausezahn)
91   # make install_allbutcurvetun       (install_allbutmausezahn)
93   (# make uninstall)
95 In order to build curvetun, libnacl must be built first. A helper script
96 called nacl_build.sh is there to facilitate this process. If you want to
97 build NaCl in the directory ~/nacl, the script should be called this way:
99   $ cd curvetun
100   $ ./nacl_build.sh ~/nacl
102 There's also an abbreviation for this by simply typing:
104   $ make nacl
106 This gives an initial output such as "Building NaCl for arch amd64 on host
107 fuuubar (grab a coffee, this takes a while) ...". If the automatically
108 detected architecture (such as amd64) is not the one you intend to compile
109 for, then edit the (cc="gcc") variable within the nacl_build.sh script to
110 your cross compiler. Yes, we know, the build system of NaCl is a bit of a
111 pain, so you might check for a pre-built package from your distribution in
112 case you are not cross compiling.
114 If NaCl already has been built on the target, it is quicker to use
115 nacl_path.sh this way:
117   $ cd curvetun
118   $ ./nacl_path.sh ~/nacl/build/include/x86 ~/nacl/build/lib/x86
120 When done, netsniff-ng's build infrastructure will read those evironment
121 variables in order to get the needed paths to NaCl.
123 If you're unsure with any make targets, check out: make help
125 In order to run the toolkit as a normal user, set the following privilege
126 separation after the build/installation:
128   $ sudo setcap cap_net_raw,cap_ipc_lock,cap_sys_admin,cap_net_admin=eip {toolname}
130 For cross-compiling netsniff-ng, the process is faily simple. Assuming you
131 want to build netsniff-ng for the Microblaze architecture, update the PATH
132 variable first, e.g.:
134   $ export PATH=<cc-tools-path>/microblazeel-unknown-linux-gnu/bin:$PATH
136 And then, build the toolkit like this:
138   $ make CROSS_COMPILE=microblazeel-unknown-linux-gnu- \
139          CROSS_LD_LIBRARY_PATH=<cc-lib-search-path>
141 Note that some adaptations might be necessary regarding the CFLAGS, since not
142 all might be supported by a different architecture. Probably the most simple
143 way would be to run make CFLAGS="-O2 -Wall".
145 For power users we have a set of zsh auto completion files, have a look at all
146 file with ending *.zsh. There's also a BPF vim syntax highlighting file in the
147 tree called bpf.vim.
149 For doing a debug build of the toolkit with less optimizations and non-stripped
150 symbols, do:
152   $ make DEBUG=1
154 For debugging the build system, full commands are shown if every make target is
155 executed with:
157   $ make Q=
159 Concerning packaging the toolkit for a Linux distribution, by default,
160 netsniff-ng has some architecture-specific tuning options enabled that don't
161 belong into a package binary of a distribution. Hence, you might want to adapt
162 some build-related things before starting to package the toolkit. All
163 necessary things (e.g., CFLAGS,WFLAGS) can be found in Makefile. Hence,
164 you need to adapt it there. You can then build and install the toolkit into
165 a prefixed path like:
167   $ make PREFIX=<path-prefix-for-package>
168   $ make PREFIX=<path-prefix-for-package> install
170 Thanks for maintaining netsniff-ng in your distribution. Further questions
171 will be answered on the public mailing list.
173 Last but not least, there is one small utility for advanced users that we have
174 not integrated into the main build process. This is a minimal BPF JIT image
175 disassembler for the Linux kernel. You can also find this tool in the Linux
176 kernel Git tree under 'tools/net/bpf_jit_disasm.c' or within the netsniff-ng
177 Git tree simply under 'bpf_jit_disasm.c'. To build it, execute:
179     $ gcc -Wall -O2 bpf_jit_disasm.c -o bpf_jit_disasm -lopcodes -lbfd -ldl
181 The rest is described in the file header comment itself, i.e. how to get to the
182 BPF JIT code.