zsh: Unify completion help messages for --version and --help
conf: oui: update oui.conf

Update oui.conf using oui-update.py

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
trafgen: remove timer-based trigger model

perf reports in mmap case a huge number of kmem_cache_alloc's
which seem to stem from triggering signals from kernel to user
application, against dummy device:

Performance counter stats for 'trafgen -i blub -o dummy0 -n100000000 -k100': <-- mmap case

           175,837 kmem:kmem_cache_alloc

      14.758900522 seconds time elapsed

Performance counter stats for 'trafgen -i blub -o dummy0 -n100000000 -k100 -t0': <-- non-mmap case

               707 kmem:kmem_cache_alloc

      15.591667364 seconds time elapsed

It seems not to case significant number of cache-misses, but
it's better to switch to a direct trigger when we cannot fill
new frames anymore. After this patch, we see a similar number
of kmem_cache_alloc's as in the non-mmap case. This basically
renders the kpull interval useless, we can optionally remove
it if we don't care about people's scripts. ;-)

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
trafgen: keep a small initial ring buffer size to reduce cache-misses

Heavily reduce the initial ring buffer size for trafgen to just 196KiB,
so that we can heavily reduce the number of cache-misses related to
cache references. People can still overwrite this setting later on via
command line option for their specific architecture if they wish.

Perhaps the RX_RING should be checked as well in netsniff-ng though the
use case there is slightly different.

Before:

 Performance counter stats for 'trafgen -i blub -o dummy0 -n100000000':

   137,765,493,346 instructions:k            #    0.82  insns per cycle
   167,438,826,578 cycles:k                  #    0.000 GHz
        59,508,315 branch-misses:k
               361 context-switches:k
                 6 cpu-migrations:k
       134,751,541 cache-misses:k            #   85.019 % of all cache refs
       158,495,358 cache-references:k
               755 kmem:kmem_cache_alloc

      15.139458202 seconds time elapsed

After:

 Performance counter stats for 'trafgen -i blub -o dummy0 -n100000000':

   137,889,782,650 instructions:k            #    0.92  insns per cycle
   150,239,185,971 cycles:k                  #    0.000 GHz
        71,583,573 branch-misses:k
               423 context-switches:k
                 7 cpu-migrations:k
            60,239 cache-misses:k            #    0.073 % of all cache refs
        82,502,468 cache-references:k
               740 kmem:kmem_cache_alloc

      12.028787964 seconds time elapsed

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
pcap_io: fill sll when reading pcap

When reading from a pcap in Kuznetsov/netsniff-ng format, we currently do
not fill out sll. Do so so that users can see pkttype and the interface.

Reported-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
dissector: display packet direction for tap'ing on netlink devices (nlmon)

Linux kernel provides nlmon device (ARPHRD_NETLINK) driver that
can tap on netlink traffic, e.g.:

Setup:
  modprobe nlmon
  ip link add type nlmon
  ip link set nlmon0 up

Capture:
  netsniff-ng -i nlmon0 ... (or -i any)

Teardown:
  ip link set nlmon0 down
  ip link del dev nlmon0
  rmmod nlmon

Provide information about the packet direction (user space or kernel
space), so that dissector will show that properly.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
link: fixed to include <sys/types.h> for caddr_t

When building against musl libc compiling bails out because of caddr_t not
being declared:

--------------------------------------------------------------------------
link.c: In function 'wireless_sigqual':
link.c:41:24: error: 'caddr_t' undeclared (first use in this function)
--------------------------------------------------------------------------

As caddr_t is declared in <sys/types.h> this header needs to be included.

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
build: add DESTDIR support

This change implements support for specifying an alternative
installation destination directory by setting DESTDIR when
calling 'make install'.

Example: make DESTDIR=/alternative-rootfs install

It is particularly useful when cross-compiling and installing
in a dedicated directory where for example the rootfs or a
build sandbox for the target architecture is mounted.

By using DESTDIR you can avoid to mess with PREFIX to include
the alternative installation directory!

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
built_in: improved to define DEFFILEMODE if not provided by the libc

musl libc doesn't provide the non-standard macros for common mode
bit masks, which other libc implementations like glibc define in
<sys/stat.h>.

Compile time error when building against musl libc:

--------------------------------------------------------------------------
netsniff-ng.c: In function 'read_pcap':
netsniff-ng.c:592:33: error: 'DEFFILEMODE' undeclared (first use in this function)
--------------------------------------------------------------------------

This change improves built_in.h to check if DEFFILEMODE is defined
and if not it defines it to be available internally.

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
docs: be more precise on readme with experimental tools

Just improve the note on tools that are still experimental.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
poll: changed to include <poll.h> instead of <sys/poll.h>

This is a very cosmetic change but I think it is good to be
standards compliant. The standard defines <poll.h> and not
<sys/poll.h>:

http://pubs.opengroup.org/onlinepubs/009696799/basedefs/poll.h.html

When building against musl libc it silences some annoying cpp
warnings like this:

-----------------------------------------------------------------------
warning: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Wcpp]
-----------------------------------------------------------------------

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
doc: add documentation of DESTDIR usage in INSTALL and make help

Document the newly introduced DESTDIR option.

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
doc: fix make help for CROSS_COMPILE option

One doesn't need to specify a path for the CROSS_COMPILE option but
a prefix identifying the target architecture.

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
built_in: changed to not unconditionally define PAGE_SIZE

When building against musl libc I encountered following issue:
---------------------------------------------------------------------------
In file included from xmalloc.h:6:0,
                 from xmalloc.c:17:
built_in.h:181:0: warning: "PAGE_SIZE" redefined [enabled by default]
In file included from /usr/include/limits.h:8:0
---------------------------------------------------------------------------

According to the POSIX standard PAGE_SIZE should be defined in <limits.h> [1]
which is the case with musl libc if for example _GNU_SOURCE or _BSD_SOURCE
are defined which both is the case in netsniff-ng sources.

On my i686 test build the interesting part of <bits/limits.h> which itself
gets included by <limits.h> looks like this:
---------------------------------------------------------------------------
 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 #define PAGE_SIZE 4096
 #define LONG_BIT 64
 #endif
---------------------------------------------------------------------------

Note:

Besides that I noticed that currently getpagesize(2) is used, which is
considered legacy and has been dropped with POSIX.1-2001 [2].

According to getpagesize(2) [2] portable applications should use sysconf(3) [3]

By using getpagesize(2) unconditionally the intention was maybe to always use
the run time configuration value of PAGE_SIZE as returned by the kernel.
At least in the case of musl libc and applying this change this would not be
the case anymore as the static PAGE_SIZE value from the header would be used!

References:

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
[2] http://man7.org/linux/man-pages/man2/getpagesize.2.html
[3] http://man7.org/linux/man-pages/man3/sysconf.3.html

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
build: curvetun: add NACL_LIB variable to configure to be able to set an alternative lib

This way one can simply set an alternative lib like libsodium for
linking the curvetun binary.

The current default linking against libnacl is preserved!

To link curvetun against libsodium you can set NACL_LIB=sodium

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
doc: curvetun: add documentation how to use libsodium instead of libnacl

Add information to INSTALL on how to build with libsodium.

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
doc: add Christian to AUTHORS file

For Christian Wiese's contributions, add him to AUTHORS.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
build: fixed PREFIX usage

This change fixes the use of PREFIX by not hard wiring /usr into the path.

Besides that if no PREFIX is provided by the user, it is set to /usr/local now
which is considered to be the right location for most LSB conforming distros if
the user is compiling from sources to not interfere with the package management
for binary packages which are build using /usr as prefix in most of the cases.

current behavior without setting PREFIX will most likely interfere
with most distro package managers when building from source:
------------------------------------------------------------------------
$ sudo make uninstall
  RM    /usr/sbin/netsniff-ng
  RM    /usr/share/man/man8/netsniff-ng.8.gz
  RM    /usr/sbin/trafgen
  RM    /usr/share/man/man8/trafgen.8.gz
  RM    /usr/sbin/astraceroute
  RM    /usr/share/man/man8/astraceroute.8.gz
  RM    /usr/sbin/ifpps
  RM    /usr/share/man/man8/ifpps.8.gz
  RM    /usr/sbin/bpfc
  RM    /usr/share/man/man8/bpfc.8.gz
  RM    /usr/sbin/curvetun
  RM    /usr/share/man/man8/curvetun.8.gz
------------------------------------------------------------------------

current behavior when setting PREFIX=/usr/local looks kind of weird
because of the hard wired /usr:
------------------------------------------------------------------------
$ sudo make PREFIX=/usr/local uninstall
  RM    /usr/local/usr/sbin/netsniff-ng
  RM    /usr/local/usr/share/man/man8/netsniff-ng.8.gz
  RM    /usr/local/usr/sbin/trafgen
  RM    /usr/local/usr/share/man/man8/trafgen.8.gz
  RM    /usr/local/usr/sbin/astraceroute
  RM    /usr/local/usr/share/man/man8/astraceroute.8.gz
  RM    /usr/local/usr/sbin/ifpps
  RM    /usr/local/usr/share/man/man8/ifpps.8.gz
  RM    /usr/local/usr/sbin/bpfc
  RM    /usr/local/usr/share/man/man8/bpfc.8.gz
  RM    /usr/local/usr/sbin/curvetun
  RM    /usr/local/usr/share/man/man8/curvetun.8.gz
------------------------------------------------------------------------

using the proposed fix without setting PREFIX:
------------------------------------------------------------------------
$ sudo make uninstall
  RM    /usr/local/sbin/netsniff-ng
  RM    /usr/local/share/man/man8/netsniff-ng.8.gz
  RM    /usr/local/sbin/trafgen
  RM    /usr/local/share/man/man8/trafgen.8.gz
  RM    /usr/local/sbin/astraceroute
  RM    /usr/local/share/man/man8/astraceroute.8.gz
  RM    /usr/local/sbin/ifpps
  RM    /usr/local/share/man/man8/ifpps.8.gz
  RM    /usr/local/sbin/bpfc
  RM    /usr/local/share/man/man8/bpfc.8.gz
  RM    /usr/local/sbin/curvetun
  RM    /usr/local/share/man/man8/curvetun.8.gz
------------------------------------------------------------------------

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
built_in: changed to use RUNTIME_PAGE_SIZE instead of PAGE_SIZE

References:

https://github.com/netsniff-ng/netsniff-ng/commit/453f6eb9d79dd5aa2812ef956b22723f0a493086
https://github.com/netsniff-ng/netsniff-ng/pull/112

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
built_in: changed RUNTIME_PAGE_SIZE to use sysconf(_SC_PAGE_SIZE) instead of getpagesize()

getpagesize(2) is considered legacy and has been dropped with POSIX.1-2001.

See discussion: https://github.com/netsniff-ng/netsniff-ng/pull/112

Signed-off-by: Christian Wiese <chris@opensde.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>